pkgsrc-WIP-changes archive

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

Import virtualbox-0.0.0nb20160710 as wip/virtualbox-svn.



Module Name:	pkgsrc-wip
Committed By:	Kamil Rytarowski <n54%gmx.com@localhost>
Pushed By:	kamil
Date:		Mon Jul 11 00:19:29 2016 +0200
Changeset:	496fd41e30040766e8d88e71c3345b1137140b7b

Added Files:
	virtualbox-svn/DESCR
	virtualbox-svn/Makefile
	virtualbox-svn/PLIST
	virtualbox-svn/distinfo
	virtualbox-svn/patches/patch-Config.kmk
	virtualbox-svn/patches/patch-Makefile.kmk
	virtualbox-svn/patches/patch-configure
	virtualbox-svn/patches/patch-include_VBox_VBoxGuest.h
	virtualbox-svn/patches/patch-include_VBox_ostypes.h
	virtualbox-svn/patches/patch-include_VBox_param.h
	virtualbox-svn/patches/patch-include_VBox_rawpci.h
	virtualbox-svn/patches/patch-include_VBox_types.h
	virtualbox-svn/patches/patch-include_VBox_usb.h
	virtualbox-svn/patches/patch-include_VBox_vmm_cfgm.h
	virtualbox-svn/patches/patch-include_VBox_vmm_cpum.h
	virtualbox-svn/patches/patch-include_VBox_vmm_dbgf.h
	virtualbox-svn/patches/patch-include_VBox_vmm_ftm.h
	virtualbox-svn/patches/patch-include_VBox_vmm_gmm.h
	virtualbox-svn/patches/patch-include_VBox_vmm_gvm.h
	virtualbox-svn/patches/patch-include_VBox_vmm_gvmm.h
	virtualbox-svn/patches/patch-include_VBox_vmm_hm.h
	virtualbox-svn/patches/patch-include_VBox_vmm_iom.h
	virtualbox-svn/patches/patch-include_VBox_vmm_mm.h
	virtualbox-svn/patches/patch-include_VBox_vmm_pdmapi.h
	virtualbox-svn/patches/patch-include_VBox_vmm_pdmasynccompletion.h
	virtualbox-svn/patches/patch-include_VBox_vmm_pdmblkcache.h
	virtualbox-svn/patches/patch-include_VBox_vmm_pdmcritsect.h
	virtualbox-svn/patches/patch-include_VBox_vmm_pdmcritsectrw.h
	virtualbox-svn/patches/patch-include_VBox_vmm_pdmdev.h
	virtualbox-svn/patches/patch-include_VBox_vmm_pdmpci.h
	virtualbox-svn/patches/patch-include_VBox_vmm_pdmqueue.h
	virtualbox-svn/patches/patch-include_VBox_vmm_pdmthread.h
	virtualbox-svn/patches/patch-include_VBox_vmm_pgm.h
	virtualbox-svn/patches/patch-include_VBox_vmm_ssm.h
	virtualbox-svn/patches/patch-include_VBox_vmm_stam.h
	virtualbox-svn/patches/patch-include_VBox_vmm_tm.h
	virtualbox-svn/patches/patch-include_VBox_vmm_uvm.h
	virtualbox-svn/patches/patch-include_VBox_vmm_vmapi.h
	virtualbox-svn/patches/patch-include_VBox_vmm_vmm.h
	virtualbox-svn/patches/patch-include_iprt_stdint.h
	virtualbox-svn/patches/patch-include_iprt_string.h
	virtualbox-svn/patches/patch-include_iprt_time.h
	virtualbox-svn/patches/patch-include_iprt_types.h
	virtualbox-svn/patches/patch-kBuild_header.kmk
	virtualbox-svn/patches/patch-src_VBox_Additions_Makefile.kmk
	virtualbox-svn/patches/patch-src_VBox_Additions_common_VBoxGuestLib_VBoxGuestR3Lib.cpp
	virtualbox-svn/patches/patch-src_VBox_Additions_common_VBoxGuestLib_VBoxGuestR3LibLog.cpp
	virtualbox-svn/patches/patch-src_VBox_Additions_common_VBoxGuest_Makefile.kmk
	virtualbox-svn/patches/patch-src_VBox_Additions_common_VBoxGuest_VBoxGuest-netbsd.c
	virtualbox-svn/patches/patch-src_VBox_Additions_common_VBoxGuest_VBoxGuest.cpp
	virtualbox-svn/patches/patch-src_VBox_Additions_common_VBoxGuest_VBoxGuestInternal.h
	virtualbox-svn/patches/patch-src_VBox_Additions_common_VBoxGuest_netbsd_Makefile
	virtualbox-svn/patches/patch-src_VBox_Additions_common_VBoxGuest_netbsd_files__vboxguest
	virtualbox-svn/patches/patch-src_VBox_Additions_common_VBoxService_VBoxService.cpp
	virtualbox-svn/patches/patch-src_VBox_Additions_common_VBoxService_VBoxServiceVMInfo.cpp
	virtualbox-svn/patches/patch-src_VBox_Additions_common_crOpenGL_Makefile.kmk
	virtualbox-svn/patches/patch-src_VBox_Additions_common_crOpenGL_NetBSD__exports.py
	virtualbox-svn/patches/patch-src_VBox_Additions_common_crOpenGL_fakedri__drv.c
	virtualbox-svn/patches/patch-src_VBox_Additions_netbsd_Installer_pkg-descr
	virtualbox-svn/patches/patch-src_VBox_Additions_netbsd_Installer_vboxguest.sh
	virtualbox-svn/patches/patch-src_VBox_Additions_netbsd_Makefile
	virtualbox-svn/patches/patch-src_VBox_Additions_netbsd_Makefile.kmk
	virtualbox-svn/patches/patch-src_VBox_Additions_netbsd_drm_Makefile
	virtualbox-svn/patches/patch-src_VBox_Additions_netbsd_drm_Makefile.kmk
	virtualbox-svn/patches/patch-src_VBox_Additions_netbsd_drm_files__vboxvideo__drm
	virtualbox-svn/patches/patch-src_VBox_Additions_netbsd_drm_vboxvideo__drm.c
	virtualbox-svn/patches/patch-src_VBox_Additions_netbsd_vboxvfs_Makefile.kmk
	virtualbox-svn/patches/patch-src_VBox_Additions_netbsd_vboxvfs_vboxvfs.h
	virtualbox-svn/patches/patch-src_VBox_Additions_netbsd_vboxvfs_vboxvfs__vfsops.c
	virtualbox-svn/patches/patch-src_VBox_Additions_netbsd_vboxvfs_vboxvfs__vnops.c
	virtualbox-svn/patches/patch-src_VBox_Debugger_DBGCCommands.cpp
	virtualbox-svn/patches/patch-src_VBox_Debugger_DBGCInternal.h
	virtualbox-svn/patches/patch-src_VBox_Debugger_DBGConsole.cpp
	virtualbox-svn/patches/patch-src_VBox_Debugger_DBGPlugInDiggers.cpp
	virtualbox-svn/patches/patch-src_VBox_Debugger_DBGPlugIns.h
	virtualbox-svn/patches/patch-src_VBox_Devices_Bus_SrvPciRawR0.cpp
	virtualbox-svn/patches/patch-src_VBox_Devices_EFI_Firmware_AppPkg_Applications_Python_PyMod-2.7.2_Include_pyport.h
	virtualbox-svn/patches/patch-src_VBox_Devices_EFI_Firmware_StdLib_Include_dirent.h
	virtualbox-svn/patches/patch-src_VBox_Devices_EFI_Firmware_StdLib_Include_glob.h
	virtualbox-svn/patches/patch-src_VBox_Devices_EFI_Firmware_StdLib_Include_locale.h
	virtualbox-svn/patches/patch-src_VBox_Devices_EFI_Firmware_StdLib_Include_sys_EfiCdefs.h
	virtualbox-svn/patches/patch-src_VBox_Devices_EFI_Firmware_StdLib_Include_sys_bswap.h
	virtualbox-svn/patches/patch-src_VBox_Devices_EFI_Firmware_StdLib_Include_sys_cdefs__aout.h
	virtualbox-svn/patches/patch-src_VBox_Devices_EFI_Firmware_StdLib_Include_sys_socket.h
	virtualbox-svn/patches/patch-src_VBox_Devices_EFI_Firmware_StdLib_Include_unistd.h
	virtualbox-svn/patches/patch-src_VBox_Devices_Makefile.kmk
	virtualbox-svn/patches/patch-src_VBox_Devices_Network_DrvNAT.cpp
	virtualbox-svn/patches/patch-src_VBox_Devices_Network_slirp_resolv__conf__parser.c
	virtualbox-svn/patches/patch-src_VBox_Devices_Network_slirp_udp.c
	virtualbox-svn/patches/patch-src_VBox_Devices_PC_DrvACPI.cpp
	virtualbox-svn/patches/patch-src_VBox_Devices_Serial_DrvHostSerial.cpp
	virtualbox-svn/patches/patch-src_VBox_Devices_Storage_DrvHostBase.cpp
	virtualbox-svn/patches/patch-src_VBox_Devices_Storage_DrvHostBase.h
	virtualbox-svn/patches/patch-src_VBox_Devices_Storage_DrvHostDVD.cpp
	virtualbox-svn/patches/patch-src_VBox_Devices_USB_netbsd_USBProxyDevice-netbsd.cpp
	virtualbox-svn/patches/patch-src_VBox_Devices_build_VBoxDD.cpp
	virtualbox-svn/patches/patch-src_VBox_Devices_build_VBoxDD.h
	virtualbox-svn/patches/patch-src_VBox_ExtPacks_BusMouseSample_Makefile.kmk
	virtualbox-svn/patches/patch-src_VBox_ExtPacks_Skeleton_Makefile.kmk
	virtualbox-svn/patches/patch-src_VBox_ExtPacks_VBoxDTrace_Makefile.kmk
	virtualbox-svn/patches/patch-src_VBox_ExtPacks_VBoxDTrace_VBoxDTraceWrapper.cpp
	virtualbox-svn/patches/patch-src_VBox_ExtPacks_VNC_Makefile.kmk
	virtualbox-svn/patches/patch-src_VBox_Frontends_VBoxAutostart_VBoxAutostart-posix.cpp
	virtualbox-svn/patches/patch-src_VBox_Frontends_VBoxBalloonCtrl_VBoxWatchdog.cpp
	virtualbox-svn/patches/patch-src_VBox_Frontends_VBoxManage_VBoxInternalManage.cpp
	virtualbox-svn/patches/patch-src_VBox_Frontends_VBoxManage_VBoxManageHelp.cpp
	virtualbox-svn/patches/patch-src_VBox_Frontends_VBoxManage_VBoxManageModifyVM.cpp
	virtualbox-svn/patches/patch-src_VBox_Frontends_VBoxSDL_Makefile.kmk
	virtualbox-svn/patches/patch-src_VBox_Frontends_VirtualBox_Makefile.kmk
	virtualbox-svn/patches/patch-src_VBox_Frontends_VirtualBox_src_VBoxGLSupportInfo.cpp
	virtualbox-svn/patches/patch-src_VBox_Frontends_VirtualBox_src_net_UIUpdateManager.cpp
	virtualbox-svn/patches/patch-src_VBox_Frontends_VirtualBox_src_settings_machine_UIMachineSettingsAudio.cpp
	virtualbox-svn/patches/patch-src_VBox_GuestHost_OpenGL_Makefile.kmk
	virtualbox-svn/patches/patch-src_VBox_GuestHost_OpenGL_include_chromium.h
	virtualbox-svn/patches/patch-src_VBox_GuestHost_OpenGL_include_cr__dll.h
	virtualbox-svn/patches/patch-src_VBox_GuestHost_OpenGL_include_cr__timer.h
	virtualbox-svn/patches/patch-src_VBox_GuestHost_OpenGL_spu__loader_glloader.py
	virtualbox-svn/patches/patch-src_VBox_GuestHost_OpenGL_util_dll.c
	virtualbox-svn/patches/patch-src_VBox_GuestHost_OpenGL_util_environment.c
	virtualbox-svn/patches/patch-src_VBox_GuestHost_OpenGL_util_timer.c
	virtualbox-svn/patches/patch-src_VBox_GuestHost_OpenGL_util_vboxhgcm.c
	virtualbox-svn/patches/patch-src_VBox_GuestHost_OpenGL_util_vboxhgsmi.c
	virtualbox-svn/patches/patch-src_VBox_GuestHost_SharedClipboard_Makefile.kmk
	virtualbox-svn/patches/patch-src_VBox_HostDrivers_Makefile.kmk
	virtualbox-svn/patches/patch-src_VBox_HostDrivers_Support_Makefile.kmk
	virtualbox-svn/patches/patch-src_VBox_HostDrivers_Support_SUPDrv.cpp
	virtualbox-svn/patches/patch-src_VBox_HostDrivers_Support_SUPDrvGip.cpp
	virtualbox-svn/patches/patch-src_VBox_HostDrivers_Support_SUPDrvIDC.h
	virtualbox-svn/patches/patch-src_VBox_HostDrivers_Support_SUPDrvInternal.h
	virtualbox-svn/patches/patch-src_VBox_HostDrivers_Support_SUPDrvTracer.cpp
	virtualbox-svn/patches/patch-src_VBox_HostDrivers_Support_SUPR3HardenedMain.cpp
	virtualbox-svn/patches/patch-src_VBox_HostDrivers_Support_netbsd_Makefile
	virtualbox-svn/patches/patch-src_VBox_HostDrivers_Support_netbsd_SUPDrv-netbsd.c
	virtualbox-svn/patches/patch-src_VBox_HostDrivers_Support_netbsd_SUPDrv-netbsd.def
	virtualbox-svn/patches/patch-src_VBox_HostDrivers_Support_netbsd_SUPLib-netbsd.cpp
	virtualbox-svn/patches/patch-src_VBox_HostDrivers_Support_netbsd_SUPR0IdcClient-netbsd.c
	virtualbox-svn/patches/patch-src_VBox_HostDrivers_Support_netbsd_files__vboxdrv
	virtualbox-svn/patches/patch-src_VBox_HostDrivers_VBoxNetAdp_Makefile.kmk
	virtualbox-svn/patches/patch-src_VBox_HostDrivers_VBoxNetAdp_VBoxNetAdpInternal.h
	virtualbox-svn/patches/patch-src_VBox_HostDrivers_VBoxNetAdp_netbsd_Makefile
	virtualbox-svn/patches/patch-src_VBox_HostDrivers_VBoxNetAdp_netbsd_VBoxNetAdp-netbsd.c
	virtualbox-svn/patches/patch-src_VBox_HostDrivers_VBoxNetAdp_netbsd_files__vboxnetadp
	virtualbox-svn/patches/patch-src_VBox_HostDrivers_VBoxNetFlt_Makefile.kmk
	virtualbox-svn/patches/patch-src_VBox_HostDrivers_VBoxNetFlt_VBoxNetFltInternal.h
	virtualbox-svn/patches/patch-src_VBox_HostDrivers_VBoxNetFlt_netbsd_Makefile
	virtualbox-svn/patches/patch-src_VBox_HostDrivers_VBoxNetFlt_netbsd_VBoxNetFlt-netbsd.c
	virtualbox-svn/patches/patch-src_VBox_HostDrivers_VBoxNetFlt_netbsd_files__vboxnetflt
	virtualbox-svn/patches/patch-src_VBox_HostDrivers_netbsd_Makefile
	virtualbox-svn/patches/patch-src_VBox_HostDrivers_netbsd_Makefile.kmk
	virtualbox-svn/patches/patch-src_VBox_HostServices_Makefile.kmk
	virtualbox-svn/patches/patch-src_VBox_HostServices_SharedClipboard_Makefile.kmk
	virtualbox-svn/patches/patch-src_VBox_HostServices_SharedOpenGL_Makefile.kmk
	virtualbox-svn/patches/patch-src_VBox_HostServices_auth_Makefile.kmk
	virtualbox-svn/patches/patch-src_VBox_HostServices_auth_pam_VBoxAuthPAM.c
	virtualbox-svn/patches/patch-src_VBox_ImageMounter_VBoxFUSE_Makefile.kmk
	virtualbox-svn/patches/patch-src_VBox_ImageMounter_VBoxFUSE_VBoxFUSE.cpp
	virtualbox-svn/patches/patch-src_VBox_Installer_Makefile.kmk
	virtualbox-svn/patches/patch-src_VBox_Installer_darwin_VirtualBox_postflight
	virtualbox-svn/patches/patch-src_VBox_Installer_darwin_VirtualBox_preflight
	virtualbox-svn/patches/patch-src_VBox_Installer_linux_VBoxSysInfo.sh
	virtualbox-svn/patches/patch-src_VBox_Installer_linux_debian_control
	virtualbox-svn/patches/patch-src_VBox_Installer_linux_rpm_VirtualBox.tmpl.spec
	virtualbox-svn/patches/patch-src_VBox_Installer_netbsd_Makefile.kmk
	virtualbox-svn/patches/patch-src_VBox_Installer_netbsd_pkg-comment
	virtualbox-svn/patches/patch-src_VBox_Installer_netbsd_pkg-descr
	virtualbox-svn/patches/patch-src_VBox_Installer_netbsd_pkg__plist
	virtualbox-svn/patches/patch-src_VBox_Installer_netbsd_postdeinstall.sh
	virtualbox-svn/patches/patch-src_VBox_Installer_netbsd_postinstall.sh
	virtualbox-svn/patches/patch-src_VBox_Installer_netbsd_virtualbox.desktop
	virtualbox-svn/patches/patch-src_VBox_Main_Makefile.kmk
	virtualbox-svn/patches/patch-src_VBox_Main_cbinding_VBoxCAPIGlue.c
	virtualbox-svn/patches/patch-src_VBox_Main_cbinding_VBoxCAPI__v2__2.h
	virtualbox-svn/patches/patch-src_VBox_Main_cbinding_VBoxCAPI__v3__0.h
	virtualbox-svn/patches/patch-src_VBox_Main_glue_NativeEventQueue.cpp
	virtualbox-svn/patches/patch-src_VBox_Main_glue_tests_Makefile
	virtualbox-svn/patches/patch-src_VBox_Main_include_ConsoleImpl.h
	virtualbox-svn/patches/patch-src_VBox_Main_include_HostUSBDeviceImpl.h
	virtualbox-svn/patches/patch-src_VBox_Main_include_USBProxyService.h
	virtualbox-svn/patches/patch-src_VBox_Main_include_ovfreader.h
	virtualbox-svn/patches/patch-src_VBox_Main_src-client_ConsoleImpl.cpp
	virtualbox-svn/patches/patch-src_VBox_Main_src-client_ConsoleImpl2.cpp
	virtualbox-svn/patches/patch-src_VBox_Main_src-server_ApplianceImpl.cpp
	virtualbox-svn/patches/patch-src_VBox_Main_src-server_HostDnsService.cpp
	virtualbox-svn/patches/patch-src_VBox_Main_src-server_HostDnsService.h
	virtualbox-svn/patches/patch-src_VBox_Main_src-server_HostImpl.cpp
	virtualbox-svn/patches/patch-src_VBox_Main_src-server_HostNetworkInterfaceImpl.cpp
	virtualbox-svn/patches/patch-src_VBox_Main_src-server_MachineImpl.cpp
	virtualbox-svn/patches/patch-src_VBox_Main_src-server_generic_NetIf-generic.cpp
	virtualbox-svn/patches/patch-src_VBox_Main_src-server_netbsd_HostHardwareNetBSD.cpp
	virtualbox-svn/patches/patch-src_VBox_Main_src-server_netbsd_Makefile.kup
	virtualbox-svn/patches/patch-src_VBox_Main_src-server_netbsd_NetIf-netbsd.cpp
	virtualbox-svn/patches/patch-src_VBox_Main_src-server_netbsd_PerformanceNetBSD.cpp
	virtualbox-svn/patches/patch-src_VBox_Main_src-server_netbsd_USBProxyServiceNetBSD.cpp
	virtualbox-svn/patches/patch-src_VBox_Main_testcase_tstCollector.cpp
	virtualbox-svn/patches/patch-src_VBox_Main_webservice_vboxweb.cpp
	virtualbox-svn/patches/patch-src_VBox_Main_xml_Settings.cpp
	virtualbox-svn/patches/patch-src_VBox_Main_xml_VirtualBox-settings.xsd
	virtualbox-svn/patches/patch-src_VBox_Makefile.kmk
	virtualbox-svn/patches/patch-src_VBox_NetworkServices_NAT_Makefile.kmk
	virtualbox-svn/patches/patch-src_VBox_NetworkServices_NAT_pxping.c
	virtualbox-svn/patches/patch-src_VBox_NetworkServices_NAT_pxudp.c
	virtualbox-svn/patches/patch-src_VBox_Runtime_Makefile.kmk
	virtualbox-svn/patches/patch-src_VBox_Runtime_VBox_log-vbox.cpp
	virtualbox-svn/patches/patch-src_VBox_Runtime_r0drv_netbsd_alloc-r0drv-netbsd.c
	virtualbox-svn/patches/patch-src_VBox_Runtime_r0drv_netbsd_assert-r0drv-netbsd.c
	virtualbox-svn/patches/patch-src_VBox_Runtime_r0drv_netbsd_initterm-r0drv-netbsd.c
	virtualbox-svn/patches/patch-src_VBox_Runtime_r0drv_netbsd_memobj-r0drv-netbsd.c
	virtualbox-svn/patches/patch-src_VBox_Runtime_r0drv_netbsd_memuserkernel-r0drv-netbsd.c
	virtualbox-svn/patches/patch-src_VBox_Runtime_r0drv_netbsd_mp-r0drv-netbsd.c
	virtualbox-svn/patches/patch-src_VBox_Runtime_r0drv_netbsd_process-r0drv-netbsd.c
	virtualbox-svn/patches/patch-src_VBox_Runtime_r0drv_netbsd_semevent-r0drv-netbsd.c
	virtualbox-svn/patches/patch-src_VBox_Runtime_r0drv_netbsd_semeventmulti-r0drv-netbsd.c
	virtualbox-svn/patches/patch-src_VBox_Runtime_r0drv_netbsd_semfastmutex-r0drv-netbsd.c
	virtualbox-svn/patches/patch-src_VBox_Runtime_r0drv_netbsd_semmutex-r0drv-netbsd.c
	virtualbox-svn/patches/patch-src_VBox_Runtime_r0drv_netbsd_sleepqueue-r0drv-netbsd.h
	virtualbox-svn/patches/patch-src_VBox_Runtime_r0drv_netbsd_spinlock-r0drv-netbsd.c
	virtualbox-svn/patches/patch-src_VBox_Runtime_r0drv_netbsd_the-netbsd-kernel.h
	virtualbox-svn/patches/patch-src_VBox_Runtime_r0drv_netbsd_thread-r0drv-netbsd.c
	virtualbox-svn/patches/patch-src_VBox_Runtime_r0drv_netbsd_thread2-r0drv-netbsd.c
	virtualbox-svn/patches/patch-src_VBox_Runtime_r0drv_netbsd_time-r0drv-netbsd.c
	virtualbox-svn/patches/patch-src_VBox_Runtime_r0drv_netbsd_timer-r0drv-netbsd.c
	virtualbox-svn/patches/patch-src_VBox_Runtime_r3_init.cpp
	virtualbox-svn/patches/patch-src_VBox_Runtime_r3_netbsd_fileaio-netbsd.cpp
	virtualbox-svn/patches/patch-src_VBox_Runtime_r3_netbsd_mp-netbsd.cpp
	virtualbox-svn/patches/patch-src_VBox_Runtime_r3_netbsd_rtProcInitExePath-netbsd.cpp
	virtualbox-svn/patches/patch-src_VBox_Runtime_r3_netbsd_systemmem-netbsd.cpp
	virtualbox-svn/patches/patch-src_VBox_Runtime_r3_posix_fileaio-posix.cpp
	virtualbox-svn/patches/patch-src_VBox_Runtime_r3_posix_fileio-posix.cpp
	virtualbox-svn/patches/patch-src_VBox_Runtime_r3_posix_fs-posix.cpp
	virtualbox-svn/patches/patch-src_VBox_Runtime_r3_posix_path2-posix.cpp
	virtualbox-svn/patches/patch-src_VBox_Runtime_r3_posix_semevent-posix.cpp
	virtualbox-svn/patches/patch-src_VBox_Runtime_r3_posix_thread-posix.cpp
	virtualbox-svn/patches/patch-src_VBox_Runtime_r3_posix_thread2-posix.cpp
	virtualbox-svn/patches/patch-src_VBox_Runtime_r3_posix_utf8-posix.cpp
	virtualbox-svn/patches/patch-src_VBox_Storage_testcase_Makefile.kmk
	virtualbox-svn/patches/patch-src_VBox_VMM_VMMR0_GMMR0.cpp
	virtualbox-svn/patches/patch-src_VBox_VMM_VMMR0_VMMR0.cpp
	virtualbox-svn/patches/patch-src_VBox_VMM_VMMR3_PGMPhys.cpp
	virtualbox-svn/patches/patch-src_VBox_VMM_VMMR3_SSM.cpp
	virtualbox-svn/patches/patch-src_VBox_VMM_VMMR3_VM.cpp
	virtualbox-svn/patches/patch-src_VBox_VMM_VMMRC_VMMRCDeps.cpp
	virtualbox-svn/patches/patch-src_VBox_VMM_include_CPUMInternal.h
	virtualbox-svn/patches/patch-src_VBox_VMM_testcase_mkdsk.sh
	virtualbox-svn/patches/patch-src_VBox_VMM_testcase_tstX86-1.cpp
	virtualbox-svn/patches/patch-src_VBox_ValidationKit_Makefile.kmk
	virtualbox-svn/patches/patch-src_VBox_ValidationKit_testboxscript_testboxscript__real.py
	virtualbox-svn/patches/patch-src_VBox_ValidationKit_testdriver_base.py
	virtualbox-svn/patches/patch-src_VBox_ValidationKit_testdriver_vbox.py
	virtualbox-svn/patches/patch-src_VBox_ValidationKit_testdriver_vboxtestvms.py
	virtualbox-svn/patches/patch-src_VBox_ValidationKit_testmanager_core_coreconsts.py
	virtualbox-svn/patches/patch-src_VBox_ValidationKit_tests_autostart_tdAutostart1.py
	virtualbox-svn/patches/patch-src_apps_Makefile.kmk
	virtualbox-svn/patches/patch-src_libs_libxml2-2.9.2_include_vboxconfig.h
	virtualbox-svn/patches/patch-src_libs_xpcom18a4_nsprpub_pr_include_md___netbsd.cfg
	virtualbox-svn/patches/patch-src_recompiler_Makefile.kmk
	virtualbox-svn/patches/patch-src_recompiler_exec.c
	virtualbox-svn/patches/patch-tools_bin_gen-slickedit-workspace.sh

Log Message:
Import virtualbox-0.0.0nb20160710 as wip/virtualbox-svn.

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=496fd41e30040766e8d88e71c3345b1137140b7b

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

diffstat:
 virtualbox-svn/DESCR                               |    7 +
 virtualbox-svn/Makefile                            |  115 +++
 virtualbox-svn/PLIST                               |    0
 virtualbox-svn/distinfo                            |  259 +++++
 virtualbox-svn/patches/patch-Config.kmk            |  172 ++++
 virtualbox-svn/patches/patch-Makefile.kmk          |  178 ++++
 virtualbox-svn/patches/patch-configure             |  112 ++
 .../patches/patch-include_VBox_VBoxGuest.h         |   41 +
 .../patches/patch-include_VBox_ostypes.h           |   13 +
 virtualbox-svn/patches/patch-include_VBox_param.h  |   18 +
 virtualbox-svn/patches/patch-include_VBox_rawpci.h |   22 +
 virtualbox-svn/patches/patch-include_VBox_types.h  |   13 +
 virtualbox-svn/patches/patch-include_VBox_usb.h    |   18 +
 .../patches/patch-include_VBox_vmm_cfgm.h          |   40 +
 .../patches/patch-include_VBox_vmm_cpum.h          |   56 +
 .../patches/patch-include_VBox_vmm_dbgf.h          |   40 +
 .../patches/patch-include_VBox_vmm_ftm.h           |   33 +
 .../patches/patch-include_VBox_vmm_gmm.h           |  224 ++++
 .../patches/patch-include_VBox_vmm_gvm.h           |   18 +
 .../patches/patch-include_VBox_vmm_gvmm.h          |   84 ++
 virtualbox-svn/patches/patch-include_VBox_vmm_hm.h |   32 +
 .../patches/patch-include_VBox_vmm_iom.h           |    9 +
 virtualbox-svn/patches/patch-include_VBox_vmm_mm.h |  290 ++++++
 .../patches/patch-include_VBox_vmm_pdmapi.h        |   71 ++
 .../patch-include_VBox_vmm_pdmasynccompletion.h    |   23 +
 .../patches/patch-include_VBox_vmm_pdmblkcache.h   |   72 ++
 .../patches/patch-include_VBox_vmm_pdmcritsect.h   |   41 +
 .../patches/patch-include_VBox_vmm_pdmcritsectrw.h |   18 +
 .../patches/patch-include_VBox_vmm_pdmdev.h        |   40 +
 .../patches/patch-include_VBox_vmm_pdmpci.h        |   28 +
 .../patches/patch-include_VBox_vmm_pdmqueue.h      |   44 +
 .../patches/patch-include_VBox_vmm_pdmthread.h     |   34 +
 .../patches/patch-include_VBox_vmm_pgm.h           |  510 ++++++++++
 .../patches/patch-include_VBox_vmm_ssm.h           |  152 +++
 .../patches/patch-include_VBox_vmm_stam.h          |   59 ++
 virtualbox-svn/patches/patch-include_VBox_vmm_tm.h |  171 ++++
 .../patches/patch-include_VBox_vmm_uvm.h           |   27 +
 .../patches/patch-include_VBox_vmm_vmapi.h         |   64 ++
 .../patches/patch-include_VBox_vmm_vmm.h           |   75 ++
 virtualbox-svn/patches/patch-include_iprt_stdint.h |   39 +
 virtualbox-svn/patches/patch-include_iprt_string.h |    9 +
 virtualbox-svn/patches/patch-include_iprt_time.h   |   18 +
 virtualbox-svn/patches/patch-include_iprt_types.h  |   24 +
 virtualbox-svn/patches/patch-kBuild_header.kmk     |   92 ++
 .../patches/patch-src_VBox_Additions_Makefile.kmk  |   56 +
 ...dditions_common_VBoxGuestLib_VBoxGuestR3Lib.cpp |   44 +
 ...tions_common_VBoxGuestLib_VBoxGuestR3LibLog.cpp |   18 +
 ...rc_VBox_Additions_common_VBoxGuest_Makefile.kmk |   78 ++
 ...x_Additions_common_VBoxGuest_VBoxGuest-netbsd.c |  636 ++++++++++++
 ...c_VBox_Additions_common_VBoxGuest_VBoxGuest.cpp |   18 +
 ..._Additions_common_VBoxGuest_VBoxGuestInternal.h |   18 +
 ...VBox_Additions_common_VBoxGuest_netbsd_Makefile |  171 ++++
 ...itions_common_VBoxGuest_netbsd_files__vboxguest |  204 ++++
 ...ox_Additions_common_VBoxService_VBoxService.cpp |   18 +
 ...itions_common_VBoxService_VBoxServiceVMInfo.cpp |   65 ++
 ...src_VBox_Additions_common_crOpenGL_Makefile.kmk |  169 ++++
 ...ox_Additions_common_crOpenGL_NetBSD__exports.py |   16 +
 ...c_VBox_Additions_common_crOpenGL_fakedri__drv.c |   42 +
 ...h-src_VBox_Additions_netbsd_Installer_pkg-descr |    8 +
 ...rc_VBox_Additions_netbsd_Installer_vboxguest.sh |  140 +++
 .../patch-src_VBox_Additions_netbsd_Makefile       |   58 ++
 .../patch-src_VBox_Additions_netbsd_Makefile.kmk   |  196 ++++
 .../patch-src_VBox_Additions_netbsd_drm_Makefile   |   31 +
 ...atch-src_VBox_Additions_netbsd_drm_Makefile.kmk |   76 ++
 ...VBox_Additions_netbsd_drm_files__vboxvideo__drm |   30 +
 ...-src_VBox_Additions_netbsd_drm_vboxvideo__drm.c |  144 +++
 ...-src_VBox_Additions_netbsd_vboxvfs_Makefile.kmk |   68 ++
 ...tch-src_VBox_Additions_netbsd_vboxvfs_vboxvfs.h |   97 ++
 ...VBox_Additions_netbsd_vboxvfs_vboxvfs__vfsops.c |  263 +++++
 ..._VBox_Additions_netbsd_vboxvfs_vboxvfs__vnops.c |  246 +++++
 .../patch-src_VBox_Debugger_DBGCCommands.cpp       |   18 +
 .../patches/patch-src_VBox_Debugger_DBGCInternal.h |   18 +
 .../patches/patch-src_VBox_Debugger_DBGConsole.cpp |   18 +
 .../patch-src_VBox_Debugger_DBGPlugInDiggers.cpp   |   17 +
 .../patches/patch-src_VBox_Debugger_DBGPlugIns.h   |   17 +
 .../patch-src_VBox_Devices_Bus_SrvPciRawR0.cpp     |   40 +
 ...pplications_Python_PyMod-2.7.2_Include_pyport.h |   23 +
 ...ox_Devices_EFI_Firmware_StdLib_Include_dirent.h |   23 +
 ...VBox_Devices_EFI_Firmware_StdLib_Include_glob.h |   15 +
 ...ox_Devices_EFI_Firmware_StdLib_Include_locale.h |   13 +
 ...ices_EFI_Firmware_StdLib_Include_sys_EfiCdefs.h |   13 +
 ...Devices_EFI_Firmware_StdLib_Include_sys_bswap.h |   15 +
 ...s_EFI_Firmware_StdLib_Include_sys_cdefs__aout.h |   13 +
 ...evices_EFI_Firmware_StdLib_Include_sys_socket.h |   13 +
 ...ox_Devices_EFI_Firmware_StdLib_Include_unistd.h |   13 +
 .../patches/patch-src_VBox_Devices_Makefile.kmk    |   51 +
 .../patch-src_VBox_Devices_Network_DrvNAT.cpp      |   18 +
 ...ox_Devices_Network_slirp_resolv__conf__parser.c |    2 +
 .../patch-src_VBox_Devices_Network_slirp_udp.c     |   13 +
 .../patches/patch-src_VBox_Devices_PC_DrvACPI.cpp  |   15 +
 ...patch-src_VBox_Devices_Serial_DrvHostSerial.cpp |  135 +++
 .../patch-src_VBox_Devices_Storage_DrvHostBase.cpp |   89 ++
 .../patch-src_VBox_Devices_Storage_DrvHostBase.h   |   22 +
 .../patch-src_VBox_Devices_Storage_DrvHostDVD.cpp  |   63 ++
 ...ox_Devices_USB_netbsd_USBProxyDevice-netbsd.cpp | 1066 ++++++++++++++++++++
 .../patch-src_VBox_Devices_build_VBoxDD.cpp        |   31 +
 .../patches/patch-src_VBox_Devices_build_VBoxDD.h  |    9 +
 ...h-src_VBox_ExtPacks_BusMouseSample_Makefile.kmk |   22 +
 .../patch-src_VBox_ExtPacks_Skeleton_Makefile.kmk  |   22 +
 ...patch-src_VBox_ExtPacks_VBoxDTrace_Makefile.kmk |   22 +
 ..._VBox_ExtPacks_VBoxDTrace_VBoxDTraceWrapper.cpp |   18 +
 .../patch-src_VBox_ExtPacks_VNC_Makefile.kmk       |   22 +
 ...Frontends_VBoxAutostart_VBoxAutostart-posix.cpp |   18 +
 ...VBox_Frontends_VBoxBalloonCtrl_VBoxWatchdog.cpp |   45 +
 ...Box_Frontends_VBoxManage_VBoxInternalManage.cpp |   54 +
 ...rc_VBox_Frontends_VBoxManage_VBoxManageHelp.cpp |   50 +
 ...Box_Frontends_VBoxManage_VBoxManageModifyVM.cpp |    2 +
 .../patch-src_VBox_Frontends_VBoxSDL_Makefile.kmk  |   17 +
 ...atch-src_VBox_Frontends_VirtualBox_Makefile.kmk |   33 +
 ..._Frontends_VirtualBox_src_VBoxGLSupportInfo.cpp |   18 +
 ...rontends_VirtualBox_src_net_UIUpdateManager.cpp |   18 +
 ...src_settings_machine_UIMachineSettingsAudio.cpp |    9 +
 .../patch-src_VBox_GuestHost_OpenGL_Makefile.kmk   |   54 +
 ...ch-src_VBox_GuestHost_OpenGL_include_chromium.h |   13 +
 ...tch-src_VBox_GuestHost_OpenGL_include_cr__dll.h |   13 +
 ...h-src_VBox_GuestHost_OpenGL_include_cr__timer.h |   13 +
 ...c_VBox_GuestHost_OpenGL_spu__loader_glloader.py |   32 +
 .../patch-src_VBox_GuestHost_OpenGL_util_dll.c     |   40 +
 ...ch-src_VBox_GuestHost_OpenGL_util_environment.c |   13 +
 .../patch-src_VBox_GuestHost_OpenGL_util_timer.c   |   13 +
 ...patch-src_VBox_GuestHost_OpenGL_util_vboxhgcm.c |   31 +
 ...atch-src_VBox_GuestHost_OpenGL_util_vboxhgsmi.c |   31 +
 ...src_VBox_GuestHost_SharedClipboard_Makefile.kmk |    9 +
 .../patch-src_VBox_HostDrivers_Makefile.kmk        |   31 +
 ...patch-src_VBox_HostDrivers_Support_Makefile.kmk |   69 ++
 .../patch-src_VBox_HostDrivers_Support_SUPDrv.cpp  |   27 +
 ...atch-src_VBox_HostDrivers_Support_SUPDrvGip.cpp |   18 +
 .../patch-src_VBox_HostDrivers_Support_SUPDrvIDC.h |   19 +
 ...h-src_VBox_HostDrivers_Support_SUPDrvInternal.h |   18 +
 ...h-src_VBox_HostDrivers_Support_SUPDrvTracer.cpp |   18 +
 ..._VBox_HostDrivers_Support_SUPR3HardenedMain.cpp |   65 ++
 ...ch-src_VBox_HostDrivers_Support_netbsd_Makefile |  189 ++++
 ...VBox_HostDrivers_Support_netbsd_SUPDrv-netbsd.c |  637 ++++++++++++
 ...ox_HostDrivers_Support_netbsd_SUPDrv-netbsd.def |    6 +
 ...ox_HostDrivers_Support_netbsd_SUPLib-netbsd.cpp |  190 ++++
 ...tDrivers_Support_netbsd_SUPR0IdcClient-netbsd.c |   60 ++
 ..._VBox_HostDrivers_Support_netbsd_files__vboxdrv |  216 ++++
 ...ch-src_VBox_HostDrivers_VBoxNetAdp_Makefile.kmk |   64 ++
 ...Box_HostDrivers_VBoxNetAdp_VBoxNetAdpInternal.h |   21 +
 ...src_VBox_HostDrivers_VBoxNetAdp_netbsd_Makefile |   40 +
 ...stDrivers_VBoxNetAdp_netbsd_VBoxNetAdp-netbsd.c |  331 ++++++
 ...HostDrivers_VBoxNetAdp_netbsd_files__vboxnetadp |   85 ++
 ...ch-src_VBox_HostDrivers_VBoxNetFlt_Makefile.kmk |   54 +
 ...Box_HostDrivers_VBoxNetFlt_VBoxNetFltInternal.h |   40 +
 ...src_VBox_HostDrivers_VBoxNetFlt_netbsd_Makefile |   43 +
 ...stDrivers_VBoxNetFlt_netbsd_VBoxNetFlt-netbsd.c |  802 +++++++++++++++
 ...HostDrivers_VBoxNetFlt_netbsd_files__vboxnetflt |   90 ++
 .../patch-src_VBox_HostDrivers_netbsd_Makefile     |   81 ++
 .../patch-src_VBox_HostDrivers_netbsd_Makefile.kmk |   30 +
 .../patch-src_VBox_HostServices_Makefile.kmk       |   24 +
 ..._VBox_HostServices_SharedClipboard_Makefile.kmk |   22 +
 ...src_VBox_HostServices_SharedOpenGL_Makefile.kmk |   17 +
 .../patch-src_VBox_HostServices_auth_Makefile.kmk  |    9 +
 ...ch-src_VBox_HostServices_auth_pam_VBoxAuthPAM.c |   13 +
 ...tch-src_VBox_ImageMounter_VBoxFUSE_Makefile.kmk |   13 +
 ...tch-src_VBox_ImageMounter_VBoxFUSE_VBoxFUSE.cpp |   27 +
 .../patches/patch-src_VBox_Installer_Makefile.kmk  |   19 +
 ...src_VBox_Installer_darwin_VirtualBox_postflight |   18 +
 ...-src_VBox_Installer_darwin_VirtualBox_preflight |   13 +
 .../patch-src_VBox_Installer_linux_VBoxSysInfo.sh  |   27 +
 .../patch-src_VBox_Installer_linux_debian_control  |   22 +
 ...c_VBox_Installer_linux_rpm_VirtualBox.tmpl.spec |   13 +
 .../patch-src_VBox_Installer_netbsd_Makefile.kmk   |  343 +++++++
 .../patch-src_VBox_Installer_netbsd_pkg-comment    |    6 +
 .../patch-src_VBox_Installer_netbsd_pkg-descr      |    8 +
 .../patch-src_VBox_Installer_netbsd_pkg__plist     |  103 ++
 ...atch-src_VBox_Installer_netbsd_postdeinstall.sh |   36 +
 .../patch-src_VBox_Installer_netbsd_postinstall.sh |   80 ++
 ...ch-src_VBox_Installer_netbsd_virtualbox.desktop |   23 +
 .../patches/patch-src_VBox_Main_Makefile.kmk       |   39 +
 .../patch-src_VBox_Main_cbinding_VBoxCAPIGlue.c    |   28 +
 .../patch-src_VBox_Main_cbinding_VBoxCAPI__v2__2.h |   14 +
 .../patch-src_VBox_Main_cbinding_VBoxCAPI__v3__0.h |   14 +
 .../patch-src_VBox_Main_glue_NativeEventQueue.cpp  |   16 +
 .../patch-src_VBox_Main_glue_tests_Makefile        |   13 +
 .../patch-src_VBox_Main_include_ConsoleImpl.h      |   22 +
 ...patch-src_VBox_Main_include_HostUSBDeviceImpl.h |    2 +
 .../patch-src_VBox_Main_include_USBProxyService.h  |    2 +
 .../patch-src_VBox_Main_include_ovfreader.h        |   19 +
 .../patch-src_VBox_Main_src-client_ConsoleImpl.cpp |   54 +
 ...patch-src_VBox_Main_src-client_ConsoleImpl2.cpp |   51 +
 ...atch-src_VBox_Main_src-server_ApplianceImpl.cpp |   25 +
 ...tch-src_VBox_Main_src-server_HostDnsService.cpp |   13 +
 ...patch-src_VBox_Main_src-server_HostDnsService.h |   31 +
 .../patch-src_VBox_Main_src-server_HostImpl.cpp    |   54 +
 ...ox_Main_src-server_HostNetworkInterfaceImpl.cpp |   16 +
 .../patch-src_VBox_Main_src-server_MachineImpl.cpp |   13 +
 ..._VBox_Main_src-server_generic_NetIf-generic.cpp |   22 +
 ...x_Main_src-server_netbsd_HostHardwareNetBSD.cpp |  389 +++++++
 ...ch-src_VBox_Main_src-server_netbsd_Makefile.kup |    6 +
 ...rc_VBox_Main_src-server_netbsd_NetIf-netbsd.cpp |  429 ++++++++
 ...ox_Main_src-server_netbsd_PerformanceNetBSD.cpp |  122 +++
 ...ain_src-server_netbsd_USBProxyServiceNetBSD.cpp |  359 +++++++
 .../patch-src_VBox_Main_testcase_tstCollector.cpp  |   19 +
 .../patch-src_VBox_Main_webservice_vboxweb.cpp     |   40 +
 .../patches/patch-src_VBox_Main_xml_Settings.cpp   |    2 +
 ...patch-src_VBox_Main_xml_VirtualBox-settings.xsd |   17 +
 virtualbox-svn/patches/patch-src_VBox_Makefile.kmk |   62 ++
 ...patch-src_VBox_NetworkServices_NAT_Makefile.kmk |   12 +
 .../patch-src_VBox_NetworkServices_NAT_pxping.c    |   13 +
 .../patch-src_VBox_NetworkServices_NAT_pxudp.c     |   13 +
 .../patches/patch-src_VBox_Runtime_Makefile.kmk    |  270 +++++
 .../patch-src_VBox_Runtime_VBox_log-vbox.cpp       |   57 ++
 ..._VBox_Runtime_r0drv_netbsd_alloc-r0drv-netbsd.c |  184 ++++
 ...VBox_Runtime_r0drv_netbsd_assert-r0drv-netbsd.c |   74 ++
 ...ox_Runtime_r0drv_netbsd_initterm-r0drv-netbsd.c |   57 ++
 ...VBox_Runtime_r0drv_netbsd_memobj-r0drv-netbsd.c |  811 +++++++++++++++
 ...ntime_r0drv_netbsd_memuserkernel-r0drv-netbsd.c |   87 ++
 ...src_VBox_Runtime_r0drv_netbsd_mp-r0drv-netbsd.c |  273 +++++
 ...Box_Runtime_r0drv_netbsd_process-r0drv-netbsd.c |   55 +
 ...ox_Runtime_r0drv_netbsd_semevent-r0drv-netbsd.c |  260 +++++
 ...ntime_r0drv_netbsd_semeventmulti-r0drv-netbsd.c |  324 ++++++
 ...untime_r0drv_netbsd_semfastmutex-r0drv-netbsd.c |  119 +++
 ...ox_Runtime_r0drv_netbsd_semmutex-r0drv-netbsd.c |  223 ++++
 ..._Runtime_r0drv_netbsd_sleepqueue-r0drv-netbsd.h |  334 ++++++
 ...ox_Runtime_r0drv_netbsd_spinlock-r0drv-netbsd.c |  214 ++++
 ...c_VBox_Runtime_r0drv_netbsd_the-netbsd-kernel.h |  106 ++
 ...VBox_Runtime_r0drv_netbsd_thread-r0drv-netbsd.c |  186 ++++
 ...Box_Runtime_r0drv_netbsd_thread2-r0drv-netbsd.c |  139 +++
 ...c_VBox_Runtime_r0drv_netbsd_time-r0drv-netbsd.c |   78 ++
 ..._VBox_Runtime_r0drv_netbsd_timer-r0drv-netbsd.c |  290 ++++++
 .../patches/patch-src_VBox_Runtime_r3_init.cpp     |   18 +
 ...h-src_VBox_Runtime_r3_netbsd_fileaio-netbsd.cpp |  676 +++++++++++++
 .../patch-src_VBox_Runtime_r3_netbsd_mp-netbsd.cpp |  205 ++++
 ..._Runtime_r3_netbsd_rtProcInitExePath-netbsd.cpp |   77 ++
 ...src_VBox_Runtime_r3_netbsd_systemmem-netbsd.cpp |   79 ++
 ...tch-src_VBox_Runtime_r3_posix_fileaio-posix.cpp |   59 ++
 ...atch-src_VBox_Runtime_r3_posix_fileio-posix.cpp |   45 +
 .../patch-src_VBox_Runtime_r3_posix_fs-posix.cpp   |   45 +
 ...patch-src_VBox_Runtime_r3_posix_path2-posix.cpp |   17 +
 ...ch-src_VBox_Runtime_r3_posix_semevent-posix.cpp |   18 +
 ...atch-src_VBox_Runtime_r3_posix_thread-posix.cpp |   18 +
 ...tch-src_VBox_Runtime_r3_posix_thread2-posix.cpp |   36 +
 .../patch-src_VBox_Runtime_r3_posix_utf8-posix.cpp |   18 +
 .../patch-src_VBox_Storage_testcase_Makefile.kmk   |    9 +
 .../patches/patch-src_VBox_VMM_VMMR0_GMMR0.cpp     |   18 +
 .../patches/patch-src_VBox_VMM_VMMR0_VMMR0.cpp     |   27 +
 .../patches/patch-src_VBox_VMM_VMMR3_PGMPhys.cpp   |   36 +
 .../patches/patch-src_VBox_VMM_VMMR3_SSM.cpp       |  442 ++++++++
 .../patches/patch-src_VBox_VMM_VMMR3_VM.cpp        |   18 +
 .../patches/patch-src_VBox_VMM_VMMRC_VMMRCDeps.cpp |   32 +
 .../patch-src_VBox_VMM_include_CPUMInternal.h      |    9 +
 .../patches/patch-src_VBox_VMM_testcase_mkdsk.sh   |   13 +
 .../patch-src_VBox_VMM_testcase_tstX86-1.cpp       |   23 +
 .../patch-src_VBox_ValidationKit_Makefile.kmk      |   45 +
 ...idationKit_testboxscript_testboxscript__real.py |   18 +
 ...patch-src_VBox_ValidationKit_testdriver_base.py |   17 +
 ...patch-src_VBox_ValidationKit_testdriver_vbox.py |   36 +
 ...rc_VBox_ValidationKit_testdriver_vboxtestvms.py |   55 +
 ...ox_ValidationKit_testmanager_core_coreconsts.py |   28 +
 ...x_ValidationKit_tests_autostart_tdAutostart1.py |   17 +
 virtualbox-svn/patches/patch-src_apps_Makefile.kmk |   17 +
 ...tch-src_libs_libxml2-2.9.2_include_vboxconfig.h |   18 +
 ...bs_xpcom18a4_nsprpub_pr_include_md___netbsd.cfg |   13 +
 .../patches/patch-src_recompiler_Makefile.kmk      |   17 +
 virtualbox-svn/patches/patch-src_recompiler_exec.c |   35 +
 .../patch-tools_bin_gen-slickedit-workspace.sh     |   12 +
 257 files changed, 21148 insertions(+)

diffs:
diff --git a/virtualbox-svn/DESCR b/virtualbox-svn/DESCR
new file mode 100644
index 0000000..d10019c
--- /dev/null
+++ b/virtualbox-svn/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-svn/Makefile b/virtualbox-svn/Makefile
new file mode 100644
index 0000000..70f78da
--- /dev/null
+++ b/virtualbox-svn/Makefile
@@ -0,0 +1,115 @@
+# $NetBSD$
+
+
+SVN_REPOSITORIES=	mirror
+SVN_ROOT.mirror=	https://www.virtualbox.org/svn/vbox
+
+.include "../../wip/mk/svn-package.mk"
+
+PKGNAME=	virtualbox-0.0.0
+CATEGORIES=	emulators
+
+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]*:../../devel/kbuild
+BUILD_DEPENDS+=	acpica-utils-[0-9]*:../../sysutils/acpica-utils
+
+TOOL_DEPENDS+=	libxml2-[0-9]*:../../textproc/libxml2 # for xmllint
+
+USE_TOOLS+=	gtar pkg-config bison flex perl
+
+WRKSRC=		${WRKDIR}/mirror/trunk
+
+HAS_CONFIGURE=		yes
+USE_LANGUAGES+=	c c++
+
+.include "../../mk/bsd.prefs.mk"
+
+.if ${OPSYS} == "Linux"
+# Required by Linux build
+BUILD_DEPENDS+=	makeself-[0-9]*:../../archivers/makeself
+.endif
+
+SUBST_CLASSES+=		paths
+SUBST_MESSAGE.paths=	Adjust paths for pkgsrc
+SUBST_STAGE.paths=	pre-configure
+#SUBST_STAGE.paths=	post-build
+SUBST_FILES.paths+=	configure
+SUBST_SED.paths+=	-e 's!^INCCRYPTO=.*!INCCRYPTO="-I${BUILDLINK_PREFIX.openssl}/include"!g'
+SUBST_SED.paths+=	-e 's!^LIBCRYPTO=.*!LIBCRYPTO="${COMPILER_RPATH_FLAG}${BUILDLINK_PREFIX.openssl}/lib -L${BUILDLINK_PREFIX.openssl}/lib -lssl -lcrypto"!g'
+SUBST_SED.paths+=	-e 's!^INCX11=.*!INCX11="-I${X11BASE}/include"!g'
+SUBST_SED.paths+=	-e 's!^LIBX11=.*!LIBX11="${COMPILER_RPATH_FLAG}${X11BASE}/lib -L${X11BASE}/lib -lXext -lX11"!g'
+SUBST_SED.paths+=	-e 's!^INCZ=.*!INCZ="-I${BUILDLINK_PREFIX.zlib}/include"!g'
+SUBST_SED.paths+=	-e 's!^LIBZ=.*!LIBZ="${COMPILER_RPATH_FLAG}${BUILDLINK_PREFIX.zlib}/lib -L${BUILDLINK_PREFIX.zlib}/lib -lz"!g'
+.if ${OPSYS} == "Linux"
+.include "../../sysutils/lvm2/buildlink3.mk"
+SUBST_SED.paths+=	-e 's!^INCDEVMAPPER=.*!INCDEVMAPPER="-I${BUILDLINK_PREFIX.lvm2}/include"!g'
+SUBST_SED.paths+=	-e 's!^LIBDEVMAPPER=.*!LIBDEVMAPPER="${COMPILER_RPATH_FLAG}${BUILDLINK_PREFIX.lvm2}/lib -L${BUILDLINK_PREFIX.lvm2}/lib -ldevmapper"!g'
+.include "../../sysutils/libcap/buildlink3.mk"
+SUBST_SED.paths+=	-e 's!^INCCAP=.*!INCCAP="-I${BUILDLINK_PREFIX.libcap}/include"!g'
+SUBST_SED.paths+=	-e 's!^LIBCAP=.*!LIBCAP="${COMPILER_RPATH_FLAG}${BUILDLINK_PREFIX.libcap}/lib -L${BUILDLINK_PREFIX.libcap}/lib -lcap"!g'
+.endif
+SUBST_SED.paths+=	-e 's!^INCCURL=.*!INCCURL="-I${BUILDLINK_PREFIX.curl}/include"!g'
+SUBST_SED.paths+=	-e 's!^LIBCURL=.*!LIBCURL="${COMPILER_RPATH_FLAG}${BUILDLINK_PREFIX.curl}/lib -L${BUILDLINK_PREFIX.curl}/lib -lcurl"!g'
+SUBST_SED.paths+=	-e 's!^INCPULSE=.*!INCPULSE="-I${BUILDLINK_PREFIX.pulseaudio}/include"!g'
+SUBST_SED.paths+=	-e 's!^LIBPULSE=.*!LIBPULSE="${COMPILER_RPATH_FLAG}${BUILDLINK_PREFIX.pulseaudio}/lib -L${BUILDLINK_PREFIX.pulseaudio}/lib"!g'
+SUBST_SED.paths+=	-e 's!^INCPNG=.*!INCPNG="-I${BUILDLINK_PREFIX.png}/include"!g'
+SUBST_SED.paths+=	-e 's!^LIBPNG=.*!LIBPNG="${COMPILER_RPATH_FLAG}${BUILDLINK_PREFIX.png}/lib -L${BUILDLINK_PREFIX.png}/lib"!g'
+SUBST_SED.paths+=	-e 's!^INCVPX=.*!INCVPX="-I${BUILDLINK_PREFIX.libvpx}/include"!g'
+SUBST_SED.paths+=	-e 's!^LIBVPX=.*!LIBVPX="${COMPILER_RPATH_FLAG}${BUILDLINK_PREFIX.libvpx}/lib -L${BUILDLINK_PREFIX.libvpx}/lib -lvpx"!g'
+# These paths are used as a shell enumeration to check
+SUBST_SED.paths+=	-e 's!^PYTHONDIR=.*!PYTHONDIR="${PREFIX}"!g'
+SUBST_SED.paths+=	-e 's!^QT4DIR=.*!QT4DIR="${QTDIR}"!g'
+# Set proper path of Python libs under ${PREFIX}/lib..
+SUBST_SED.paths+=	-e 's!lib/x86_64-linux-gnu lib/i386-linux-gnu lib64 lib/64 lib!lib!g'
+# Use pkgsrc provided Python version
+SUBST_SED.paths+=	-e 's!SUPPYTHONLIBS=.*!SUPPYTHONLIBS="python${PYVERSSUFFIX}"!g'
+# Add needed rpath for testing execution of an application linked with libpython
+SUBST_SED.paths+=	-e 's!PYTHONLIBRPATH=.*!PYTHONLIBRPATH="${COMPILER_RPATH_FLAG}${PREFIX}/lib"!g'
+
+VBLIBDIR=	${PREFIX}/lib/virtualbox
+
+KMK_ENV_VARS+=	KBUILD_PATH=${WRKSRC}/kBuild
+KMK_ENV_VARS+=	KBUILD_LIB_SEARCH_ROOTS="/ /usr/ ${X11BASE}/ ${PREFIX}/"
+# Multiple jobs tend to be broken
+KMK_FLAGS+=	-j1
+
+pre-configure:
+	${RUN} ${ECHO} "VBOX_GCC_OPT=${CXXFLAGS}" >> ${WRKSRC}/LocalConfig.kmk
+	${RUN} ${ECHO} "VBOX_WITH_ORIGIN:=" >> ${WRKSRC}/LocalConfig.kmk
+	${RUN} ${ECHO} "VBOX_WITH_RUNPATH:=${VBLIBDIR}" >> ${WRKSRC}/LocalConfig.kmk
+	${RUN} ${ECHO} "VBOX_PATH_APP_PRIVATE_ARCH:=${VBLIBDIR}" >> ${WRKSRC}/LocalConfig.kmk
+	${RUN} ${ECHO} "VBOX_PATH_APP_PRIVATE:=${VBLIBDIR}" >> ${WRKSRC}/LocalConfig.kmk
+	${RUN} ${ECHO} "VBOX_WITH_TESTCASES=" >> ${WRKSRC}/LocalConfig.kmk
+	${RUN} ${ECHO} "VBOX_WITH_TESTSUITE:=" >> ${WRKSRC}/LocalConfig.kmk
+	${RUN} ${ECHO} "VBOX_JAVA_HOME:=${JAVA_HOME}" >> ${WRKSRC}/LocalConfig.kmk
+	${RUN} ${ECHO} "VBOX_USE_SYSTEM_XORG_HEADERS:=1" >> ${WRKSRC}/LocalConfig.kmk
+
+do-build:
+	${RUN} cd ${WRKSRC} && . ./env.sh && ${KMK_ENV_VARS} kmk ${KMK_FLAGS}
+
+do-install:
+	${RUN} cd ${WRKSRC} && . ./env.sh && kmk install
+
+.include "../../mk/java-vm.mk"
+.include "../../net/libIDL/buildlink3.mk"
+.include "../../audio/pulseaudio/buildlink3.mk"
+.include "../../multimedia/libvpx/buildlink3.mk"
+.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 "../../devel/glib2/buildlink3.mk"
+.include "../../x11/libXext/buildlink3.mk"
+.include "../../x11/qt4-libs/buildlink3.mk"
+.include "../../lang/python/pyversion.mk"
+.include "../../lang/python/application.mk"
+.include "../../lang/python/tool.mk"
+.include "../../mk/bsd.pkg.mk"
diff --git a/virtualbox-svn/PLIST b/virtualbox-svn/PLIST
new file mode 100644
index 0000000..e69de29
diff --git a/virtualbox-svn/distinfo b/virtualbox-svn/distinfo
new file mode 100644
index 0000000..03afe9f
--- /dev/null
+++ b/virtualbox-svn/distinfo
@@ -0,0 +1,259 @@
+$NetBSD$
+
+SHA1 (VirtualBox-5.0.16.tar.bz2) = ca7b3fadda37b1b281f78ef2d573aceacab7d9fd
+RMD160 (VirtualBox-5.0.16.tar.bz2) = 6d7a5d6cae5367d26a015895c09294ff0282d062
+SHA512 (VirtualBox-5.0.16.tar.bz2) = 3da3a227360fb50d299e99770378f65e8cb99525377343fa8faff2360be66643d46f68323d6a8b8d4d26182082f171bb35ab2497167bf6df18827a5ea7742074
+Size (VirtualBox-5.0.16.tar.bz2) = 111062984 bytes
+SHA1 (patch-Config.kmk) = bf75f895acb2e931d03a651f0f3c073168e87f51
+SHA1 (patch-Makefile.kmk) = e658f6c320a115cbb0592eb6d0bd13b3da65e6a6
+SHA1 (patch-configure) = e4107b03d50583c65aa30d12fd62beb1de5f3703
+SHA1 (patch-include_VBox_VBoxGuest.h) = 4f41910ca3abbc502bad31cb9f9b427566025765
+SHA1 (patch-include_VBox_ostypes.h) = fd452f95c79b2e5c98a048af21f6561c80adebc5
+SHA1 (patch-include_VBox_param.h) = 1efcacb3e7890344dc132fee85b945bf9baa9614
+SHA1 (patch-include_VBox_rawpci.h) = e79ddcf19ea8862bc648678cb8212ebd33b38098
+SHA1 (patch-include_VBox_types.h) = 2f4c71862085a5694c080b498bdb82a55ad712b8
+SHA1 (patch-include_VBox_usb.h) = c16d333f6dee240f1d4147cc49c04451dfb776a7
+SHA1 (patch-include_VBox_vmm_cfgm.h) = f83d729ed8ffd9f059c9d06bb002d9fa54670bb1
+SHA1 (patch-include_VBox_vmm_cpum.h) = e27ece4c6b634875440d1de46a05b1e57410fc28
+SHA1 (patch-include_VBox_vmm_dbgf.h) = 43a139b5800a93369ddd7d1e054446f05a160bc2
+SHA1 (patch-include_VBox_vmm_ftm.h) = 3a9350453e466dbc96baf27b5d93b912da474811
+SHA1 (patch-include_VBox_vmm_gmm.h) = 090b7e673cf5ad580ca3ba36aa58d665808e5ec0
+SHA1 (patch-include_VBox_vmm_gvm.h) = 424767981594e5c10be1a79083fa49d7fb84eb34
+SHA1 (patch-include_VBox_vmm_gvmm.h) = 4807df4ee6ab5c6536a52959643b188e85338808
+SHA1 (patch-include_VBox_vmm_hm.h) = 3d0f03d1c713f6f23e3b891b670545c56b9aa618
+SHA1 (patch-include_VBox_vmm_iom.h) = 195c0aaf6debcfb8c8780f40c365580b578cf66a
+SHA1 (patch-include_VBox_vmm_mm.h) = ff8727b1167ce1e78726f6dcb38e18a8bef1ee9a
+SHA1 (patch-include_VBox_vmm_pdmapi.h) = 0fa6e55b256ef4fff937b9d2fde0966d61ca0e8f
+SHA1 (patch-include_VBox_vmm_pdmasynccompletion.h) = d2450d59d45205ea9088a724cc6ef0bebabfc7c7
+SHA1 (patch-include_VBox_vmm_pdmblkcache.h) = 9a2a4583ecc8ff127e6fe2f597cc2a92b941bd3c
+SHA1 (patch-include_VBox_vmm_pdmcritsect.h) = 4081ac5f87a6b2d8778dc03aa8b42ab349c4ce3f
+SHA1 (patch-include_VBox_vmm_pdmcritsectrw.h) = 3eefdd3a539d30e38ca3a2fffdfd1cc134cb69c2
+SHA1 (patch-include_VBox_vmm_pdmdev.h) = 2d839e1dfbaa545fd894ca7f3d4837143fc6450d
+SHA1 (patch-include_VBox_vmm_pdmpci.h) = b2c2662cc85ce0f6af11e7846c8127a740bd778f
+SHA1 (patch-include_VBox_vmm_pdmqueue.h) = 1530794bb5698746be12a92d2a511f0961cfb612
+SHA1 (patch-include_VBox_vmm_pdmthread.h) = 849fe1991fccda5a6c142b559932ca31df8a2f08
+SHA1 (patch-include_VBox_vmm_pgm.h) = 3ac8e962da6d44c47fa155234a50fe7e63546fed
+SHA1 (patch-include_VBox_vmm_ssm.h) = d3897c09739809332df66121f94ca64fc829eb6f
+SHA1 (patch-include_VBox_vmm_stam.h) = 17ada0b96c1d688187c4d8b98824912bea9480b4
+SHA1 (patch-include_VBox_vmm_tm.h) = 1ee6f17044409fa83407904083b8940a15398495
+SHA1 (patch-include_VBox_vmm_uvm.h) = ace6cdfc0a1002a4de1bbbeb76c5fc04cc0b4486
+SHA1 (patch-include_VBox_vmm_vmapi.h) = ef685e1b9d7c61a7c1c76637f38b187d6dd6c4b1
+SHA1 (patch-include_VBox_vmm_vmm.h) = 70d5a6b4b84d5bb38a1998a779a449d501521aa5
+SHA1 (patch-include_iprt_stdint.h) = 40d6466fa5cb9a67082d3926e658236b265a4eef
+SHA1 (patch-include_iprt_string.h) = 23a35be874a57415fdeb9bf82348319dc60f787e
+SHA1 (patch-include_iprt_time.h) = 9940a7b65300990d2fbeb7629813323e8b7971c5
+SHA1 (patch-include_iprt_types.h) = d16aefb1bb6e93e1cab002d7149ab46823cdf10a
+SHA1 (patch-kBuild_header.kmk) = b08bde255f27e9e62d15c649b16a34d72b4d79f6
+SHA1 (patch-src_VBox_Additions_Makefile.kmk) = e47ebb5cbfb51d103f76e1316b18e835fb5d6b1d
+SHA1 (patch-src_VBox_Additions_common_VBoxGuestLib_VBoxGuestR3Lib.cpp) = 99138a3a7abd00e74c50f0fdc841ac7984e11a08
+SHA1 (patch-src_VBox_Additions_common_VBoxGuestLib_VBoxGuestR3LibLog.cpp) = e0b83d8785a8bfe000c6467d125d3b45c1517ff7
+SHA1 (patch-src_VBox_Additions_common_VBoxGuest_Makefile.kmk) = 8c2cbd6e7fca2b685608c3103361ad039158281d
+SHA1 (patch-src_VBox_Additions_common_VBoxGuest_VBoxGuest-netbsd.c) = 2f064ab71cc663c8af000f96e2f4d906e37c4b90
+SHA1 (patch-src_VBox_Additions_common_VBoxGuest_VBoxGuest.cpp) = 70e98134ae1a57a8fe62df831ab91e2e29fe8419
+SHA1 (patch-src_VBox_Additions_common_VBoxGuest_VBoxGuestInternal.h) = 230b0725aedfa38476e63c10c2c38ce2302ebae0
+SHA1 (patch-src_VBox_Additions_common_VBoxGuest_netbsd_Makefile) = 0bf4f2612ee76df864204e96ffbd5c5a0361438a
+SHA1 (patch-src_VBox_Additions_common_VBoxGuest_netbsd_files__vboxguest) = c620e3df9c61ab6fc6f5914f39945a5ab8a622b1
+SHA1 (patch-src_VBox_Additions_common_VBoxService_VBoxService.cpp) = d2f1a2e2f18dff2b03348949c40f9f2a4fd5c4c4
+SHA1 (patch-src_VBox_Additions_common_VBoxService_VBoxServiceVMInfo.cpp) = f243f7fa833c05fae684ed8df5bb826dd630c86a
+SHA1 (patch-src_VBox_Additions_common_crOpenGL_Makefile.kmk) = 32431bb66f615477476db8c16ac3959ccbbf9da6
+SHA1 (patch-src_VBox_Additions_common_crOpenGL_NetBSD__exports.py) = d410ce3fb1494664c0443def76b166a80a767d66
+SHA1 (patch-src_VBox_Additions_common_crOpenGL_fakedri__drv.c) = 9b164dfd0ddc77dfe62ad8e0ea3f8bb40091af93
+SHA1 (patch-src_VBox_Additions_netbsd_Installer_pkg-descr) = 656e1953f0b9c8eb09fe25fbb09af502b30efa9c
+SHA1 (patch-src_VBox_Additions_netbsd_Installer_vboxguest.sh) = 25295205110c7a68fc57104f688084b2fc56828c
+SHA1 (patch-src_VBox_Additions_netbsd_Makefile) = 98da08e34af9003a55a121d431a7116374c485cd
+SHA1 (patch-src_VBox_Additions_netbsd_Makefile.kmk) = 03bc78e8f42b05445e9335fcd2c76e1122887313
+SHA1 (patch-src_VBox_Additions_netbsd_drm_Makefile) = 8b557d6450a658b577b117c6b3b7ab6778768977
+SHA1 (patch-src_VBox_Additions_netbsd_drm_Makefile.kmk) = 0f59622dcc0de56a61becc3dbc158d307e0483ca
+SHA1 (patch-src_VBox_Additions_netbsd_drm_files__vboxvideo__drm) = fdd8b4c6ec76fc765496be62ed0aad6435e5aead
+SHA1 (patch-src_VBox_Additions_netbsd_drm_vboxvideo__drm.c) = 498d7f621af8d3719e79fd5fa2690bfdb2e0368f
+SHA1 (patch-src_VBox_Additions_netbsd_vboxvfs_Makefile.kmk) = 30187f5b31e824a54ec01767e3f79d2f17708854
+SHA1 (patch-src_VBox_Additions_netbsd_vboxvfs_vboxvfs.h) = 4d0fc6c06af40e66ec70b5bb459739e150eb6c04
+SHA1 (patch-src_VBox_Additions_netbsd_vboxvfs_vboxvfs__vfsops.c) = 7f1c95df11fa32e3c693fcb28fe8484c738174da
+SHA1 (patch-src_VBox_Additions_netbsd_vboxvfs_vboxvfs__vnops.c) = e94574f46776b704755603d3a87be0ef6dee0827
+SHA1 (patch-src_VBox_Debugger_DBGCCommands.cpp) = 2fedb75b6309b33c026e33aede7d09e622fd044b
+SHA1 (patch-src_VBox_Debugger_DBGCInternal.h) = 08da7c39cfe85599d2bba8f6c4eaa26490bbf59b
+SHA1 (patch-src_VBox_Debugger_DBGConsole.cpp) = 27b108e8b7660ffededdf9b99120f40f2e3b9667
+SHA1 (patch-src_VBox_Debugger_DBGPlugInDiggers.cpp) = 3851f8bb02e1e00d504ca73542663ff78359bf01
+SHA1 (patch-src_VBox_Debugger_DBGPlugIns.h) = c98f48c70574f05d6afa33e5309610d74c0c32ec
+SHA1 (patch-src_VBox_Devices_Bus_SrvPciRawR0.cpp) = 2adaa8676ed8077bb6296f71e2b5852cde5b17e7
+SHA1 (patch-src_VBox_Devices_EFI_Firmware_AppPkg_Applications_Python_PyMod-2.7.2_Include_pyport.h) = 15e6b460ac962c607304268c640751af70eee1fa
+SHA1 (patch-src_VBox_Devices_EFI_Firmware_StdLib_Include_dirent.h) = 1ee0559b7051c74b50f1cf8e4ce2d73f1a08a094
+SHA1 (patch-src_VBox_Devices_EFI_Firmware_StdLib_Include_glob.h) = 92735bd434f4108c4ceacc3dcddd08842d62f137
+SHA1 (patch-src_VBox_Devices_EFI_Firmware_StdLib_Include_locale.h) = 9259891d0e70e5f17aa5cee6bbf8730e925fce3e
+SHA1 (patch-src_VBox_Devices_EFI_Firmware_StdLib_Include_sys_EfiCdefs.h) = 652297b8bb7fb69087039db5ba22b821416c565d
+SHA1 (patch-src_VBox_Devices_EFI_Firmware_StdLib_Include_sys_bswap.h) = e3f747df90cd8feea104c3b9eb325f5af8a5bfe2
+SHA1 (patch-src_VBox_Devices_EFI_Firmware_StdLib_Include_sys_cdefs__aout.h) = d17a8603a012cf41656be7ab427129b2242d3560
+SHA1 (patch-src_VBox_Devices_EFI_Firmware_StdLib_Include_sys_socket.h) = 6c9b2f7bd453416ec166fb79a1d1b97dd31e3c6a
+SHA1 (patch-src_VBox_Devices_EFI_Firmware_StdLib_Include_unistd.h) = 83bb09386d9c7f12702737eaee016466753734eb
+SHA1 (patch-src_VBox_Devices_Makefile.kmk) = c81420d2a090263ba46cd74c2924afbedb3e8717
+SHA1 (patch-src_VBox_Devices_Network_DrvNAT.cpp) = c24f0b47ee671833fcc9d8bb9a569cd1c6710d95
+SHA1 (patch-src_VBox_Devices_Network_slirp_resolv__conf__parser.c) = adc83b19e793491b1c6ea0fd8b46cd9f32e592fc
+SHA1 (patch-src_VBox_Devices_Network_slirp_udp.c) = 2e4e1030bcb66c5260d980216e40ed4e677c8914
+SHA1 (patch-src_VBox_Devices_PC_DrvACPI.cpp) = b1890a95780b425098f448c468816f9d9ce8c64e
+SHA1 (patch-src_VBox_Devices_Serial_DrvHostSerial.cpp) = 0d007ffe9ee83fa40b66970ec20f5d8cf42a26af
+SHA1 (patch-src_VBox_Devices_Storage_DrvHostBase.cpp) = aa5485a0fcd72f6188cca3339e17ca839e60ae1a
+SHA1 (patch-src_VBox_Devices_Storage_DrvHostBase.h) = e470c659f37730f0e01533918125c2d204b72e33
+SHA1 (patch-src_VBox_Devices_Storage_DrvHostDVD.cpp) = 2412e4c3fb0cc2eafe9aca57fa03f9f133c6083d
+SHA1 (patch-src_VBox_Devices_USB_netbsd_USBProxyDevice-netbsd.cpp) = 4e59b2b9576e185d19ff8ac442381d12c6203c17
+SHA1 (patch-src_VBox_Devices_build_VBoxDD.cpp) = c1920302563590815085f8c35f67601197631b8d
+SHA1 (patch-src_VBox_Devices_build_VBoxDD.h) = 3594559454aa51fe96cb3fbbc304fd788f386ffe
+SHA1 (patch-src_VBox_ExtPacks_BusMouseSample_Makefile.kmk) = 30258f2d52fd5d79a6678eb636366956273f2cea
+SHA1 (patch-src_VBox_ExtPacks_Skeleton_Makefile.kmk) = 619d98569376322460b4fc1176b6839224ebf0f8
+SHA1 (patch-src_VBox_ExtPacks_VBoxDTrace_Makefile.kmk) = 3c22df455dc5a573a0c6603fb6b368a6bae10005
+SHA1 (patch-src_VBox_ExtPacks_VBoxDTrace_VBoxDTraceWrapper.cpp) = f84f01b25fd870d247af1c07da91d137e43c9432
+SHA1 (patch-src_VBox_ExtPacks_VNC_Makefile.kmk) = bb1d503b158c67ee719813a60067098f48b0fc16
+SHA1 (patch-src_VBox_Frontends_VBoxAutostart_VBoxAutostart-posix.cpp) = a71304926b9ee6483db98a6820c412e240412f94
+SHA1 (patch-src_VBox_Frontends_VBoxBalloonCtrl_VBoxWatchdog.cpp) = f3cab833ad225707727b9c086e31eded736e21f6
+SHA1 (patch-src_VBox_Frontends_VBoxManage_VBoxInternalManage.cpp) = 6b4215e4559b3164978f1a5c2f9e222af90a1a7b
+SHA1 (patch-src_VBox_Frontends_VBoxManage_VBoxManageHelp.cpp) = f4887fa62c8f731c025cd2ae6a7f5d3fbc698adf
+SHA1 (patch-src_VBox_Frontends_VBoxManage_VBoxManageModifyVM.cpp) = adc83b19e793491b1c6ea0fd8b46cd9f32e592fc
+SHA1 (patch-src_VBox_Frontends_VBoxSDL_Makefile.kmk) = 2b97c7a5f9c6966c4416be63f7f2b9248cf76cd8
+SHA1 (patch-src_VBox_Frontends_VirtualBox_Makefile.kmk) = e42d3404532931389c637f9da4124aae06f24e5f
+SHA1 (patch-src_VBox_Frontends_VirtualBox_src_VBoxGLSupportInfo.cpp) = f6d5e4197f48b87a92c856b293234da32074ab54
+SHA1 (patch-src_VBox_Frontends_VirtualBox_src_net_UIUpdateManager.cpp) = a8b72c225780fe1e95f97960817256c1c5239bec
+SHA1 (patch-src_VBox_Frontends_VirtualBox_src_settings_machine_UIMachineSettingsAudio.cpp) = 6297923122001d8aafa9181e993f4d8537090a27
+SHA1 (patch-src_VBox_GuestHost_OpenGL_Makefile.kmk) = ab26b3a7948475f9419d4523a62d29de6baa8833
+SHA1 (patch-src_VBox_GuestHost_OpenGL_include_chromium.h) = f165da53ecffecf1efe717e3910eb89c85aa691b
+SHA1 (patch-src_VBox_GuestHost_OpenGL_include_cr__dll.h) = 14afc936727aa02d40d01d50e50a527f3b628c54
+SHA1 (patch-src_VBox_GuestHost_OpenGL_include_cr__timer.h) = fbc3e84725b65cf7cfae6a1c8c021f006482d61b
+SHA1 (patch-src_VBox_GuestHost_OpenGL_spu__loader_glloader.py) = c0adfee444458753c0ffbe62e5045213a4d51b95
+SHA1 (patch-src_VBox_GuestHost_OpenGL_util_dll.c) = 105691414621862e115c3fa84892357fc74077ae
+SHA1 (patch-src_VBox_GuestHost_OpenGL_util_environment.c) = 90e646ceb1a9502a916bb99b33529894210a8e94
+SHA1 (patch-src_VBox_GuestHost_OpenGL_util_timer.c) = 59d4b1296d928254c38bb79fac89d2e34f6ff301
+SHA1 (patch-src_VBox_GuestHost_OpenGL_util_vboxhgcm.c) = a36f1b8cb73c6f24758822942291b46d548177f6
+SHA1 (patch-src_VBox_GuestHost_OpenGL_util_vboxhgsmi.c) = b81fa899ee99b2db490e3bac0b14d4115fc89e47
+SHA1 (patch-src_VBox_GuestHost_SharedClipboard_Makefile.kmk) = 4bb2ab80e8824d20e0358d1d374d8b0b30daa95c
+SHA1 (patch-src_VBox_HostDrivers_Makefile.kmk) = 0ac9a8767c9ce56e93cd614bcffe7c86da5fac1a
+SHA1 (patch-src_VBox_HostDrivers_Support_Makefile.kmk) = 0b9358eb11bf274c8ba5ffd6056ce76bab1ef6ea
+SHA1 (patch-src_VBox_HostDrivers_Support_SUPDrv.cpp) = ed448e5e39ba5101f6b66ad8faf6793b7cc23a87
+SHA1 (patch-src_VBox_HostDrivers_Support_SUPDrvGip.cpp) = af044f4f74cd4879b05538c5d7fbb8dd97f1b678
+SHA1 (patch-src_VBox_HostDrivers_Support_SUPDrvIDC.h) = 340f0b02bd21ba463578d1560a3e3f494a874890
+SHA1 (patch-src_VBox_HostDrivers_Support_SUPDrvInternal.h) = e40bd87c79e140ef1d7a774679ff6cd22dc281b9
+SHA1 (patch-src_VBox_HostDrivers_Support_SUPDrvTracer.cpp) = 754583a84916aca5a8c378658d7eab7356ad7d00
+SHA1 (patch-src_VBox_HostDrivers_Support_SUPR3HardenedMain.cpp) = 7f7b43e3ff9869aebfb9097c027063a37d452171
+SHA1 (patch-src_VBox_HostDrivers_Support_netbsd_Makefile) = 42a33228b7bded32fb9b543d1de0b9d2acb57f90
+SHA1 (patch-src_VBox_HostDrivers_Support_netbsd_SUPDrv-netbsd.c) = fbc5fd6f45657e3323f731f09a1da298dd06db7c
+SHA1 (patch-src_VBox_HostDrivers_Support_netbsd_SUPDrv-netbsd.def) = 85eb317c813e124b1b9556f9cdb5725ec6278f8f
+SHA1 (patch-src_VBox_HostDrivers_Support_netbsd_SUPLib-netbsd.cpp) = b6690a459513a372be5200381fcb34b6e5b220d9
+SHA1 (patch-src_VBox_HostDrivers_Support_netbsd_SUPR0IdcClient-netbsd.c) = dd51dbf5274d223424124fb29886d8737f02bce7
+SHA1 (patch-src_VBox_HostDrivers_Support_netbsd_files__vboxdrv) = b2d6c50361f6709ad6d2bec4632074cc36233959
+SHA1 (patch-src_VBox_HostDrivers_VBoxNetAdp_Makefile.kmk) = 5d2bf3d9bd06e1deaab8060c17aed30fd80411d0
+SHA1 (patch-src_VBox_HostDrivers_VBoxNetAdp_VBoxNetAdpInternal.h) = d738f197a2d3a736f56aff5005fed7756c543827
+SHA1 (patch-src_VBox_HostDrivers_VBoxNetAdp_netbsd_Makefile) = 5fa21e33796ca01d143abac5c6f6537a233676ab
+SHA1 (patch-src_VBox_HostDrivers_VBoxNetAdp_netbsd_VBoxNetAdp-netbsd.c) = 08de7421b2937c723a6d612e3a913a257eba2e72
+SHA1 (patch-src_VBox_HostDrivers_VBoxNetAdp_netbsd_files__vboxnetadp) = 11f5cb24de890b66e247c29ec0cb4a9773c06089
+SHA1 (patch-src_VBox_HostDrivers_VBoxNetFlt_Makefile.kmk) = 6754290694ea73a6d5ba53ba1de901ad2c8be159
+SHA1 (patch-src_VBox_HostDrivers_VBoxNetFlt_VBoxNetFltInternal.h) = 1cd4b438d22169d39229625c2b9852290e93c42f
+SHA1 (patch-src_VBox_HostDrivers_VBoxNetFlt_netbsd_Makefile) = 96c5c1ffe7b16b349c0bc4c8da85d8f677867c62
+SHA1 (patch-src_VBox_HostDrivers_VBoxNetFlt_netbsd_VBoxNetFlt-netbsd.c) = 19f2c118a358b2de02be90a18d9280c686948bff
+SHA1 (patch-src_VBox_HostDrivers_VBoxNetFlt_netbsd_files__vboxnetflt) = 0777bc7009f6644e024089524606e67769615830
+SHA1 (patch-src_VBox_HostDrivers_netbsd_Makefile) = b949a73b17a516be0cbfe1cd9f486ad9c69abcd8
+SHA1 (patch-src_VBox_HostDrivers_netbsd_Makefile.kmk) = 0ebb3b51f15aa94cfc1cf502536dff7140f082d9
+SHA1 (patch-src_VBox_HostServices_Makefile.kmk) = 5c6cc9480c3ae255ff71cc4cb10a72309e1d244a
+SHA1 (patch-src_VBox_HostServices_SharedClipboard_Makefile.kmk) = a5d01d4beb8e359f9acee4cd1538b13afc1e5388
+SHA1 (patch-src_VBox_HostServices_SharedOpenGL_Makefile.kmk) = c175df67bcac45a944facae0b05dd0a06e34b5be
+SHA1 (patch-src_VBox_HostServices_auth_Makefile.kmk) = 53c0e0052e452a70527a0caaa25c50a7b8f919c0
+SHA1 (patch-src_VBox_HostServices_auth_pam_VBoxAuthPAM.c) = b8015ac5a32d32cc6d50985cccb898449cbe99ec
+SHA1 (patch-src_VBox_ImageMounter_VBoxFUSE_Makefile.kmk) = a4d2970cf51a657ceb9373fae5238a9c29b94961
+SHA1 (patch-src_VBox_ImageMounter_VBoxFUSE_VBoxFUSE.cpp) = fe2f5e836eacb7304891f2955caddf7bc52ae988
+SHA1 (patch-src_VBox_Installer_Makefile.kmk) = 90beb8bf00c0207446af4d3db92ad745c8d1be72
+SHA1 (patch-src_VBox_Installer_darwin_VirtualBox_postflight) = d2251d079cc9e683a6d0aeb8b5a43bd64b19f3a3
+SHA1 (patch-src_VBox_Installer_darwin_VirtualBox_preflight) = b8918b156eafb5febce4be1c2f28f576b949a47f
+SHA1 (patch-src_VBox_Installer_linux_VBoxSysInfo.sh) = 67a71cb960c314bf9c02d5459f91fde20e9a68f2
+SHA1 (patch-src_VBox_Installer_linux_debian_control) = 2b75a4db1873ad1e5bd52bfa11448b218cb3bff5
+SHA1 (patch-src_VBox_Installer_linux_rpm_VirtualBox.tmpl.spec) = cf6e5b9f34cb0b708a04d0b552e2c46d6f05526e
+SHA1 (patch-src_VBox_Installer_netbsd_Makefile.kmk) = cf4b57bb7d83b940a4a6e21760e8f255e76d996f
+SHA1 (patch-src_VBox_Installer_netbsd_pkg-comment) = 4b2ce009a24ab94c1f83c1f4bc6ed4537246d9a1
+SHA1 (patch-src_VBox_Installer_netbsd_pkg-descr) = b7c85ea5685ad7da628247d5926542b82863e748
+SHA1 (patch-src_VBox_Installer_netbsd_pkg__plist) = f8c784bb044bde2a3e78382f98c8479cb0b5054e
+SHA1 (patch-src_VBox_Installer_netbsd_postdeinstall.sh) = 97e6762b381fe2239adc6b52cd5352815405747a
+SHA1 (patch-src_VBox_Installer_netbsd_postinstall.sh) = ef1356ccf355d789733a6522435242e607e34058
+SHA1 (patch-src_VBox_Installer_netbsd_virtualbox.desktop) = f0973e025a4333750e741cbacf16275cc4d5982d
+SHA1 (patch-src_VBox_Main_Makefile.kmk) = addbc2719567070eac969912abc7ce91177cb12d
+SHA1 (patch-src_VBox_Main_cbinding_VBoxCAPIGlue.c) = f2ab8096d65b200bad3171875706d3acd3e86ea4
+SHA1 (patch-src_VBox_Main_cbinding_VBoxCAPI__v2__2.h) = 0a66eb2fa8ebcb1dd8a720dd3dadbb03a8a8c5b7
+SHA1 (patch-src_VBox_Main_cbinding_VBoxCAPI__v3__0.h) = 0c49c14b973ea74bdb0bf6e3c124d87ba1eaeb20
+SHA1 (patch-src_VBox_Main_glue_NativeEventQueue.cpp) = f566c3cd73c323f78c38487bde29b88ca86e9c96
+SHA1 (patch-src_VBox_Main_glue_tests_Makefile) = 19002fe2622195a6342eeec8cb180ced75ad7c0a
+SHA1 (patch-src_VBox_Main_include_ConsoleImpl.h) = 5bc4916830e8f7e2c47c5c98d9491312f9543f1d
+SHA1 (patch-src_VBox_Main_include_HostUSBDeviceImpl.h) = adc83b19e793491b1c6ea0fd8b46cd9f32e592fc
+SHA1 (patch-src_VBox_Main_include_USBProxyService.h) = adc83b19e793491b1c6ea0fd8b46cd9f32e592fc
+SHA1 (patch-src_VBox_Main_include_ovfreader.h) = f2e8caa5daf609f80040f14cc28baedc999b806a
+SHA1 (patch-src_VBox_Main_src-client_ConsoleImpl.cpp) = b3da50392a63f5f4313782751df7abfbaf33d2bf
+SHA1 (patch-src_VBox_Main_src-client_ConsoleImpl2.cpp) = bc1696f533a8fb675d061411981eda29db63555e
+SHA1 (patch-src_VBox_Main_src-server_ApplianceImpl.cpp) = 3e1d6959ab6f8422fdd898f376ec114ff9fefd11
+SHA1 (patch-src_VBox_Main_src-server_HostDnsService.cpp) = 493f34bc90ee49085cfddb7f44dd9ab31c95b774
+SHA1 (patch-src_VBox_Main_src-server_HostDnsService.h) = df468bf3ed607b0858a180954a29d45062e21fcd
+SHA1 (patch-src_VBox_Main_src-server_HostImpl.cpp) = 27eb0d009a1b0770c9ef6b555f6fa3b5dce2bac9
+SHA1 (patch-src_VBox_Main_src-server_HostNetworkInterfaceImpl.cpp) = 19cd7af464a0c71c4396210ce554076c30bb1cae
+SHA1 (patch-src_VBox_Main_src-server_MachineImpl.cpp) = ad6a19bfc0ae125aacd4cb31cbb98cc0e2347c79
+SHA1 (patch-src_VBox_Main_src-server_generic_NetIf-generic.cpp) = b6f3629d789d24e5fcae35d6730400e90829c81c
+SHA1 (patch-src_VBox_Main_src-server_netbsd_HostHardwareNetBSD.cpp) = fd74325565b81014924f8fb8307c322c3194e4b3
+SHA1 (patch-src_VBox_Main_src-server_netbsd_Makefile.kup) = d74d57c9bb23cd2ac869e8b4dd65979ea5d43752
+SHA1 (patch-src_VBox_Main_src-server_netbsd_NetIf-netbsd.cpp) = 5979bd5a04a7ad8463c43c51d5f1575f78121127
+SHA1 (patch-src_VBox_Main_src-server_netbsd_PerformanceNetBSD.cpp) = 9ed0245868e054892e0d939205ffa72f0f9ae562
+SHA1 (patch-src_VBox_Main_src-server_netbsd_USBProxyServiceNetBSD.cpp) = 2295ec43bd4256bb93d2e7bbde6fd1dae5cf7e0b
+SHA1 (patch-src_VBox_Main_testcase_tstCollector.cpp) = 6947b195a11e59936aa9cc0f4ba89aa303c15ab1
+SHA1 (patch-src_VBox_Main_webservice_vboxweb.cpp) = 3386319324815e539d734c769766ba621210ba32
+SHA1 (patch-src_VBox_Main_xml_Settings.cpp) = adc83b19e793491b1c6ea0fd8b46cd9f32e592fc
+SHA1 (patch-src_VBox_Main_xml_VirtualBox-settings.xsd) = e5cd29442dcc67cc9b8019a14903e8501c3042fa
+SHA1 (patch-src_VBox_Makefile.kmk) = 751bc56a4305cf29866e644bcc70410bdda9be36
+SHA1 (patch-src_VBox_NetworkServices_NAT_Makefile.kmk) = cb489f3e32ea551faa59f1172500731ab2e74863
+SHA1 (patch-src_VBox_NetworkServices_NAT_pxping.c) = 7e7f3fd26ae5f787e5cb9299d24eea9c4a53529a
+SHA1 (patch-src_VBox_NetworkServices_NAT_pxudp.c) = 56dd97543fd9be4096d4b3aa1fd25075ec4ff7f3
+SHA1 (patch-src_VBox_Runtime_Makefile.kmk) = 2f47f4900aaf7c676c95793cfc60fd102be4415e
+SHA1 (patch-src_VBox_Runtime_VBox_log-vbox.cpp) = b833b5e038652518f3c0ad74c699bc0ab57f56d5
+SHA1 (patch-src_VBox_Runtime_r0drv_netbsd_alloc-r0drv-netbsd.c) = 8d39beeb6c649a68794b17e0cec27fc6acb68fed
+SHA1 (patch-src_VBox_Runtime_r0drv_netbsd_assert-r0drv-netbsd.c) = a333976118abdc7f6c143c95f648ab9aa51c885e
+SHA1 (patch-src_VBox_Runtime_r0drv_netbsd_initterm-r0drv-netbsd.c) = 80a02c8837b25253f891ae8af1b6c8418cbd1852
+SHA1 (patch-src_VBox_Runtime_r0drv_netbsd_memobj-r0drv-netbsd.c) = ffd98f71fb5ff12a5d054d8b2ed2a933fbc44b2c
+SHA1 (patch-src_VBox_Runtime_r0drv_netbsd_memuserkernel-r0drv-netbsd.c) = 2822ca57f3b8a1b5df5a09137108a910fd9a10fb
+SHA1 (patch-src_VBox_Runtime_r0drv_netbsd_mp-r0drv-netbsd.c) = 780b8e6780b134de01218d5d356862b105ed1934
+SHA1 (patch-src_VBox_Runtime_r0drv_netbsd_process-r0drv-netbsd.c) = e76ad01b63d8a2435e02f6e64c0bdf3b9ba35031
+SHA1 (patch-src_VBox_Runtime_r0drv_netbsd_semevent-r0drv-netbsd.c) = a3f4ad38aeba4d37af35382e704028e10695552c
+SHA1 (patch-src_VBox_Runtime_r0drv_netbsd_semeventmulti-r0drv-netbsd.c) = 86f9df32d970e9f06717325439cdf4ea0652c799
+SHA1 (patch-src_VBox_Runtime_r0drv_netbsd_semfastmutex-r0drv-netbsd.c) = 22d00b556b7f3839ebd95a336a589bc80938940a
+SHA1 (patch-src_VBox_Runtime_r0drv_netbsd_semmutex-r0drv-netbsd.c) = b560eaf7a9f0b5fe5e1b22c9937520b11931f107
+SHA1 (patch-src_VBox_Runtime_r0drv_netbsd_sleepqueue-r0drv-netbsd.h) = 3aab753113d2ee1af15bf58799d4bf608447bc77
+SHA1 (patch-src_VBox_Runtime_r0drv_netbsd_spinlock-r0drv-netbsd.c) = 9bfc083274e80d0707bc335580e04acb84934ec6
+SHA1 (patch-src_VBox_Runtime_r0drv_netbsd_the-netbsd-kernel.h) = b1e998b8e79471a313f16aa8a74342e6d2e4a61c
+SHA1 (patch-src_VBox_Runtime_r0drv_netbsd_thread-r0drv-netbsd.c) = 72050cedb648a1f8a40045d0754eb9b069ccb6ba
+SHA1 (patch-src_VBox_Runtime_r0drv_netbsd_thread2-r0drv-netbsd.c) = 911cecba018896d7626a1cb7ef60c00d8159d419
+SHA1 (patch-src_VBox_Runtime_r0drv_netbsd_time-r0drv-netbsd.c) = c3e475887b1751943ac066187d5034f3c1ba9b72
+SHA1 (patch-src_VBox_Runtime_r0drv_netbsd_timer-r0drv-netbsd.c) = 9ff20109f3b7459544b0de405e305c0ee5a89ac0
+SHA1 (patch-src_VBox_Runtime_r3_init.cpp) = 1d80d2335a2fe24a17f954812073bca6f9a3f8e7
+SHA1 (patch-src_VBox_Runtime_r3_netbsd_fileaio-netbsd.cpp) = 4398c5ee439acbea4e7a1d3be1069345870f2143
+SHA1 (patch-src_VBox_Runtime_r3_netbsd_mp-netbsd.cpp) = c753459fc84c64aa560ca46d0eef78d575b3b91f
+SHA1 (patch-src_VBox_Runtime_r3_netbsd_rtProcInitExePath-netbsd.cpp) = 8395efc0496b3590403ae5af34840bc515189781
+SHA1 (patch-src_VBox_Runtime_r3_netbsd_systemmem-netbsd.cpp) = 8839c15e35275013952da1573f66d79c40dc78a4
+SHA1 (patch-src_VBox_Runtime_r3_posix_fileaio-posix.cpp) = 71651627904b5ff98a2b2771a09bcc99a2eb82ad
+SHA1 (patch-src_VBox_Runtime_r3_posix_fileio-posix.cpp) = 7a1938001c15ce6bf6f46777cde671ece9ba1e32
+SHA1 (patch-src_VBox_Runtime_r3_posix_fs-posix.cpp) = d5563cc3821f29bc056c21f86d32eb4b1010eb11
+SHA1 (patch-src_VBox_Runtime_r3_posix_path2-posix.cpp) = 512e64a1ae953748f589e95f95b3945935310514
+SHA1 (patch-src_VBox_Runtime_r3_posix_semevent-posix.cpp) = a14adc94fc580c1b46bd0c090f97d97b0aed1996
+SHA1 (patch-src_VBox_Runtime_r3_posix_thread-posix.cpp) = c6e672e0a394cd013e71341689c680c4bff81d38
+SHA1 (patch-src_VBox_Runtime_r3_posix_thread2-posix.cpp) = cab9219ea9a423713c0a1e4381955bd9c78615d1
+SHA1 (patch-src_VBox_Runtime_r3_posix_utf8-posix.cpp) = fe28a89beddc6e6c1ddcc2df2b7ddd893b370af2
+SHA1 (patch-src_VBox_Storage_testcase_Makefile.kmk) = edafb43c93359d0b37fbe4bec839370f2d2db29e
+SHA1 (patch-src_VBox_VMM_VMMR0_GMMR0.cpp) = 08336e3aa159e2d2092cacbd16c2011963fe3908
+SHA1 (patch-src_VBox_VMM_VMMR0_VMMR0.cpp) = 57f17e39057edea79be1fa16a43f0624eaf2a15b
+SHA1 (patch-src_VBox_VMM_VMMR3_PGMPhys.cpp) = 4b934d9c2dfcffc38eb4b9e834d91328c284a50b
+SHA1 (patch-src_VBox_VMM_VMMR3_SSM.cpp) = 63e22ce701acb9b965d95aa886a1880b73b4d116
+SHA1 (patch-src_VBox_VMM_VMMR3_VM.cpp) = bf65afe2fe4012c332a3914eeaddde7a980c19b5
+SHA1 (patch-src_VBox_VMM_VMMRC_VMMRCDeps.cpp) = 4c6a6919633b07e1e6a9b93ec2c49dfec598f7cd
+SHA1 (patch-src_VBox_VMM_include_CPUMInternal.h) = 76d1c9a974bb0fc27d0eeffeaa071632ce303ca0
+SHA1 (patch-src_VBox_VMM_testcase_mkdsk.sh) = b45e17ad1ea5ab524fd4e36448b29b5700e20fec
+SHA1 (patch-src_VBox_VMM_testcase_tstX86-1.cpp) = bbdefc55c2ca664475417a127093995c6e618b79
+SHA1 (patch-src_VBox_ValidationKit_Makefile.kmk) = a9d0dbc43708423f088798dd4fdfc79e2d54c90a
+SHA1 (patch-src_VBox_ValidationKit_testboxscript_testboxscript__real.py) = a082697becf86a7690ec11353319b8761c1eaf4f
+SHA1 (patch-src_VBox_ValidationKit_testdriver_base.py) = 4af1913442af97e74227ae4a855149e6eb4a83f5
+SHA1 (patch-src_VBox_ValidationKit_testdriver_vbox.py) = b7c02df0233aaa946145c598fc5be0ee0c910589
+SHA1 (patch-src_VBox_ValidationKit_testdriver_vboxtestvms.py) = a9d41e33691622c9ee52fedbbac5e3261b0fe335
+SHA1 (patch-src_VBox_ValidationKit_testmanager_core_coreconsts.py) = 68eec44aa0d0b824593b77d26ca9d79f4e2a9c78
+SHA1 (patch-src_VBox_ValidationKit_tests_autostart_tdAutostart1.py) = 750ed6069a119efe97ebc082b74d6a1c8ee6950a
+SHA1 (patch-src_apps_Makefile.kmk) = 578f077b8961fab80d839c7024e3e89cec29c3e0
+SHA1 (patch-src_libs_libxml2-2.9.2_include_vboxconfig.h) = 461438f04dcf7f54051f897834f3fc6457ddfdf0
+SHA1 (patch-src_libs_xpcom18a4_nsprpub_pr_include_md___netbsd.cfg) = ef93614e10b24f2952202b90db6fc26c0c83ddac
+SHA1 (patch-src_recompiler_Makefile.kmk) = 0f849ac56932b41882f056df3b59a5626fe8608b
+SHA1 (patch-src_recompiler_exec.c) = b8d61864eb2b6426607c850585b1ccd11446e905
+SHA1 (patch-tools_bin_gen-slickedit-workspace.sh) = ce2645ee9c26b252566807e3b21b8540624d8d18
diff --git a/virtualbox-svn/patches/patch-Config.kmk b/virtualbox-svn/patches/patch-Config.kmk
new file mode 100644
index 0000000..34bcdfb
--- /dev/null
+++ b/virtualbox-svn/patches/patch-Config.kmk
@@ -0,0 +1,172 @@
+$NetBSD$
+
+--- Config.kmk.orig	2016-07-10 19:49:02.000000000 +0000
++++ Config.kmk
+@@ -2000,7 +2000,7 @@ VBOX_CHECK_IMPORTS ?= $(PATH_OBJ)/VBoxCh
+ # GNU tar if present.
+ if1of ($(KBUILD_TARGET), linux os2 win)
+  VBOX_GTAR ?= tar
+-else if1of ($(KBUILD_TARGET), freebsd solaris)
++else if1of ($(KBUILD_TARGET), freebsd netbsd solaris)
+  VBOX_GTAR ?= gtar
+ endif
+ 
+@@ -3776,8 +3776,8 @@ ifdef VBOX_WITH_RAW_MODE
+  endif
+ 
+  ifeq ($(VBOX_LDR_FMT32),elf)
+-  TEMPLATE_VBoxRcExe_CFLAGS   = $(filter-out -nostdinc,$(TEMPLATE_VBoxRc_CFLAGS)) -O0
+-  TEMPLATE_VBoxRcExe_CXXFLAGS = $(filter-out -nostdinc,$(TEMPLATE_VBoxRc_CXXFLAGS)) -O0
++  TEMPLATE_VBoxRcExe_CFLAGS   = -O0
++  TEMPLATE_VBoxRcExe_CXXFLAGS = -O0
+   TEMPLATE_VBoxRcExe_LDFLAGS  = -g
+   TEMPLATE_VBoxRcExe_LDFLAGS.dbgopt = -g
+   TEMPLATE_VBoxRcExe_LDFLAGS.strict = -g
+@@ -3906,9 +3906,9 @@ endif
+ 
+ ifeq ($(VBOX_LDR_FMT),lx)
+ TEMPLATE_VBoxR0_TOOL                = GXX3OMF
+-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 -fno-common
+-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 -fno-common -fno-rtti
+-TEMPLATE_VBoxR0_LDFLAGS             = -nostdlib -Zdll
++TEMPLATE_VBoxR0_CFLAGS              = -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 -fno-common
++TEMPLATE_VBoxR0_CXXFLAGS            = -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 -fno-common -fno-rtti
++TEMPLATE_VBoxR0_LDFLAGS             = -Zdll
+ TEMPLATE_VBoxR0_LIBS                = \
+ 	$(VBOX_GCC_LIBGCC) \
+ 	$(VBOX_OBJ_SYS0) \
+@@ -4038,14 +4038,14 @@ TEMPLATE_VBOXR0DRV_INCS               +=
+ ## @todo try use VBOX_GCC_PEDANTIC_CXX
+ TEMPLATE_VBOXR0DRV_CXXFLAGS            = $(VBOX_DARWIN_DEF_SDK_CXXFLAGS) \
+ 	-g $(VBOX_GCC_pipe) $(VBOX_GCC_WARN) -Wno-long-long $(VBOX_GCC_fdiagnostics-show-option) \
+-	-fno-common -nostdinc -fno-builtin -finline $(VBOX_GCC_fvisibility-inlines-hidden) $(VBOX_GCC_fvisibility-hidden) \
++	-fno-common -fno-builtin -finline $(VBOX_GCC_fvisibility-inlines-hidden) $(VBOX_GCC_fvisibility-hidden) \
+ 	-fno-keep-inline-functions -fno-exceptions -msoft-float \
+ 	-fapple-kext -fno-rtti -fcheck-new -force_cpusubtype_ALL \
+ 	$(VBOX_GCC_R0_OPT) $(VBOX_GCC_R0_FP) -fno-strict-aliasing -fasm-blocks
+ TEMPLATE_VBOXR0DRV_CXXFLAGS.amd64      = -m64 -mkernel -mno-red-zone -gdwarf-2
+ TEMPLATE_VBOXR0DRV_CXXFLAGS.x86        = -m32 -static
+ TEMPLATE_VBOXR0DRV_CFLAGS              = $(VBOX_DARWIN_DEF_SDK_CFLAGS) \
+-	-g $(VBOX_GCC_pipe) $(VBOX_GCC_WARN) -Wno-long-long -fno-common -nostdinc -fno-builtin -finline \
++	-g $(VBOX_GCC_pipe) $(VBOX_GCC_WARN) -Wno-long-long -fno-common -fno-builtin -finline \
+ 	-fno-keep-inline-functions -fno-exceptions $(VBOX_GCC_fvisibility-hidden) -msoft-float \
+ 	-Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations \
+ 	-Werror-implicit-function-declaration -force_cpusubtype_ALL \
+@@ -4134,7 +4134,7 @@ TEMPLATE_VBOXR0DRV_CFLAGS              =
+ 	-Wimplicit-function-declaration -Werror-implicit-function-declaration \
+ 	-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
++	-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.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 \
+@@ -4142,8 +4142,7 @@ TEMPLATE_VBOXR0DRV_CFLAGS.amd64        =
+ TEMPLATE_VBOXR0DRV_CXXFLAGS            = -fno-exceptions -fno-rtti \
+ 	$(VBOX_GCC_WARN) -Wpointer-arith -Winline \
+ 	-O2 -fno-strict-aliasing -fno-common -finline-limit=8000 \
+-	$(VBOX_GCC_fno-stack-protector) $(VBOX_GCC_R0_OPT) $(VBOX_GCC_R0_FP) \
+-	-nostdinc
++	$(VBOX_GCC_fno-stack-protector) $(VBOX_GCC_R0_OPT) $(VBOX_GCC_R0_FP)
+ TEMPLATE_VBOXR0DRV_CXXFLAGS.x86        = $(TEMPLATE_VBOXR0DRV_CFLAGS.x86)
+ TEMPLATE_VBOXR0DRV_CXXFLAGS.amd64      = $(TEMPLATE_VBOXR0DRV_CFLAGS.amd64)
+ TEMPLATE_VBOXR0DRV_SYSSUFF             = .ko
+@@ -4214,6 +4213,80 @@ TEMPLATE_VBOXR0DRV_CXXFLAGS.x86       = 
+ TEMPLATE_VBOXR0DRV_CXXFLAGS.amd64     = $(TEMPLATE_VBOXR0DRV_CFLAGS.amd64) -fno-exceptions -fno-rtti
+ endif # Haiku
+ 
++ifeq ($(KBUILD_TARGET),netbsd)
++## The location of the NetBSD kernel source.
++VBOX_NETBSD_SRC ?= /usr/src/sys
++## The FreeBSD /usr/include.
++VBOX_NETBSD_SYS_INCS ?= /usr/include
++
++TEMPLATE_VBOXR0DRV_TOOL                = $(VBOX_GCC_TOOL)
++TEMPLATE_VBOXR0DRV_LDTOOL              = NETBSDKMODLD
++TEMPLATE_VBOXR0DRV_DEFS               += _KERNEL KLD_MODULE
++TEMPLATE_VBOXR0DRV_INCS                = \
++	$(VBOX_NETBSD_SRC) \
++	$(VBOX_NETBSD_SRC)/../include \
++	$(VBOX_NETBSD_SYS_INCS)
++# omitting: -Wcast-qual, -Wredundant-decls
++TEMPLATE_VBOXR0DRV_CFLAGS              =  \
++	$(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 -ffreestanding -fno-strict-aliasing -fno-common -finline-limit=8000 \
++	$(VBOX_GCC_fno-stack-protector) $(VBOX_GCC_R0_OPT) $(VBOX_GCC_R0_FP) \
++	-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.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-strict-aliasing -fno-common -finline-limit=8000 \
++	$(VBOX_GCC_fno-stack-protector) $(VBOX_GCC_R0_OPT) $(VBOX_GCC_R0_FP) \
++	
++TEMPLATE_VBOXR0DRV_CXXFLAGS.x86        = $(TEMPLATE_VBOXR0DRV_CFLAGS.x86)
++TEMPLATE_VBOXR0DRV_CXXFLAGS.amd64      = $(TEMPLATE_VBOXR0DRV_CFLAGS.amd64)
++TEMPLATE_VBOXR0DRV_SYSSUFF             = .kmod
++TEMPLATE_VBOXR0DRV_LDFLAGS             = -d --warn-common
++TEMPLATE_VBOXR0DRV_LDFLAGS.x86         = -m elf_i386_fbsd
++TEMPLATE_VBOXR0DRV_LDFLAGS.amd64       = -m elf_x86_64_fbsd
++
++TOOL_NETBSDKMODLD = NetBSD kernel module linker.
++# See kBuild/tools/GCC3.kmk for docs.
++TOOL_NETBSDKMODLD_LINK_SYSMOD_OUTPUT_MAYBE = $(outbase).map
++TOOL_NETBSDKMODLD_LINK_SYSMOD_DEPEND = $(foreach lib,$(libs),$(if $(findstring $(lib),$(subst /,x,$(lib))),, $(lib)))
++TOOL_NETBSDKMODLD_LINK_SYSMOD_DEPORD =
++ ifeq ($(KBUILD_TARGET_ARCH),amd64)
++TOOL_NETBSDKMODLD_LINK_SYSMOD_OUTPUT =
++define TOOL_NETBSDKMODLD_LINK_SYSMOD_CMDS
++# Link intermediate .kld (a relocatable object).
++	ld $(flags) -r -o  $(out) $(objs) \
++		$(foreach p,$(libpath), -L$(p))\
++		$(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))
++# Strip non-exported symbols private and localize the exported ones.
++	awk -f $(VBOX_NETBSD_SRC)/conf/kmod_syms.awk  $(out) $(if $(othersrc), $(othersrc),/dev/null) \
++		| xargs -J% objcopy % $(out)
++
++## Strip debug info (comment out if debugging or something).
++	objcopy --strip-debug $(out)
++endef
++ else # x86
++TOOL_NETBSDKMODLD_LINK_SYSMOD_OUTPUT = $(outbase).kld
++define TOOL_NETBSDKMODLD_LINK_SYSMOD_CMDS
++# Link intermediate .kld (a relocatable object).
++	ld $(flags) -r -o $(outbase).kld $(objs) \
++		$(foreach p,$(libpath), -L$(p))\
++		$(foreach lib,$(libs), $(if $(findstring $(lib),$(subst /,x,$(lib))), -l$(patsubst lib%,%,$(basename $(lib))), $(lib)))
++# Strip non-exported symbols private and localize the exported ones.
++	awk -f $(VBOX_NETBSD_SRC)/conf/kmod_syms.awk $(outbase).kld $(if $(othersrc), $(othersrc),/dev/null) \
++		| xargs -J% objcopy % $(outbase).kld
++
++# Link the final .ko (a shared object).
++	ld $(flags) -Bshareable -o $(out) $(outbase).kld
++endef
++ endif # x86
++
++endif # NetBSD
++
+ ifdef VBOX_WITH_VBOXDRV
+  ifndef TEMPLATE_VBOXR0DRV_TOOL
+   $(warning Warning: VBox Build: Target $(KBUILD_HOST) is not officially supported!)
+@@ -4930,7 +5003,7 @@ endif
+ TEMPLATE_VBoxNoCrtGccLib = VBox no-crt GCC libraries and modules, yasm/nasm.
+ TEMPLATE_VBoxNoCrtGccLib_DEFS              = IN_RING3 IPRT_NO_CRT $(ARCH_BITS_DEFS)
+ TEMPLATE_VBoxNoCrtGccLib_ASDEFS            = ASM_CALL64_GCC
+-TEMPLATE_VBoxNoCrtGccLib_CFLAGS            = -nostdinc -fno-strict-aliasing -fno-math-errno $(VBOX_GCC_WARN) -Werror-implicit-function-declaration
++TEMPLATE_VBoxNoCrtGccLib_CFLAGS            = -fno-strict-aliasing -fno-math-errno $(VBOX_GCC_WARN) -Werror-implicit-function-declaration
+ TEMPLATE_VBoxNoCrtGccLib_CFLAGS.x86        = -m32
+ TEMPLATE_VBoxNoCrtGccLib_CFLAGS.amd64      = -m64 -mcmodel=medium -fno-common
+ TEMPLATE_VBoxNoCrtGccLib_CFLAGS.sparc32    = -m32
+@@ -6016,7 +6089,7 @@ TEMPLATE_VBOXGUESTR3EXE_DEFS     := $(fi
+ TEMPLATE_VBOXGUESTR3EXE_DEFS.linux := $(TEMPLATE_VBOXR3EXE_DEFS.linux) LOG_USE_C99 RT_WITHOUT_EXEC_ALLOC
+ ifeq ($(KBUILD_TARGET),linux) # As few libs as possible on linux.
+  TEMPLATE_VBOXGUESTR3EXE_LIBS     = pthread rt m dl
+-else if1of ($(KBUILD_TARGET), darwin freebsd netbsd openbsd)
++else if1of ($(KBUILD_TARGET), darwin freebsd openbsd)
+  TEMPLATE_VBOXGUESTR3EXE_LIBS     = $(TEMPLATE_VBOXR3EXE_LIBS) iconv
+ else ifeq ($(KBUILD_TARGET), solaris)
+  TEMPLATE_VBOXGUESTR3EXE_LIBS     = $(TEMPLATE_VBOXR3EXE_LIBS) nsl
diff --git a/virtualbox-svn/patches/patch-Makefile.kmk b/virtualbox-svn/patches/patch-Makefile.kmk
new file mode 100644
index 0000000..c1c3804
--- /dev/null
+++ b/virtualbox-svn/patches/patch-Makefile.kmk
@@ -0,0 +1,178 @@
+$NetBSD$
+
+--- Makefile.kmk.orig	2016-03-04 19:22:54.000000000 +0000
++++ Makefile.kmk
+@@ -525,6 +525,7 @@ VBOX_CORE_DOXYFILE_INPUT_DIRS = \
+ 	src/VBox/HostDrivers/Support \
+ 	src/VBox/HostDrivers/Support/darwin \
+ 	src/VBox/HostDrivers/Support/freebsd \
++	src/VBox/HostDrivers/Support/netbsd \
+ 	src/VBox/HostDrivers/Support/linux \
+ 	src/VBox/HostDrivers/Support/os2 \
+ 	src/VBox/HostDrivers/Support/solaris \
+@@ -612,6 +613,7 @@ VBOX_CORE_DOXYFILE_INPUT_DIRS = \
+ 	src/VBox/Additions/common/VBoxControl \
+ 	src/VBox/Additions/common/VBoxGuest \
+ 	src/VBox/Additions/common/VBoxGuest/freebsd \
++	src/VBox/Additions/common/VBoxGuest/netbsd \
+ 	src/VBox/Additions/common/VBoxGuest/linux \
+ 	src/VBox/Additions/common/VBoxGuest/win \
+ 	src/VBox/Additions/common/VBoxGuestLib \
+@@ -628,6 +630,10 @@ VBOX_CORE_DOXYFILE_INPUT_DIRS = \
+ 	src/VBox/Additions/freebsd/Installer \
+ 	src/VBox/Additions/freebsd/drm \
+ 	src/VBox/Additions/freebsd/vboxvfs \
++	src/VBox/Additions/netbsd \
++	src/VBox/Additions/netbsd/Installer \
++	src/VBox/Additions/netbsd/drm \
++	src/VBox/Additions/netbsd/vboxvfs \
+ 	src/VBox/Additions/linux \
+ 	src/VBox/Additions/linux/drm \
+ 	src/VBox/Additions/linux/installer \
+@@ -913,7 +919,7 @@ VBOX_RSYNC_IN_FN = rsync -a -v --delete 
+ 	--exclude=tinderclient.log \
+ 	--exclude=tools/FetchDir/ \
+ 	--exclude=webtools/ \
+-	$(foreach os,darwin freebsd linux solaris os2 win,$(if-expr "$(1)" != "$(os)", \
++	$(foreach os,darwin freebsd netbsd linux solaris os2 win,$(if-expr "$(1)" != "$(os)", \
+ 		--exclude=tools/$(os).x86/ \
+ 		--exclude=tools/$(os).amd64/ \
+ 		--exclude=out/$(os).amd64/ \
+@@ -1163,6 +1169,8 @@ additions-packing:
+ 	+ $(KMK) VBOX_ONLY_ADDITIONS=1 \
+ 		VBOX_WITH_ADDITIONS_ISO.freebsd.amd64= \
+ 		VBOX_WITH_ADDITIONS_ISO.freebsd.x86= \
++		VBOX_WITH_ADDITIONS_ISO.netbsd.amd64= \
++		VBOX_WITH_ADDITIONS_ISO.netbsd.x86= \
+ 		VBOX_WITH_ADDITIONS_ISO.linux.amd64= \
+ 		VBOX_WITH_ADDITIONS_ISO.linux.x86=1 \
+ 		VBOX_WITH_COMBINED_LINUX_GUEST_PACKAGE=1 \
+@@ -1202,6 +1210,8 @@ extpacks-fetch:
+ 	+ $(KMK) -C tools fetch KBUILD_TARGET_ARCH=x86   KBUILD_TARGET=darwin  BUILD_TARGET_ARCH=x86   BUILD_TARGET=darwin   VBOX_ONLY_EXTPACKS=1
+ #	+ $(KMK) -C tools fetch KBUILD_TARGET_ARCH=amd64 KBUILD_TARGET=freebsd BUILD_TARGET_ARCH=amd64 BUILD_TARGET=freebsd  VBOX_ONLY_EXTPACKS=1
+ #	+ $(KMK) -C tools fetch KBUILD_TARGET_ARCH=x86   KBUILD_TARGET=freebsd BUILD_TARGET_ARCH=x86   BUILD_TARGET=freebsd  VBOX_ONLY_EXTPACKS=1
++#	+ $(KMK) -C tools fetch KBUILD_TARGET_ARCH=amd64 KBUILD_TARGET=netbsd  BUILD_TARGET_ARCH=amd64 BUILD_TARGET=netbsd   VBOX_ONLY_EXTPACKS=1
++#	+ $(KMK) -C tools fetch KBUILD_TARGET_ARCH=x86   KBUILD_TARGET=netbsd  BUILD_TARGET_ARCH=x86   BUILD_TARGET=netbsd   VBOX_ONLY_EXTPACKS=1
+ 	+ $(KMK) -C tools fetch KBUILD_TARGET_ARCH=amd64 KBUILD_TARGET=linux   BUILD_TARGET_ARCH=amd64 BUILD_TARGET=linux    VBOX_ONLY_EXTPACKS=1
+ 	+ $(KMK) -C tools fetch KBUILD_TARGET_ARCH=x86   KBUILD_TARGET=linux   BUILD_TARGET_ARCH=x86   BUILD_TARGET=linux    VBOX_ONLY_EXTPACKS=1
+ #	+ $(KMK) -C tools fetch KBUILD_TARGET_ARCH=x86   KBUILD_TARGET=os2     BUILD_TARGET_ARCH=x86   BUILD_TARGET=os2      VBOX_ONLY_EXTPACKS=1
+@@ -1218,7 +1228,9 @@ extpacks-build: \
+ 	extpacks-build-linux \
+ 	extpacks-build-darwin.amd64 \
+ 	extpacks-build-freebsd.amd64 \
+-	extpacks-build-freebsd.x86
++	extpacks-build-freebsd.x86 \
++	extpacks-build-netbsd.amd64 \
++	extpacks-build-netbsd.x86
+ 
+ VBOX_EXTPACKS_BUILD.amd64 = VBOX_ONLY_EXTPACKS=1 \
+ 	KBUILD_TYPE=$(KBUILD_TYPE) BUILD_TYPE=$(KBUILD_TYPE) \
+@@ -1339,6 +1351,24 @@ extpacks-build-freebsd.x86: $(VBOX_EXTPA
+ #	$(call VBOX_BLD_VM_MSG_END__,FreeBSD/x86 extension packs)
+ #endif
+ 
++extpacks-build-netbsd.amd64: $(VBOX_EXTPACKS_BUILD_WIN_HOST_FIRST)
++#ifeq ($(KBUILD_TARGET).$(KBUILD_TARGET_ARCH),netbsd.amd64)
++#	+ $(VBOX_KMK_TIME) $(KMK) $(VBOX_EXTPACKS_BUILD.amd64) all $(VBOX_EXTPACKS_HOST_BUILD_TWEAK)
++#else
++#	$(call VBOX_BLD_VM_MSG_BEGIN,NetBSD/amd64 extension packs)
++#	$(VBOX_KMK_TIME) ssh vbox@$(VBOX_BLD_VM_NBSD_AMD64_IP) " echo $@ && cd /mnt/tinderbox/$(VBOX_EXTPACKS_BUILD_SUBDIRNAME) && tools/env.sh --no-wine kmk $(VBOX_EXTPACKS_BUILD.amd64) all"
++#	$(call VBOX_BLD_VM_MSG_END__,NetBSD/amd64 extension packs)
++#endif
++
++extpacks-build-netbsd.x86: $(VBOX_EXTPACKS_BUILD_WIN_HOST_FIRST)
++#ifeq ($(KBUILD_TARGET).$(KBUILD_TARGET_ARCH),netbsd.x86)
++#	+ $(VBOX_KMK_TIME) $(KMK) $(VBOX_EXTPACKS_BUILD.x86) all $(VBOX_EXTPACKS_HOST_BUILD_TWEAK)
++#else
++#	$(call VBOX_BLD_VM_MSG_BEGIN,NetBSD/x86 extension packs)
++#	$(VBOX_KMK_TIME) ssh vbox@$(VBOX_BLD_VM_NBSD_X86_IP) " echo $@ && cd /mnt/tinderbox/$(VBOX_EXTPACKS_BUILD_SUBDIRNAME) && tools/env.sh --no-wine kmk $(VBOX_EXTPACKS_BUILD.x86) all"
++#	$(call VBOX_BLD_VM_MSG_END__,NetBSD/x86 extension packs)
++#endif
++
+ extpacks-build-darwin.amd64: $(VBOX_EXTPACKS_BUILD_WIN_HOST_FIRST)
+ ifeq ($(KBUILD_TARGET).$(KBUILD_TARGET_ARCH),darwin.amd64)
+ 	+ $(VBOX_KMK_TIME) $(KMK) $(VBOX_EXTPACKS_BUILD.amd64) all $(VBOX_EXTPACKS_HOST_BUILD_TWEAK)
+@@ -1354,7 +1384,7 @@ extpacks-packing:
+ 	+ $(KMK) VBOX_ONLY_EXTPACKS=1 \
+ 		VBOX_WITH_EXTPACK_OS_ARCHS="darwin.amd64 linux.amd64 linux.x86 solaris.amd64 win.amd64 win.x86" \
+ 		packing
+-# +++ freebsd.amd64 freebsd.x86 os2.x86 ^^^
++# +++ freebsd.amd64 freebsd.x86 netbsd.amd64 netbsd.x86 os2.x86 ^^^
+ 
+ .PHONY: \
+ 	extpacks-build-win.x86 \
+@@ -1366,6 +1396,8 @@ extpacks-packing:
+ 	extpacks-build-linux.x86 \
+ 	extpacks-build-freebsd.amd64 \
+ 	extpacks-build-freebsd.x86 \
++	extpacks-build-netbsd.amd64 \
++	extpacks-build-netbsd.x86 \
+ 	extpacks-build-darwin.amd64 \
+ 	extpacks-packing
+ 
+@@ -1382,6 +1414,8 @@ validationkit-fetch:
+ 	+ $(KMK) -C tools fetch KBUILD_TARGET_ARCH=x86   KBUILD_TARGET=darwin  BUILD_TARGET_ARCH=x86   BUILD_TARGET=darwin    VBOX_ONLY_VALIDATIONKIT=1
+ #	+ $(KMK) -C tools fetch KBUILD_TARGET_ARCH=amd64 KBUILD_TARGET=freebsd BUILD_TARGET_ARCH=amd64 BUILD_TARGET=freebsd   VBOX_ONLY_VALIDATIONKIT=1
+ #	+ $(KMK) -C tools fetch KBUILD_TARGET_ARCH=x86   KBUILD_TARGET=freebsd BUILD_TARGET_ARCH=x86   BUILD_TARGET=freebsd   VBOX_ONLY_VALIDATIONKIT=1
++#	+ $(KMK) -C tools fetch KBUILD_TARGET_ARCH=amd64 KBUILD_TARGET=netbsd  BUILD_TARGET_ARCH=amd64 BUILD_TARGET=netbsd    VBOX_ONLY_VALIDATIONKIT=1
++#	+ $(KMK) -C tools fetch KBUILD_TARGET_ARCH=x86   KBUILD_TARGET=netbsd  BUILD_TARGET_ARCH=x86   BUILD_TARGET=netbsd    VBOX_ONLY_VALIDATIONKIT=1
+ 	+ $(KMK) -C tools fetch KBUILD_TARGET_ARCH=amd64 KBUILD_TARGET=linux   BUILD_TARGET_ARCH=amd64 BUILD_TARGET=linux     VBOX_ONLY_VALIDATIONKIT=1
+ 	+ $(KMK) -C tools fetch KBUILD_TARGET_ARCH=x86   KBUILD_TARGET=linux   BUILD_TARGET_ARCH=x86   BUILD_TARGET=linux     VBOX_ONLY_VALIDATIONKIT=1
+ 	+ $(KMK) -C tools fetch KBUILD_TARGET_ARCH=x86   KBUILD_TARGET=os2     BUILD_TARGET_ARCH=x86   BUILD_TARGET=os2       VBOX_ONLY_VALIDATIONKIT=1
+@@ -1401,6 +1435,8 @@ validationkit-build: \
+ 	validationkit-build-linux \
+ 	validationkit-build-freebsd.amd64 \
+ 	validationkit-build-freebsd.x86 \
++	validationkit-build-netbsd.amd64 \
++	validationkit-build-netbsd.x86 \
+ 	validationkit-build-darwin.amd64 \
+ 	validationkit-build-darwin.x86
+ 
+@@ -1564,6 +1600,24 @@ validationkit-build-freebsd.x86:   $(VBO
+ #	$(call VBOX_BLD_VM_MSG_END__,Freebsd/x86 Validation Kit)
+ #endif
+ 
++validationkit-build-netbsd.amd64:   $(VBOX_VALIDATIONKIT_BUILD_WIN_HOST_FIRST)
++#ifeq ($(KBUILD_TARGET).$(KBUILD_TARGET_ARCH),netbsd.amd64)
++#	+ $(VBOX_KMK_TIME) $(KMK) $(VBOX_VALIDATIONKIT_BUILD.amd64) all $(VBOX_VALIDATIONKIT_HOST_BUILD_TWEAK)
++#else
++#	$(call VBOX_BLD_VM_MSG_BEGIN,Netbsd/amd64 Validation Kit)
++#	$(VBOX_KMK_TIME) ssh vbox@$(VBOX_BLD_VM_NBSD_AMD64_IP) " echo $@ && cd /mnt/tinderbox/$(VBOX_VALIDATIONKIT_BUILD_SUBDIRNAME) && tools/env.sh --no-wine kmk $(VBOX_VALIDATIONKIT_BUILD.amd64) all"
++#	$(call VBOX_BLD_VM_MSG_END__,Netbsd/amd64 Validation Kit)
++#endif
++
++validationkit-build-netbsd.x86:   $(VBOX_VALIDATIONKIT_BUILD_WIN_HOST_FIRST)
++#ifeq ($(KBUILD_TARGET).$(KBUILD_TARGET_ARCH),netbsd.x86)
++#	+ $(VBOX_KMK_TIME) $(KMK) $(VBOX_VALIDATIONKIT_BUILD.x86) all $(VBOX_VALIDATIONKIT_HOST_BUILD_TWEAK)
++#else
++#	$(call VBOX_BLD_VM_MSG_BEGIN,Netbsd/x86 Validation Kit)
++#	$(VBOX_KMK_TIME) ssh vbox@$(VBOX_BLD_VM_NBSD_X86_IP) " echo $@ && cd /mnt/tinderbox/$(VBOX_VALIDATIONKIT_BUILD_SUBDIRNAME) && tools/env.sh --no-wine kmk $(VBOX_VALIDATIONKIT_BUILD.x86) all"
++#	$(call VBOX_BLD_VM_MSG_END__,Netbsd/x86 Validation Kit)
++#endif
++
+ validationkit-build-darwin.amd64:   $(VBOX_VALIDATIONKIT_BUILD_WIN_HOST_FIRST)
+ ifeq ($(KBUILD_TARGET).$(KBUILD_TARGET_ARCH),darwin.amd64)
+ 	+ $(VBOX_KMK_TIME) $(KMK) $(VBOX_VALIDATIONKIT_BUILD.amd64) all $(VBOX_VALIDATIONKIT_HOST_BUILD_TWEAK)
+@@ -1593,6 +1647,8 @@ validationkit-packing:
+ 		VBOX_WITH_VALIDATIONKIT_PACKING.darwin.x86=2 \
+ 		VBOX_WITH_VALIDATIONKIT_PACKING.freebsd.amd64= \
+ 		VBOX_WITH_VALIDATIONKIT_PACKING.freebsd.x86= \
++		VBOX_WITH_VALIDATIONKIT_PACKING.netbsd.amd64= \
++		VBOX_WITH_VALIDATIONKIT_PACKING.netbsd.x86= \
+ 		VBOX_WITH_VALIDATIONKIT_PACKING.linux.amd64=1 \
+ 		VBOX_WITH_VALIDATIONKIT_PACKING.linux.x86=1 \
+ 		VBOX_WITH_VALIDATIONKIT_PACKING.os2.x86=1 \
+@@ -1615,6 +1671,8 @@ validationkit-packing:
+ 	validationkit-build-linux.x86 \
+ 	validationkit-build-freebsd.amd64 \
+ 	validationkit-build-freebsd.x86 \
++	validationkit-build-netbsd.amd64 \
++	validationkit-build-netbsd.x86 \
+ 	validationkit-build-darwin.amd64 \
+ 	validationkit-build-darwin.x86 \
+ 	validationkit-packing
+@@ -1819,4 +1877,3 @@ sdk:
+ 
+ sdk-fetch:
+ 	+ $(KMK) VBOX_ONLY_SDK=1 -C tools
+-
diff --git a/virtualbox-svn/patches/patch-configure b/virtualbox-svn/patches/patch-configure
new file mode 100644
index 0000000..8e0ae0f
--- /dev/null
+++ b/virtualbox-svn/patches/patch-configure
@@ -0,0 +1,112 @@
+$NetBSD$
+
+--- configure.orig	2016-07-10 19:41:32.000000000 +0000
++++ configure
+@@ -51,6 +51,8 @@ case "$OS" in
+     ;;
+   freebsd)
+     ;;
++  netbsd)
++    ;;
+   sunos)
+     OS='solaris'
+     ;;
+@@ -117,6 +119,7 @@ MKISOFS="mkisofs"
+ INCCRYPTO=""
+ LIBCRYPTO="-lssl -lcrypto"
+ LIBPTHREAD="-lpthread"
++INCCAP=""
+ LIBCAP="-lcap"
+ GSOAP=""
+ GSOAP_IMPORT=""
+@@ -135,19 +138,12 @@ LIBVNCSERVER="-lvncserver"
+ INCDEVMAPPER=""
+ LIBDEVMAPPER="-ldevmapper"
+ CXX_FLAGS=""
+-if [ "$OS" = "freebsd" ]; then
+-  INCCURL="-I/usr/local/include"
+-  LIBCURL="-L/usr/local/lib -lcurl"
+-  INCPULSE="-I/usr/local/include"
+-  LIBPULSE="-L/usr/local/lib"
+-  INCPNG="-I/usr/local/include"
+-  LIBPNG="-L/usr/local/lib -lpng"
+-else
+-  INCCURL=""
+-  LIBCURL="-lcurl"
+-  INCPNG=""
+-  LIBPNG="-lpng"
+-fi
++INCCURL="-I/usr/local/include"
++LIBCURL="-L/usr/local/lib -lcurl"
++INCPULSE="-I/usr/local/include"
++LIBPULSE="-L/usr/local/lib"
++INCPNG="-I/usr/local/include"
++LIBPNG="-L/usr/local/lib -lpng"
+ INCVPX=""
+ LIBVPX="-lvpx"
+ PKGCONFIG="`which_wrapper pkg-config`"
+@@ -538,6 +534,7 @@ check_open_watcom()
+     "darwin")   wc_bin="binosx";;  # ??
+     "dos")      wc_bin="binw";;
+     "freebsd")  wc_bin="binfbsd";; # ??
++    "freebsd")  wc_bin="binnbsd";; # ??
+     "linux")    wc_bin="binl";;
+     "solaris")  wc_bin="binsol";;  # ??
+     "os2")      wc_bin="binp";;
+@@ -923,7 +920,7 @@ EOF
+   [ -n "$INCZ" ] && I_INCZ=`prefix_I "$INCZ"`
+   if test_compile "$LIBZ $I_INCZ" zlib zlib; then
+     if test_execute; then
+-      echo "if1of (\$(KBUILD_TARGET),darwin freebsd haiku linux)" >> $CNF
++      echo "if1of (\$(KBUILD_TARGET),darwin freebsd netbsd haiku linux)" >> $CNF
+       cnf_append " SDK_VBOX_ZLIB_LIBS" "`strip_l "$LIBZ"`"
+       cnf_append " SDK_VBOX_ZLIB_INCS" "$INCZ"
+       echo "endif" >> $CNF
+@@ -1907,9 +1904,9 @@ EOF
+   echo "compiling the following source file:" >> $LOG
+   cat $ODIR.tmp_src.c >> $LOG
+   echo "using the following command line:" >> $LOG
+-  echo "$CC -O -Wall -o $ODIR.tmp_out $ODIR.tmp_src.c -nostdinc -I$LINUX/include " \
++  echo "$CC -O -Wall -o $ODIR.tmp_out $ODIR.tmp_src.c -I$LINUX/include " \
+       "-I$LINUX/include/generated/uapi" >> $LOG
+-  $CC -O -Wall -o $ODIR.tmp_out $ODIR.tmp_src.c -nostdinc -I$LINUX/include \
++  $CC -O -Wall -o $ODIR.tmp_out $ODIR.tmp_src.c -I$LINUX/include \
+       -I$LINUX/include/generated/uapi >> $LOG 2>&1
+   if [ $? -ne 0 ]; then
+     echo
+@@ -2038,7 +2035,7 @@ extern "C" int main(void)
+   return 0;
+ }
+ EOF
+-  if test_compile $LIBCAP libcap libcap; then
++  if test_compile $INCCAP $LIBCAP libcap libcap; then
+     if test_execute; then
+       log_success "found"
+     fi
+@@ -2470,7 +2467,7 @@ EOF
+ [ $OSE          -eq 0 ] && echo "  --disable-extpack        don't build the extpack"
+ [ $WITH_DOCS    -eq 1 ] && echo "  --disable-docs           don't build the documentation"
+ [ $WITH_LIBVPX  -eq 1 ] && echo "  --disable-libvpx         don't use libvpx for video capturing"
+-[ "$OS" = "linux" -o "$OS" = "freebsd" ] && echo "  --enable-vde             enable VDE networking"
++[ "$OS" = "linux" -o "$OS" = "freebsd" -o "$OS" = "netbsd" ] && echo "  --enable-vde             enable VDE networking"
+ cat << EOF
+   --disable-udptunnel      disable UDP tunnel networking
+   --disable-devmapper      disable device mapper library access
+@@ -2939,7 +2936,7 @@ if [ $ONLY_ADDITIONS -eq 0 ]; then
+   [ $WITH_JAVA   -eq 1 ] && check_java
+ 
+   # PulseAudio
+-  if [ "$OS" = "linux" -o "$OS" = "freebsd" ]; then
++  if [ "$OS" = "linux" -o "$OS" = "freebsd" -o "$OS" = "netbsd" ]; then
+     if [ $WITH_PULSE -eq 1 ]; then
+       check_pulse
+     elif [ $WITH_PULSE -eq 0 ]; then
+@@ -2998,7 +2995,7 @@ if [ $ONLY_ADDITIONS -eq 0 -a $WITH_UDPT
+ fi
+ 
+ # VDE
+-if [ $ONLY_ADDITIONS -eq 0 -a "$OS" = "linux" -o "$OS" = "freebsd" ]; then
++if [ $ONLY_ADDITIONS -eq 0 -a "$OS" = "linux" -o "$OS" = "freebsd" -o "$OS" = "netbsd" ]; then
+   if [ $WITH_VDE -eq 1 ]; then
+     cnf_append "VBOX_WITH_VDE" "1"
+   fi
diff --git a/virtualbox-svn/patches/patch-include_VBox_VBoxGuest.h b/virtualbox-svn/patches/patch-include_VBox_VBoxGuest.h
new file mode 100644
index 0000000..80104bc
--- /dev/null
+++ b/virtualbox-svn/patches/patch-include_VBox_VBoxGuest.h
@@ -0,0 +1,41 @@
+$NetBSD$
+
+--- include/VBox/VBoxGuest.h.orig	2016-03-04 19:22:56.000000000 +0000
++++ include/VBox/VBoxGuest.h
+@@ -204,6 +204,13 @@ typedef const VBGLBIGREQ *PCVBGLBIGREQ;
+ # define VBOXGUEST_IOCTL_CODE_FAST_(Function)       _IO(  'V', (Function))
+ # define VBOXGUEST_IOCTL_STRIP_SIZE(Code)           IOCBASECMD(Code)
+ 
++#elif defined(RT_OS_NETBSD) /** @todo r=bird: Please do it like SUPDRVIOC to keep it as similar as possible. */
++# include <sys/ioccom.h>
++
++# define VBOXGUEST_IOCTL_CODE_(Function, Size)      _IOWR('V', (Function), VBGLBIGREQ)
++# define VBOXGUEST_IOCTL_CODE_FAST_(Function)       _IO(  'V', (Function))
++# define VBOXGUEST_IOCTL_STRIP_SIZE(Code)           IOCBASECMD(Code)
++
+ #else /* BSD Like */
+   /* Automatic buffering, size limited to 4KB on *BSD and 8KB on Darwin - commands the limit, 4KB. */
+ # include <sys/ioccom.h>
+@@ -534,7 +541,7 @@ typedef VBOXGUESTOS2IDCCONNECT *PVBOXGUE
+ 
+ #endif /* RT_OS_OS2 */
+ 
+-#if defined(RT_OS_LINUX) || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD)
++#if defined(RT_OS_LINUX) || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+ 
+ /* Private IOCtls between user space and the kernel video driver.  DRM private
+  * IOCtls always have the type 'd' and a number between 0x40 and 0x99 (0x9F?) */
+@@ -554,7 +561,7 @@ typedef VBOXGUESTOS2IDCCONNECT *PVBOXGUE
+ # define DRM_IOCTL_VBOX_ENABLE_HGSMI     VBOX_DRM_IOCTL(ENABLE_HGSMI)
+ # define VBOXVIDEO_IOCTL_ENABLE_HGSMI    _IO('d', DRM_IOCTL_VBOX_ENABLE_HGSMI)
+ 
+-#endif /* RT_OS_LINUX || RT_OS_SOLARIS || RT_OS_FREEBSD */
++#endif /* RT_OS_LINUX || RT_OS_SOLARIS || RT_OS_FREEBSD || RT_OS_FREEBSD */
+ 
+ #endif /* !defined(IN_RC) && !defined(IN_RING0_AGNOSTIC) && !defined(IPRT_NO_CRT) */
+ 
+@@ -562,4 +569,3 @@ typedef VBOXGUESTOS2IDCCONNECT *PVBOXGUE
+ 
+ /** @} */
+ #endif
+-
diff --git a/virtualbox-svn/patches/patch-include_VBox_ostypes.h b/virtualbox-svn/patches/patch-include_VBox_ostypes.h
new file mode 100644
index 0000000..fd20b34
--- /dev/null
+++ b/virtualbox-svn/patches/patch-include_VBox_ostypes.h
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- include/VBox/ostypes.h.orig	2016-03-04 19:22:57.000000000 +0000
++++ include/VBox/ostypes.h
+@@ -157,6 +157,8 @@ typedef enum VBOXOSFAMILY
+     VBOXOSFAMILY_Solaris64        = 8,
+     VBOXOSFAMILY_MacOSX32         = 9,
+     VBOXOSFAMILY_MacOSX64         = 10,
++    VBOXOSFAMILY_NetBSD32         = 11,
++    VBOXOSFAMILY_NetBSD64         = 12,
+     /** The usual 32-bit hack. */
+     VBOXOSFAMILY_32BIT_HACK = 0x7fffffff
+ } VBOXOSFAMILY;
diff --git a/virtualbox-svn/patches/patch-include_VBox_param.h b/virtualbox-svn/patches/patch-include_VBox_param.h
new file mode 100644
index 0000000..b59ef5e
--- /dev/null
+++ b/virtualbox-svn/patches/patch-include_VBox_param.h
@@ -0,0 +1,18 @@
+$NetBSD$
+
+--- include/VBox/param.h.orig	2016-03-04 19:22:57.000000000 +0000
++++ include/VBox/param.h
+@@ -45,7 +45,7 @@
+  * @remarks This must match GMMR0Init; currently we only support page fusion on
+  *          all 64-bit hosts except Mac OS X */
+ #if (   HC_ARCH_BITS == 64          /* ASM-NOINC */ \
+-     && (defined(RT_OS_FREEBSD) || defined(RT_OS_LINUX) || defined(RT_OS_SOLARIS) || defined(RT_OS_WINDOWS)) ) /* ASM-NOINC */ \
++     && (defined(RT_OS_FREEBSD) || defined(RT_OS_LINUX) || defined(RT_OS_SOLARIS) || defined(RT_OS_WINDOWS) || defined(RT_OS_NETBSD)) ) /* ASM-NOINC */ \
+  || defined(DOXYGEN_RUNNING)        /* ASM-NOINC */
+ # define VBOX_WITH_PAGE_SHARING     /* ASM-NOINC */
+ #endif                              /* ASM-NOINC */
+@@ -172,4 +172,3 @@
+ /** @} */
+ 
+ #endif
+-
diff --git a/virtualbox-svn/patches/patch-include_VBox_rawpci.h b/virtualbox-svn/patches/patch-include_VBox_rawpci.h
new file mode 100644
index 0000000..968741a
--- /dev/null
+++ b/virtualbox-svn/patches/patch-include_VBox_rawpci.h
@@ -0,0 +1,22 @@
+$NetBSD$
+
+--- include/VBox/rawpci.h.orig	2016-03-04 19:22:58.000000000 +0000
++++ include/VBox/rawpci.h
+@@ -532,7 +532,7 @@ typedef struct RAWPCIFACTORY
+      * @param   pPciData    Pointer to PCI data.
+      */
+     DECLR0CALLBACKMEMBER(int, pfnInitVm,(PRAWPCIFACTORY       pFactory,
+-                                         PVM                  pVM,
++                                         vbox_PVM                  pVM,
+                                          PRAWPCIPERVM         pPciData));
+ 
+     /**
+@@ -545,7 +545,7 @@ typedef struct RAWPCIFACTORY
+      * @param   pPciData    Pointer to PCI data.
+      */
+     DECLR0CALLBACKMEMBER(void, pfnDeinitVm,(PRAWPCIFACTORY       pFactory,
+-                                            PVM                  pVM,
++                                            vbox_PVM                  pVM,
+                                             PRAWPCIPERVM         pPciData));
+ } RAWPCIFACTORY;
+ 
diff --git a/virtualbox-svn/patches/patch-include_VBox_types.h b/virtualbox-svn/patches/patch-include_VBox_types.h
new file mode 100644
index 0000000..451963d
--- /dev/null
+++ b/virtualbox-svn/patches/patch-include_VBox_types.h
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- include/VBox/types.h.orig	2016-03-04 19:22:58.000000000 +0000
++++ include/VBox/types.h
+@@ -75,7 +75,7 @@ typedef SUPSEMEVENTMULTI                
+ 
+ 
+ /** Pointer to a VM. */
+-typedef struct VM                  *PVM;
++typedef struct VM                  *vbox_PVM;
+ /** Pointer to a VM - Ring-0 Ptr. */
+ typedef R0PTRTYPE(struct VM *)      PVMR0;
+ /** Pointer to a VM - Ring-3 Ptr. */
diff --git a/virtualbox-svn/patches/patch-include_VBox_usb.h b/virtualbox-svn/patches/patch-include_VBox_usb.h
new file mode 100644
index 0000000..5e48325
--- /dev/null
+++ b/virtualbox-svn/patches/patch-include_VBox_usb.h
@@ -0,0 +1,18 @@
+$NetBSD$
+
+--- include/VBox/usb.h.orig	2016-03-04 19:22:58.000000000 +0000
++++ include/VBox/usb.h
+@@ -124,7 +124,7 @@ typedef struct USBDEVICE
+     uint8_t         bBus;
+     /** The port number. */
+     uint8_t         bPort;
+-#if defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD)
++#if defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+     /** Device number. */
+     uint8_t         bDevNum;
+ #endif
+@@ -260,4 +260,3 @@ typedef USBCONFIGDESC *PUSBCONFIGDESC;
+ RT_C_DECLS_END
+ 
+ #endif
+-
diff --git a/virtualbox-svn/patches/patch-include_VBox_vmm_cfgm.h b/virtualbox-svn/patches/patch-include_VBox_vmm_cfgm.h
new file mode 100644
index 0000000..19fa9ef
--- /dev/null
+++ b/virtualbox-svn/patches/patch-include_VBox_vmm_cfgm.h
@@ -0,0 +1,40 @@
+$NetBSD$
+
+--- include/VBox/vmm/cfgm.h.orig	2016-03-04 19:22:58.000000000 +0000
++++ include/VBox/vmm/cfgm.h
+@@ -78,13 +78,13 @@ typedef enum CFGMCONFIGTYPE
+  * @param   pVM         The cross context VM structure.
+  * @param   pvUser      The argument supplied to VMR3Create().
+  */
+-typedef DECLCALLBACK(int) FNCFGMCONSTRUCTOR(PUVM pUVM, PVM pVM, void *pvUser);
++typedef DECLCALLBACK(int) FNCFGMCONSTRUCTOR(PUVM pUVM, vbox_PVM pVM, void *pvUser);
+ /** Pointer to a FNCFGMCONSTRUCTOR(). */
+ typedef FNCFGMCONSTRUCTOR *PFNCFGMCONSTRUCTOR;
+ 
+-VMMR3DECL(int)          CFGMR3Init(PVM pVM, PFNCFGMCONSTRUCTOR pfnCFGMConstructor, void *pvUser);
+-VMMR3DECL(int)          CFGMR3Term(PVM pVM);
+-VMMR3DECL(int)          CFGMR3ConstructDefaultTree(PVM pVM);
++VMMR3DECL(int)          CFGMR3Init(vbox_PVM pVM, PFNCFGMCONSTRUCTOR pfnCFGMConstructor, void *pvUser);
++VMMR3DECL(int)          CFGMR3Term(vbox_PVM pVM);
++VMMR3DECL(int)          CFGMR3ConstructDefaultTree(vbox_PVM pVM);
+ 
+ VMMR3DECL(PCFGMNODE)    CFGMR3CreateTree(PUVM pUVM);
+ VMMR3DECL(int)          CFGMR3DestroyTree(PCFGMNODE pRoot);
+@@ -190,10 +190,10 @@ VMMR3DECL(int)          CFGMR3QueryStrin
+ /** @name Tree Navigation and Enumeration.
+  * @{
+  */
+-VMMR3DECL(PCFGMNODE)    CFGMR3GetRoot(PVM pVM);
++VMMR3DECL(PCFGMNODE)    CFGMR3GetRoot(vbox_PVM pVM);
+ VMMR3DECL(PCFGMNODE)    CFGMR3GetRootU(PUVM pUVM);
+ VMMR3DECL(PCFGMNODE)    CFGMR3GetParent(PCFGMNODE pNode);
+-VMMR3DECL(PCFGMNODE)    CFGMR3GetParentEx(PVM pVM, PCFGMNODE pNode);
++VMMR3DECL(PCFGMNODE)    CFGMR3GetParentEx(vbox_PVM pVM, PCFGMNODE pNode);
+ VMMR3DECL(PCFGMNODE)    CFGMR3GetChild(PCFGMNODE pNode, const char *pszPath);
+ VMMR3DECL(PCFGMNODE)    CFGMR3GetChildF(PCFGMNODE pNode, const char *pszPathFormat, ...) RT_IPRT_FORMAT_ATTR(2, 3);
+ VMMR3DECL(PCFGMNODE)    CFGMR3GetChildFV(PCFGMNODE pNode, const char *pszPathFormat, va_list Args) RT_IPRT_FORMAT_ATTR(3, 0);
+@@ -224,4 +224,3 @@ RT_C_DECLS_END
+ /** @} */
+ 
+ #endif
+-
diff --git a/virtualbox-svn/patches/patch-include_VBox_vmm_cpum.h b/virtualbox-svn/patches/patch-include_VBox_vmm_cpum.h
new file mode 100644
index 0000000..692c246
--- /dev/null
+++ b/virtualbox-svn/patches/patch-include_VBox_vmm_cpum.h
@@ -0,0 +1,56 @@
+$NetBSD$
+
+--- include/VBox/vmm/cpum.h.orig	2016-07-10 19:42:15.000000000 +0000
++++ include/VBox/vmm/cpum.h
+@@ -1077,8 +1077,8 @@ VMMDECL(void)       CPUMGetGuestCpuId(PV
+ VMMDECL(uint64_t)   CPUMGetGuestEFER(PVMCPU pVCpu);
+ VMMDECL(VBOXSTRICTRC)   CPUMQueryGuestMsr(PVMCPU pVCpu, uint32_t idMsr, uint64_t *puValue);
+ VMMDECL(VBOXSTRICTRC)   CPUMSetGuestMsr(PVMCPU pVCpu, uint32_t idMsr, uint64_t uValue);
+-VMMDECL(CPUMCPUVENDOR)  CPUMGetGuestCpuVendor(PVM pVM);
+-VMMDECL(CPUMCPUVENDOR)  CPUMGetHostCpuVendor(PVM pVM);
++VMMDECL(CPUMCPUVENDOR)  CPUMGetGuestCpuVendor(vbox_PVM pVM);
++VMMDECL(CPUMCPUVENDOR)  CPUMGetHostCpuVendor(vbox_PVM pVM);
+ /** @} */
+ 
+ /** @name Guest Register Setters.
+@@ -1381,7 +1381,7 @@ VMMDECL(uint32_t)       CPUMGetGuestCPL(
+ VMMDECL(CPUMMODE)       CPUMGetGuestMode(PVMCPU pVCpu);
+ VMMDECL(uint32_t)       CPUMGetGuestCodeBits(PVMCPU pVCpu);
+ VMMDECL(DISCPUMODE)     CPUMGetGuestDisMode(PVMCPU pVCpu);
+-VMMDECL(uint64_t)       CPUMGetGuestScalableBusFrequency(PVM pVM);
++VMMDECL(uint64_t)       CPUMGetGuestScalableBusFrequency(vbox_PVM pVM);
+ 
+ /** @name Typical scalable bus frequency values.
+  * @{ */
+@@ -1425,18 +1425,18 @@ VMMR3DECL(const char *)     CPUMR3CpuIdU
+ VMMR3DECL(CPUMCPUVENDOR)    CPUMR3CpuIdDetectVendorEx(uint32_t uEAX, uint32_t uEBX, uint32_t uECX, uint32_t uEDX);
+ VMMR3DECL(const char *)     CPUMR3CpuVendorName(CPUMCPUVENDOR enmVendor);
+ 
+-VMMR3DECL(int)              CPUMR3MsrRangesInsert(PVM pVM, PCCPUMMSRRANGE pNewRange);
++VMMR3DECL(int)              CPUMR3MsrRangesInsert(vbox_PVM pVM, PCCPUMMSRRANGE pNewRange);
+ 
+ # if defined(VBOX_WITH_RAW_MODE) || defined(DOXYGEN_RUNNING)
+ /** @name APIs for the CPUID raw-mode patch (legacy).
+  * @{ */
+-VMMR3_INT_DECL(RCPTRTYPE(PCCPUMCPUID))     CPUMR3GetGuestCpuIdPatmDefRCPtr(PVM pVM);
+-VMMR3_INT_DECL(uint32_t)                   CPUMR3GetGuestCpuIdPatmStdMax(PVM pVM);
+-VMMR3_INT_DECL(uint32_t)                   CPUMR3GetGuestCpuIdPatmExtMax(PVM pVM);
+-VMMR3_INT_DECL(uint32_t)                   CPUMR3GetGuestCpuIdPatmCentaurMax(PVM pVM);
+-VMMR3_INT_DECL(RCPTRTYPE(PCCPUMCPUID))     CPUMR3GetGuestCpuIdPatmStdRCPtr(PVM pVM);
+-VMMR3_INT_DECL(RCPTRTYPE(PCCPUMCPUID))     CPUMR3GetGuestCpuIdPatmExtRCPtr(PVM pVM);
+-VMMR3_INT_DECL(RCPTRTYPE(PCCPUMCPUID))     CPUMR3GetGuestCpuIdPatmCentaurRCPtr(PVM pVM);
++VMMR3_INT_DECL(RCPTRTYPE(PCCPUMCPUID))     CPUMR3GetGuestCpuIdPatmDefRCPtr(vbox_PVM pVM);
++VMMR3_INT_DECL(uint32_t)                   CPUMR3GetGuestCpuIdPatmStdMax(vbox_PVM pVM);
++VMMR3_INT_DECL(uint32_t)                   CPUMR3GetGuestCpuIdPatmExtMax(vbox_PVM pVM);
++VMMR3_INT_DECL(uint32_t)                   CPUMR3GetGuestCpuIdPatmCentaurMax(vbox_PVM pVM);
++VMMR3_INT_DECL(RCPTRTYPE(PCCPUMCPUID))     CPUMR3GetGuestCpuIdPatmStdRCPtr(vbox_PVM pVM);
++VMMR3_INT_DECL(RCPTRTYPE(PCCPUMCPUID))     CPUMR3GetGuestCpuIdPatmExtRCPtr(vbox_PVM pVM);
++VMMR3_INT_DECL(RCPTRTYPE(PCCPUMCPUID))     CPUMR3GetGuestCpuIdPatmCentaurRCPtr(vbox_PVM pVM);
+ /** @} */
+ # endif
+ 
+@@ -1524,4 +1524,3 @@ RT_C_DECLS_END
+ 
+ 
+ #endif
+-
diff --git a/virtualbox-svn/patches/patch-include_VBox_vmm_dbgf.h b/virtualbox-svn/patches/patch-include_VBox_vmm_dbgf.h
new file mode 100644
index 0000000..1d95034
--- /dev/null
+++ b/virtualbox-svn/patches/patch-include_VBox_vmm_dbgf.h
@@ -0,0 +1,40 @@
+$NetBSD$
+
+--- include/VBox/vmm/dbgf.h.orig	2016-07-10 19:42:15.000000000 +0000
++++ include/VBox/vmm/dbgf.h
+@@ -46,8 +46,8 @@ RT_C_DECLS_BEGIN
+ /** @defgroup grp_dbgf_rz  The RZ DBGF API
+  * @{
+  */
+-VMMRZ_INT_DECL(int) DBGFRZTrap01Handler(PVM pVM, PVMCPU pVCpu, PCPUMCTXCORE pRegFrame, RTGCUINTREG uDr6, bool fAltStepping);
+-VMMRZ_INT_DECL(int) DBGFRZTrap03Handler(PVM pVM, PVMCPU pVCpu, PCPUMCTXCORE pRegFrame);
++VMMRZ_INT_DECL(int) DBGFRZTrap01Handler(vbox_PVM pVM, PVMCPU pVCpu, PCPUMCTXCORE pRegFrame, RTGCUINTREG uDr6, bool fAltStepping);
++VMMRZ_INT_DECL(int) DBGFRZTrap03Handler(vbox_PVM pVM, PVMCPU pVCpu, PCPUMCTXCORE pRegFrame);
+ /** @} */
+ #endif
+ 
+@@ -923,7 +923,7 @@ typedef FNDBGFHANDLERDRV  *PFNDBGFHANDLE
+  * @param   pHlp        Callback functions for doing output.
+  * @param   pszArgs     Argument string. Optional and specific to the handler.
+  */
+-typedef DECLCALLBACK(void) FNDBGFHANDLERINT(PVM pVM, PCDBGFINFOHLP pHlp, const char *pszArgs);
++typedef DECLCALLBACK(void) FNDBGFHANDLERINT(vbox_PVM pVM, PCDBGFINFOHLP pHlp, const char *pszArgs);
+ /** Pointer to a FNDBGFHANDLERINT function. */
+ typedef FNDBGFHANDLERINT  *PFNDBGFHANDLERINT;
+ 
+@@ -1940,8 +1940,8 @@ VMMR3DECL(int) DBGFR3RegCpuSetBatch( PUV
+ 
+ VMMR3DECL(const char *) DBGFR3RegCpuName(PUVM pUVM, DBGFREG enmReg, DBGFREGVALTYPE enmType);
+ 
+-VMMR3_INT_DECL(int) DBGFR3RegRegisterCpu(PVM pVM, PVMCPU pVCpu, PCDBGFREGDESC paRegisters, bool fGuestRegs);
+-VMMR3_INT_DECL(int) DBGFR3RegRegisterDevice(PVM pVM, PCDBGFREGDESC paRegisters, PPDMDEVINS pDevIns,
++VMMR3_INT_DECL(int) DBGFR3RegRegisterCpu(vbox_PVM pVM, PVMCPU pVCpu, PCDBGFREGDESC paRegisters, bool fGuestRegs);
++VMMR3_INT_DECL(int) DBGFR3RegRegisterDevice(vbox_PVM pVM, PCDBGFREGDESC paRegisters, PPDMDEVINS pDevIns,
+                                             const char *pszPrefix, uint32_t iInstance);
+ 
+ /**
+@@ -2494,4 +2494,3 @@ VMMR3DECL(int)  DBGFR3TypeValDumpEx(PUVM
+ RT_C_DECLS_END
+ 
+ #endif
+-
diff --git a/virtualbox-svn/patches/patch-include_VBox_vmm_ftm.h b/virtualbox-svn/patches/patch-include_VBox_vmm_ftm.h
new file mode 100644
index 0000000..c015d63
--- /dev/null
+++ b/virtualbox-svn/patches/patch-include_VBox_vmm_ftm.h
@@ -0,0 +1,33 @@
+$NetBSD$
+
+--- include/VBox/vmm/ftm.h.orig	2016-03-04 19:22:58.000000000 +0000
++++ include/VBox/vmm/ftm.h
+@@ -48,8 +48,8 @@ typedef enum FTMCHECKPOINTTYPE
+     FTMCHECKPOINTTYPE_32BIT_HACK = 0x7fffffff
+ } FTMCHECKPOINTTYPE;
+ 
+-VMM_INT_DECL(bool)  FTMIsDeltaLoadSaveActive(PVM pVM);
+-VMM_INT_DECL(int)   FTMSetCheckpoint(PVM pVM, FTMCHECKPOINTTYPE enmType);
++VMM_INT_DECL(bool)  FTMIsDeltaLoadSaveActive(vbox_PVM pVM);
++VMM_INT_DECL(int)   FTMSetCheckpoint(vbox_PVM pVM, FTMCHECKPOINTTYPE enmType);
+ 
+ #ifdef IN_RING3
+ /** @defgroup grp_ftm_r3     The FTM Host Context Ring-3 API
+@@ -58,9 +58,9 @@ VMM_INT_DECL(int)   FTMSetCheckpoint(PVM
+ VMMR3DECL(int)      FTMR3PowerOn(PUVM pUVM, bool fMaster, unsigned uInterval, const char *pszAddress, unsigned uPort, const char *pszPassword);
+ VMMR3DECL(int)      FTMR3CancelStandby(PUVM pUVM);
+ 
+-VMMR3_INT_DECL(int) FTMR3Init(PVM pVM);
+-VMMR3_INT_DECL(int) FTMR3Term(PVM pVM);
+-VMMR3_INT_DECL(int) FTMR3SetCheckpoint(PVM pVM, FTMCHECKPOINTTYPE enmType);
++VMMR3_INT_DECL(int) FTMR3Init(vbox_PVM pVM);
++VMMR3_INT_DECL(int) FTMR3Term(vbox_PVM pVM);
++VMMR3_INT_DECL(int) FTMR3SetCheckpoint(vbox_PVM pVM, FTMCHECKPOINTTYPE enmType);
+ 
+ #endif /* IN_RING3 */
+ 
+@@ -71,4 +71,3 @@ VMMR3_INT_DECL(int) FTMR3SetCheckpoint(P
+ RT_C_DECLS_END
+ 
+ #endif
+-
diff --git a/virtualbox-svn/patches/patch-include_VBox_vmm_gmm.h b/virtualbox-svn/patches/patch-include_VBox_vmm_gmm.h
new file mode 100644
index 0000000..56c1302
--- /dev/null
+++ b/virtualbox-svn/patches/patch-include_VBox_vmm_gmm.h
@@ -0,0 +1,224 @@
+$NetBSD$
+
+--- include/VBox/vmm/gmm.h.orig	2016-03-04 19:22:58.000000000 +0000
++++ include/VBox/vmm/gmm.h
+@@ -399,26 +399,26 @@ GMMR0DECL(int)  GMMR0Init(void);
+ GMMR0DECL(void) GMMR0Term(void);
+ GMMR0DECL(void) GMMR0InitPerVMData(PGVM pGVM);
+ GMMR0DECL(void) GMMR0CleanupVM(PGVM pGVM);
+-GMMR0DECL(int)  GMMR0InitialReservation(PVM pVM, VMCPUID idCpu, uint64_t cBasePages, uint32_t cShadowPages, uint32_t cFixedPages,
++GMMR0DECL(int)  GMMR0InitialReservation(vbox_PVM pVM, VMCPUID idCpu, uint64_t cBasePages, uint32_t cShadowPages, uint32_t cFixedPages,
+                                         GMMOCPOLICY enmPolicy, GMMPRIORITY enmPriority);
+-GMMR0DECL(int)  GMMR0UpdateReservation(PVM pVM, VMCPUID idCpu, uint64_t cBasePages, uint32_t cShadowPages, uint32_t cFixedPages);
+-GMMR0DECL(int)  GMMR0AllocateHandyPages(PVM pVM, VMCPUID idCpu, uint32_t cPagesToUpdate, uint32_t cPagesToAlloc, PGMMPAGEDESC paPages);
+-GMMR0DECL(int)  GMMR0AllocatePages(PVM pVM, VMCPUID idCpu, uint32_t cPages, PGMMPAGEDESC paPages, GMMACCOUNT enmAccount);
+-GMMR0DECL(int)  GMMR0AllocateLargePage(PVM pVM, VMCPUID idCpu, uint32_t cbPage, uint32_t *pIdPage, RTHCPHYS *pHCPhys);
+-GMMR0DECL(int)  GMMR0FreePages(PVM pVM, VMCPUID idCpu, uint32_t cPages, PGMMFREEPAGEDESC paPages, GMMACCOUNT enmAccount);
+-GMMR0DECL(int)  GMMR0FreeLargePage(PVM pVM, VMCPUID idCpu, uint32_t idPage);
+-GMMR0DECL(int)  GMMR0BalloonedPages(PVM pVM, VMCPUID idCpu, GMMBALLOONACTION enmAction, uint32_t cBalloonedPages);
+-GMMR0DECL(int)  GMMR0MapUnmapChunk(PVM pVM, uint32_t idChunkMap, uint32_t idChunkUnmap, PRTR3PTR ppvR3);
+-GMMR0DECL(int)  GMMR0SeedChunk(PVM pVM, VMCPUID idCpu, RTR3PTR pvR3);
+-GMMR0DECL(int)  GMMR0RegisterSharedModule(PVM pVM, VMCPUID idCpu, VBOXOSFAMILY enmGuestOS, char *pszModuleName, char *pszVersion,
++GMMR0DECL(int)  GMMR0UpdateReservation(vbox_PVM pVM, VMCPUID idCpu, uint64_t cBasePages, uint32_t cShadowPages, uint32_t cFixedPages);
++GMMR0DECL(int)  GMMR0AllocateHandyPages(vbox_PVM pVM, VMCPUID idCpu, uint32_t cPagesToUpdate, uint32_t cPagesToAlloc, PGMMPAGEDESC paPages);
++GMMR0DECL(int)  GMMR0AllocatePages(vbox_PVM pVM, VMCPUID idCpu, uint32_t cPages, PGMMPAGEDESC paPages, GMMACCOUNT enmAccount);
++GMMR0DECL(int)  GMMR0AllocateLargePage(vbox_PVM pVM, VMCPUID idCpu, uint32_t cbPage, uint32_t *pIdPage, RTHCPHYS *pHCPhys);
++GMMR0DECL(int)  GMMR0FreePages(vbox_PVM pVM, VMCPUID idCpu, uint32_t cPages, PGMMFREEPAGEDESC paPages, GMMACCOUNT enmAccount);
++GMMR0DECL(int)  GMMR0FreeLargePage(vbox_PVM pVM, VMCPUID idCpu, uint32_t idPage);
++GMMR0DECL(int)  GMMR0BalloonedPages(vbox_PVM pVM, VMCPUID idCpu, GMMBALLOONACTION enmAction, uint32_t cBalloonedPages);
++GMMR0DECL(int)  GMMR0MapUnmapChunk(vbox_PVM pVM, uint32_t idChunkMap, uint32_t idChunkUnmap, PRTR3PTR ppvR3);
++GMMR0DECL(int)  GMMR0SeedChunk(vbox_PVM pVM, VMCPUID idCpu, RTR3PTR pvR3);
++GMMR0DECL(int)  GMMR0RegisterSharedModule(vbox_PVM pVM, VMCPUID idCpu, VBOXOSFAMILY enmGuestOS, char *pszModuleName, char *pszVersion,
+                                           RTGCPTR GCBaseAddr,  uint32_t cbModule, uint32_t cRegions,
+                                           struct VMMDEVSHAREDREGIONDESC const *paRegions);
+-GMMR0DECL(int)  GMMR0UnregisterSharedModule(PVM pVM, VMCPUID idCpu, char *pszModuleName, char *pszVersion, RTGCPTR GCBaseAddr, uint32_t cbModule);
+-GMMR0DECL(int)  GMMR0UnregisterAllSharedModules(PVM pVM, VMCPUID idCpu);
+-GMMR0DECL(int)  GMMR0CheckSharedModules(PVM pVM, PVMCPU pVCpu);
+-GMMR0DECL(int)  GMMR0ResetSharedModules(PVM pVM, VMCPUID idCpu);
+-GMMR0DECL(int)  GMMR0CheckSharedModulesStart(PVM pVM);
+-GMMR0DECL(int)  GMMR0CheckSharedModulesEnd(PVM pVM);
++GMMR0DECL(int)  GMMR0UnregisterSharedModule(vbox_PVM pVM, VMCPUID idCpu, char *pszModuleName, char *pszVersion, RTGCPTR GCBaseAddr, uint32_t cbModule);
++GMMR0DECL(int)  GMMR0UnregisterAllSharedModules(vbox_PVM pVM, VMCPUID idCpu);
++GMMR0DECL(int)  GMMR0CheckSharedModules(vbox_PVM pVM, PVMCPU pVCpu);
++GMMR0DECL(int)  GMMR0ResetSharedModules(vbox_PVM pVM, VMCPUID idCpu);
++GMMR0DECL(int)  GMMR0CheckSharedModulesStart(vbox_PVM pVM);
++GMMR0DECL(int)  GMMR0CheckSharedModulesEnd(vbox_PVM pVM);
+ GMMR0DECL(int)  GMMR0QueryStatistics(PGMMSTATS pStats, PSUPDRVSESSION pSession);
+ GMMR0DECL(int)  GMMR0ResetStatistics(PCGMMSTATS pStats, PSUPDRVSESSION pSession);
+ 
+@@ -439,7 +439,7 @@ typedef struct GMMINITIALRESERVATIONREQ
+ /** Pointer to a GMMR0InitialReservationReq / VMMR0_DO_GMM_INITIAL_RESERVATION request buffer. */
+ typedef GMMINITIALRESERVATIONREQ *PGMMINITIALRESERVATIONREQ;
+ 
+-GMMR0DECL(int)  GMMR0InitialReservationReq(PVM pVM, VMCPUID idCpu, PGMMINITIALRESERVATIONREQ pReq);
++GMMR0DECL(int)  GMMR0InitialReservationReq(vbox_PVM pVM, VMCPUID idCpu, PGMMINITIALRESERVATIONREQ pReq);
+ 
+ 
+ /**
+@@ -457,7 +457,7 @@ typedef struct GMMUPDATERESERVATIONREQ
+ /** Pointer to a GMMR0InitialReservationReq / VMMR0_DO_GMM_INITIAL_RESERVATION request buffer. */
+ typedef GMMUPDATERESERVATIONREQ *PGMMUPDATERESERVATIONREQ;
+ 
+-GMMR0DECL(int)  GMMR0UpdateReservationReq(PVM pVM, VMCPUID idCpu, PGMMUPDATERESERVATIONREQ pReq);
++GMMR0DECL(int)  GMMR0UpdateReservationReq(vbox_PVM pVM, VMCPUID idCpu, PGMMUPDATERESERVATIONREQ pReq);
+ 
+ 
+ /**
+@@ -478,7 +478,7 @@ typedef struct GMMALLOCATEPAGESREQ
+ /** Pointer to a GMMR0AllocatePagesReq / VMMR0_DO_GMM_ALLOCATE_PAGES request buffer. */
+ typedef GMMALLOCATEPAGESREQ *PGMMALLOCATEPAGESREQ;
+ 
+-GMMR0DECL(int)  GMMR0AllocatePagesReq(PVM pVM, VMCPUID idCpu, PGMMALLOCATEPAGESREQ pReq);
++GMMR0DECL(int)  GMMR0AllocatePagesReq(vbox_PVM pVM, VMCPUID idCpu, PGMMALLOCATEPAGESREQ pReq);
+ 
+ 
+ /**
+@@ -499,7 +499,7 @@ typedef struct GMMFREEPAGESREQ
+ /** Pointer to a GMMR0FreePagesReq / VMMR0_DO_GMM_FREE_PAGES request buffer. */
+ typedef GMMFREEPAGESREQ *PGMMFREEPAGESREQ;
+ 
+-GMMR0DECL(int)  GMMR0FreePagesReq(PVM pVM, VMCPUID idCpu, PGMMFREEPAGESREQ pReq);
++GMMR0DECL(int)  GMMR0FreePagesReq(vbox_PVM pVM, VMCPUID idCpu, PGMMFREEPAGESREQ pReq);
+ 
+ /**
+  * Request buffer for GMMR0BalloonedPagesReq / VMMR0_DO_GMM_BALLOONED_PAGES.
+@@ -517,7 +517,7 @@ typedef struct GMMBALLOONEDPAGESREQ
+ /** Pointer to a GMMR0BalloonedPagesReq / VMMR0_DO_GMM_BALLOONED_PAGES request buffer. */
+ typedef GMMBALLOONEDPAGESREQ *PGMMBALLOONEDPAGESREQ;
+ 
+-GMMR0DECL(int)  GMMR0BalloonedPagesReq(PVM pVM, VMCPUID idCpu, PGMMBALLOONEDPAGESREQ pReq);
++GMMR0DECL(int)  GMMR0BalloonedPagesReq(vbox_PVM pVM, VMCPUID idCpu, PGMMBALLOONEDPAGESREQ pReq);
+ 
+ 
+ /**
+@@ -542,8 +542,8 @@ typedef struct GMMMEMSTATSREQ
+ /** Pointer to a GMMR0QueryHypervisorMemoryStatsReq / VMMR0_DO_GMM_QUERY_HYPERVISOR_MEM_STATS request buffer. */
+ typedef GMMMEMSTATSREQ *PGMMMEMSTATSREQ;
+ 
+-GMMR0DECL(int)  GMMR0QueryHypervisorMemoryStatsReq(PVM pVM, PGMMMEMSTATSREQ pReq);
+-GMMR0DECL(int)  GMMR0QueryMemoryStatsReq(PVM pVM, VMCPUID idCpu, PGMMMEMSTATSREQ pReq);
++GMMR0DECL(int)  GMMR0QueryHypervisorMemoryStatsReq(vbox_PVM pVM, PGMMMEMSTATSREQ pReq);
++GMMR0DECL(int)  GMMR0QueryMemoryStatsReq(vbox_PVM pVM, VMCPUID idCpu, PGMMMEMSTATSREQ pReq);
+ 
+ /**
+  * Request buffer for GMMR0MapUnmapChunkReq / VMMR0_DO_GMM_MAP_UNMAP_CHUNK.
+@@ -563,7 +563,7 @@ typedef struct GMMMAPUNMAPCHUNKREQ
+ /** Pointer to a GMMR0MapUnmapChunkReq / VMMR0_DO_GMM_MAP_UNMAP_CHUNK request buffer. */
+ typedef GMMMAPUNMAPCHUNKREQ *PGMMMAPUNMAPCHUNKREQ;
+ 
+-GMMR0DECL(int)  GMMR0MapUnmapChunkReq(PVM pVM, PGMMMAPUNMAPCHUNKREQ pReq);
++GMMR0DECL(int)  GMMR0MapUnmapChunkReq(vbox_PVM pVM, PGMMMAPUNMAPCHUNKREQ pReq);
+ 
+ 
+ /**
+@@ -580,7 +580,7 @@ typedef struct GMMFREELARGEPAGEREQ
+ /** Pointer to a GMMR0FreePagesReq / VMMR0_DO_GMM_FREE_PAGES request buffer. */
+ typedef GMMFREELARGEPAGEREQ *PGMMFREELARGEPAGEREQ;
+ 
+-GMMR0DECL(int) GMMR0FreeLargePageReq(PVM pVM, VMCPUID idCpu, PGMMFREELARGEPAGEREQ pReq);
++GMMR0DECL(int) GMMR0FreeLargePageReq(vbox_PVM pVM, VMCPUID idCpu, PGMMFREELARGEPAGEREQ pReq);
+ 
+ /** Maximum length of the shared module name string, terminator included. */
+ #define GMM_SHARED_MODULE_MAX_NAME_STRING       128
+@@ -615,7 +615,7 @@ typedef struct GMMREGISTERSHAREDMODULERE
+ /** Pointer to a GMMR0RegisterSharedModuleReq / VMMR0_DO_GMM_REGISTER_SHARED_MODULE request buffer. */
+ typedef GMMREGISTERSHAREDMODULEREQ *PGMMREGISTERSHAREDMODULEREQ;
+ 
+-GMMR0DECL(int) GMMR0RegisterSharedModuleReq(PVM pVM, VMCPUID idCpu, PGMMREGISTERSHAREDMODULEREQ pReq);
++GMMR0DECL(int) GMMR0RegisterSharedModuleReq(vbox_PVM pVM, VMCPUID idCpu, PGMMREGISTERSHAREDMODULEREQ pReq);
+ 
+ /**
+  * Shared region descriptor
+@@ -702,7 +702,7 @@ typedef struct GMMUNREGISTERSHAREDMODULE
+ /** Pointer to a GMMR0UnregisterSharedModuleReq / VMMR0_DO_GMM_UNREGISTER_SHARED_MODULE request buffer. */
+ typedef GMMUNREGISTERSHAREDMODULEREQ *PGMMUNREGISTERSHAREDMODULEREQ;
+ 
+-GMMR0DECL(int) GMMR0UnregisterSharedModuleReq(PVM pVM, VMCPUID idCpu, PGMMUNREGISTERSHAREDMODULEREQ pReq);
++GMMR0DECL(int) GMMR0UnregisterSharedModuleReq(vbox_PVM pVM, VMCPUID idCpu, PGMMUNREGISTERSHAREDMODULEREQ pReq);
+ 
+ #if defined(VBOX_STRICT) && HC_ARCH_BITS == 64
+ /**
+@@ -721,7 +721,7 @@ typedef struct GMMFINDDUPLICATEPAGEREQ
+ /** Pointer to a GMMR0FindDuplicatePageReq / VMMR0_DO_GMM_FIND_DUPLICATE_PAGE request buffer. */
+ typedef GMMFINDDUPLICATEPAGEREQ *PGMMFINDDUPLICATEPAGEREQ;
+ 
+-GMMR0DECL(int) GMMR0FindDuplicatePageReq(PVM pVM, PGMMFINDDUPLICATEPAGEREQ pReq);
++GMMR0DECL(int) GMMR0FindDuplicatePageReq(vbox_PVM pVM, PGMMFINDDUPLICATEPAGEREQ pReq);
+ #endif /* VBOX_STRICT && HC_ARCH_BITS == 64 */
+ 
+ 
+@@ -742,7 +742,7 @@ typedef struct GMMQUERYSTATISTICSSREQ
+  *  request buffer. */
+ typedef GMMQUERYSTATISTICSSREQ *PGMMQUERYSTATISTICSSREQ;
+ 
+-GMMR0DECL(int)      GMMR0QueryStatisticsReq(PVM pVM, PGMMQUERYSTATISTICSSREQ pReq);
++GMMR0DECL(int)      GMMR0QueryStatisticsReq(vbox_PVM pVM, PGMMQUERYSTATISTICSSREQ pReq);
+ 
+ 
+ /**
+@@ -763,7 +763,7 @@ typedef struct GMMRESETSTATISTICSSREQ
+  *  request buffer. */
+ typedef GMMRESETSTATISTICSSREQ *PGMMRESETSTATISTICSSREQ;
+ 
+-GMMR0DECL(int)      GMMR0ResetStatisticsReq(PVM pVM, PGMMRESETSTATISTICSSREQ pReq);
++GMMR0DECL(int)      GMMR0ResetStatisticsReq(vbox_PVM pVM, PGMMRESETSTATISTICSSREQ pReq);
+ 
+ 
+ 
+@@ -771,31 +771,31 @@ GMMR0DECL(int)      GMMR0ResetStatistics
+ /** @defgroup grp_gmm_r3    The Global Memory Manager Ring-3 API Wrappers
+  * @{
+  */
+-GMMR3DECL(int)  GMMR3InitialReservation(PVM pVM, uint64_t cBasePages, uint32_t cShadowPages, uint32_t cFixedPages,
++GMMR3DECL(int)  GMMR3InitialReservation(vbox_PVM pVM, uint64_t cBasePages, uint32_t cShadowPages, uint32_t cFixedPages,
+                                         GMMOCPOLICY enmPolicy, GMMPRIORITY enmPriority);
+-GMMR3DECL(int)  GMMR3UpdateReservation(PVM pVM, uint64_t cBasePages, uint32_t cShadowPages, uint32_t cFixedPages);
+-GMMR3DECL(int)  GMMR3AllocatePagesPrepare(PVM pVM, PGMMALLOCATEPAGESREQ *ppReq, uint32_t cPages, GMMACCOUNT enmAccount);
+-GMMR3DECL(int)  GMMR3AllocatePagesPerform(PVM pVM, PGMMALLOCATEPAGESREQ pReq);
++GMMR3DECL(int)  GMMR3UpdateReservation(vbox_PVM pVM, uint64_t cBasePages, uint32_t cShadowPages, uint32_t cFixedPages);
++GMMR3DECL(int)  GMMR3AllocatePagesPrepare(vbox_PVM pVM, PGMMALLOCATEPAGESREQ *ppReq, uint32_t cPages, GMMACCOUNT enmAccount);
++GMMR3DECL(int)  GMMR3AllocatePagesPerform(vbox_PVM pVM, PGMMALLOCATEPAGESREQ pReq);
+ GMMR3DECL(void) GMMR3AllocatePagesCleanup(PGMMALLOCATEPAGESREQ pReq);
+-GMMR3DECL(int)  GMMR3FreePagesPrepare(PVM pVM, PGMMFREEPAGESREQ *ppReq, uint32_t cPages, GMMACCOUNT enmAccount);
+-GMMR3DECL(void) GMMR3FreePagesRePrep(PVM pVM, PGMMFREEPAGESREQ pReq, uint32_t cPages, GMMACCOUNT enmAccount);
+-GMMR3DECL(int)  GMMR3FreePagesPerform(PVM pVM, PGMMFREEPAGESREQ pReq, uint32_t cActualPages);
++GMMR3DECL(int)  GMMR3FreePagesPrepare(vbox_PVM pVM, PGMMFREEPAGESREQ *ppReq, uint32_t cPages, GMMACCOUNT enmAccount);
++GMMR3DECL(void) GMMR3FreePagesRePrep(vbox_PVM pVM, PGMMFREEPAGESREQ pReq, uint32_t cPages, GMMACCOUNT enmAccount);
++GMMR3DECL(int)  GMMR3FreePagesPerform(vbox_PVM pVM, PGMMFREEPAGESREQ pReq, uint32_t cActualPages);
+ GMMR3DECL(void) GMMR3FreePagesCleanup(PGMMFREEPAGESREQ pReq);
+-GMMR3DECL(void) GMMR3FreeAllocatedPages(PVM pVM, GMMALLOCATEPAGESREQ const *pAllocReq);
+-GMMR3DECL(int)  GMMR3AllocateLargePage(PVM pVM,  uint32_t cbPage);
+-GMMR3DECL(int)  GMMR3FreeLargePage(PVM pVM,  uint32_t idPage);
+-GMMR3DECL(int)  GMMR3MapUnmapChunk(PVM pVM, uint32_t idChunkMap, uint32_t idChunkUnmap, PRTR3PTR ppvR3);
+-GMMR3DECL(int)  GMMR3SeedChunk(PVM pVM, RTR3PTR pvR3);
+-GMMR3DECL(int)  GMMR3QueryHypervisorMemoryStats(PVM pVM, uint64_t *pcTotalAllocPages, uint64_t *pcTotalFreePages, uint64_t *pcTotalBalloonPages, uint64_t *puTotalBalloonSize);
+-GMMR3DECL(int)  GMMR3QueryMemoryStats(PVM pVM, uint64_t *pcAllocPages, uint64_t *pcMaxPages, uint64_t *pcBalloonPages);
+-GMMR3DECL(int)  GMMR3BalloonedPages(PVM pVM, GMMBALLOONACTION enmAction, uint32_t cBalloonedPages);
+-GMMR3DECL(int)  GMMR3RegisterSharedModule(PVM pVM, PGMMREGISTERSHAREDMODULEREQ pReq);
+-GMMR3DECL(int)  GMMR3UnregisterSharedModule(PVM pVM, PGMMUNREGISTERSHAREDMODULEREQ pReq);
+-GMMR3DECL(int)  GMMR3CheckSharedModules(PVM pVM);
+-GMMR3DECL(int)  GMMR3ResetSharedModules(PVM pVM);
++GMMR3DECL(void) GMMR3FreeAllocatedPages(vbox_PVM pVM, GMMALLOCATEPAGESREQ const *pAllocReq);
++GMMR3DECL(int)  GMMR3AllocateLargePage(vbox_PVM pVM,  uint32_t cbPage);
++GMMR3DECL(int)  GMMR3FreeLargePage(vbox_PVM pVM,  uint32_t idPage);
++GMMR3DECL(int)  GMMR3MapUnmapChunk(vbox_PVM pVM, uint32_t idChunkMap, uint32_t idChunkUnmap, PRTR3PTR ppvR3);
++GMMR3DECL(int)  GMMR3SeedChunk(vbox_PVM pVM, RTR3PTR pvR3);
++GMMR3DECL(int)  GMMR3QueryHypervisorMemoryStats(vbox_PVM pVM, uint64_t *pcTotalAllocPages, uint64_t *pcTotalFreePages, uint64_t *pcTotalBalloonPages, uint64_t *puTotalBalloonSize);
++GMMR3DECL(int)  GMMR3QueryMemoryStats(vbox_PVM pVM, uint64_t *pcAllocPages, uint64_t *pcMaxPages, uint64_t *pcBalloonPages);
++GMMR3DECL(int)  GMMR3BalloonedPages(vbox_PVM pVM, GMMBALLOONACTION enmAction, uint32_t cBalloonedPages);
++GMMR3DECL(int)  GMMR3RegisterSharedModule(vbox_PVM pVM, PGMMREGISTERSHAREDMODULEREQ pReq);
++GMMR3DECL(int)  GMMR3UnregisterSharedModule(vbox_PVM pVM, PGMMUNREGISTERSHAREDMODULEREQ pReq);
++GMMR3DECL(int)  GMMR3CheckSharedModules(vbox_PVM pVM);
++GMMR3DECL(int)  GMMR3ResetSharedModules(vbox_PVM pVM);
+ 
+ # if defined(VBOX_STRICT) && HC_ARCH_BITS == 64
+-GMMR3DECL(bool) GMMR3IsDuplicatePage(PVM pVM, uint32_t idPage);
++GMMR3DECL(bool) GMMR3IsDuplicatePage(vbox_PVM pVM, uint32_t idPage);
+ # endif
+ 
+ /** @} */
+@@ -806,4 +806,3 @@ GMMR3DECL(bool) GMMR3IsDuplicatePage(PVM
+ RT_C_DECLS_END
+ 
+ #endif
+-
diff --git a/virtualbox-svn/patches/patch-include_VBox_vmm_gvm.h b/virtualbox-svn/patches/patch-include_VBox_vmm_gvm.h
new file mode 100644
index 0000000..6a22459
--- /dev/null
+++ b/virtualbox-svn/patches/patch-include_VBox_vmm_gvm.h
@@ -0,0 +1,18 @@
+$NetBSD$
+
+--- include/VBox/vmm/gvm.h.orig	2016-03-04 19:22:58.000000000 +0000
++++ include/VBox/vmm/gvm.h
+@@ -80,7 +80,7 @@ typedef struct GVM
+     /** The global VM handle for this VM. */
+     uint32_t        hSelf;
+     /** The ring-0 mapping of the VM structure. */
+-    PVM             pVM;
++    vbox_PVM             pVM;
+     /** Number of Virtual CPUs, i.e. how many entries there are in aCpus.
+      * Same same as VM::cCpus. */
+     uint32_t        cCpus;
+@@ -124,4 +124,3 @@ typedef struct GVM
+ /** @} */
+ 
+ #endif
+-
diff --git a/virtualbox-svn/patches/patch-include_VBox_vmm_gvmm.h b/virtualbox-svn/patches/patch-include_VBox_vmm_gvmm.h
new file mode 100644
index 0000000..4351f5f
--- /dev/null
+++ b/virtualbox-svn/patches/patch-include_VBox_vmm_gvmm.h
@@ -0,0 +1,84 @@
+$NetBSD$
+
+--- include/VBox/vmm/gvmm.h.orig	2016-03-04 19:22:58.000000000 +0000
++++ include/VBox/vmm/gvmm.h
+@@ -158,27 +158,27 @@ GVMMR0DECL(void)    GVMMR0Term(void);
+ GVMMR0DECL(int)     GVMMR0SetConfig(PSUPDRVSESSION pSession, const char *pszName, uint64_t u64Value);
+ GVMMR0DECL(int)     GVMMR0QueryConfig(PSUPDRVSESSION pSession, const char *pszName, uint64_t *pu64Value);
+ 
+-GVMMR0DECL(int)     GVMMR0CreateVM(PSUPDRVSESSION pSession, uint32_t cCpus, PVM *ppVM);
+-GVMMR0DECL(int)     GVMMR0InitVM(PVM pVM);
+-GVMMR0DECL(void)    GVMMR0DoneInitVM(PVM pVM);
+-GVMMR0DECL(bool)    GVMMR0DoingTermVM(PVM pVM, PGVM pGVM);
+-GVMMR0DECL(int)     GVMMR0DestroyVM(PVM pVM);
+-GVMMR0DECL(int)     GVMMR0RegisterVCpu(PVM pVM, VMCPUID idCpu);
++GVMMR0DECL(int)     GVMMR0CreateVM(PSUPDRVSESSION pSession, uint32_t cCpus, vbox_PVM *ppVM);
++GVMMR0DECL(int)     GVMMR0InitVM(vbox_PVM pVM);
++GVMMR0DECL(void)    GVMMR0DoneInitVM(vbox_PVM pVM);
++GVMMR0DECL(bool)    GVMMR0DoingTermVM(vbox_PVM pVM, PGVM pGVM);
++GVMMR0DECL(int)     GVMMR0DestroyVM(vbox_PVM pVM);
++GVMMR0DECL(int)     GVMMR0RegisterVCpu(vbox_PVM pVM, VMCPUID idCpu);
+ GVMMR0DECL(PGVM)    GVMMR0ByHandle(uint32_t hGVM);
+-GVMMR0DECL(int)     GVMMR0ByVM(PVM pVM, PGVM *ppGVM);
+-GVMMR0DECL(int)     GVMMR0ByVMAndEMT(PVM pVM, VMCPUID idCpu, PGVM *ppGVM);
+-GVMMR0DECL(PVM)     GVMMR0GetVMByHandle(uint32_t hGVM);
+-GVMMR0DECL(PVM)     GVMMR0GetVMByEMT(RTNATIVETHREAD hEMT);
+-GVMMR0DECL(int)     GVMMR0SchedHalt(PVM pVM, VMCPUID idCpu, uint64_t u64ExpireGipTime);
+-GVMMR0DECL(int)     GVMMR0SchedWakeUp(PVM pVM, VMCPUID idCpu);
+-GVMMR0DECL(int)     GVMMR0SchedWakeUpEx(PVM pVM, VMCPUID idCpu, bool fTakeUsedLock);
+-GVMMR0DECL(int)     GVMMR0SchedPoke(PVM pVM, VMCPUID idCpu);
+-GVMMR0DECL(int)     GVMMR0SchedPokeEx(PVM pVM, VMCPUID idCpu, bool fTakeUsedLock);
+-GVMMR0DECL(int)     GVMMR0SchedWakeUpAndPokeCpus(PVM pVM, PCVMCPUSET pSleepSet, PCVMCPUSET pPokeSet);
+-GVMMR0DECL(int)     GVMMR0SchedPoll(PVM pVM, VMCPUID idCpu, bool fYield);
+-GVMMR0DECL(void)    GVMMR0SchedUpdatePeriodicPreemptionTimer(PVM pVM, RTCPUID idHostCpu, uint32_t uHz);
+-GVMMR0DECL(int)     GVMMR0QueryStatistics(PGVMMSTATS pStats, PSUPDRVSESSION pSession, PVM pVM);
+-GVMMR0DECL(int)     GVMMR0ResetStatistics(PCGVMMSTATS pStats, PSUPDRVSESSION pSession, PVM pVM);
++GVMMR0DECL(int)     GVMMR0ByVM(vbox_PVM pVM, PGVM *ppGVM);
++GVMMR0DECL(int)     GVMMR0ByVMAndEMT(vbox_PVM pVM, VMCPUID idCpu, PGVM *ppGVM);
++GVMMR0DECL(vbox_PVM)     GVMMR0GetVMByHandle(uint32_t hGVM);
++GVMMR0DECL(vbox_PVM)     GVMMR0GetVMByEMT(RTNATIVETHREAD hEMT);
++GVMMR0DECL(int)     GVMMR0SchedHalt(vbox_PVM pVM, VMCPUID idCpu, uint64_t u64ExpireGipTime);
++GVMMR0DECL(int)     GVMMR0SchedWakeUp(vbox_PVM pVM, VMCPUID idCpu);
++GVMMR0DECL(int)     GVMMR0SchedWakeUpEx(vbox_PVM pVM, VMCPUID idCpu, bool fTakeUsedLock);
++GVMMR0DECL(int)     GVMMR0SchedPoke(vbox_PVM pVM, VMCPUID idCpu);
++GVMMR0DECL(int)     GVMMR0SchedPokeEx(vbox_PVM pVM, VMCPUID idCpu, bool fTakeUsedLock);
++GVMMR0DECL(int)     GVMMR0SchedWakeUpAndPokeCpus(vbox_PVM pVM, PCVMCPUSET pSleepSet, PCVMCPUSET pPokeSet);
++GVMMR0DECL(int)     GVMMR0SchedPoll(vbox_PVM pVM, VMCPUID idCpu, bool fYield);
++GVMMR0DECL(void)    GVMMR0SchedUpdatePeriodicPreemptionTimer(vbox_PVM pVM, RTCPUID idHostCpu, uint32_t uHz);
++GVMMR0DECL(int)     GVMMR0QueryStatistics(PGVMMSTATS pStats, PSUPDRVSESSION pSession, vbox_PVM pVM);
++GVMMR0DECL(int)     GVMMR0ResetStatistics(PCGVMMSTATS pStats, PSUPDRVSESSION pSession, vbox_PVM pVM);
+ 
+ 
+ /**
+@@ -219,7 +219,7 @@ typedef struct GVMMSCHEDWAKEUPANDPOKECPU
+ /** Pointer to a GVMMR0QueryStatisticsReq / VMMR0_DO_GVMM_QUERY_STATISTICS request buffer. */
+ typedef GVMMSCHEDWAKEUPANDPOKECPUSREQ *PGVMMSCHEDWAKEUPANDPOKECPUSREQ;
+ 
+-GVMMR0DECL(int)     GVMMR0SchedWakeUpAndPokeCpusReq(PVM pVM, PGVMMSCHEDWAKEUPANDPOKECPUSREQ pReq);
++GVMMR0DECL(int)     GVMMR0SchedWakeUpAndPokeCpusReq(vbox_PVM pVM, PGVMMSCHEDWAKEUPANDPOKECPUSREQ pReq);
+ 
+ 
+ /**
+@@ -238,7 +238,7 @@ typedef struct GVMMQUERYSTATISTICSSREQ
+ /** Pointer to a GVMMR0QueryStatisticsReq / VMMR0_DO_GVMM_QUERY_STATISTICS request buffer. */
+ typedef GVMMQUERYSTATISTICSSREQ *PGVMMQUERYSTATISTICSSREQ;
+ 
+-GVMMR0DECL(int)     GVMMR0QueryStatisticsReq(PVM pVM, PGVMMQUERYSTATISTICSSREQ pReq);
++GVMMR0DECL(int)     GVMMR0QueryStatisticsReq(vbox_PVM pVM, PGVMMQUERYSTATISTICSSREQ pReq);
+ 
+ 
+ /**
+@@ -258,7 +258,7 @@ typedef struct GVMMRESETSTATISTICSSREQ
+ /** Pointer to a GVMMR0ResetStatisticsReq / VMMR0_DO_GVMM_RESET_STATISTICS request buffer. */
+ typedef GVMMRESETSTATISTICSSREQ *PGVMMRESETSTATISTICSSREQ;
+ 
+-GVMMR0DECL(int)     GVMMR0ResetStatisticsReq(PVM pVM, PGVMMRESETSTATISTICSSREQ pReq);
++GVMMR0DECL(int)     GVMMR0ResetStatisticsReq(vbox_PVM pVM, PGVMMRESETSTATISTICSSREQ pReq);
+ 
+ 
+ /** @} */
+@@ -266,4 +266,3 @@ GVMMR0DECL(int)     GVMMR0ResetStatistic
+ RT_C_DECLS_END
+ 
+ #endif
+-
diff --git a/virtualbox-svn/patches/patch-include_VBox_vmm_hm.h b/virtualbox-svn/patches/patch-include_VBox_vmm_hm.h
new file mode 100644
index 0000000..165f579
--- /dev/null
+++ b/virtualbox-svn/patches/patch-include_VBox_vmm_hm.h
@@ -0,0 +1,32 @@
+$NetBSD$
+
+--- include/VBox/vmm/hm.h.orig	2016-07-10 19:42:15.000000000 +0000
++++ include/VBox/vmm/hm.h
+@@ -149,14 +149,14 @@ VMM_INT_DECL(void)              HMHyperc
+ 
+ #ifndef IN_RC
+ VMM_INT_DECL(int)               HMFlushTLB(PVMCPU pVCpu);
+-VMM_INT_DECL(int)               HMFlushTLBOnAllVCpus(PVM pVM);
+-VMM_INT_DECL(int)               HMInvalidatePageOnAllVCpus(PVM pVM, RTGCPTR GCVirt);
+-VMM_INT_DECL(int)               HMInvalidatePhysPage(PVM pVM, RTGCPHYS GCPhys);
+-VMM_INT_DECL(bool)              HMIsNestedPagingActive(PVM pVM);
+-VMM_INT_DECL(bool)              HMAreNestedPagingAndFullGuestExecEnabled(PVM pVM);
+-VMM_INT_DECL(bool)              HMIsLongModeAllowed(PVM pVM);
+-VMM_INT_DECL(bool)              HMAreMsrBitmapsAvailable(PVM pVM);
+-VMM_INT_DECL(PGMMODE)           HMGetShwPagingMode(PVM pVM);
++VMM_INT_DECL(int)               HMFlushTLBOnAllVCpus(vbox_PVM pVM);
++VMM_INT_DECL(int)               HMInvalidatePageOnAllVCpus(vbox_PVM pVM, RTGCPTR GCVirt);
++VMM_INT_DECL(int)               HMInvalidatePhysPage(vbox_PVM pVM, RTGCPHYS GCPhys);
++VMM_INT_DECL(bool)              HMIsNestedPagingActive(vbox_PVM pVM);
++VMM_INT_DECL(bool)              HMAreNestedPagingAndFullGuestExecEnabled(vbox_PVM pVM);
++VMM_INT_DECL(bool)              HMIsLongModeAllowed(vbox_PVM pVM);
++VMM_INT_DECL(bool)              HMAreMsrBitmapsAvailable(vbox_PVM pVM);
++VMM_INT_DECL(PGMMODE)           HMGetShwPagingMode(vbox_PVM pVM);
+ #else /* Nops in RC: */
+ # define HMFlushTLB(pVCpu)                              do { } while (0)
+ # define HMIsNestedPagingActive(pVM)                    false
+@@ -248,4 +248,3 @@ RT_C_DECLS_END
+ 
+ 
+ #endif
+-
diff --git a/virtualbox-svn/patches/patch-include_VBox_vmm_iom.h b/virtualbox-svn/patches/patch-include_VBox_vmm_iom.h
new file mode 100644
index 0000000..b053ee1
--- /dev/null
+++ b/virtualbox-svn/patches/patch-include_VBox_vmm_iom.h
@@ -0,0 +1,9 @@
+$NetBSD$
+
+--- include/VBox/vmm/iom.h.orig	2016-07-10 19:42:15.000000000 +0000
++++ include/VBox/vmm/iom.h
+@@ -363,4 +363,3 @@ VMMR3_INT_DECL(void) IOMR3NotifyDebugEve
+ RT_C_DECLS_END
+ 
+ #endif
+-
diff --git a/virtualbox-svn/patches/patch-include_VBox_vmm_mm.h b/virtualbox-svn/patches/patch-include_VBox_vmm_mm.h
new file mode 100644
index 0000000..789a468
--- /dev/null
+++ b/virtualbox-svn/patches/patch-include_VBox_vmm_mm.h
@@ -0,0 +1,290 @@
+$NetBSD$
+
+--- include/VBox/vmm/mm.h.orig	2016-03-04 19:22:58.000000000 +0000
++++ include/VBox/vmm/mm.h
+@@ -145,20 +145,20 @@ typedef enum MMTAG
+ /** @defgroup grp_mm_hyper  Hypervisor Memory Management
+  * @{ */
+ 
+-VMMDECL(RTR3PTR)    MMHyperR0ToR3(PVM pVM, RTR0PTR R0Ptr);
+-VMMDECL(RTRCPTR)    MMHyperR0ToRC(PVM pVM, RTR0PTR R0Ptr);
++VMMDECL(RTR3PTR)    MMHyperR0ToR3(vbox_PVM pVM, RTR0PTR R0Ptr);
++VMMDECL(RTRCPTR)    MMHyperR0ToRC(vbox_PVM pVM, RTR0PTR R0Ptr);
+ #ifndef IN_RING0
+-VMMDECL(void *)     MMHyperR0ToCC(PVM pVM, RTR0PTR R0Ptr);
++VMMDECL(void *)     MMHyperR0ToCC(vbox_PVM pVM, RTR0PTR R0Ptr);
+ #endif
+-VMMDECL(RTR0PTR)    MMHyperR3ToR0(PVM pVM, RTR3PTR R3Ptr);
+-VMMDECL(RTRCPTR)    MMHyperR3ToRC(PVM pVM, RTR3PTR R3Ptr);
+-VMMDECL(RTR3PTR)    MMHyperRCToR3(PVM pVM, RTRCPTR RCPtr);
+-VMMDECL(RTR0PTR)    MMHyperRCToR0(PVM pVM, RTRCPTR RCPtr);
++VMMDECL(RTR0PTR)    MMHyperR3ToR0(vbox_PVM pVM, RTR3PTR R3Ptr);
++VMMDECL(RTRCPTR)    MMHyperR3ToRC(vbox_PVM pVM, RTR3PTR R3Ptr);
++VMMDECL(RTR3PTR)    MMHyperRCToR3(vbox_PVM pVM, RTRCPTR RCPtr);
++VMMDECL(RTR0PTR)    MMHyperRCToR0(vbox_PVM pVM, RTRCPTR RCPtr);
+ 
+ #ifndef IN_RING3
+-VMMDECL(void *)     MMHyperR3ToCC(PVM pVM, RTR3PTR R3Ptr);
++VMMDECL(void *)     MMHyperR3ToCC(vbox_PVM pVM, RTR3PTR R3Ptr);
+ #else
+-DECLINLINE(void *)  MMHyperR3ToCC(PVM pVM, RTR3PTR R3Ptr)
++DECLINLINE(void *)  MMHyperR3ToCC(vbox_PVM pVM, RTR3PTR R3Ptr)
+ {
+     NOREF(pVM);
+     return R3Ptr;
+@@ -167,9 +167,9 @@ DECLINLINE(void *)  MMHyperR3ToCC(PVM pV
+ 
+ 
+ #ifndef IN_RC
+-VMMDECL(void *)     MMHyperRCToCC(PVM pVM, RTRCPTR RCPtr);
++VMMDECL(void *)     MMHyperRCToCC(vbox_PVM pVM, RTRCPTR RCPtr);
+ #else
+-DECLINLINE(void *)  MMHyperRCToCC(PVM pVM, RTRCPTR RCPtr)
++DECLINLINE(void *)  MMHyperRCToCC(vbox_PVM pVM, RTRCPTR RCPtr)
+ {
+     NOREF(pVM);
+     return (void *)RCPtr;
+@@ -177,9 +177,9 @@ DECLINLINE(void *)  MMHyperRCToCC(PVM pV
+ #endif
+ 
+ #ifndef IN_RING3
+-VMMDECL(RTR3PTR)    MMHyperCCToR3(PVM pVM, void *pv);
++VMMDECL(RTR3PTR)    MMHyperCCToR3(vbox_PVM pVM, void *pv);
+ #else
+-DECLINLINE(RTR3PTR) MMHyperCCToR3(PVM pVM, void *pv)
++DECLINLINE(RTR3PTR) MMHyperCCToR3(vbox_PVM pVM, void *pv)
+ {
+     NOREF(pVM);
+     return pv;
+@@ -187,9 +187,9 @@ DECLINLINE(RTR3PTR) MMHyperCCToR3(PVM pV
+ #endif
+ 
+ #ifndef IN_RING0
+-VMMDECL(RTR0PTR)    MMHyperCCToR0(PVM pVM, void *pv);
++VMMDECL(RTR0PTR)    MMHyperCCToR0(vbox_PVM pVM, void *pv);
+ #else
+-DECLINLINE(RTR0PTR) MMHyperCCToR0(PVM pVM, void *pv)
++DECLINLINE(RTR0PTR) MMHyperCCToR0(vbox_PVM pVM, void *pv)
+ {
+     NOREF(pVM);
+     return pv;
+@@ -197,9 +197,9 @@ DECLINLINE(RTR0PTR) MMHyperCCToR0(PVM pV
+ #endif
+ 
+ #ifndef IN_RC
+-VMMDECL(RTRCPTR)    MMHyperCCToRC(PVM pVM, void *pv);
++VMMDECL(RTRCPTR)    MMHyperCCToRC(vbox_PVM pVM, void *pv);
+ #else
+-DECLINLINE(RTRCPTR) MMHyperCCToRC(PVM pVM, void *pv)
++DECLINLINE(RTRCPTR) MMHyperCCToRC(vbox_PVM pVM, void *pv)
+ {
+     NOREF(pVM);
+     return (RTRCPTR)pv;
+@@ -207,26 +207,26 @@ DECLINLINE(RTRCPTR) MMHyperCCToRC(PVM pV
+ #endif
+ 
+ 
+-VMMDECL(int)        MMHyperAlloc(PVM pVM, size_t cb, uint32_t uAlignment, MMTAG enmTag, void **ppv);
+-VMMDECL(int)        MMHyperDupMem(PVM pVM, const void *pvSrc, size_t cb, unsigned uAlignment, MMTAG enmTag, void **ppv);
+-VMMDECL(int)        MMHyperFree(PVM pVM, void *pv);
+-VMMDECL(void)       MMHyperHeapCheck(PVM pVM);
+-VMMDECL(int)        MMR3LockCall(PVM pVM);
++VMMDECL(int)        MMHyperAlloc(vbox_PVM pVM, size_t cb, uint32_t uAlignment, MMTAG enmTag, void **ppv);
++VMMDECL(int)        MMHyperDupMem(vbox_PVM pVM, const void *pvSrc, size_t cb, unsigned uAlignment, MMTAG enmTag, void **ppv);
++VMMDECL(int)        MMHyperFree(vbox_PVM pVM, void *pv);
++VMMDECL(void)       MMHyperHeapCheck(vbox_PVM pVM);
++VMMDECL(int)        MMR3LockCall(vbox_PVM pVM);
+ #ifdef DEBUG
+-VMMDECL(void)       MMHyperHeapDump(PVM pVM);
++VMMDECL(void)       MMHyperHeapDump(vbox_PVM pVM);
+ #endif
+-VMMDECL(size_t)     MMHyperHeapGetFreeSize(PVM pVM);
+-VMMDECL(size_t)     MMHyperHeapGetSize(PVM pVM);
+-VMMDECL(void *)     MMHyperHeapOffsetToPtr(PVM pVM, uint32_t offHeap);
+-VMMDECL(uint32_t)   MMHyperHeapPtrToOffset(PVM pVM, void *pv);
+-VMMDECL(RTGCPTR)    MMHyperGetArea(PVM pVM, size_t *pcb);
+-VMMDECL(bool)       MMHyperIsInsideArea(PVM pVM, RTGCPTR GCPtr);
++VMMDECL(size_t)     MMHyperHeapGetFreeSize(vbox_PVM pVM);
++VMMDECL(size_t)     MMHyperHeapGetSize(vbox_PVM pVM);
++VMMDECL(void *)     MMHyperHeapOffsetToPtr(vbox_PVM pVM, uint32_t offHeap);
++VMMDECL(uint32_t)   MMHyperHeapPtrToOffset(vbox_PVM pVM, void *pv);
++VMMDECL(RTGCPTR)    MMHyperGetArea(vbox_PVM pVM, size_t *pcb);
++VMMDECL(bool)       MMHyperIsInsideArea(vbox_PVM pVM, RTGCPTR GCPtr);
+ 
+ 
+-VMMDECL(RTHCPHYS)   MMPage2Phys(PVM pVM, void *pvPage);
+-VMMDECL(void *)     MMPagePhys2Page(PVM pVM, RTHCPHYS HCPhysPage);
+-VMMDECL(int)        MMPagePhys2PageEx(PVM pVM, RTHCPHYS HCPhysPage, void **ppvPage);
+-VMMDECL(int)        MMPagePhys2PageTry(PVM pVM, RTHCPHYS HCPhysPage, void **ppvPage);
++VMMDECL(RTHCPHYS)   MMPage2Phys(vbox_PVM pVM, void *pvPage);
++VMMDECL(void *)     MMPagePhys2Page(vbox_PVM pVM, RTHCPHYS HCPhysPage);
++VMMDECL(int)        MMPagePhys2PageEx(vbox_PVM pVM, RTHCPHYS HCPhysPage, void **ppvPage);
++VMMDECL(int)        MMPagePhys2PageTry(vbox_PVM pVM, RTHCPHYS HCPhysPage, void **ppvPage);
+ 
+ 
+ /** @def MMHYPER_RC_ASSERT_RCPTR
+@@ -249,81 +249,81 @@ VMMDECL(int)        MMPagePhys2PageTry(P
+  */
+ 
+ VMMR3DECL(int)      MMR3InitUVM(PUVM pUVM);
+-VMMR3DECL(int)      MMR3Init(PVM pVM);
+-VMMR3DECL(int)      MMR3InitPaging(PVM pVM);
+-VMMR3DECL(int)      MMR3HyperInitFinalize(PVM pVM);
+-VMMR3DECL(int)      MMR3Term(PVM pVM);
++VMMR3DECL(int)      MMR3Init(vbox_PVM pVM);
++VMMR3DECL(int)      MMR3InitPaging(vbox_PVM pVM);
++VMMR3DECL(int)      MMR3HyperInitFinalize(vbox_PVM pVM);
++VMMR3DECL(int)      MMR3Term(vbox_PVM pVM);
+ VMMR3DECL(void)     MMR3TermUVM(PUVM pUVM);
+-VMMR3_INT_DECL(bool) MMR3IsInitialized(PVM pVM);
+-VMMR3DECL(int)      MMR3ReserveHandyPages(PVM pVM, uint32_t cHandyPages);
+-VMMR3DECL(int)      MMR3IncreaseBaseReservation(PVM pVM, uint64_t cAddBasePages);
+-VMMR3DECL(int)      MMR3AdjustFixedReservation(PVM pVM, int32_t cDeltaFixedPages, const char *pszDesc);
+-VMMR3DECL(int)      MMR3UpdateShadowReservation(PVM pVM, uint32_t cShadowPages);
++VMMR3_INT_DECL(bool) MMR3IsInitialized(vbox_PVM pVM);
++VMMR3DECL(int)      MMR3ReserveHandyPages(vbox_PVM pVM, uint32_t cHandyPages);
++VMMR3DECL(int)      MMR3IncreaseBaseReservation(vbox_PVM pVM, uint64_t cAddBasePages);
++VMMR3DECL(int)      MMR3AdjustFixedReservation(vbox_PVM pVM, int32_t cDeltaFixedPages, const char *pszDesc);
++VMMR3DECL(int)      MMR3UpdateShadowReservation(vbox_PVM pVM, uint32_t cShadowPages);
+ 
+-VMMR3DECL(int)      MMR3HCPhys2HCVirt(PVM pVM, RTHCPHYS HCPhys, void **ppv);
++VMMR3DECL(int)      MMR3HCPhys2HCVirt(vbox_PVM pVM, RTHCPHYS HCPhys, void **ppv);
+ 
+ /** @defgroup grp_mm_r3_hyper  Hypervisor Memory Manager (HC R3 Portion)
+  * @{ */
+-VMMR3DECL(int)      MMR3HyperAllocOnceNoRel(PVM pVM, size_t cb, uint32_t uAlignment, MMTAG enmTag, void **ppv);
+-VMMR3DECL(int)      MMR3HyperAllocOnceNoRelEx(PVM pVM, size_t cb, uint32_t uAlignment, MMTAG enmTag, uint32_t fFlags, void **ppv);
+-VMMR3DECL(int)      MMR3HyperRealloc(PVM pVM, void *pv, size_t cb, unsigned uAlignmentNew, MMTAG enmTagNew, size_t cbNew, void **ppv);
++VMMR3DECL(int)      MMR3HyperAllocOnceNoRel(vbox_PVM pVM, size_t cb, uint32_t uAlignment, MMTAG enmTag, void **ppv);
++VMMR3DECL(int)      MMR3HyperAllocOnceNoRelEx(vbox_PVM pVM, size_t cb, uint32_t uAlignment, MMTAG enmTag, uint32_t fFlags, void **ppv);
++VMMR3DECL(int)      MMR3HyperRealloc(vbox_PVM pVM, void *pv, size_t cb, unsigned uAlignmentNew, MMTAG enmTagNew, size_t cbNew, void **ppv);
+ /** @name  MMR3HyperAllocOnceNoRelEx flags
+  * @{ */
+ /** Must have kernel mapping.
+  * If not specified, the R0 pointer may point to the user process mapping. */
+ #define MMHYPER_AONR_FLAGS_KERNEL_MAPPING   RT_BIT(0)
+ /** @} */
+-VMMR3DECL(int)      MMR3HyperSetGuard(PVM pVM, void *pvStart, size_t cb, bool fSet);
+-VMMR3DECL(int)      MMR3HyperMapHCPhys(PVM pVM, void *pvR3, RTR0PTR pvR0, RTHCPHYS HCPhys, size_t cb, const char *pszDesc, PRTGCPTR pGCPtr);
+-VMMR3DECL(int)      MMR3HyperMapGCPhys(PVM pVM, RTGCPHYS GCPhys, size_t cb, const char *pszDesc, PRTGCPTR pGCPtr);
+-VMMR3DECL(int)      MMR3HyperMapMMIO2(PVM pVM, PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS off, RTGCPHYS cb, const char *pszDesc, PRTRCPTR pRCPtr);
+-VMMR3DECL(int)      MMR3HyperMapPages(PVM pVM, void *pvR3, RTR0PTR pvR0, size_t cPages, PCSUPPAGE paPages, const char *pszDesc, PRTGCPTR pGCPtr);
+-VMMR3DECL(int)      MMR3HyperReserve(PVM pVM, unsigned cb, const char *pszDesc, PRTGCPTR pGCPtr);
+-VMMR3DECL(RTHCPHYS) MMR3HyperHCVirt2HCPhys(PVM pVM, void *pvHC);
+-VMMR3DECL(int)      MMR3HyperHCVirt2HCPhysEx(PVM pVM, void *pvHC, PRTHCPHYS pHCPhys);
+-VMMR3DECL(void *)   MMR3HyperHCPhys2HCVirt(PVM pVM, RTHCPHYS HCPhys);
+-VMMR3DECL(int)      MMR3HyperHCPhys2HCVirtEx(PVM pVM, RTHCPHYS HCPhys, void **ppv);
+-VMMR3_INT_DECL(int) MMR3HyperQueryInfoFromHCPhys(PVM pVM, RTHCPHYS HCPhys, char *pszWhat, size_t cbWhat, uint32_t *pcbAlloc);
+-VMMR3DECL(int)      MMR3HyperReadGCVirt(PVM pVM, void *pvDst, RTGCPTR GCPtr, size_t cb);
++VMMR3DECL(int)      MMR3HyperSetGuard(vbox_PVM pVM, void *pvStart, size_t cb, bool fSet);
++VMMR3DECL(int)      MMR3HyperMapHCPhys(vbox_PVM pVM, void *pvR3, RTR0PTR pvR0, RTHCPHYS HCPhys, size_t cb, const char *pszDesc, PRTGCPTR pGCPtr);
++VMMR3DECL(int)      MMR3HyperMapGCPhys(vbox_PVM pVM, RTGCPHYS GCPhys, size_t cb, const char *pszDesc, PRTGCPTR pGCPtr);
++VMMR3DECL(int)      MMR3HyperMapMMIO2(vbox_PVM pVM, PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS off, RTGCPHYS cb, const char *pszDesc, PRTRCPTR pRCPtr);
++VMMR3DECL(int)      MMR3HyperMapPages(vbox_PVM pVM, void *pvR3, RTR0PTR pvR0, size_t cPages, PCSUPPAGE paPages, const char *pszDesc, PRTGCPTR pGCPtr);
++VMMR3DECL(int)      MMR3HyperReserve(vbox_PVM pVM, unsigned cb, const char *pszDesc, PRTGCPTR pGCPtr);
++VMMR3DECL(RTHCPHYS) MMR3HyperHCVirt2HCPhys(vbox_PVM pVM, void *pvHC);
++VMMR3DECL(int)      MMR3HyperHCVirt2HCPhysEx(vbox_PVM pVM, void *pvHC, PRTHCPHYS pHCPhys);
++VMMR3DECL(void *)   MMR3HyperHCPhys2HCVirt(vbox_PVM pVM, RTHCPHYS HCPhys);
++VMMR3DECL(int)      MMR3HyperHCPhys2HCVirtEx(vbox_PVM pVM, RTHCPHYS HCPhys, void **ppv);
++VMMR3_INT_DECL(int) MMR3HyperQueryInfoFromHCPhys(vbox_PVM pVM, RTHCPHYS HCPhys, char *pszWhat, size_t cbWhat, uint32_t *pcbAlloc);
++VMMR3DECL(int)      MMR3HyperReadGCVirt(vbox_PVM pVM, void *pvDst, RTGCPTR GCPtr, size_t cb);
+ /** @} */
+ 
+ 
+ /** @defgroup grp_mm_phys   Guest Physical Memory Manager
+  * @todo retire this group, elimintating or moving MMR3PhysGetRamSize to PGMPhys.
+  * @{ */
+-VMMR3DECL(uint64_t) MMR3PhysGetRamSize(PVM pVM);
++VMMR3DECL(uint64_t) MMR3PhysGetRamSize(vbox_PVM pVM);
+ /** @} */
+ 
+ 
+ /** @defgroup grp_mm_page   Physical Page Pool
+  * @{ */
+-VMMR3DECL(void *)   MMR3PageAlloc(PVM pVM);
+-VMMR3DECL(RTHCPHYS) MMR3PageAllocPhys(PVM pVM);
+-VMMR3DECL(void)     MMR3PageFree(PVM pVM, void *pvPage);
+-VMMR3DECL(void *)   MMR3PageAllocLow(PVM pVM);
+-VMMR3DECL(void)     MMR3PageFreeLow(PVM pVM, void *pvPage);
+-VMMR3DECL(void)     MMR3PageFreeByPhys(PVM pVM, RTHCPHYS HCPhysPage);
+-VMMR3DECL(void *)   MMR3PageDummyHCPtr(PVM pVM);
+-VMMR3DECL(RTHCPHYS) MMR3PageDummyHCPhys(PVM pVM);
++VMMR3DECL(void *)   MMR3PageAlloc(vbox_PVM pVM);
++VMMR3DECL(RTHCPHYS) MMR3PageAllocPhys(vbox_PVM pVM);
++VMMR3DECL(void)     MMR3PageFree(vbox_PVM pVM, void *pvPage);
++VMMR3DECL(void *)   MMR3PageAllocLow(vbox_PVM pVM);
++VMMR3DECL(void)     MMR3PageFreeLow(vbox_PVM pVM, void *pvPage);
++VMMR3DECL(void)     MMR3PageFreeByPhys(vbox_PVM pVM, RTHCPHYS HCPhysPage);
++VMMR3DECL(void *)   MMR3PageDummyHCPtr(vbox_PVM pVM);
++VMMR3DECL(RTHCPHYS) MMR3PageDummyHCPhys(vbox_PVM pVM);
+ /** @} */
+ 
+ 
+ /** @defgroup grp_mm_heap   Heap Manager
+  * @{ */
+-VMMR3DECL(void *)   MMR3HeapAlloc(PVM pVM, MMTAG enmTag, size_t cbSize);
++VMMR3DECL(void *)   MMR3HeapAlloc(vbox_PVM pVM, MMTAG enmTag, size_t cbSize);
+ VMMR3DECL(void *)   MMR3HeapAllocU(PUVM pUVM, MMTAG enmTag, size_t cbSize);
+-VMMR3DECL(int)      MMR3HeapAllocEx(PVM pVM, MMTAG enmTag, size_t cbSize, void **ppv);
++VMMR3DECL(int)      MMR3HeapAllocEx(vbox_PVM pVM, MMTAG enmTag, size_t cbSize, void **ppv);
+ VMMR3DECL(int)      MMR3HeapAllocExU(PUVM pUVM, MMTAG enmTag, size_t cbSize, void **ppv);
+-VMMR3DECL(void *)   MMR3HeapAllocZ(PVM pVM, MMTAG enmTag, size_t cbSize);
++VMMR3DECL(void *)   MMR3HeapAllocZ(vbox_PVM pVM, MMTAG enmTag, size_t cbSize);
+ VMMR3DECL(void *)   MMR3HeapAllocZU(PUVM pUVM, MMTAG enmTag, size_t cbSize);
+-VMMR3DECL(int)      MMR3HeapAllocZEx(PVM pVM, MMTAG enmTag, size_t cbSize, void **ppv);
++VMMR3DECL(int)      MMR3HeapAllocZEx(vbox_PVM pVM, MMTAG enmTag, size_t cbSize, void **ppv);
+ VMMR3DECL(int)      MMR3HeapAllocZExU(PUVM pUVM, MMTAG enmTag, size_t cbSize, void **ppv);
+ VMMR3DECL(void *)   MMR3HeapRealloc(void *pv, size_t cbNewSize);
+-VMMR3DECL(char *)   MMR3HeapStrDup(PVM pVM, MMTAG enmTag, const char *psz);
++VMMR3DECL(char *)   MMR3HeapStrDup(vbox_PVM pVM, MMTAG enmTag, const char *psz);
+ VMMR3DECL(char *)   MMR3HeapStrDupU(PUVM pUVM, MMTAG enmTag, const char *psz);
+-VMMR3DECL(char *)   MMR3HeapAPrintf(PVM pVM, MMTAG enmTag, const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(3, 4);
++VMMR3DECL(char *)   MMR3HeapAPrintf(vbox_PVM pVM, MMTAG enmTag, const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(3, 4);
+ VMMR3DECL(char *)   MMR3HeapAPrintfU(PUVM pUVM, MMTAG enmTag, const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(3, 4);
+-VMMR3DECL(char *)   MMR3HeapAPrintfV(PVM pVM, MMTAG enmTag, const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(3, 0);
++VMMR3DECL(char *)   MMR3HeapAPrintfV(vbox_PVM pVM, MMTAG enmTag, const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(3, 0);
+ VMMR3DECL(char *)   MMR3HeapAPrintfVU(PUVM pUVM, MMTAG enmTag, const char *pszFormat, va_list va) RT_IPRT_FORMAT_ATTR(3, 0);
+ VMMR3DECL(void)     MMR3HeapFree(void *pv);
+ /** @} */
+@@ -333,11 +333,11 @@ VMMR3DECL(void)     MMR3HeapFree(void *p
+  * The memory is safely accessible from kernel context as well as user land.
+  *
+  * @{ */
+-VMMR3DECL(void *)   MMR3UkHeapAlloc(PVM pVM, MMTAG enmTag, size_t cbSize, PRTR0PTR pR0Ptr);
+-VMMR3DECL(int)      MMR3UkHeapAllocEx(PVM pVM, MMTAG enmTag, size_t cbSize, void **ppv, PRTR0PTR pR0Ptr);
+-VMMR3DECL(void *)   MMR3UkHeapAllocZ(PVM pVM, MMTAG enmTag, size_t cbSize, PRTR0PTR pR0Ptr);
+-VMMR3DECL(int)      MMR3UkHeapAllocZEx(PVM pVM, MMTAG enmTag, size_t cbSize, void **ppv, PRTR0PTR pR0Ptr);
+-VMMR3DECL(void)     MMR3UkHeapFree(PVM pVM, void *pv, MMTAG enmTag);
++VMMR3DECL(void *)   MMR3UkHeapAlloc(vbox_PVM pVM, MMTAG enmTag, size_t cbSize, PRTR0PTR pR0Ptr);
++VMMR3DECL(int)      MMR3UkHeapAllocEx(vbox_PVM pVM, MMTAG enmTag, size_t cbSize, void **ppv, PRTR0PTR pR0Ptr);
++VMMR3DECL(void *)   MMR3UkHeapAllocZ(vbox_PVM pVM, MMTAG enmTag, size_t cbSize, PRTR0PTR pR0Ptr);
++VMMR3DECL(int)      MMR3UkHeapAllocZEx(vbox_PVM pVM, MMTAG enmTag, size_t cbSize, void **ppv, PRTR0PTR pR0Ptr);
++VMMR3DECL(void)     MMR3UkHeapFree(vbox_PVM pVM, void *pv, MMTAG enmTag);
+ /** @} */
+ 
+ /** @} */
+@@ -350,15 +350,15 @@ VMMR3DECL(void)     MMR3UkHeapFree(PVM p
+  * @{
+  */
+ 
+-VMMRCDECL(void)     MMGCRamRegisterTrapHandler(PVM pVM);
+-VMMRCDECL(void)     MMGCRamDeregisterTrapHandler(PVM pVM);
++VMMRCDECL(void)     MMGCRamRegisterTrapHandler(vbox_PVM pVM);
++VMMRCDECL(void)     MMGCRamDeregisterTrapHandler(vbox_PVM pVM);
+ VMMRCDECL(int)      MMGCRamReadNoTrapHandler(void *pDst, void *pSrc, size_t cb);
+ /**
+  * @deprecated Don't use this as it doesn't check the page state.
+  */
+ VMMRCDECL(int)      MMGCRamWriteNoTrapHandler(void *pDst, void *pSrc, size_t cb);
+-VMMRCDECL(int)      MMGCRamRead(PVM pVM, void *pDst, void *pSrc, size_t cb);
+-VMMRCDECL(int)      MMGCRamWrite(PVM pVM, void *pDst, void *pSrc, size_t cb);
++VMMRCDECL(int)      MMGCRamRead(vbox_PVM pVM, void *pDst, void *pSrc, size_t cb);
++VMMRCDECL(int)      MMGCRamWrite(vbox_PVM pVM, void *pDst, void *pSrc, size_t cb);
+ 
+ /** @} */
+ #endif /* IN_RC || DOXYGEN_RUNNING */
+@@ -368,4 +368,3 @@ RT_C_DECLS_END
+ 
+ 
+ #endif
+-
diff --git a/virtualbox-svn/patches/patch-include_VBox_vmm_pdmapi.h b/virtualbox-svn/patches/patch-include_VBox_vmm_pdmapi.h
new file mode 100644
index 0000000..e6802a6
--- /dev/null
+++ b/virtualbox-svn/patches/patch-include_VBox_vmm_pdmapi.h
@@ -0,0 +1,71 @@
+$NetBSD$
+
+--- include/VBox/vmm/pdmapi.h.orig	2016-07-10 19:42:15.000000000 +0000
++++ include/VBox/vmm/pdmapi.h
+@@ -127,28 +127,28 @@ typedef enum  PDMLDRCTX
+  * @param   enmCtx          The context the module is loaded into.
+  * @param   pvArg           User argument.
+  */
+-typedef DECLCALLBACK(int) FNPDMR3ENUM(PVM pVM, const char *pszFilename, const char *pszName,
++typedef DECLCALLBACK(int) FNPDMR3ENUM(vbox_PVM pVM, const char *pszFilename, const char *pszName,
+                                       RTUINTPTR ImageBase, size_t cbImage, PDMLDRCTX enmCtx, void *pvArg);
+ /** Pointer to a FNPDMR3ENUM() function. */
+ typedef FNPDMR3ENUM *PFNPDMR3ENUM;
+-VMMR3DECL(int)          PDMR3LdrEnumModules(PVM pVM, PFNPDMR3ENUM pfnCallback, void *pvArg);
++VMMR3DECL(int)          PDMR3LdrEnumModules(vbox_PVM pVM, PFNPDMR3ENUM pfnCallback, void *pvArg);
+ VMMR3_INT_DECL(void)    PDMR3LdrRelocateU(PUVM pUVM, RTGCINTPTR offDelta);
+-VMMR3_INT_DECL(int)     PDMR3LdrGetSymbolR3(PVM pVM, const char *pszModule, const char *pszSymbol, void **ppvValue);
+-VMMR3DECL(int)          PDMR3LdrGetSymbolR0(PVM pVM, const char *pszModule, const char *pszSymbol, PRTR0PTR ppvValue);
+-VMMR3DECL(int)          PDMR3LdrGetSymbolR0Lazy(PVM pVM, const char *pszModule, const char *pszSearchPath, const char *pszSymbol, PRTR0PTR ppvValue);
+-VMMR3DECL(int)          PDMR3LdrLoadRC(PVM pVM, const char *pszFilename, const char *pszName);
+-VMMR3DECL(int)          PDMR3LdrGetSymbolRC(PVM pVM, const char *pszModule, const char *pszSymbol, PRTRCPTR pRCPtrValue);
+-VMMR3DECL(int)          PDMR3LdrGetSymbolRCLazy(PVM pVM, const char *pszModule, const char *pszSearchPath, const char *pszSymbol,
++VMMR3_INT_DECL(int)     PDMR3LdrGetSymbolR3(vbox_PVM pVM, const char *pszModule, const char *pszSymbol, void **ppvValue);
++VMMR3DECL(int)          PDMR3LdrGetSymbolR0(vbox_PVM pVM, const char *pszModule, const char *pszSymbol, PRTR0PTR ppvValue);
++VMMR3DECL(int)          PDMR3LdrGetSymbolR0Lazy(vbox_PVM pVM, const char *pszModule, const char *pszSearchPath, const char *pszSymbol, PRTR0PTR ppvValue);
++VMMR3DECL(int)          PDMR3LdrLoadRC(vbox_PVM pVM, const char *pszFilename, const char *pszName);
++VMMR3DECL(int)          PDMR3LdrGetSymbolRC(vbox_PVM pVM, const char *pszModule, const char *pszSymbol, PRTRCPTR pRCPtrValue);
++VMMR3DECL(int)          PDMR3LdrGetSymbolRCLazy(vbox_PVM pVM, const char *pszModule, const char *pszSearchPath, const char *pszSymbol,
+                                                 PRTRCPTR pRCPtrValue);
+-VMMR3_INT_DECL(int)     PDMR3LdrQueryRCModFromPC(PVM pVM, RTRCPTR uPC,
++VMMR3_INT_DECL(int)     PDMR3LdrQueryRCModFromPC(vbox_PVM pVM, RTRCPTR uPC,
+                                                  char *pszModName,  size_t cchModName,  PRTRCPTR pMod,
+                                                  char *pszNearSym1, size_t cchNearSym1, PRTRCPTR pNearSym1,
+                                                  char *pszNearSym2, size_t cchNearSym2, PRTRCPTR pNearSym2);
+-VMMR3_INT_DECL(int)     PDMR3LdrQueryR0ModFromPC(PVM pVM, RTR0PTR uPC,
++VMMR3_INT_DECL(int)     PDMR3LdrQueryR0ModFromPC(vbox_PVM pVM, RTR0PTR uPC,
+                                                  char *pszModName,  size_t cchModName,  PRTR0PTR pMod,
+                                                  char *pszNearSym1, size_t cchNearSym1, PRTR0PTR pNearSym1,
+                                                  char *pszNearSym2, size_t cchNearSym2, PRTR0PTR pNearSym2);
+-VMMR3_INT_DECL(int)     PDMR3LdrGetInterfaceSymbols(PVM pVM, void *pvInterface, size_t cbInterface,
++VMMR3_INT_DECL(int)     PDMR3LdrGetInterfaceSymbols(vbox_PVM pVM, void *pvInterface, size_t cbInterface,
+                                                     const char *pszModule, const char *pszSearchPath,
+                                                     const char *pszSymPrefix, const char *pszSymList,
+                                                     bool fRing0OrRC);
+@@ -161,7 +161,7 @@ VMMR3DECL(int)          PDMR3QueryDriver
+ VMMR3DECL(int)          PDMR3DeviceAttach(PUVM pUVM, const char *pszDevice, unsigned iInstance, unsigned iLun, uint32_t fFlags,
+                                           PPDMIBASE *ppBase);
+ VMMR3DECL(int)          PDMR3DeviceDetach(PUVM pUVM, const char *pszDevice, unsigned iInstance, unsigned iLun, uint32_t fFlags);
+-VMMR3_INT_DECL(PPDMCRITSECT) PDMR3DevGetCritSect(PVM pVM, PPDMDEVINS pDevIns);
++VMMR3_INT_DECL(PPDMCRITSECT) PDMR3DevGetCritSect(vbox_PVM pVM, PPDMDEVINS pDevIns);
+ VMMR3DECL(int)          PDMR3DriverAttach(PUVM pUVM, const char *pszDevice, unsigned iDevIns, unsigned iLun, uint32_t fFlags,
+                                           PPPDMIBASE ppBase);
+ VMMR3DECL(int)          PDMR3DriverDetach(PUVM pUVM, const char *pszDevice, unsigned iDevIns, unsigned iLun,
+@@ -214,7 +214,7 @@ typedef struct PDMDRIVERCALLREQHANDLERRE
+  * request buffer. */
+ typedef PDMDRIVERCALLREQHANDLERREQ *PPDMDRIVERCALLREQHANDLERREQ;
+ 
+-VMMR0_INT_DECL(int) PDMR0DriverCallReqHandler(PVM pVM, PPDMDRIVERCALLREQHANDLERREQ pReq);
++VMMR0_INT_DECL(int) PDMR0DriverCallReqHandler(vbox_PVM pVM, PPDMDRIVERCALLREQHANDLERREQ pReq);
+ 
+ /**
+  * Request buffer for PDMR0DeviceCallReqHandler / VMMR0_DO_PDM_DEVICE_CALL_REQ_HANDLER.
+@@ -239,7 +239,7 @@ typedef struct PDMDEVICECALLREQHANDLERRE
+  * VMMR0_DO_PDM_DEVICE_CALL_REQ_HANDLER request buffer. */
+ typedef PDMDEVICECALLREQHANDLERREQ *PPDMDEVICECALLREQHANDLERREQ;
+ 
+-VMMR0_INT_DECL(int) PDMR0DeviceCallReqHandler(PVM pVM, PPDMDEVICECALLREQHANDLERREQ pReq);
++VMMR0_INT_DECL(int) PDMR0DeviceCallReqHandler(vbox_PVM pVM, PPDMDEVICECALLREQHANDLERREQ pReq);
+ 
+ /** @} */
+ 
diff --git a/virtualbox-svn/patches/patch-include_VBox_vmm_pdmasynccompletion.h b/virtualbox-svn/patches/patch-include_VBox_vmm_pdmasynccompletion.h
new file mode 100644
index 0000000..f2d0063
--- /dev/null
+++ b/virtualbox-svn/patches/patch-include_VBox_vmm_pdmasynccompletion.h
@@ -0,0 +1,23 @@
+$NetBSD$
+
+--- include/VBox/vmm/pdmasynccompletion.h.orig	2016-03-04 19:22:58.000000000 +0000
++++ include/VBox/vmm/pdmasynccompletion.h
+@@ -100,11 +100,11 @@ typedef FNPDMASYNCCOMPLETEUSB *PFNPDMASY
+  * @param   pvUser2     User argument for the template.
+  * @param   rc          The status code of the completed request.
+  */
+-typedef DECLCALLBACK(void) FNPDMASYNCCOMPLETEINT(PVM pVM, void *pvUser, void *pvUser2, int rc);
++typedef DECLCALLBACK(void) FNPDMASYNCCOMPLETEINT(vbox_PVM pVM, void *pvUser, void *pvUser2, int rc);
+ /** Pointer to a FNPDMASYNCCOMPLETEINT(). */
+ typedef FNPDMASYNCCOMPLETEINT *PFNPDMASYNCCOMPLETEINT;
+ 
+-VMMR3DECL(int) PDMR3AsyncCompletionTemplateCreateInternal(PVM pVM, PPPDMASYNCCOMPLETIONTEMPLATE ppTemplate,
++VMMR3DECL(int) PDMR3AsyncCompletionTemplateCreateInternal(vbox_PVM pVM, PPPDMASYNCCOMPLETIONTEMPLATE ppTemplate,
+                                                           PFNPDMASYNCCOMPLETEINT pfnCompleted, void *pvUser2, const char *pszDesc);
+ VMMR3DECL(int) PDMR3AsyncCompletionTemplateDestroy(PPDMASYNCCOMPLETIONTEMPLATE pTemplate);
+ VMMR3DECL(int) PDMR3AsyncCompletionEpCreateForFile(PPPDMASYNCCOMPLETIONENDPOINT ppEndpoint,
+@@ -146,4 +146,3 @@ VMMR3DECL(int) PDMR3AsyncCompletionBwMgr
+ RT_C_DECLS_END
+ 
+ #endif
+-
diff --git a/virtualbox-svn/patches/patch-include_VBox_vmm_pdmblkcache.h b/virtualbox-svn/patches/patch-include_VBox_vmm_pdmblkcache.h
new file mode 100644
index 0000000..5a69328
--- /dev/null
+++ b/virtualbox-svn/patches/patch-include_VBox_vmm_pdmblkcache.h
@@ -0,0 +1,72 @@
+$NetBSD$
+
+--- include/VBox/vmm/pdmblkcache.h.orig	2016-03-04 19:22:58.000000000 +0000
++++ include/VBox/vmm/pdmblkcache.h
+@@ -230,7 +230,7 @@ typedef FNPDMBLKCACHEXFERENQUEUEDISCARDU
+  * @param   pfnXferEnqueueDiscard    The discard request enqueue callback.
+  * @param   pcszId                   Unique ID used to identify the user.
+  */
+-VMMR3DECL(int) PDMR3BlkCacheRetainDriver(PVM pVM, PPDMDRVINS pDrvIns, PPPDMBLKCACHE ppBlkCache,
++VMMR3DECL(int) PDMR3BlkCacheRetainDriver(vbox_PVM pVM, PPDMDRVINS pDrvIns, PPPDMBLKCACHE ppBlkCache,
+                                          PFNPDMBLKCACHEXFERCOMPLETEDRV pfnXferComplete,
+                                          PFNPDMBLKCACHEXFERENQUEUEDRV pfnXferEnqueue,
+                                          PFNPDMBLKCACHEXFERENQUEUEDISCARDDRV pfnXferEnqueueDiscard,
+@@ -248,7 +248,7 @@ VMMR3DECL(int) PDMR3BlkCacheRetainDriver
+  * @param   pfnXferEnqueueDiscard    The discard request enqueue callback.
+  * @param   pcszId                   Unique ID used to identify the user.
+  */
+-VMMR3DECL(int) PDMR3BlkCacheRetainDevice(PVM pVM, PPDMDEVINS pDevIns, PPPDMBLKCACHE ppBlkCache,
++VMMR3DECL(int) PDMR3BlkCacheRetainDevice(vbox_PVM pVM, PPDMDEVINS pDevIns, PPPDMBLKCACHE ppBlkCache,
+                                          PFNPDMBLKCACHEXFERCOMPLETEDEV pfnXferComplete,
+                                          PFNPDMBLKCACHEXFERENQUEUEDEV pfnXferEnqueue,
+                                          PFNPDMBLKCACHEXFERENQUEUEDISCARDDEV pfnXferEnqueueDiscard,
+@@ -266,7 +266,7 @@ VMMR3DECL(int) PDMR3BlkCacheRetainDevice
+  * @param   pfnXferEnqueueDiscard    The discard request enqueue callback.
+  * @param   pcszId                   Unique ID used to identify the user.
+  */
+-VMMR3DECL(int) PDMR3BlkCacheRetainUsb(PVM pVM, PPDMUSBINS pUsbIns, PPPDMBLKCACHE ppBlkCache,
++VMMR3DECL(int) PDMR3BlkCacheRetainUsb(vbox_PVM pVM, PPDMUSBINS pUsbIns, PPPDMBLKCACHE ppBlkCache,
+                                       PFNPDMBLKCACHEXFERCOMPLETEUSB pfnXferComplete,
+                                       PFNPDMBLKCACHEXFERENQUEUEUSB pfnXferEnqueue,
+                                       PFNPDMBLKCACHEXFERENQUEUEDISCARDUSB pfnXferEnqueueDiscard,
+@@ -284,7 +284,7 @@ VMMR3DECL(int) PDMR3BlkCacheRetainUsb(PV
+  * @param   pfnXferEnqueueDiscard    The discard request enqueue callback.
+  * @param   pcszId                   Unique ID used to identify the user.
+  */
+-VMMR3DECL(int) PDMR3BlkCacheRetainInt(PVM pVM, void *pvUser, PPPDMBLKCACHE ppBlkCache,
++VMMR3DECL(int) PDMR3BlkCacheRetainInt(vbox_PVM pVM, void *pvUser, PPPDMBLKCACHE ppBlkCache,
+                                       PFNPDMBLKCACHEXFERCOMPLETEINT pfnXferComplete,
+                                       PFNPDMBLKCACHEXFERENQUEUEINT pfnXferEnqueue,
+                                       PFNPDMBLKCACHEXFERENQUEUEDISCARDINT pfnXferEnqueueDiscard,
+@@ -305,7 +305,7 @@ VMMR3DECL(void) PDMR3BlkCacheRelease(PPD
+  * @param   pVM             The cross context VM structure.
+  * @param   pDevIns         The device instance.
+  */
+-VMMR3DECL(void) PDMR3BlkCacheReleaseDevice(PVM pVM, PPDMDEVINS pDevIns);
++VMMR3DECL(void) PDMR3BlkCacheReleaseDevice(vbox_PVM pVM, PPDMDEVINS pDevIns);
+ 
+ /**
+  * Releases all block cache handles for a driver instance.
+@@ -314,7 +314,7 @@ VMMR3DECL(void) PDMR3BlkCacheReleaseDevi
+  * @param   pVM             The cross context VM structure.
+  * @param   pDrvIns         The driver instance.
+  */
+-VMMR3DECL(void) PDMR3BlkCacheReleaseDriver(PVM pVM, PPDMDRVINS pDrvIns);
++VMMR3DECL(void) PDMR3BlkCacheReleaseDriver(vbox_PVM pVM, PPDMDRVINS pDrvIns);
+ 
+ /**
+  * Releases all block cache handles for a USB device instance.
+@@ -323,7 +323,7 @@ VMMR3DECL(void) PDMR3BlkCacheReleaseDriv
+  * @param   pVM             The cross context VM structure.
+  * @param   pUsbIns         The USB device instance.
+  */
+-VMMR3DECL(void) PDMR3BlkCacheReleaseUsb(PVM pVM, PPDMUSBINS pUsbIns);
++VMMR3DECL(void) PDMR3BlkCacheReleaseUsb(vbox_PVM pVM, PPDMUSBINS pUsbIns);
+ 
+ /**
+  * Creates a read task on the given endpoint.
+@@ -418,4 +418,3 @@ VMMR3DECL(int) PDMR3BlkCacheClear(PPDMBL
+ RT_C_DECLS_END
+ 
+ #endif
+-
diff --git a/virtualbox-svn/patches/patch-include_VBox_vmm_pdmcritsect.h b/virtualbox-svn/patches/patch-include_VBox_vmm_pdmcritsect.h
new file mode 100644
index 0000000..d71b3de
--- /dev/null
+++ b/virtualbox-svn/patches/patch-include_VBox_vmm_pdmcritsect.h
@@ -0,0 +1,41 @@
+$NetBSD$
+
+--- include/VBox/vmm/pdmcritsect.h.orig	2016-03-04 19:22:58.000000000 +0000
++++ include/VBox/vmm/pdmcritsect.h
+@@ -51,14 +51,14 @@ typedef union PDMCRITSECT
+ #endif
+ } PDMCRITSECT;
+ 
+-VMMR3_INT_DECL(int)     PDMR3CritSectBothTerm(PVM pVM);
+-VMMR3_INT_DECL(void)    PDMR3CritSectLeaveAll(PVM pVM);
++VMMR3_INT_DECL(int)     PDMR3CritSectBothTerm(vbox_PVM pVM);
++VMMR3_INT_DECL(void)    PDMR3CritSectLeaveAll(vbox_PVM pVM);
+ VMM_INT_DECL(void)      PDMCritSectBothFF(PVMCPU pVCpu);
+ 
+ 
+-VMMR3DECL(uint32_t) PDMR3CritSectCountOwned(PVM pVM, char *pszNames, size_t cbNames);
++VMMR3DECL(uint32_t) PDMR3CritSectCountOwned(vbox_PVM pVM, char *pszNames, size_t cbNames);
+ 
+-VMMR3DECL(int)      PDMR3CritSectInit(PVM pVM, PPDMCRITSECT pCritSect, RT_SRC_POS_DECL,
++VMMR3DECL(int)      PDMR3CritSectInit(vbox_PVM pVM, PPDMCRITSECT pCritSect, RT_SRC_POS_DECL,
+                                       const char *pszNameFmt, ...) RT_IPRT_FORMAT_ATTR(6, 7);
+ VMMR3DECL(int)      PDMR3CritSectEnterEx(PPDMCRITSECT pCritSect, bool fCallRing3);
+ VMMR3DECL(bool)     PDMR3CritSectYield(PPDMCRITSECT pCritSect);
+@@ -80,9 +80,9 @@ VMMDECL(bool)       PDMCritSectIsInitial
+ VMMDECL(bool)       PDMCritSectHasWaiters(PCPDMCRITSECT pCritSect);
+ VMMDECL(uint32_t)   PDMCritSectGetRecursion(PCPDMCRITSECT pCritSect);
+ 
+-VMMR3DECL(PPDMCRITSECT)             PDMR3CritSectGetNop(PVM pVM);
+-VMMR3DECL(R0PTRTYPE(PPDMCRITSECT))  PDMR3CritSectGetNopR0(PVM pVM);
+-VMMR3DECL(RCPTRTYPE(PPDMCRITSECT))  PDMR3CritSectGetNopRC(PVM pVM);
++VMMR3DECL(PPDMCRITSECT)             PDMR3CritSectGetNop(vbox_PVM pVM);
++VMMR3DECL(R0PTRTYPE(PPDMCRITSECT))  PDMR3CritSectGetNopR0(vbox_PVM pVM);
++VMMR3DECL(RCPTRTYPE(PPDMCRITSECT))  PDMR3CritSectGetNopRC(vbox_PVM pVM);
+ 
+ /* Strict build: Remap the two enter calls to the debug versions. */
+ #ifdef VBOX_STRICT
+@@ -100,4 +100,3 @@ VMMR3DECL(RCPTRTYPE(PPDMCRITSECT))  PDMR
+ RT_C_DECLS_END
+ 
+ #endif
+-
diff --git a/virtualbox-svn/patches/patch-include_VBox_vmm_pdmcritsectrw.h b/virtualbox-svn/patches/patch-include_VBox_vmm_pdmcritsectrw.h
new file mode 100644
index 0000000..35b4206
--- /dev/null
+++ b/virtualbox-svn/patches/patch-include_VBox_vmm_pdmcritsectrw.h
@@ -0,0 +1,18 @@
+$NetBSD$
+
+--- include/VBox/vmm/pdmcritsectrw.h.orig	2016-03-04 19:22:59.000000000 +0000
++++ include/VBox/vmm/pdmcritsectrw.h
+@@ -50,7 +50,7 @@ typedef union PDMCRITSECTRW
+ #endif
+ } PDMCRITSECTRW;
+ 
+-VMMR3DECL(int)      PDMR3CritSectRwInit(PVM pVM, PPDMCRITSECTRW pCritSect, RT_SRC_POS_DECL,
++VMMR3DECL(int)      PDMR3CritSectRwInit(vbox_PVM pVM, PPDMCRITSECTRW pCritSect, RT_SRC_POS_DECL,
+                                         const char *pszNameFmt, ...) RT_IPRT_FORMAT_ATTR(6, 7);
+ VMMR3DECL(int)      PDMR3CritSectRwDelete(PPDMCRITSECTRW pCritSect);
+ VMMR3DECL(const char *) PDMR3CritSectRwName(PCPDMCRITSECTRW pCritSect);
+@@ -95,4 +95,3 @@ VMMDECL(bool)       PDMCritSectRwIsIniti
+ RT_C_DECLS_END
+ 
+ #endif
+-
diff --git a/virtualbox-svn/patches/patch-include_VBox_vmm_pdmdev.h b/virtualbox-svn/patches/patch-include_VBox_vmm_pdmdev.h
new file mode 100644
index 0000000..b60a6ec
--- /dev/null
+++ b/virtualbox-svn/patches/patch-include_VBox_vmm_pdmdev.h
@@ -0,0 +1,40 @@
+$NetBSD$
+
+--- include/VBox/vmm/pdmdev.h.orig	2016-03-04 19:22:59.000000000 +0000
++++ include/VBox/vmm/pdmdev.h
+@@ -3524,7 +3524,7 @@ typedef struct PDMDEVHLPR3
+      * @returns VM Handle.
+      * @param   pDevIns             The device instance.
+      */
+-    DECLR3CALLBACKMEMBER(PVM, pfnGetVM,(PPDMDEVINS pDevIns));
++    DECLR3CALLBACKMEMBER(vbox_PVM, pfnGetVM,(PPDMDEVINS pDevIns));
+ 
+     /**
+      * Gets the VMCPU handle. Restricted API.
+@@ -3847,7 +3847,7 @@ typedef struct PDMDEVHLPRC
+      * @returns VM Handle.
+      * @param   pDevIns         Device instance.
+      */
+-    DECLRCCALLBACKMEMBER(PVM, pfnGetVM,(PPDMDEVINS pDevIns));
++    DECLRCCALLBACKMEMBER(vbox_PVM, pfnGetVM,(PPDMDEVINS pDevIns));
+ 
+     /**
+      * Gets the VMCPU handle. Restricted API.
+@@ -4076,7 +4076,7 @@ typedef struct PDMDEVHLPR0
+      * @returns VM Handle.
+      * @param   pDevIns         Device instance.
+      */
+-    DECLR0CALLBACKMEMBER(PVM, pfnGetVM,(PPDMDEVINS pDevIns));
++    DECLR0CALLBACKMEMBER(vbox_PVM, pfnGetVM,(PPDMDEVINS pDevIns));
+ 
+     /**
+      * Checks if our current CPU state allows for IO block emulation fallback to the recompiler
+@@ -5218,7 +5218,7 @@ DECLINLINE(PUVM) PDMDevHlpGetUVM(PPDMDEV
+ /**
+  * @copydoc PDMDEVHLPR3::pfnGetVM
+  */
+-DECLINLINE(PVM) PDMDevHlpGetVM(PPDMDEVINS pDevIns)
++DECLINLINE(vbox_PVM) PDMDevHlpGetVM(PPDMDEVINS pDevIns)
+ {
+     return pDevIns->CTX_SUFF(pHlp)->pfnGetVM(pDevIns);
+ }
diff --git a/virtualbox-svn/patches/patch-include_VBox_vmm_pdmpci.h b/virtualbox-svn/patches/patch-include_VBox_vmm_pdmpci.h
new file mode 100644
index 0000000..aad7cb0
--- /dev/null
+++ b/virtualbox-svn/patches/patch-include_VBox_vmm_pdmpci.h
@@ -0,0 +1,28 @@
+$NetBSD$
+
+--- include/VBox/vmm/pdmpci.h.orig	2016-03-04 19:22:59.000000000 +0000
++++ include/VBox/vmm/pdmpci.h
+@@ -353,7 +353,7 @@ PCIRAWR0DECL(int)  PciRawR0Init(void);
+ /**
+  * Process request (in R0).
+  */
+-PCIRAWR0DECL(int)  PciRawR0ProcessReq(PSUPDRVSESSION pSession, PVM pVM, PPCIRAWSENDREQ pReq);
++PCIRAWR0DECL(int)  PciRawR0ProcessReq(PSUPDRVSESSION pSession, vbox_PVM pVM, PPCIRAWSENDREQ pReq);
+ /**
+  * Terminate R0 PCI module.
+  */
+@@ -362,12 +362,12 @@ PCIRAWR0DECL(void) PciRawR0Term(void);
+ /**
+  * Per-VM R0 module init.
+  */
+-PCIRAWR0DECL(int)  PciRawR0InitVM(PVM pVM);
++PCIRAWR0DECL(int)  PciRawR0InitVM(vbox_PVM pVM);
+ 
+ /**
+  * Per-VM R0 module termination routine.
+  */
+-PCIRAWR0DECL(void)  PciRawR0TermVM(PVM pVM);
++PCIRAWR0DECL(void)  PciRawR0TermVM(vbox_PVM pVM);
+ 
+ /**
+  * Flags returned by pfnPciDeviceConstructStart(), to notify device
diff --git a/virtualbox-svn/patches/patch-include_VBox_vmm_pdmqueue.h b/virtualbox-svn/patches/patch-include_VBox_vmm_pdmqueue.h
new file mode 100644
index 0000000..2c98ef4
--- /dev/null
+++ b/virtualbox-svn/patches/patch-include_VBox_vmm_pdmqueue.h
@@ -0,0 +1,44 @@
+$NetBSD$
+
+--- include/VBox/vmm/pdmqueue.h.orig	2016-03-04 19:22:59.000000000 +0000
++++ include/VBox/vmm/pdmqueue.h
+@@ -111,7 +111,7 @@ typedef FNPDMQUEUEDRV *PFNPDMQUEUEDRV;
+  * @remarks No locks will be held, but for now it's safe to assume that only one
+  *          EMT will do queue callbacks at any one time.
+  */
+-typedef DECLCALLBACK(bool) FNPDMQUEUEINT(PVM pVM, PPDMQUEUEITEMCORE pItem);
++typedef DECLCALLBACK(bool) FNPDMQUEUEINT(vbox_PVM pVM, PPDMQUEUEITEMCORE pItem);
+ /** Pointer to a FNPDMQUEUEINT(). */
+ typedef FNPDMQUEUEINT *PFNPDMQUEUEINT;
+ 
+@@ -130,18 +130,18 @@ typedef DECLCALLBACK(bool) FNPDMQUEUEEXT
+ typedef FNPDMQUEUEEXT *PFNPDMQUEUEEXT;
+ 
+ #ifdef VBOX_IN_VMM
+-VMMR3_INT_DECL(int)  PDMR3QueueCreateDevice(PVM pVM, PPDMDEVINS pDevIns, size_t cbItem, uint32_t cItems, uint32_t cMilliesInterval,
++VMMR3_INT_DECL(int)  PDMR3QueueCreateDevice(vbox_PVM pVM, PPDMDEVINS pDevIns, size_t cbItem, uint32_t cItems, uint32_t cMilliesInterval,
+                                             PFNPDMQUEUEDEV pfnCallback, bool fRZEnabled, const char *pszName, PPDMQUEUE *ppQueue);
+-VMMR3_INT_DECL(int)  PDMR3QueueCreateDriver(PVM pVM, PPDMDRVINS pDrvIns, size_t cbItem, uint32_t cItems, uint32_t cMilliesInterval,
++VMMR3_INT_DECL(int)  PDMR3QueueCreateDriver(vbox_PVM pVM, PPDMDRVINS pDrvIns, size_t cbItem, uint32_t cItems, uint32_t cMilliesInterval,
+                                             PFNPDMQUEUEDRV pfnCallback, const char *pszName, PPDMQUEUE *ppQueue);
+-VMMR3_INT_DECL(int)  PDMR3QueueCreateInternal(PVM pVM, size_t cbItem, uint32_t cItems, uint32_t cMilliesInterval,
++VMMR3_INT_DECL(int)  PDMR3QueueCreateInternal(vbox_PVM pVM, size_t cbItem, uint32_t cItems, uint32_t cMilliesInterval,
+                                               PFNPDMQUEUEINT pfnCallback, bool fGCEnabled, const char *pszName, PPDMQUEUE *ppQueue);
+-VMMR3_INT_DECL(int)  PDMR3QueueCreateExternal(PVM pVM, size_t cbItem, uint32_t cItems, uint32_t cMilliesInterval,
++VMMR3_INT_DECL(int)  PDMR3QueueCreateExternal(vbox_PVM pVM, size_t cbItem, uint32_t cItems, uint32_t cMilliesInterval,
+                                               PFNPDMQUEUEEXT pfnCallback, void *pvUser, const char *pszName, PPDMQUEUE *ppQueue);
+ VMMR3_INT_DECL(int)  PDMR3QueueDestroy(PPDMQUEUE pQueue);
+-VMMR3_INT_DECL(int)  PDMR3QueueDestroyDevice(PVM pVM, PPDMDEVINS pDevIns);
+-VMMR3_INT_DECL(int)  PDMR3QueueDestroyDriver(PVM pVM, PPDMDRVINS pDrvIns);
+-VMMR3_INT_DECL(void) PDMR3QueueFlushAll(PVM pVM);
++VMMR3_INT_DECL(int)  PDMR3QueueDestroyDevice(vbox_PVM pVM, PPDMDEVINS pDevIns);
++VMMR3_INT_DECL(int)  PDMR3QueueDestroyDriver(vbox_PVM pVM, PPDMDRVINS pDrvIns);
++VMMR3_INT_DECL(void) PDMR3QueueFlushAll(vbox_PVM pVM);
+ #endif /* VBOX_IN_VMM */
+ 
+ VMMDECL(PPDMQUEUEITEMCORE)    PDMQueueAlloc(PPDMQUEUE pQueue);
+@@ -156,4 +156,3 @@ VMMDECL(bool)                 PDMQueueFl
+ RT_C_DECLS_END
+ 
+ #endif
+-
diff --git a/virtualbox-svn/patches/patch-include_VBox_vmm_pdmthread.h b/virtualbox-svn/patches/patch-include_VBox_vmm_pdmthread.h
new file mode 100644
index 0000000..e4ccc72
--- /dev/null
+++ b/virtualbox-svn/patches/patch-include_VBox_vmm_pdmthread.h
@@ -0,0 +1,34 @@
+$NetBSD$
+
+--- include/VBox/vmm/pdmthread.h.orig	2016-03-04 19:22:59.000000000 +0000
++++ include/VBox/vmm/pdmthread.h
+@@ -123,7 +123,7 @@ typedef FNPDMTHREADDRV *PFNPDMTHREADDRV;
+  * @param   pVM         The cross context VM structure.
+  * @param   pThread     The PDM thread data.
+  */
+-typedef DECLCALLBACK(int) FNPDMTHREADINT(PVM pVM, PPDMTHREAD pThread);
++typedef DECLCALLBACK(int) FNPDMTHREADINT(vbox_PVM pVM, PPDMTHREAD pThread);
+ /** Pointer to a FNPDMTHREADINT(). */
+ typedef FNPDMTHREADINT *PFNPDMTHREADINT;
+ 
+@@ -179,7 +179,7 @@ typedef FNPDMTHREADWAKEUPDRV *PFNPDMTHRE
+  * @param   pVM         The cross context VM structure.
+  * @param   pThread     The PDM thread data.
+  */
+-typedef DECLCALLBACK(int) FNPDMTHREADWAKEUPINT(PVM pVM, PPDMTHREAD pThread);
++typedef DECLCALLBACK(int) FNPDMTHREADWAKEUPINT(vbox_PVM pVM, PPDMTHREAD pThread);
+ /** Pointer to a FNPDMTHREADWAKEUPINT(). */
+ typedef FNPDMTHREADWAKEUPINT *PFNPDMTHREADWAKEUPINT;
+ 
+@@ -279,9 +279,9 @@ typedef struct PDMTHREAD
+ #define PDMTHREAD_VERSION                       PDM_VERSION_MAKE(0xefff, 1, 0)
+ 
+ #ifdef IN_RING3
+-VMMR3DECL(int) PDMR3ThreadCreate(PVM pVM, PPPDMTHREAD ppThread, void *pvUser, PFNPDMTHREADINT pfnThread,
++VMMR3DECL(int) PDMR3ThreadCreate(vbox_PVM pVM, PPPDMTHREAD ppThread, void *pvUser, PFNPDMTHREADINT pfnThread,
+                                  PFNPDMTHREADWAKEUPINT pfnWakeUp, size_t cbStack, RTTHREADTYPE enmType, const char *pszName);
+-VMMR3DECL(int) PDMR3ThreadCreateExternal(PVM pVM, PPPDMTHREAD ppThread, void *pvUser, PFNPDMTHREADEXT pfnThread,
++VMMR3DECL(int) PDMR3ThreadCreateExternal(vbox_PVM pVM, PPPDMTHREAD ppThread, void *pvUser, PFNPDMTHREADEXT pfnThread,
+                                          PFNPDMTHREADWAKEUPEXT pfnWakeUp, size_t cbStack, RTTHREADTYPE enmType, const char *pszName);
+ VMMR3DECL(int) PDMR3ThreadDestroy(PPDMTHREAD pThread, int *pRcThread);
+ VMMR3DECL(int) PDMR3ThreadIAmSuspending(PPDMTHREAD pThread);
diff --git a/virtualbox-svn/patches/patch-include_VBox_vmm_pgm.h b/virtualbox-svn/patches/patch-include_VBox_vmm_pgm.h
new file mode 100644
index 0000000..1bef11f
--- /dev/null
+++ b/virtualbox-svn/patches/patch-include_VBox_vmm_pgm.h
@@ -0,0 +1,510 @@
+$NetBSD$
+
+--- include/VBox/vmm/pgm.h.orig	2016-03-04 19:22:59.000000000 +0000
++++ include/VBox/vmm/pgm.h
+@@ -72,7 +72,7 @@ typedef enum PGMRELOCATECALL
+  * @remark  The return value is no a failure indicator, it's an acceptance
+  *          indicator. Relocation can not fail!
+  */
+-typedef DECLCALLBACK(bool) FNPGMRELOCATE(PVM pVM, RTGCPTR GCPtrOld, RTGCPTR GCPtrNew, PGMRELOCATECALL enmMode, void *pvUser);
++typedef DECLCALLBACK(bool) FNPGMRELOCATE(vbox_PVM pVM, RTGCPTR GCPtrOld, RTGCPTR GCPtrNew, PGMRELOCATECALL enmMode, void *pvUser);
+ /** Pointer to a relocation callback function. */
+ typedef FNPGMRELOCATE *PFNPGMRELOCATE;
+ 
+@@ -178,7 +178,7 @@ typedef enum PGMACCESSTYPE
+  * @param   pvUser      User argument.
+  * @thread  EMT(pVCpu)
+  */
+-typedef DECLCALLBACK(VBOXSTRICTRC) FNPGMRZPHYSPFHANDLER(PVM pVM, PVMCPU pVCpu, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame,
++typedef DECLCALLBACK(VBOXSTRICTRC) FNPGMRZPHYSPFHANDLER(vbox_PVM pVM, PVMCPU pVCpu, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame,
+                                                         RTGCPTR pvFault, RTGCPHYS GCPhysFault, void *pvUser);
+ /** Pointer to PGM access callback. */
+ typedef FNPGMRZPHYSPFHANDLER *PFNPGMRZPHYSPFHANDLER;
+@@ -209,7 +209,7 @@ typedef FNPGMRZPHYSPFHANDLER *PFNPGMRZPH
+  * @param   pvUser          User argument.
+  * @thread  EMT(pVCpu)
+  */
+-typedef DECLCALLBACK(VBOXSTRICTRC) FNPGMPHYSHANDLER(PVM pVM, PVMCPU pVCpu, RTGCPHYS GCPhys, void *pvPhys, void *pvBuf, size_t cbBuf,
++typedef DECLCALLBACK(VBOXSTRICTRC) FNPGMPHYSHANDLER(vbox_PVM pVM, PVMCPU pVCpu, RTGCPHYS GCPhys, void *pvPhys, void *pvBuf, size_t cbBuf,
+                                                     PGMACCESSTYPE enmAccessType, PGMACCESSORIGIN enmOrigin, void *pvUser);
+ /** Pointer to PGM access callback. */
+ typedef FNPGMPHYSHANDLER *PFNPGMPHYSHANDLER;
+@@ -248,7 +248,7 @@ typedef enum PGMVIRTHANDLERKIND
+  * @param   pvUser          User argument.
+  * @thread  EMT(pVCpu)
+  */
+-typedef DECLCALLBACK(VBOXSTRICTRC) FNPGMRCVIRTPFHANDLER(PVM pVM, PVMCPU pVCpu, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame,
++typedef DECLCALLBACK(VBOXSTRICTRC) FNPGMRCVIRTPFHANDLER(vbox_PVM pVM, PVMCPU pVCpu, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame,
+                                                         RTGCPTR pvFault, RTGCPTR pvRange, uintptr_t offRange, void *pvUser);
+ /** Pointer to PGM access callback. */
+ typedef FNPGMRCVIRTPFHANDLER *PFNPGMRCVIRTPFHANDLER;
+@@ -274,7 +274,7 @@ typedef FNPGMRCVIRTPFHANDLER *PFNPGMRCVI
+  * @param   pvUser          User argument.
+  * @thread  EMT(pVCpu)
+  */
+-typedef DECLCALLBACK(VBOXSTRICTRC) FNPGMVIRTHANDLER(PVM pVM, PVMCPU pVCpu, RTGCPTR GCPtr, void *pvPtr, void *pvBuf, size_t cbBuf,
++typedef DECLCALLBACK(VBOXSTRICTRC) FNPGMVIRTHANDLER(vbox_PVM pVM, PVMCPU pVCpu, RTGCPTR GCPtr, void *pvPtr, void *pvBuf, size_t cbBuf,
+                                                     PGMACCESSTYPE enmAccessType, PGMACCESSORIGIN enmOrigin, void *pvUser);
+ /** Pointer to PGM access callback. */
+ typedef FNPGMVIRTHANDLER *PFNPGMVIRTHANDLER;
+@@ -292,7 +292,7 @@ typedef FNPGMVIRTHANDLER *PFNPGMVIRTHAND
+  *          in r13179 (1.1) and stopped working with r13806 (PGMPool merge,
+  *          v1.2), exactly a month later.
+  */
+-typedef DECLCALLBACK(int) FNPGMR3VIRTINVALIDATE(PVM pVM, PVMCPU pVCpu, RTGCPTR GCPtr, void *pvUser);
++typedef DECLCALLBACK(int) FNPGMR3VIRTINVALIDATE(vbox_PVM pVM, PVMCPU pVCpu, RTGCPTR GCPtr, void *pvUser);
+ /** Pointer to PGM invalidation callback. */
+ typedef FNPGMR3VIRTINVALIDATE *PFNPGMR3VIRTINVALIDATE;
+ 
+@@ -306,7 +306,7 @@ typedef FNPGMR3VIRTINVALIDATE *PFNPGMR3V
+  * @param   cbRange         Size of the dirty range in bytes.
+  * @param   pvUser          User argument.
+  */
+-typedef DECLCALLBACK(int) FNPGMENUMDIRTYFTPAGES(PVM pVM, RTGCPHYS GCPhys, uint8_t *pRange, unsigned cbRange, void *pvUser);
++typedef DECLCALLBACK(int) FNPGMENUMDIRTYFTPAGES(vbox_PVM pVM, RTGCPHYS GCPhys, uint8_t *pRange, unsigned cbRange, void *pvUser);
+ /** Pointer to PGMR3PhysEnumDirtyFTPages callback. */
+ typedef FNPGMENUMDIRTYFTPAGES *PFNPGMENUMDIRTYFTPAGES;
+ 
+@@ -364,31 +364,31 @@ typedef enum PGMMODE
+       || (enmProt) == PGMROMPROT_READ_ROM_WRITE_RAM )
+ 
+ 
+-VMMDECL(bool)           PGMIsLockOwner(PVM pVM);
++VMMDECL(bool)           PGMIsLockOwner(vbox_PVM pVM);
+ 
+ VMMDECL(int)            PGMRegisterStringFormatTypes(void);
+ VMMDECL(void)           PGMDeregisterStringFormatTypes(void);
+ VMMDECL(RTHCPHYS)       PGMGetHyperCR3(PVMCPU pVCpu);
+ VMMDECL(RTHCPHYS)       PGMGetNestedCR3(PVMCPU pVCpu, PGMMODE enmShadowMode);
+-VMMDECL(RTHCPHYS)       PGMGetInterHCCR3(PVM pVM);
+-VMMDECL(RTHCPHYS)       PGMGetInterRCCR3(PVM pVM, PVMCPU pVCpu);
+-VMMDECL(RTHCPHYS)       PGMGetInter32BitCR3(PVM pVM);
+-VMMDECL(RTHCPHYS)       PGMGetInterPaeCR3(PVM pVM);
+-VMMDECL(RTHCPHYS)       PGMGetInterAmd64CR3(PVM pVM);
++VMMDECL(RTHCPHYS)       PGMGetInterHCCR3(vbox_PVM pVM);
++VMMDECL(RTHCPHYS)       PGMGetInterRCCR3(vbox_PVM pVM, PVMCPU pVCpu);
++VMMDECL(RTHCPHYS)       PGMGetInter32BitCR3(vbox_PVM pVM);
++VMMDECL(RTHCPHYS)       PGMGetInterPaeCR3(vbox_PVM pVM);
++VMMDECL(RTHCPHYS)       PGMGetInterAmd64CR3(vbox_PVM pVM);
+ VMMDECL(int)            PGMTrap0eHandler(PVMCPU pVCpu, RTGCUINT uErr, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault);
+ VMMDECL(int)            PGMPrefetchPage(PVMCPU pVCpu, RTGCPTR GCPtrPage);
+ VMMDECL(int)            PGMVerifyAccess(PVMCPU pVCpu, RTGCPTR Addr, uint32_t cbSize, uint32_t fAccess);
+ VMMDECL(int)            PGMIsValidAccess(PVMCPU pVCpu, RTGCPTR Addr, uint32_t cbSize, uint32_t fAccess);
+-VMMDECL(VBOXSTRICTRC)   PGMInterpretInstruction(PVM pVM, PVMCPU pVCpu, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault);
+-VMMDECL(int)            PGMMap(PVM pVM, RTGCPTR GCPtr, RTHCPHYS HCPhys, uint32_t cbPages, unsigned fFlags);
+-VMMDECL(int)            PGMMapGetPage(PVM pVM, RTGCPTR GCPtr, uint64_t *pfFlags, PRTHCPHYS pHCPhys);
+-VMMDECL(int)            PGMMapSetPage(PVM pVM, RTGCPTR GCPtr, uint64_t cb, uint64_t fFlags);
+-VMMDECL(int)            PGMMapModifyPage(PVM pVM, RTGCPTR GCPtr, size_t cb, uint64_t fFlags, uint64_t fMask);
++VMMDECL(VBOXSTRICTRC)   PGMInterpretInstruction(vbox_PVM pVM, PVMCPU pVCpu, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault);
++VMMDECL(int)            PGMMap(vbox_PVM pVM, RTGCPTR GCPtr, RTHCPHYS HCPhys, uint32_t cbPages, unsigned fFlags);
++VMMDECL(int)            PGMMapGetPage(vbox_PVM pVM, RTGCPTR GCPtr, uint64_t *pfFlags, PRTHCPHYS pHCPhys);
++VMMDECL(int)            PGMMapSetPage(vbox_PVM pVM, RTGCPTR GCPtr, uint64_t cb, uint64_t fFlags);
++VMMDECL(int)            PGMMapModifyPage(vbox_PVM pVM, RTGCPTR GCPtr, size_t cb, uint64_t fFlags, uint64_t fMask);
+ #ifndef IN_RING0
+-VMMDECL(bool)           PGMMapHasConflicts(PVM pVM);
++VMMDECL(bool)           PGMMapHasConflicts(vbox_PVM pVM);
+ #endif
+ #ifdef VBOX_STRICT
+-VMMDECL(void)           PGMMapCheck(PVM pVM);
++VMMDECL(void)           PGMMapCheck(vbox_PVM pVM);
+ #endif
+ VMMDECL(int)            PGMShwGetPage(PVMCPU pVCpu, RTGCPTR GCPtr, uint64_t *pfFlags, PRTHCPHYS pHCPhys);
+ VMMDECL(int)            PGMShwMakePageReadonly(PVMCPU pVCpu, RTGCPTR GCPtr, uint32_t fFlags);
+@@ -418,10 +418,10 @@ VMMDECL(int)        PGMChangeMode(PVMCPU
+ VMMDECL(void)       PGMCr0WpEnabled(PVMCPU pVCpu);
+ VMMDECL(PGMMODE)    PGMGetGuestMode(PVMCPU pVCpu);
+ VMMDECL(PGMMODE)    PGMGetShadowMode(PVMCPU pVCpu);
+-VMMDECL(PGMMODE)    PGMGetHostMode(PVM pVM);
++VMMDECL(PGMMODE)    PGMGetHostMode(vbox_PVM pVM);
+ VMMDECL(const char *) PGMGetModeName(PGMMODE enmMode);
+ VMM_INT_DECL(void)  PGMNotifyNxeChanged(PVMCPU pVCpu, bool fNxe);
+-VMMDECL(bool)       PGMHasDirtyPages(PVM pVM);
++VMMDECL(bool)       PGMHasDirtyPages(vbox_PVM pVM);
+ 
+ /** PGM physical access handler type registration handle (heap offset, valid
+  * cross contexts without needing fixing up).  Callbacks and handler type is
+@@ -431,22 +431,22 @@ typedef uint32_t PGMPHYSHANDLERTYPE;
+ typedef PGMPHYSHANDLERTYPE *PPGMPHYSHANDLERTYPE;
+ /** NIL value for PGM physical access handler type handle. */
+ #define NIL_PGMPHYSHANDLERTYPE  UINT32_MAX
+-VMMDECL(uint32_t)   PGMHandlerPhysicalTypeRelease(PVM pVM, PGMPHYSHANDLERTYPE hType);
+-VMMDECL(uint32_t)   PGMHandlerPhysicalTypeRetain(PVM pVM, PGMPHYSHANDLERTYPE hType);
++VMMDECL(uint32_t)   PGMHandlerPhysicalTypeRelease(vbox_PVM pVM, PGMPHYSHANDLERTYPE hType);
++VMMDECL(uint32_t)   PGMHandlerPhysicalTypeRetain(vbox_PVM pVM, PGMPHYSHANDLERTYPE hType);
+ 
+-VMMDECL(int)        PGMHandlerPhysicalRegister(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS GCPhysLast, PGMPHYSHANDLERTYPE hType,
++VMMDECL(int)        PGMHandlerPhysicalRegister(vbox_PVM pVM, RTGCPHYS GCPhys, RTGCPHYS GCPhysLast, PGMPHYSHANDLERTYPE hType,
+                                                RTR3PTR pvUserR3, RTR0PTR pvUserR0, RTRCPTR pvUserRC,
+                                                R3PTRTYPE(const char *) pszDesc);
+-VMMDECL(int)        PGMHandlerPhysicalModify(PVM pVM, RTGCPHYS GCPhysCurrent, RTGCPHYS GCPhys, RTGCPHYS GCPhysLast);
+-VMMDECL(int)        PGMHandlerPhysicalDeregister(PVM pVM, RTGCPHYS GCPhys);
+-VMMDECL(int)        PGMHandlerPhysicalChangeUserArgs(PVM pVM, RTGCPHYS GCPhys, RTR3PTR pvUserR3, RTR0PTR pvUserR0, RTRCPTR pvUserRC);
+-VMMDECL(int)        PGMHandlerPhysicalSplit(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS GCPhysSplit);
+-VMMDECL(int)        PGMHandlerPhysicalJoin(PVM pVM, RTGCPHYS GCPhys1, RTGCPHYS GCPhys2);
+-VMMDECL(int)        PGMHandlerPhysicalPageTempOff(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS GCPhysPage);
+-VMMDECL(int)        PGMHandlerPhysicalPageAlias(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS GCPhysPage, RTGCPHYS GCPhysPageRemap);
+-VMMDECL(int)        PGMHandlerPhysicalPageAliasHC(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS GCPhysPage, RTHCPHYS HCPhysPageRemap);
+-VMMDECL(int)        PGMHandlerPhysicalReset(PVM pVM, RTGCPHYS GCPhys);
+-VMMDECL(bool)       PGMHandlerPhysicalIsRegistered(PVM pVM, RTGCPHYS GCPhys);
++VMMDECL(int)        PGMHandlerPhysicalModify(vbox_PVM pVM, RTGCPHYS GCPhysCurrent, RTGCPHYS GCPhys, RTGCPHYS GCPhysLast);
++VMMDECL(int)        PGMHandlerPhysicalDeregister(vbox_PVM pVM, RTGCPHYS GCPhys);
++VMMDECL(int)        PGMHandlerPhysicalChangeUserArgs(vbox_PVM pVM, RTGCPHYS GCPhys, RTR3PTR pvUserR3, RTR0PTR pvUserR0, RTRCPTR pvUserRC);
++VMMDECL(int)        PGMHandlerPhysicalSplit(vbox_PVM pVM, RTGCPHYS GCPhys, RTGCPHYS GCPhysSplit);
++VMMDECL(int)        PGMHandlerPhysicalJoin(vbox_PVM pVM, RTGCPHYS GCPhys1, RTGCPHYS GCPhys2);
++VMMDECL(int)        PGMHandlerPhysicalPageTempOff(vbox_PVM pVM, RTGCPHYS GCPhys, RTGCPHYS GCPhysPage);
++VMMDECL(int)        PGMHandlerPhysicalPageAlias(vbox_PVM pVM, RTGCPHYS GCPhys, RTGCPHYS GCPhysPage, RTGCPHYS GCPhysPageRemap);
++VMMDECL(int)        PGMHandlerPhysicalPageAliasHC(vbox_PVM pVM, RTGCPHYS GCPhys, RTGCPHYS GCPhysPage, RTHCPHYS HCPhysPageRemap);
++VMMDECL(int)        PGMHandlerPhysicalReset(vbox_PVM pVM, RTGCPHYS GCPhys);
++VMMDECL(bool)       PGMHandlerPhysicalIsRegistered(vbox_PVM pVM, RTGCPHYS GCPhys);
+ 
+ /** PGM virtual access handler type registration handle (heap offset, valid
+  * cross contexts without needing fixing up).  Callbacks and handler type is
+@@ -457,9 +457,9 @@ typedef PGMVIRTHANDLERTYPE *PPGMVIRTHAND
+ /** NIL value for PGM virtual access handler type handle. */
+ #define NIL_PGMVIRTHANDLERTYPE  UINT32_MAX
+ #ifdef VBOX_WITH_RAW_MODE
+-VMM_INT_DECL(uint32_t) PGMHandlerVirtualTypeRelease(PVM pVM, PGMVIRTHANDLERTYPE hType);
+-VMM_INT_DECL(uint32_t) PGMHandlerVirtualTypeRetain(PVM pVM, PGMVIRTHANDLERTYPE hType);
+-VMM_INT_DECL(bool)     PGMHandlerVirtualIsRegistered(PVM pVM, RTGCPTR GCPtr);
++VMM_INT_DECL(uint32_t) PGMHandlerVirtualTypeRelease(vbox_PVM pVM, PGMVIRTHANDLERTYPE hType);
++VMM_INT_DECL(uint32_t) PGMHandlerVirtualTypeRetain(vbox_PVM pVM, PGMVIRTHANDLERTYPE hType);
++VMM_INT_DECL(bool)     PGMHandlerVirtualIsRegistered(vbox_PVM pVM, RTGCPTR GCPtr);
+ #endif
+ 
+ 
+@@ -498,20 +498,20 @@ typedef enum PGMPAGETYPE
+ } PGMPAGETYPE;
+ AssertCompile(PGMPAGETYPE_END == 8);
+ 
+-VMM_INT_DECL(PGMPAGETYPE) PGMPhysGetPageType(PVM pVM, RTGCPHYS GCPhys);
++VMM_INT_DECL(PGMPAGETYPE) PGMPhysGetPageType(vbox_PVM pVM, RTGCPHYS GCPhys);
+ 
+-VMM_INT_DECL(int)   PGMPhysGCPhys2HCPhys(PVM pVM, RTGCPHYS GCPhys, PRTHCPHYS pHCPhys);
++VMM_INT_DECL(int)   PGMPhysGCPhys2HCPhys(vbox_PVM pVM, RTGCPHYS GCPhys, PRTHCPHYS pHCPhys);
+ VMM_INT_DECL(int)   PGMPhysGCPtr2HCPhys(PVMCPU pVCpu, RTGCPTR GCPtr, PRTHCPHYS pHCPhys);
+-VMM_INT_DECL(int)   PGMPhysGCPhys2CCPtr(PVM pVM, RTGCPHYS GCPhys, void **ppv, PPGMPAGEMAPLOCK pLock);
+-VMM_INT_DECL(int)   PGMPhysGCPhys2CCPtrReadOnly(PVM pVM, RTGCPHYS GCPhys, void const **ppv, PPGMPAGEMAPLOCK pLock);
++VMM_INT_DECL(int)   PGMPhysGCPhys2CCPtr(vbox_PVM pVM, RTGCPHYS GCPhys, void **ppv, PPGMPAGEMAPLOCK pLock);
++VMM_INT_DECL(int)   PGMPhysGCPhys2CCPtrReadOnly(vbox_PVM pVM, RTGCPHYS GCPhys, void const **ppv, PPGMPAGEMAPLOCK pLock);
+ VMM_INT_DECL(int)   PGMPhysGCPtr2CCPtr(PVMCPU pVCpu, RTGCPTR GCPtr, void **ppv, PPGMPAGEMAPLOCK pLock);
+ VMM_INT_DECL(int)   PGMPhysGCPtr2CCPtrReadOnly(PVMCPU pVCpu, RTGCPTR GCPtr, void const **ppv, PPGMPAGEMAPLOCK pLock);
+ 
+ VMMDECL(bool)       PGMPhysIsA20Enabled(PVMCPU pVCpu);
+-VMMDECL(bool)       PGMPhysIsGCPhysValid(PVM pVM, RTGCPHYS GCPhys);
+-VMMDECL(bool)       PGMPhysIsGCPhysNormal(PVM pVM, RTGCPHYS GCPhys);
++VMMDECL(bool)       PGMPhysIsGCPhysValid(vbox_PVM pVM, RTGCPHYS GCPhys);
++VMMDECL(bool)       PGMPhysIsGCPhysNormal(vbox_PVM pVM, RTGCPHYS GCPhys);
+ VMMDECL(int)        PGMPhysGCPtr2GCPhys(PVMCPU pVCpu, RTGCPTR GCPtr, PRTGCPHYS pGCPhys);
+-VMMDECL(void)       PGMPhysReleasePageMappingLock(PVM pVM, PPGMPAGEMAPLOCK pLock);
++VMMDECL(void)       PGMPhysReleasePageMappingLock(vbox_PVM pVM, PPGMPAGEMAPLOCK pLock);
+ 
+ /** @def PGM_PHYS_RW_IS_SUCCESS
+  * Check whether a PGMPhysRead, PGMPhysWrite, PGMPhysReadGCPtr or
+@@ -595,26 +595,26 @@ VMMDECL(void)       PGMPhysReleasePageMa
+     } while (0)
+ #endif
+ 
+-VMMDECL(VBOXSTRICTRC) PGMPhysRead(PVM pVM, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead, PGMACCESSORIGIN enmOrigin);
+-VMMDECL(VBOXSTRICTRC) PGMPhysWrite(PVM pVM, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite, PGMACCESSORIGIN enmOrigin);
++VMMDECL(VBOXSTRICTRC) PGMPhysRead(vbox_PVM pVM, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead, PGMACCESSORIGIN enmOrigin);
++VMMDECL(VBOXSTRICTRC) PGMPhysWrite(vbox_PVM pVM, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite, PGMACCESSORIGIN enmOrigin);
+ VMMDECL(VBOXSTRICTRC) PGMPhysReadGCPtr(PVMCPU pVCpu, void *pvDst, RTGCPTR GCPtrSrc, size_t cb, PGMACCESSORIGIN enmOrigin);
+ VMMDECL(VBOXSTRICTRC) PGMPhysWriteGCPtr(PVMCPU pVCpu, RTGCPTR GCPtrDst, const void *pvSrc, size_t cb, PGMACCESSORIGIN enmOrigin);
+ 
+-VMMDECL(int)        PGMPhysSimpleReadGCPhys(PVM pVM, void *pvDst, RTGCPHYS GCPhysSrc, size_t cb);
+-VMMDECL(int)        PGMPhysSimpleWriteGCPhys(PVM pVM, RTGCPHYS GCPhysDst, const void *pvSrc, size_t cb);
++VMMDECL(int)        PGMPhysSimpleReadGCPhys(vbox_PVM pVM, void *pvDst, RTGCPHYS GCPhysSrc, size_t cb);
++VMMDECL(int)        PGMPhysSimpleWriteGCPhys(vbox_PVM pVM, RTGCPHYS GCPhysDst, const void *pvSrc, size_t cb);
+ VMMDECL(int)        PGMPhysSimpleReadGCPtr(PVMCPU pVCpu, void *pvDst, RTGCPTR GCPtrSrc, size_t cb);
+ VMMDECL(int)        PGMPhysSimpleWriteGCPtr(PVMCPU pVCpu, RTGCPTR GCPtrDst, const void *pvSrc, size_t cb);
+ VMMDECL(int)        PGMPhysSimpleDirtyWriteGCPtr(PVMCPU pVCpu, RTGCPTR GCPtrDst, const void *pvSrc, size_t cb);
+ VMMDECL(int)        PGMPhysInterpretedRead(PVMCPU pVCpu, PCPUMCTXCORE pCtxCore, void *pvDst, RTGCPTR GCPtrSrc, size_t cb);
+ VMMDECL(int)        PGMPhysInterpretedReadNoHandlers(PVMCPU pVCpu, PCPUMCTXCORE pCtxCore, void *pvDst, RTGCUINTPTR GCPtrSrc, size_t cb, bool fRaiseTrap);
+ VMMDECL(int)        PGMPhysInterpretedWriteNoHandlers(PVMCPU pVCpu, PCPUMCTXCORE pCtxCore, RTGCPTR GCPtrDst, void const *pvSrc, size_t cb, bool fRaiseTrap);
+-VMM_INT_DECL(int)   PGMPhysIemGCPhys2Ptr(PVM pVM, PVMCPU pVCpu, RTGCPHYS GCPhys, bool fWritable, bool fByPassHandlers, void **ppv, PPGMPAGEMAPLOCK pLock);
+-VMM_INT_DECL(int)   PGMPhysIemQueryAccess(PVM pVM, RTGCPHYS GCPhys, bool fWritable, bool fByPassHandlers);
++VMM_INT_DECL(int)   PGMPhysIemGCPhys2Ptr(vbox_PVM pVM, PVMCPU pVCpu, RTGCPHYS GCPhys, bool fWritable, bool fByPassHandlers, void **ppv, PPGMPAGEMAPLOCK pLock);
++VMM_INT_DECL(int)   PGMPhysIemQueryAccess(vbox_PVM pVM, RTGCPHYS GCPhys, bool fWritable, bool fByPassHandlers);
+ 
+ #ifdef VBOX_STRICT
+-VMMDECL(unsigned)   PGMAssertHandlerAndFlagsInSync(PVM pVM);
+-VMMDECL(unsigned)   PGMAssertNoMappingConflicts(PVM pVM);
+-VMMDECL(unsigned)   PGMAssertCR3(PVM pVM, PVMCPU pVCpu, uint64_t cr3, uint64_t cr4);
++VMMDECL(unsigned)   PGMAssertHandlerAndFlagsInSync(vbox_PVM pVM);
++VMMDECL(unsigned)   PGMAssertNoMappingConflicts(vbox_PVM pVM);
++VMMDECL(unsigned)   PGMAssertCR3(vbox_PVM pVM, PVMCPU pVCpu, uint64_t cr3, uint64_t cr4);
+ #endif /* VBOX_STRICT */
+ 
+ #if defined(IN_RC) || defined(VBOX_WITH_2X_4GB_ADDR_SPACE)
+@@ -625,7 +625,7 @@ VMMDECL(uint32_t)   PGMRZDynMapPushAutoS
+ VMMDECL(void)       PGMRZDynMapPopAutoSubset(PVMCPU pVCpu, uint32_t iPrevSubset);
+ #endif
+ 
+-VMMDECL(int)        PGMSetLargePageUsage(PVM pVM, bool fUseLargePages);
++VMMDECL(int)        PGMSetLargePageUsage(vbox_PVM pVM, bool fUseLargePages);
+ 
+ /**
+  * Query large page usage state
+@@ -640,7 +640,7 @@ VMMDECL(int)        PGMSetLargePageUsage
+ /** @defgroup grp_pgm_gc  The PGM Guest Context API
+  * @{
+  */
+-VMMRCDECL(int)      PGMRCDynMapInit(PVM pVM);
++VMMRCDECL(int)      PGMRCDynMapInit(vbox_PVM pVM);
+ /** @} */
+ #endif /* IN_RC */
+ 
+@@ -649,18 +649,18 @@ VMMRCDECL(int)      PGMRCDynMapInit(PVM 
+ /** @defgroup grp_pgm_r0  The PGM Host Context Ring-0 API
+  * @{
+  */
+-VMMR0_INT_DECL(int) PGMR0PhysAllocateHandyPages(PVM pVM, PVMCPU pVCpu);
+-VMMR0_INT_DECL(int) PGMR0PhysFlushHandyPages(PVM pVM, PVMCPU pVCpu);
+-VMMR0_INT_DECL(int) PGMR0PhysAllocateLargeHandyPage(PVM pVM, PVMCPU pVCpu);
+-VMMR0_INT_DECL(int) PGMR0PhysSetupIommu(PVM pVM);
+-VMMR0DECL(int)      PGMR0SharedModuleCheck(PVM pVM, PGVM pGVM, VMCPUID idCpu, PGMMSHAREDMODULE pModule, PCRTGCPTR64 paRegionsGCPtrs);
+-VMMR0DECL(int)      PGMR0Trap0eHandlerNestedPaging(PVM pVM, PVMCPU pVCpu, PGMMODE enmShwPagingMode, RTGCUINT uErr, PCPUMCTXCORE pRegFrame, RTGCPHYS pvFault);
+-VMMR0DECL(VBOXSTRICTRC) PGMR0Trap0eHandlerNPMisconfig(PVM pVM, PVMCPU pVCpu, PGMMODE enmShwPagingMode, PCPUMCTXCORE pRegFrame, RTGCPHYS GCPhysFault, uint32_t uErr);
++VMMR0_INT_DECL(int) PGMR0PhysAllocateHandyPages(vbox_PVM pVM, PVMCPU pVCpu);
++VMMR0_INT_DECL(int) PGMR0PhysFlushHandyPages(vbox_PVM pVM, PVMCPU pVCpu);
++VMMR0_INT_DECL(int) PGMR0PhysAllocateLargeHandyPage(vbox_PVM pVM, PVMCPU pVCpu);
++VMMR0_INT_DECL(int) PGMR0PhysSetupIommu(vbox_PVM pVM);
++VMMR0DECL(int)      PGMR0SharedModuleCheck(vbox_PVM pVM, PGVM pGVM, VMCPUID idCpu, PGMMSHAREDMODULE pModule, PCRTGCPTR64 paRegionsGCPtrs);
++VMMR0DECL(int)      PGMR0Trap0eHandlerNestedPaging(vbox_PVM pVM, PVMCPU pVCpu, PGMMODE enmShwPagingMode, RTGCUINT uErr, PCPUMCTXCORE pRegFrame, RTGCPHYS pvFault);
++VMMR0DECL(VBOXSTRICTRC) PGMR0Trap0eHandlerNPMisconfig(vbox_PVM pVM, PVMCPU pVCpu, PGMMODE enmShwPagingMode, PCPUMCTXCORE pRegFrame, RTGCPHYS GCPhysFault, uint32_t uErr);
+ # ifdef VBOX_WITH_2X_4GB_ADDR_SPACE
+ VMMR0DECL(int)      PGMR0DynMapInit(void);
+ VMMR0DECL(void)     PGMR0DynMapTerm(void);
+-VMMR0DECL(int)      PGMR0DynMapInitVM(PVM pVM);
+-VMMR0DECL(void)     PGMR0DynMapTermVM(PVM pVM);
++VMMR0DECL(int)      PGMR0DynMapInitVM(vbox_PVM pVM);
++VMMR0DECL(void)     PGMR0DynMapTermVM(vbox_PVM pVM);
+ VMMR0DECL(int)      PGMR0DynMapAssertIntegrity(void);
+ VMMR0DECL(bool)     PGMR0DynMapStartOrMigrateAutoSet(PVMCPU pVCpu);
+ VMMR0DECL(void)     PGMR0DynMapMigrateAutoSet(PVMCPU pVCpu);
+@@ -674,39 +674,39 @@ VMMR0DECL(void)     PGMR0DynMapMigrateAu
+ /** @defgroup grp_pgm_r3  The PGM Host Context Ring-3 API
+  * @{
+  */
+-VMMR3DECL(int)      PGMR3Init(PVM pVM);
+-VMMR3DECL(int)      PGMR3InitDynMap(PVM pVM);
+-VMMR3DECL(int)      PGMR3InitFinalize(PVM pVM);
+-VMMR3_INT_DECL(int) PGMR3InitCompleted(PVM pVM, VMINITCOMPLETED enmWhat);
+-VMMR3DECL(void)     PGMR3Relocate(PVM pVM, RTGCINTPTR offDelta);
+-VMMR3DECL(void)     PGMR3ResetCpu(PVM pVM, PVMCPU pVCpu);
+-VMMR3_INT_DECL(void)    PGMR3Reset(PVM pVM);
+-VMMR3_INT_DECL(void)    PGMR3ResetNoMorePhysWritesFlag(PVM pVM);
+-VMMR3_INT_DECL(void)    PGMR3MemSetup(PVM pVM, bool fReset);
+-VMMR3DECL(int)      PGMR3Term(PVM pVM);
+-VMMR3DECL(int)      PGMR3LockCall(PVM pVM);
+-VMMR3DECL(int)      PGMR3ChangeMode(PVM pVM, PVMCPU pVCpu, PGMMODE enmGuestMode);
+-
+-VMMR3DECL(int)      PGMR3PhysRegisterRam(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb, const char *pszDesc);
+-VMMR3DECL(int)      PGMR3PhysChangeMemBalloon(PVM pVM, bool fInflate, unsigned cPages, RTGCPHYS *paPhysPage);
+-VMMR3DECL(int)      PGMR3PhysWriteProtectRAM(PVM pVM);
+-VMMR3DECL(int)      PGMR3PhysEnumDirtyFTPages(PVM pVM, PFNPGMENUMDIRTYFTPAGES pfnEnum, void *pvUser);
+-VMMR3DECL(uint32_t) PGMR3PhysGetRamRangeCount(PVM pVM);
+-VMMR3DECL(int)      PGMR3PhysGetRange(PVM pVM, uint32_t iRange, PRTGCPHYS pGCPhysStart, PRTGCPHYS pGCPhysLast,
++VMMR3DECL(int)      PGMR3Init(vbox_PVM pVM);
++VMMR3DECL(int)      PGMR3InitDynMap(vbox_PVM pVM);
++VMMR3DECL(int)      PGMR3InitFinalize(vbox_PVM pVM);
++VMMR3_INT_DECL(int) PGMR3InitCompleted(vbox_PVM pVM, VMINITCOMPLETED enmWhat);
++VMMR3DECL(void)     PGMR3Relocate(vbox_PVM pVM, RTGCINTPTR offDelta);
++VMMR3DECL(void)     PGMR3ResetCpu(vbox_PVM pVM, PVMCPU pVCpu);
++VMMR3_INT_DECL(void)    PGMR3Reset(vbox_PVM pVM);
++VMMR3_INT_DECL(void)    PGMR3ResetNoMorePhysWritesFlag(vbox_PVM pVM);
++VMMR3_INT_DECL(void)    PGMR3MemSetup(vbox_PVM pVM, bool fReset);
++VMMR3DECL(int)      PGMR3Term(vbox_PVM pVM);
++VMMR3DECL(int)      PGMR3LockCall(vbox_PVM pVM);
++VMMR3DECL(int)      PGMR3ChangeMode(vbox_PVM pVM, PVMCPU pVCpu, PGMMODE enmGuestMode);
++
++VMMR3DECL(int)      PGMR3PhysRegisterRam(vbox_PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb, const char *pszDesc);
++VMMR3DECL(int)      PGMR3PhysChangeMemBalloon(vbox_PVM pVM, bool fInflate, unsigned cPages, RTGCPHYS *paPhysPage);
++VMMR3DECL(int)      PGMR3PhysWriteProtectRAM(vbox_PVM pVM);
++VMMR3DECL(int)      PGMR3PhysEnumDirtyFTPages(vbox_PVM pVM, PFNPGMENUMDIRTYFTPAGES pfnEnum, void *pvUser);
++VMMR3DECL(uint32_t) PGMR3PhysGetRamRangeCount(vbox_PVM pVM);
++VMMR3DECL(int)      PGMR3PhysGetRange(vbox_PVM pVM, uint32_t iRange, PRTGCPHYS pGCPhysStart, PRTGCPHYS pGCPhysLast,
+                                       const char **ppszDesc, bool *pfIsMmio);
+ VMMR3DECL(int)      PGMR3QueryMemoryStats(PUVM pUVM, uint64_t *pcbTotalMem, uint64_t *pcbPrivateMem, uint64_t *pcbSharedMem, uint64_t *pcbZeroMem);
+ VMMR3DECL(int)      PGMR3QueryGlobalMemoryStats(PUVM pUVM, uint64_t *pcbAllocMem, uint64_t *pcbFreeMem, uint64_t *pcbBallonedMem, uint64_t *pcbSharedMem);
+ 
+-VMMR3DECL(int)      PGMR3PhysMMIORegister(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb, PGMPHYSHANDLERTYPE hType,
++VMMR3DECL(int)      PGMR3PhysMMIORegister(vbox_PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb, PGMPHYSHANDLERTYPE hType,
+                                           RTR3PTR pvUserR3, RTR0PTR pvUserR0, RTRCPTR pvUserRC, const char *pszDesc);
+-VMMR3DECL(int)      PGMR3PhysMMIODeregister(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb);
+-VMMR3DECL(int)      PGMR3PhysMMIO2Register(PVM pVM, PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS cb, uint32_t fFlags, void **ppv, const char *pszDesc);
+-VMMR3DECL(int)      PGMR3PhysMMIO2Deregister(PVM pVM, PPDMDEVINS pDevIns, uint32_t iRegion);
+-VMMR3DECL(int)      PGMR3PhysMMIO2Map(PVM pVM, PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS GCPhys);
+-VMMR3DECL(int)      PGMR3PhysMMIO2Unmap(PVM pVM, PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS GCPhys);
+-VMMR3DECL(bool)     PGMR3PhysMMIO2IsBase(PVM pVM, PPDMDEVINS pDevIns, RTGCPHYS GCPhys);
+-VMMR3DECL(int)      PGMR3PhysMMIO2GetHCPhys(PVM pVM, PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS off, PRTHCPHYS pHCPhys);
+-VMMR3DECL(int)      PGMR3PhysMMIO2MapKernel(PVM pVM, PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS off, RTGCPHYS cb, const char *pszDesc, PRTR0PTR pR0Ptr);
++VMMR3DECL(int)      PGMR3PhysMMIODeregister(vbox_PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb);
++VMMR3DECL(int)      PGMR3PhysMMIO2Register(vbox_PVM pVM, PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS cb, uint32_t fFlags, void **ppv, const char *pszDesc);
++VMMR3DECL(int)      PGMR3PhysMMIO2Deregister(vbox_PVM pVM, PPDMDEVINS pDevIns, uint32_t iRegion);
++VMMR3DECL(int)      PGMR3PhysMMIO2Map(vbox_PVM pVM, PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS GCPhys);
++VMMR3DECL(int)      PGMR3PhysMMIO2Unmap(vbox_PVM pVM, PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS GCPhys);
++VMMR3DECL(bool)     PGMR3PhysMMIO2IsBase(vbox_PVM pVM, PPDMDEVINS pDevIns, RTGCPHYS GCPhys);
++VMMR3DECL(int)      PGMR3PhysMMIO2GetHCPhys(vbox_PVM pVM, PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS off, PRTHCPHYS pHCPhys);
++VMMR3DECL(int)      PGMR3PhysMMIO2MapKernel(vbox_PVM pVM, PPDMDEVINS pDevIns, uint32_t iRegion, RTGCPHYS off, RTGCPHYS cb, const char *pszDesc, PRTR0PTR pR0Ptr);
+ 
+ /** @name PGMR3PhysRegisterRom flags.
+  * @{ */
+@@ -717,102 +717,102 @@ VMMR3DECL(int)      PGMR3PhysMMIO2MapKer
+ #define PGMPHYS_ROM_FLAGS_PERMANENT_BINARY  RT_BIT_32(1)
+ /** @} */
+ 
+-VMMR3DECL(int)      PGMR3PhysRomRegister(PVM pVM, PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTGCPHYS cb,
++VMMR3DECL(int)      PGMR3PhysRomRegister(vbox_PVM pVM, PPDMDEVINS pDevIns, RTGCPHYS GCPhys, RTGCPHYS cb,
+                                          const void *pvBinary, uint32_t cbBinary, uint32_t fFlags, const char *pszDesc);
+-VMMR3DECL(int)      PGMR3PhysRomProtect(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb, PGMROMPROT enmProt);
+-VMMR3DECL(int)      PGMR3PhysRegister(PVM pVM, void *pvRam, RTGCPHYS GCPhys, size_t cb, unsigned fFlags, const SUPPAGE *paPages, const char *pszDesc);
++VMMR3DECL(int)      PGMR3PhysRomProtect(vbox_PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb, PGMROMPROT enmProt);
++VMMR3DECL(int)      PGMR3PhysRegister(vbox_PVM pVM, void *pvRam, RTGCPHYS GCPhys, size_t cb, unsigned fFlags, const SUPPAGE *paPages, const char *pszDesc);
+ VMMDECL(void)       PGMR3PhysSetA20(PVMCPU pVCpu, bool fEnable);
+ /** @name PGMR3MapPT flags.
+  * @{ */
+ /** The mapping may be unmapped later. The default is permanent mappings. */
+ #define PGMR3MAPPT_FLAGS_UNMAPPABLE     RT_BIT(0)
+ /** @} */
+-VMMR3DECL(int)      PGMR3MapPT(PVM pVM, RTGCPTR GCPtr, uint32_t cb, uint32_t fFlags, PFNPGMRELOCATE pfnRelocate, void *pvUser, const char *pszDesc);
+-VMMR3DECL(int)      PGMR3UnmapPT(PVM pVM, RTGCPTR GCPtr);
+-VMMR3DECL(int)      PGMR3FinalizeMappings(PVM pVM);
+-VMMR3DECL(int)      PGMR3MappingsSize(PVM pVM, uint32_t *pcb);
+-VMMR3DECL(int)      PGMR3MappingsFix(PVM pVM, RTGCPTR GCPtrBase, uint32_t cb);
+-VMMR3DECL(int)      PGMR3MappingsUnfix(PVM pVM);
+-VMMR3DECL(bool)     PGMR3MappingsNeedReFixing(PVM pVM);
++VMMR3DECL(int)      PGMR3MapPT(vbox_PVM pVM, RTGCPTR GCPtr, uint32_t cb, uint32_t fFlags, PFNPGMRELOCATE pfnRelocate, void *pvUser, const char *pszDesc);
++VMMR3DECL(int)      PGMR3UnmapPT(vbox_PVM pVM, RTGCPTR GCPtr);
++VMMR3DECL(int)      PGMR3FinalizeMappings(vbox_PVM pVM);
++VMMR3DECL(int)      PGMR3MappingsSize(vbox_PVM pVM, uint32_t *pcb);
++VMMR3DECL(int)      PGMR3MappingsFix(vbox_PVM pVM, RTGCPTR GCPtrBase, uint32_t cb);
++VMMR3DECL(int)      PGMR3MappingsUnfix(vbox_PVM pVM);
++VMMR3DECL(bool)     PGMR3MappingsNeedReFixing(vbox_PVM pVM);
+ #if defined(VBOX_WITH_RAW_MODE) || HC_ARCH_BITS == 32 /* (latter for 64-bit guests on 32-bit hosts) */
+-VMMR3DECL(int)      PGMR3MapIntermediate(PVM pVM, RTUINTPTR Addr, RTHCPHYS HCPhys, unsigned cbPages);
++VMMR3DECL(int)      PGMR3MapIntermediate(vbox_PVM pVM, RTUINTPTR Addr, RTHCPHYS HCPhys, unsigned cbPages);
+ #endif
+-VMMR3DECL(int)      PGMR3MapRead(PVM pVM, void *pvDst, RTGCPTR GCPtrSrc, size_t cb);
++VMMR3DECL(int)      PGMR3MapRead(vbox_PVM pVM, void *pvDst, RTGCPTR GCPtrSrc, size_t cb);
+ 
+-VMMR3_INT_DECL(int) PGMR3HandlerPhysicalTypeRegisterEx(PVM pVM, PGMPHYSHANDLERKIND enmKind,
++VMMR3_INT_DECL(int) PGMR3HandlerPhysicalTypeRegisterEx(vbox_PVM pVM, PGMPHYSHANDLERKIND enmKind,
+                                                        PFNPGMPHYSHANDLER pfnHandlerR3,
+                                                        R0PTRTYPE(PFNPGMPHYSHANDLER)     pfnHandlerR0,
+                                                        R0PTRTYPE(PFNPGMRZPHYSPFHANDLER) pfnPfHandlerR0,
+                                                        RCPTRTYPE(PFNPGMPHYSHANDLER)     pfnHandlerRC,
+                                                        RCPTRTYPE(PFNPGMRZPHYSPFHANDLER) pfnPfHandlerRC,
+                                                        const char *pszDesc, PPGMPHYSHANDLERTYPE phType);
+-VMMR3DECL(int)      PGMR3HandlerPhysicalTypeRegister(PVM pVM, PGMPHYSHANDLERKIND enmKind,
++VMMR3DECL(int)      PGMR3HandlerPhysicalTypeRegister(vbox_PVM pVM, PGMPHYSHANDLERKIND enmKind,
+                                                      R3PTRTYPE(PFNPGMPHYSHANDLER) pfnHandlerR3,
+                                                      const char *pszModR0, const char *pszHandlerR0, const char *pszPfHandlerR0,
+                                                      const char *pszModRC, const char *pszHandlerRC, const char *pszPfHandlerRC,
+                                                      const char *pszDesc,
+                                                      PPGMPHYSHANDLERTYPE phType);
+ #ifdef VBOX_WITH_RAW_MODE
+-VMMR3_INT_DECL(int) PGMR3HandlerVirtualTypeRegisterEx(PVM pVM, PGMVIRTHANDLERKIND enmKind, bool fRelocUserRC,
++VMMR3_INT_DECL(int) PGMR3HandlerVirtualTypeRegisterEx(vbox_PVM pVM, PGMVIRTHANDLERKIND enmKind, bool fRelocUserRC,
+                                                       PFNPGMR3VIRTINVALIDATE pfnInvalidateR3,
+                                                       PFNPGMVIRTHANDLER pfnHandlerR3,
+                                                       RCPTRTYPE(FNPGMVIRTHANDLER) pfnHandlerRC,
+                                                       RCPTRTYPE(FNPGMRCVIRTPFHANDLER) pfnPfHandlerRC,
+                                                       const char *pszDesc, PPGMVIRTHANDLERTYPE phType);
+-VMMR3_INT_DECL(int) PGMR3HandlerVirtualTypeRegister(PVM pVM, PGMVIRTHANDLERKIND enmKind, bool fRelocUserRC,
++VMMR3_INT_DECL(int) PGMR3HandlerVirtualTypeRegister(vbox_PVM pVM, PGMVIRTHANDLERKIND enmKind, bool fRelocUserRC,
+                                                     PFNPGMR3VIRTINVALIDATE pfnInvalidateR3,
+                                                     PFNPGMVIRTHANDLER pfnHandlerR3,
+                                                     const char *pszHandlerRC, const char *pszPfHandlerRC, const char *pszDesc,
+                                                     PPGMVIRTHANDLERTYPE phType);
+-VMMR3_INT_DECL(int) PGMR3HandlerVirtualRegister(PVM pVM, PVMCPU pVCpu, PGMVIRTHANDLERTYPE hType, RTGCPTR GCPtr,
++VMMR3_INT_DECL(int) PGMR3HandlerVirtualRegister(vbox_PVM pVM, PVMCPU pVCpu, PGMVIRTHANDLERTYPE hType, RTGCPTR GCPtr,
+                                                 RTGCPTR GCPtrLast, void *pvUserR3, RTRCPTR pvUserRC, const char *pszDesc);
+-VMMR3_INT_DECL(int) PGMHandlerVirtualChangeType(PVM pVM, RTGCPTR GCPtr, PGMVIRTHANDLERTYPE hNewType);
+-VMMR3_INT_DECL(int) PGMHandlerVirtualDeregister(PVM pVM, PVMCPU pVCpu, RTGCPTR GCPtr, bool fHypervisor);
++VMMR3_INT_DECL(int) PGMHandlerVirtualChangeType(vbox_PVM pVM, RTGCPTR GCPtr, PGMVIRTHANDLERTYPE hNewType);
++VMMR3_INT_DECL(int) PGMHandlerVirtualDeregister(vbox_PVM pVM, PVMCPU pVCpu, RTGCPTR GCPtr, bool fHypervisor);
+ #endif
+-VMMR3DECL(int)      PGMR3PoolGrow(PVM pVM);
++VMMR3DECL(int)      PGMR3PoolGrow(vbox_PVM pVM);
+ 
+-VMMR3DECL(int)      PGMR3PhysTlbGCPhys2Ptr(PVM pVM, RTGCPHYS GCPhys, bool fWritable, void **ppv);
+-VMMR3DECL(uint8_t)  PGMR3PhysReadU8(PVM pVM, RTGCPHYS GCPhys, PGMACCESSORIGIN enmOrigin);
+-VMMR3DECL(uint16_t) PGMR3PhysReadU16(PVM pVM, RTGCPHYS GCPhys, PGMACCESSORIGIN enmOrigin);
+-VMMR3DECL(uint32_t) PGMR3PhysReadU32(PVM pVM, RTGCPHYS GCPhys, PGMACCESSORIGIN enmOrigin);
+-VMMR3DECL(uint64_t) PGMR3PhysReadU64(PVM pVM, RTGCPHYS GCPhys, PGMACCESSORIGIN enmOrigin);
+-VMMR3DECL(void)     PGMR3PhysWriteU8(PVM pVM, RTGCPHYS GCPhys, uint8_t Value, PGMACCESSORIGIN enmOrigin);
+-VMMR3DECL(void)     PGMR3PhysWriteU16(PVM pVM, RTGCPHYS GCPhys, uint16_t Value, PGMACCESSORIGIN enmOrigin);
+-VMMR3DECL(void)     PGMR3PhysWriteU32(PVM pVM, RTGCPHYS GCPhys, uint32_t Value, PGMACCESSORIGIN enmOrigin);
+-VMMR3DECL(void)     PGMR3PhysWriteU64(PVM pVM, RTGCPHYS GCPhys, uint64_t Value, PGMACCESSORIGIN enmOrigin);
+-VMMR3DECL(int)      PGMR3PhysReadExternal(PVM pVM, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead, PGMACCESSORIGIN enmOrigin);
+-VMMR3DECL(int)      PGMR3PhysWriteExternal(PVM pVM, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite, PGMACCESSORIGIN enmOrigin);
+-VMMR3DECL(int)      PGMR3PhysGCPhys2CCPtrExternal(PVM pVM, RTGCPHYS GCPhys, void **ppv, PPGMPAGEMAPLOCK pLock);
+-VMMR3DECL(int)      PGMR3PhysGCPhys2CCPtrReadOnlyExternal(PVM pVM, RTGCPHYS GCPhys, void const **ppv, PPGMPAGEMAPLOCK pLock);
+-VMMR3DECL(int)      PGMR3PhysChunkMap(PVM pVM, uint32_t idChunk);
+-VMMR3DECL(void)     PGMR3PhysChunkInvalidateTLB(PVM pVM);
+-VMMR3DECL(int)      PGMR3PhysAllocateHandyPages(PVM pVM);
+-VMMR3DECL(int)      PGMR3PhysAllocateLargeHandyPage(PVM pVM, RTGCPHYS GCPhys);
++VMMR3DECL(int)      PGMR3PhysTlbGCPhys2Ptr(vbox_PVM pVM, RTGCPHYS GCPhys, bool fWritable, void **ppv);
++VMMR3DECL(uint8_t)  PGMR3PhysReadU8(vbox_PVM pVM, RTGCPHYS GCPhys, PGMACCESSORIGIN enmOrigin);
++VMMR3DECL(uint16_t) PGMR3PhysReadU16(vbox_PVM pVM, RTGCPHYS GCPhys, PGMACCESSORIGIN enmOrigin);
++VMMR3DECL(uint32_t) PGMR3PhysReadU32(vbox_PVM pVM, RTGCPHYS GCPhys, PGMACCESSORIGIN enmOrigin);
++VMMR3DECL(uint64_t) PGMR3PhysReadU64(vbox_PVM pVM, RTGCPHYS GCPhys, PGMACCESSORIGIN enmOrigin);
++VMMR3DECL(void)     PGMR3PhysWriteU8(vbox_PVM pVM, RTGCPHYS GCPhys, uint8_t Value, PGMACCESSORIGIN enmOrigin);
++VMMR3DECL(void)     PGMR3PhysWriteU16(vbox_PVM pVM, RTGCPHYS GCPhys, uint16_t Value, PGMACCESSORIGIN enmOrigin);
++VMMR3DECL(void)     PGMR3PhysWriteU32(vbox_PVM pVM, RTGCPHYS GCPhys, uint32_t Value, PGMACCESSORIGIN enmOrigin);
++VMMR3DECL(void)     PGMR3PhysWriteU64(vbox_PVM pVM, RTGCPHYS GCPhys, uint64_t Value, PGMACCESSORIGIN enmOrigin);
++VMMR3DECL(int)      PGMR3PhysReadExternal(vbox_PVM pVM, RTGCPHYS GCPhys, void *pvBuf, size_t cbRead, PGMACCESSORIGIN enmOrigin);
++VMMR3DECL(int)      PGMR3PhysWriteExternal(vbox_PVM pVM, RTGCPHYS GCPhys, const void *pvBuf, size_t cbWrite, PGMACCESSORIGIN enmOrigin);
++VMMR3DECL(int)      PGMR3PhysGCPhys2CCPtrExternal(vbox_PVM pVM, RTGCPHYS GCPhys, void **ppv, PPGMPAGEMAPLOCK pLock);
++VMMR3DECL(int)      PGMR3PhysGCPhys2CCPtrReadOnlyExternal(vbox_PVM pVM, RTGCPHYS GCPhys, void const **ppv, PPGMPAGEMAPLOCK pLock);
++VMMR3DECL(int)      PGMR3PhysChunkMap(vbox_PVM pVM, uint32_t idChunk);
++VMMR3DECL(void)     PGMR3PhysChunkInvalidateTLB(vbox_PVM pVM);
++VMMR3DECL(int)      PGMR3PhysAllocateHandyPages(vbox_PVM pVM);
++VMMR3DECL(int)      PGMR3PhysAllocateLargeHandyPage(vbox_PVM pVM, RTGCPHYS GCPhys);
+ 
+-VMMR3DECL(int)      PGMR3CheckIntegrity(PVM pVM);
++VMMR3DECL(int)      PGMR3CheckIntegrity(vbox_PVM pVM);
+ 
+ VMMR3DECL(int)      PGMR3DbgR3Ptr2GCPhys(PUVM pUVM, RTR3PTR R3Ptr, PRTGCPHYS pGCPhys);
+ VMMR3DECL(int)      PGMR3DbgR3Ptr2HCPhys(PUVM pUVM, RTR3PTR R3Ptr, PRTHCPHYS pHCPhys);
+ VMMR3DECL(int)      PGMR3DbgHCPhys2GCPhys(PUVM pUVM, RTHCPHYS HCPhys, PRTGCPHYS pGCPhys);
+-VMMR3_INT_DECL(int) PGMR3DbgReadGCPhys(PVM pVM, void *pvDst, RTGCPHYS GCPhysSrc, size_t cb, uint32_t fFlags, size_t *pcbRead);
+-VMMR3_INT_DECL(int) PGMR3DbgWriteGCPhys(PVM pVM, RTGCPHYS GCPhysDst, const void *pvSrc, size_t cb, uint32_t fFlags, size_t *pcbWritten);
+-VMMR3_INT_DECL(int) PGMR3DbgReadGCPtr(PVM pVM, void *pvDst, RTGCPTR GCPtrSrc, size_t cb, uint32_t fFlags, size_t *pcbRead);
+-VMMR3_INT_DECL(int) PGMR3DbgWriteGCPtr(PVM pVM, RTGCPTR GCPtrDst, void const *pvSrc, size_t cb, uint32_t fFlags, size_t *pcbWritten);
+-VMMR3_INT_DECL(int) PGMR3DbgScanPhysical(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cbRange, RTGCPHYS GCPhysAlign, const uint8_t *pabNeedle, size_t cbNeedle, PRTGCPHYS pGCPhysHit);
+-VMMR3_INT_DECL(int) PGMR3DbgScanVirtual(PVM pVM, PVMCPU pVCpu, RTGCPTR GCPtr, RTGCPTR cbRange, RTGCPTR GCPtrAlign, const uint8_t *pabNeedle, size_t cbNeedle, PRTGCUINTPTR pGCPhysHit);
+-VMMR3_INT_DECL(int) PGMR3DumpHierarchyShw(PVM pVM, uint64_t cr3, uint32_t fFlags, uint64_t u64FirstAddr, uint64_t u64LastAddr, uint32_t cMaxDepth, PCDBGFINFOHLP pHlp);
+-VMMR3_INT_DECL(int) PGMR3DumpHierarchyGst(PVM pVM, uint64_t cr3, uint32_t fFlags, RTGCPTR FirstAddr, RTGCPTR LastAddr, uint32_t cMaxDepth, PCDBGFINFOHLP pHlp);
++VMMR3_INT_DECL(int) PGMR3DbgReadGCPhys(vbox_PVM pVM, void *pvDst, RTGCPHYS GCPhysSrc, size_t cb, uint32_t fFlags, size_t *pcbRead);
++VMMR3_INT_DECL(int) PGMR3DbgWriteGCPhys(vbox_PVM pVM, RTGCPHYS GCPhysDst, const void *pvSrc, size_t cb, uint32_t fFlags, size_t *pcbWritten);
++VMMR3_INT_DECL(int) PGMR3DbgReadGCPtr(vbox_PVM pVM, void *pvDst, RTGCPTR GCPtrSrc, size_t cb, uint32_t fFlags, size_t *pcbRead);
++VMMR3_INT_DECL(int) PGMR3DbgWriteGCPtr(vbox_PVM pVM, RTGCPTR GCPtrDst, void const *pvSrc, size_t cb, uint32_t fFlags, size_t *pcbWritten);
++VMMR3_INT_DECL(int) PGMR3DbgScanPhysical(vbox_PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cbRange, RTGCPHYS GCPhysAlign, const uint8_t *pabNeedle, size_t cbNeedle, PRTGCPHYS pGCPhysHit);
++VMMR3_INT_DECL(int) PGMR3DbgScanVirtual(vbox_PVM pVM, PVMCPU pVCpu, RTGCPTR GCPtr, RTGCPTR cbRange, RTGCPTR GCPtrAlign, const uint8_t *pabNeedle, size_t cbNeedle, PRTGCUINTPTR pGCPhysHit);
++VMMR3_INT_DECL(int) PGMR3DumpHierarchyShw(vbox_PVM pVM, uint64_t cr3, uint32_t fFlags, uint64_t u64FirstAddr, uint64_t u64LastAddr, uint32_t cMaxDepth, PCDBGFINFOHLP pHlp);
++VMMR3_INT_DECL(int) PGMR3DumpHierarchyGst(vbox_PVM pVM, uint64_t cr3, uint32_t fFlags, RTGCPTR FirstAddr, RTGCPTR LastAddr, uint32_t cMaxDepth, PCDBGFINFOHLP pHlp);
+ 
+ 
+ /** @name Page sharing
+  * @{ */
+-VMMR3DECL(int)     PGMR3SharedModuleRegister(PVM pVM, VBOXOSFAMILY enmGuestOS, char *pszModuleName, char *pszVersion,
++VMMR3DECL(int)     PGMR3SharedModuleRegister(vbox_PVM pVM, VBOXOSFAMILY enmGuestOS, char *pszModuleName, char *pszVersion,
+                                              RTGCPTR GCBaseAddr, uint32_t cbModule,
+                                              uint32_t cRegions, VMMDEVSHAREDREGIONDESC const *paRegions);
+-VMMR3DECL(int)     PGMR3SharedModuleUnregister(PVM pVM, char *pszModuleName, char *pszVersion,
++VMMR3DECL(int)     PGMR3SharedModuleUnregister(vbox_PVM pVM, char *pszModuleName, char *pszVersion,
+                                                RTGCPTR GCBaseAddr, uint32_t cbModule);
+-VMMR3DECL(int)     PGMR3SharedModuleCheckAll(PVM pVM);
+-VMMR3DECL(int)     PGMR3SharedModuleGetPageState(PVM pVM, RTGCPTR GCPtrPage, bool *pfShared, uint64_t *pfPageFlags);
++VMMR3DECL(int)     PGMR3SharedModuleCheckAll(vbox_PVM pVM);
++VMMR3DECL(int)     PGMR3SharedModuleGetPageState(vbox_PVM pVM, RTGCPTR GCPtrPage, bool *pfShared, uint64_t *pfPageFlags);
+ /** @} */
+ 
+ /** @} */
+@@ -822,4 +822,3 @@ RT_C_DECLS_END
+ 
+ /** @} */
+ #endif
+-
diff --git a/virtualbox-svn/patches/patch-include_VBox_vmm_ssm.h b/virtualbox-svn/patches/patch-include_VBox_vmm_ssm.h
new file mode 100644
index 0000000..1065683
--- /dev/null
+++ b/virtualbox-svn/patches/patch-include_VBox_vmm_ssm.h
@@ -0,0 +1,152 @@
+$NetBSD$
+
+--- include/VBox/vmm/ssm.h.orig	2016-03-04 19:22:59.000000000 +0000
++++ include/VBox/vmm/ssm.h
+@@ -818,7 +818,7 @@ typedef FNSSMDRVLOADDONE *PFNSSMDRVLOADD
+  * @param   pSSM            SSM operation handle.
+  * @thread  Any.
+  */
+-typedef DECLCALLBACK(int) FNSSMINTLIVEPREP(PVM pVM, PSSMHANDLE pSSM);
++typedef DECLCALLBACK(int) FNSSMINTLIVEPREP(vbox_PVM pVM, PSSMHANDLE pSSM);
+ /** Pointer to a FNSSMINTLIVEPREP() function. */
+ typedef FNSSMINTLIVEPREP *PFNSSMINTLIVEPREP;
+ 
+@@ -834,7 +834,7 @@ typedef FNSSMINTLIVEPREP *PFNSSMINTLIVEP
+  * @param   uPass           The data pass.
+  * @thread  Any.
+  */
+-typedef DECLCALLBACK(int) FNSSMINTLIVEEXEC(PVM pVM, PSSMHANDLE pSSM, uint32_t uPass);
++typedef DECLCALLBACK(int) FNSSMINTLIVEEXEC(vbox_PVM pVM, PSSMHANDLE pSSM, uint32_t uPass);
+ /** Pointer to a FNSSMINTLIVEEXEC() function. */
+ typedef FNSSMINTLIVEEXEC *PFNSSMINTLIVEEXEC;
+ 
+@@ -856,7 +856,7 @@ typedef FNSSMINTLIVEEXEC *PFNSSMINTLIVEE
+  * @param   uPass           The data pass.
+  * @thread  Any.
+  */
+-typedef DECLCALLBACK(int) FNSSMINTLIVEVOTE(PVM pVM, PSSMHANDLE pSSM, uint32_t uPass);
++typedef DECLCALLBACK(int) FNSSMINTLIVEVOTE(vbox_PVM pVM, PSSMHANDLE pSSM, uint32_t uPass);
+ /** Pointer to a FNSSMINTLIVEVOTE() function. */
+ typedef FNSSMINTLIVEVOTE *PFNSSMINTLIVEVOTE;
+ 
+@@ -867,7 +867,7 @@ typedef FNSSMINTLIVEVOTE *PFNSSMINTLIVEV
+  * @param   pVM             The cross context VM structure.
+  * @param   pSSM            SSM operation handle.
+  */
+-typedef DECLCALLBACK(int) FNSSMINTSAVEPREP(PVM pVM, PSSMHANDLE pSSM);
++typedef DECLCALLBACK(int) FNSSMINTSAVEPREP(vbox_PVM pVM, PSSMHANDLE pSSM);
+ /** Pointer to a FNSSMINTSAVEPREP() function. */
+ typedef FNSSMINTSAVEPREP *PFNSSMINTSAVEPREP;
+ 
+@@ -878,7 +878,7 @@ typedef FNSSMINTSAVEPREP *PFNSSMINTSAVEP
+  * @param   pVM             The cross context VM structure.
+  * @param   pSSM            SSM operation handle.
+  */
+-typedef DECLCALLBACK(int) FNSSMINTSAVEEXEC(PVM pVM, PSSMHANDLE pSSM);
++typedef DECLCALLBACK(int) FNSSMINTSAVEEXEC(vbox_PVM pVM, PSSMHANDLE pSSM);
+ /** Pointer to a FNSSMINTSAVEEXEC() function. */
+ typedef FNSSMINTSAVEEXEC *PFNSSMINTSAVEEXEC;
+ 
+@@ -889,7 +889,7 @@ typedef FNSSMINTSAVEEXEC *PFNSSMINTSAVEE
+  * @param   pVM             The cross context VM structure.
+  * @param   pSSM            SSM operation handle.
+  */
+-typedef DECLCALLBACK(int) FNSSMINTSAVEDONE(PVM pVM, PSSMHANDLE pSSM);
++typedef DECLCALLBACK(int) FNSSMINTSAVEDONE(vbox_PVM pVM, PSSMHANDLE pSSM);
+ /** Pointer to a FNSSMINTSAVEDONE() function. */
+ typedef FNSSMINTSAVEDONE *PFNSSMINTSAVEDONE;
+ 
+@@ -900,7 +900,7 @@ typedef FNSSMINTSAVEDONE *PFNSSMINTSAVED
+  * @param   pVM             The cross context VM structure.
+  * @param   pSSM            SSM operation handle.
+  */
+-typedef DECLCALLBACK(int) FNSSMINTLOADPREP(PVM pVM, PSSMHANDLE pSSM);
++typedef DECLCALLBACK(int) FNSSMINTLOADPREP(vbox_PVM pVM, PSSMHANDLE pSSM);
+ /** Pointer to a FNSSMINTLOADPREP() function. */
+ typedef FNSSMINTLOADPREP *PFNSSMINTLOADPREP;
+ 
+@@ -914,7 +914,7 @@ typedef FNSSMINTLOADPREP *PFNSSMINTLOADP
+  * @param   uPass           The pass. This is always SSM_PASS_FINAL for units
+  *                          that doesn't specify a pfnSaveLive callback.
+  */
+-typedef DECLCALLBACK(int) FNSSMINTLOADEXEC(PVM pVM, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass);
++typedef DECLCALLBACK(int) FNSSMINTLOADEXEC(vbox_PVM pVM, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass);
+ /** Pointer to a FNSSMINTLOADEXEC() function. */
+ typedef FNSSMINTLOADEXEC *PFNSSMINTLOADEXEC;
+ 
+@@ -925,7 +925,7 @@ typedef FNSSMINTLOADEXEC *PFNSSMINTLOADE
+  * @param   pVM             The cross context VM structure.
+  * @param   pSSM            SSM operation handle.
+  */
+-typedef DECLCALLBACK(int) FNSSMINTLOADDONE(PVM pVM, PSSMHANDLE pSSM);
++typedef DECLCALLBACK(int) FNSSMINTLOADDONE(vbox_PVM pVM, PSSMHANDLE pSSM);
+ /** Pointer to a FNSSMINTLOADDONE() function. */
+ typedef FNSSMINTLOADDONE *PFNSSMINTLOADDONE;
+ 
+@@ -1155,25 +1155,25 @@ typedef struct SSMSTRMOPS
+ #define SSMSTRMOPS_VERSION      UINT32_C(0x55aa0001)
+ 
+ 
+-VMMR3_INT_DECL(void)    SSMR3Term(PVM pVM);
++VMMR3_INT_DECL(void)    SSMR3Term(vbox_PVM pVM);
+ VMMR3_INT_DECL(int)
+-SSMR3RegisterDevice(PVM pVM, PPDMDEVINS pDevIns, const char *pszName, uint32_t uInstance, uint32_t uVersion,
++SSMR3RegisterDevice(vbox_PVM pVM, PPDMDEVINS pDevIns, const char *pszName, uint32_t uInstance, uint32_t uVersion,
+                     size_t cbGuess, const char *pszBefore,
+                     PFNSSMDEVLIVEPREP pfnLivePrep, PFNSSMDEVLIVEEXEC pfnLiveExec, PFNSSMDEVLIVEVOTE pfnLiveVote,
+                     PFNSSMDEVSAVEPREP pfnSavePrep, PFNSSMDEVSAVEEXEC pfnSaveExec, PFNSSMDEVSAVEDONE pfnSaveDone,
+                     PFNSSMDEVLOADPREP pfnLoadPrep, PFNSSMDEVLOADEXEC pfnLoadExec, PFNSSMDEVLOADDONE pfnLoadDone);
+ VMMR3_INT_DECL(int)
+-SSMR3RegisterDriver(PVM pVM, PPDMDRVINS pDrvIns, const char *pszName, uint32_t uInstance, uint32_t uVersion, size_t cbGuess,
++SSMR3RegisterDriver(vbox_PVM pVM, PPDMDRVINS pDrvIns, const char *pszName, uint32_t uInstance, uint32_t uVersion, size_t cbGuess,
+                     PFNSSMDRVLIVEPREP pfnLivePrep, PFNSSMDRVLIVEEXEC pfnLiveExec, PFNSSMDRVLIVEVOTE pfnLiveVote,
+                     PFNSSMDRVSAVEPREP pfnSavePrep, PFNSSMDRVSAVEEXEC pfnSaveExec, PFNSSMDRVSAVEDONE pfnSaveDone,
+                     PFNSSMDRVLOADPREP pfnLoadPrep, PFNSSMDRVLOADEXEC pfnLoadExec, PFNSSMDRVLOADDONE pfnLoadDone);
+ VMMR3_INT_DECL(int)
+-SSMR3RegisterUsb(PVM pVM, PPDMUSBINS pUsbIns, const char *pszName, uint32_t uInstance, uint32_t uVersion, size_t cbGuess,
++SSMR3RegisterUsb(vbox_PVM pVM, PPDMUSBINS pUsbIns, const char *pszName, uint32_t uInstance, uint32_t uVersion, size_t cbGuess,
+                  PFNSSMUSBLIVEPREP pfnLivePrep, PFNSSMUSBLIVEEXEC pfnLiveExec, PFNSSMUSBLIVEVOTE pfnLiveVote,
+                  PFNSSMUSBSAVEPREP pfnSavePrep, PFNSSMUSBSAVEEXEC pfnSaveExec, PFNSSMUSBSAVEDONE pfnSaveDone,
+                  PFNSSMUSBLOADPREP pfnLoadPrep, PFNSSMUSBLOADEXEC pfnLoadExec, PFNSSMUSBLOADDONE pfnLoadDone);
+ VMMR3DECL(int)
+-SSMR3RegisterInternal(PVM pVM, const char *pszName, uint32_t uInstance, uint32_t uVersion, size_t cbGuess,
++SSMR3RegisterInternal(vbox_PVM pVM, const char *pszName, uint32_t uInstance, uint32_t uVersion, size_t cbGuess,
+                       PFNSSMINTLIVEPREP pfnLivePrep, PFNSSMINTLIVEEXEC pfnLiveExec, PFNSSMINTLIVEVOTE pfnLiveVote,
+                       PFNSSMINTSAVEPREP pfnSavePrep, PFNSSMINTSAVEEXEC pfnSaveExec, PFNSSMINTSAVEDONE pfnSaveDone,
+                       PFNSSMINTLOADPREP pfnLoadPrep, PFNSSMINTLOADEXEC pfnLoadExec, PFNSSMINTLOADDONE pfnLoadDone);
+@@ -1182,21 +1182,21 @@ SSMR3RegisterExternal(PUVM pUVM, const c
+                       PFNSSMEXTLIVEPREP pfnLivePrep, PFNSSMEXTLIVEEXEC pfnLiveExec, PFNSSMEXTLIVEVOTE pfnLiveVote,
+                       PFNSSMEXTSAVEPREP pfnSavePrep, PFNSSMEXTSAVEEXEC pfnSaveExec, PFNSSMEXTSAVEDONE pfnSaveDone,
+                       PFNSSMEXTLOADPREP pfnLoadPrep, PFNSSMEXTLOADEXEC pfnLoadExec, PFNSSMEXTLOADDONE pfnLoadDone, void *pvUser);
+-VMMR3DECL(int)          SSMR3RegisterStub(PVM pVM, const char *pszName, uint32_t uInstance);
+-VMMR3_INT_DECL(int)     SSMR3DeregisterDevice(PVM pVM, PPDMDEVINS pDevIns, const char *pszName, uint32_t uInstance);
+-VMMR3_INT_DECL(int)     SSMR3DeregisterDriver(PVM pVM, PPDMDRVINS pDrvIns, const char *pszName, uint32_t uInstance);
+-VMMR3_INT_DECL(int)     SSMR3DeregisterUsb(PVM pVM, PPDMUSBINS pUsbIns, const char *pszName, uint32_t uInstance);
+-VMMR3DECL(int)          SSMR3DeregisterInternal(PVM pVM, const char *pszName);
+-VMMR3DECL(int)          SSMR3DeregisterExternal(PVM pVM, const char *pszName);
+-VMMR3DECL(int)          SSMR3Save(PVM pVM, const char *pszFilename, PCSSMSTRMOPS pStreamOps, void *pvStreamOpsUser, SSMAFTER enmAfter, PFNVMPROGRESS pfnProgress, void *pvUser);
+-VMMR3_INT_DECL(int)     SSMR3LiveSave(PVM pVM, uint32_t cMsMaxDowntime,
++VMMR3DECL(int)          SSMR3RegisterStub(vbox_PVM pVM, const char *pszName, uint32_t uInstance);
++VMMR3_INT_DECL(int)     SSMR3DeregisterDevice(vbox_PVM pVM, PPDMDEVINS pDevIns, const char *pszName, uint32_t uInstance);
++VMMR3_INT_DECL(int)     SSMR3DeregisterDriver(vbox_PVM pVM, PPDMDRVINS pDrvIns, const char *pszName, uint32_t uInstance);
++VMMR3_INT_DECL(int)     SSMR3DeregisterUsb(vbox_PVM pVM, PPDMUSBINS pUsbIns, const char *pszName, uint32_t uInstance);
++VMMR3DECL(int)          SSMR3DeregisterInternal(vbox_PVM pVM, const char *pszName);
++VMMR3DECL(int)          SSMR3DeregisterExternal(vbox_PVM pVM, const char *pszName);
++VMMR3DECL(int)          SSMR3Save(vbox_PVM pVM, const char *pszFilename, PCSSMSTRMOPS pStreamOps, void *pvStreamOpsUser, SSMAFTER enmAfter, PFNVMPROGRESS pfnProgress, void *pvUser);
++VMMR3_INT_DECL(int)     SSMR3LiveSave(vbox_PVM pVM, uint32_t cMsMaxDowntime,
+                                       const char *pszFilename, PCSSMSTRMOPS pStreamOps, void *pvStreamOps,
+                                       SSMAFTER enmAfter, PFNVMPROGRESS pfnProgress, void *pvProgressUser,
+                                       PSSMHANDLE *ppSSM);
+ VMMR3_INT_DECL(int)     SSMR3LiveDoStep1(PSSMHANDLE pSSM);
+ VMMR3_INT_DECL(int)     SSMR3LiveDoStep2(PSSMHANDLE pSSM);
+ VMMR3_INT_DECL(int)     SSMR3LiveDone(PSSMHANDLE pSSM);
+-VMMR3DECL(int)          SSMR3Load(PVM pVM, const char *pszFilename, PCSSMSTRMOPS pStreamOps, void *pvStreamOpsUser,
++VMMR3DECL(int)          SSMR3Load(vbox_PVM pVM, const char *pszFilename, PCSSMSTRMOPS pStreamOps, void *pvStreamOpsUser,
+                                   SSMAFTER enmAfter, PFNVMPROGRESS pfnProgress, void *pvProgressUser);
+ VMMR3DECL(int)          SSMR3ValidateFile(const char *pszFilename, bool fChecksumIt);
+ VMMR3DECL(int)          SSMR3Open(const char *pszFilename, unsigned fFlags, PSSMHANDLE *ppSSM);
+@@ -1299,4 +1299,3 @@ VMMR3DECL(int) SSMR3SetCfgError(PSSMHAND
+ RT_C_DECLS_END
+ 
+ #endif
+-
diff --git a/virtualbox-svn/patches/patch-include_VBox_vmm_stam.h b/virtualbox-svn/patches/patch-include_VBox_vmm_stam.h
new file mode 100644
index 0000000..57612dc
--- /dev/null
+++ b/virtualbox-svn/patches/patch-include_VBox_vmm_stam.h
@@ -0,0 +1,59 @@
+$NetBSD$
+
+--- include/VBox/vmm/stam.h.orig	2016-03-04 19:22:59.000000000 +0000
++++ include/VBox/vmm/stam.h
+@@ -1106,7 +1106,7 @@ VMMR3DECL(int)  STAMR3InitUVM(PUVM pUVM)
+ VMMR3DECL(void) STAMR3TermUVM(PUVM pUVM);
+ VMMR3DECL(int)  STAMR3RegisterU(PUVM pUVM, void *pvSample, STAMTYPE enmType, STAMVISIBILITY enmVisibility,
+                                 const char *pszName, STAMUNIT enmUnit, const char *pszDesc);
+-VMMR3DECL(int)  STAMR3Register(PVM pVM, void *pvSample, STAMTYPE enmType, STAMVISIBILITY enmVisibility,
++VMMR3DECL(int)  STAMR3Register(vbox_PVM pVM, void *pvSample, STAMTYPE enmType, STAMVISIBILITY enmVisibility,
+                                const char *pszName, STAMUNIT enmUnit, const char *pszDesc);
+ 
+ /** @def STAM_REL_REG
+@@ -1167,11 +1167,11 @@ VMMR3DECL(int)  STAMR3Register(PVM pVM, 
+ 
+ VMMR3DECL(int)  STAMR3RegisterFU(PUVM pUVM, void *pvSample, STAMTYPE enmType, STAMVISIBILITY enmVisibility, STAMUNIT enmUnit,
+                                  const char *pszDesc, const char *pszName, ...) RT_IPRT_FORMAT_ATTR(7, 8);
+-VMMR3DECL(int)  STAMR3RegisterF(PVM pVM, void *pvSample, STAMTYPE enmType, STAMVISIBILITY enmVisibility, STAMUNIT enmUnit,
++VMMR3DECL(int)  STAMR3RegisterF(vbox_PVM pVM, void *pvSample, STAMTYPE enmType, STAMVISIBILITY enmVisibility, STAMUNIT enmUnit,
+                                 const char *pszDesc, const char *pszName, ...) RT_IPRT_FORMAT_ATTR(7, 8);
+ VMMR3DECL(int)  STAMR3RegisterVU(PUVM pUVM, void *pvSample, STAMTYPE enmType, STAMVISIBILITY enmVisibility, STAMUNIT enmUnit,
+                                  const char *pszDesc, const char *pszName, va_list args) RT_IPRT_FORMAT_ATTR(7, 0);
+-VMMR3DECL(int)  STAMR3RegisterV(PVM pVM, void *pvSample, STAMTYPE enmType, STAMVISIBILITY enmVisibility, STAMUNIT enmUnit,
++VMMR3DECL(int)  STAMR3RegisterV(vbox_PVM pVM, void *pvSample, STAMTYPE enmType, STAMVISIBILITY enmVisibility, STAMUNIT enmUnit,
+                                 const char *pszDesc, const char *pszName, va_list args) RT_IPRT_FORMAT_ATTR(7, 0);
+ 
+ /**
+@@ -1179,7 +1179,7 @@ VMMR3DECL(int)  STAMR3RegisterV(PVM pVM,
+  * @param   pVM         The cross context VM structure.
+  * @param   pvSample    The sample registered using STAMR3RegisterCallback.
+  */
+-typedef void FNSTAMR3CALLBACKRESET(PVM pVM, void *pvSample);
++typedef void FNSTAMR3CALLBACKRESET(vbox_PVM pVM, void *pvSample);
+ /** Pointer to a STAM sample reset callback. */
+ typedef FNSTAMR3CALLBACKRESET *PFNSTAMR3CALLBACKRESET;
+ 
+@@ -1191,14 +1191,14 @@ typedef FNSTAMR3CALLBACKRESET *PFNSTAMR3
+  * @param   pszBuf      The buffer to print into.
+  * @param   cchBuf      The size of the buffer.
+  */
+-typedef void FNSTAMR3CALLBACKPRINT(PVM pVM, void *pvSample, char *pszBuf, size_t cchBuf);
++typedef void FNSTAMR3CALLBACKPRINT(vbox_PVM pVM, void *pvSample, char *pszBuf, size_t cchBuf);
+ /** Pointer to a STAM sample print callback. */
+ typedef FNSTAMR3CALLBACKPRINT *PFNSTAMR3CALLBACKPRINT;
+ 
+-VMMR3DECL(int)  STAMR3RegisterCallback(PVM pVM, void *pvSample, STAMVISIBILITY enmVisibility, STAMUNIT enmUnit,
++VMMR3DECL(int)  STAMR3RegisterCallback(vbox_PVM pVM, void *pvSample, STAMVISIBILITY enmVisibility, STAMUNIT enmUnit,
+                                        PFNSTAMR3CALLBACKRESET pfnReset, PFNSTAMR3CALLBACKPRINT pfnPrint,
+                                        const char *pszDesc, const char *pszName, ...) RT_IPRT_FORMAT_ATTR(8, 9);
+-VMMR3DECL(int)  STAMR3RegisterCallbackV(PVM pVM, void *pvSample, STAMVISIBILITY enmVisibility, STAMUNIT enmUnit,
++VMMR3DECL(int)  STAMR3RegisterCallbackV(vbox_PVM pVM, void *pvSample, STAMVISIBILITY enmVisibility, STAMUNIT enmUnit,
+                                         PFNSTAMR3CALLBACKRESET pfnReset, PFNSTAMR3CALLBACKPRINT pfnPrint,
+                                         const char *pszDesc, const char *pszName, va_list args) RT_IPRT_FORMAT_ATTR(8, 0);
+ VMMR3DECL(int)  STAMR3Deregister(PUVM pUVM, const char *pszPat);
+@@ -1241,4 +1241,3 @@ VMMR3DECL(const char *) STAMR3GetUnit(ST
+ RT_C_DECLS_END
+ 
+ #endif
+-
diff --git a/virtualbox-svn/patches/patch-include_VBox_vmm_tm.h b/virtualbox-svn/patches/patch-include_VBox_vmm_tm.h
new file mode 100644
index 0000000..dd11a08
--- /dev/null
+++ b/virtualbox-svn/patches/patch-include_VBox_vmm_tm.h
@@ -0,0 +1,171 @@
+$NetBSD$
+
+--- include/VBox/vmm/tm.h.orig	2016-03-04 19:22:59.000000000 +0000
++++ include/VBox/vmm/tm.h
+@@ -86,14 +86,14 @@ VMMDECL(void)           TMNotifyEndOfExe
+ VMM_INT_DECL(void)      TMNotifyStartOfHalt(PVMCPU pVCpu);
+ VMM_INT_DECL(void)      TMNotifyEndOfHalt(PVMCPU pVCpu);
+ #ifdef IN_RING3
+-VMMR3DECL(int)          TMR3NotifySuspend(PVM pVM, PVMCPU pVCpu);
+-VMMR3DECL(int)          TMR3NotifyResume(PVM pVM, PVMCPU pVCpu);
++VMMR3DECL(int)          TMR3NotifySuspend(vbox_PVM pVM, PVMCPU pVCpu);
++VMMR3DECL(int)          TMR3NotifyResume(vbox_PVM pVM, PVMCPU pVCpu);
+ VMMR3DECL(int)          TMR3SetWarpDrive(PUVM pUVM, uint32_t u32Percent);
+ VMMR3DECL(uint32_t)     TMR3GetWarpDrive(PUVM pUVM);
+ #endif
+-VMM_INT_DECL(uint32_t)  TMCalcHostTimerFrequency(PVM pVM, PVMCPU pVCpu);
++VMM_INT_DECL(uint32_t)  TMCalcHostTimerFrequency(vbox_PVM pVM, PVMCPU pVCpu);
+ #ifdef IN_RING3
+-VMMR3DECL(int)          TMR3GetCpuLoadTimes(PVM pVM, VMCPUID idCpu, uint64_t *pcNsTotal, uint64_t *pcNsExecuting,
++VMMR3DECL(int)          TMR3GetCpuLoadTimes(vbox_PVM pVM, VMCPUID idCpu, uint64_t *pcNsTotal, uint64_t *pcNsExecuting,
+                                             uint64_t *pcNsHalted, uint64_t *pcNsOther);
+ #endif
+ 
+@@ -101,31 +101,31 @@ VMMR3DECL(int)          TMR3GetCpuLoadTi
+ /** @name Real Clock Methods
+  * @{
+  */
+-VMM_INT_DECL(uint64_t)  TMRealGet(PVM pVM);
+-VMM_INT_DECL(uint64_t)  TMRealGetFreq(PVM pVM);
++VMM_INT_DECL(uint64_t)  TMRealGet(vbox_PVM pVM);
++VMM_INT_DECL(uint64_t)  TMRealGetFreq(vbox_PVM pVM);
+ /** @} */
+ 
+ 
+ /** @name Virtual Clock Methods
+  * @{
+  */
+-VMM_INT_DECL(uint64_t)  TMVirtualGet(PVM pVM);
+-VMM_INT_DECL(uint64_t)  TMVirtualGetNoCheck(PVM pVM);
+-VMM_INT_DECL(uint64_t)  TMVirtualSyncGetLag(PVM pVM);
+-VMM_INT_DECL(uint32_t)  TMVirtualSyncGetCatchUpPct(PVM pVM);
+-VMM_INT_DECL(uint64_t)  TMVirtualGetFreq(PVM pVM);
+-VMM_INT_DECL(uint64_t)  TMVirtualSyncGet(PVM pVM);
+-VMM_INT_DECL(uint64_t)  TMVirtualSyncGetNoCheck(PVM pVM);
+-VMM_INT_DECL(uint64_t)  TMVirtualSyncGetEx(PVM pVM, bool fCheckTimers);
+-VMM_INT_DECL(uint64_t)  TMVirtualSyncGetWithDeadlineNoCheck(PVM pVM, uint64_t *pcNsToDeadline);
+-VMMDECL(uint64_t)       TMVirtualSyncGetNsToDeadline(PVM pVM);
+-VMM_INT_DECL(uint64_t)  TMVirtualToNano(PVM pVM, uint64_t u64VirtualTicks);
+-VMM_INT_DECL(uint64_t)  TMVirtualToMicro(PVM pVM, uint64_t u64VirtualTicks);
+-VMM_INT_DECL(uint64_t)  TMVirtualToMilli(PVM pVM, uint64_t u64VirtualTicks);
+-VMM_INT_DECL(uint64_t)  TMVirtualFromNano(PVM pVM, uint64_t u64NanoTS);
+-VMM_INT_DECL(uint64_t)  TMVirtualFromMicro(PVM pVM, uint64_t u64MicroTS);
+-VMM_INT_DECL(uint64_t)  TMVirtualFromMilli(PVM pVM, uint64_t u64MilliTS);
+-VMM_INT_DECL(bool)      TMVirtualIsTicking(PVM pVM);
++VMM_INT_DECL(uint64_t)  TMVirtualGet(vbox_PVM pVM);
++VMM_INT_DECL(uint64_t)  TMVirtualGetNoCheck(vbox_PVM pVM);
++VMM_INT_DECL(uint64_t)  TMVirtualSyncGetLag(vbox_PVM pVM);
++VMM_INT_DECL(uint32_t)  TMVirtualSyncGetCatchUpPct(vbox_PVM pVM);
++VMM_INT_DECL(uint64_t)  TMVirtualGetFreq(vbox_PVM pVM);
++VMM_INT_DECL(uint64_t)  TMVirtualSyncGet(vbox_PVM pVM);
++VMM_INT_DECL(uint64_t)  TMVirtualSyncGetNoCheck(vbox_PVM pVM);
++VMM_INT_DECL(uint64_t)  TMVirtualSyncGetEx(vbox_PVM pVM, bool fCheckTimers);
++VMM_INT_DECL(uint64_t)  TMVirtualSyncGetWithDeadlineNoCheck(vbox_PVM pVM, uint64_t *pcNsToDeadline);
++VMMDECL(uint64_t)       TMVirtualSyncGetNsToDeadline(vbox_PVM pVM);
++VMM_INT_DECL(uint64_t)  TMVirtualToNano(vbox_PVM pVM, uint64_t u64VirtualTicks);
++VMM_INT_DECL(uint64_t)  TMVirtualToMicro(vbox_PVM pVM, uint64_t u64VirtualTicks);
++VMM_INT_DECL(uint64_t)  TMVirtualToMilli(vbox_PVM pVM, uint64_t u64VirtualTicks);
++VMM_INT_DECL(uint64_t)  TMVirtualFromNano(vbox_PVM pVM, uint64_t u64NanoTS);
++VMM_INT_DECL(uint64_t)  TMVirtualFromMicro(vbox_PVM pVM, uint64_t u64MicroTS);
++VMM_INT_DECL(uint64_t)  TMVirtualFromMilli(vbox_PVM pVM, uint64_t u64MilliTS);
++VMM_INT_DECL(bool)      TMVirtualIsTicking(vbox_PVM pVM);
+ /** @} */
+ 
+ 
+@@ -134,12 +134,12 @@ VMM_INT_DECL(bool)      TMVirtualIsTicki
+  */
+ VMMDECL(uint64_t)       TMCpuTickGet(PVMCPU pVCpu);
+ VMM_INT_DECL(uint64_t)  TMCpuTickGetNoCheck(PVMCPU pVCpu);
+-VMM_INT_DECL(bool)      TMCpuTickCanUseRealTSC(PVM pVM, PVMCPU pVCpu, uint64_t *poffRealTSC, bool *pfParavirtTsc);
+-VMM_INT_DECL(uint64_t)  TMCpuTickGetDeadlineAndTscOffset(PVM pVM, PVMCPU pVCpu, uint64_t *poffRealTSC, bool *pfOffsettedTsc, bool *pfParavirtTsc);
+-VMM_INT_DECL(int)       TMCpuTickSet(PVM pVM, PVMCPU pVCpu, uint64_t u64Tick);
++VMM_INT_DECL(bool)      TMCpuTickCanUseRealTSC(vbox_PVM pVM, PVMCPU pVCpu, uint64_t *poffRealTSC, bool *pfParavirtTsc);
++VMM_INT_DECL(uint64_t)  TMCpuTickGetDeadlineAndTscOffset(vbox_PVM pVM, PVMCPU pVCpu, uint64_t *poffRealTSC, bool *pfOffsettedTsc, bool *pfParavirtTsc);
++VMM_INT_DECL(int)       TMCpuTickSet(vbox_PVM pVM, PVMCPU pVCpu, uint64_t u64Tick);
+ VMM_INT_DECL(int)       TMCpuTickSetLastSeen(PVMCPU pVCpu, uint64_t u64LastSeenTick);
+ VMM_INT_DECL(uint64_t)  TMCpuTickGetLastSeen(PVMCPU pVCpu);
+-VMMDECL(uint64_t)       TMCpuTicksPerSecond(PVM pVM);
++VMMDECL(uint64_t)       TMCpuTicksPerSecond(vbox_PVM pVM);
+ VMM_INT_DECL(bool)      TMCpuTickIsTicking(PVMCPU pVCpu);
+ /** @} */
+ 
+@@ -198,7 +198,7 @@ typedef FNTMTIMERSRV *PFNTMTIMERSRV;
+  * @param   pTimer          The timer handle.
+  * @param   pvUser          User argument specified upon timer creation.
+  */
+-typedef DECLCALLBACK(void) FNTMTIMERINT(PVM pVM, PTMTIMER pTimer, void *pvUser);
++typedef DECLCALLBACK(void) FNTMTIMERINT(vbox_PVM pVM, PTMTIMER pTimer, void *pvUser);
+ /** Pointer to internal timer callback function. */
+ typedef FNTMTIMERINT *PFNTMTIMERINT;
+ 
+@@ -239,9 +239,9 @@ VMMDECL(uint64_t)       TMTimerFromNano(
+ VMMDECL(uint64_t)       TMTimerFromMicro(PTMTIMER pTimer, uint64_t cMicroSecs);
+ VMMDECL(uint64_t)       TMTimerFromMilli(PTMTIMER pTimer, uint64_t cMilliSecs);
+ 
+-VMMDECL(bool)           TMTimerPollBool(PVM pVM, PVMCPU pVCpu);
+-VMM_INT_DECL(void)      TMTimerPollVoid(PVM pVM, PVMCPU pVCpu);
+-VMM_INT_DECL(uint64_t)  TMTimerPollGIP(PVM pVM, PVMCPU pVCpu, uint64_t *pu64Delta);
++VMMDECL(bool)           TMTimerPollBool(vbox_PVM pVM, PVMCPU pVCpu);
++VMM_INT_DECL(void)      TMTimerPollVoid(vbox_PVM pVM, PVMCPU pVCpu);
++VMM_INT_DECL(uint64_t)  TMTimerPollGIP(vbox_PVM pVM, PVMCPU pVCpu, uint64_t *pu64Delta);
+ /** @} */
+ 
+ 
+@@ -249,31 +249,31 @@ VMM_INT_DECL(uint64_t)  TMTimerPollGIP(P
+ /** @defgroup grp_tm_r3     The TM Host Context Ring-3 API
+  * @{
+  */
+-VMM_INT_DECL(int)       TMR3Init(PVM pVM);
+-VMM_INT_DECL(int)       TMR3InitFinalize(PVM pVM);
+-VMM_INT_DECL(void)      TMR3Relocate(PVM pVM, RTGCINTPTR offDelta);
+-VMM_INT_DECL(int)       TMR3Term(PVM pVM);
+-VMM_INT_DECL(void)      TMR3Reset(PVM pVM);
+-VMM_INT_DECL(int)       TMR3GetImportRC(PVM pVM, const char *pszSymbol, PRTRCPTR pRCPtrValue);
+-VMM_INT_DECL(int)       TMR3TimerCreateDevice(PVM pVM, PPDMDEVINS pDevIns, TMCLOCK enmClock, PFNTMTIMERDEV pfnCallback, void *pvUser, uint32_t fFlags, const char *pszDesc, PPTMTIMERR3 ppTimer);
+-VMM_INT_DECL(int)       TMR3TimerCreateUsb(PVM pVM, PPDMUSBINS pUsbIns, TMCLOCK enmClock, PFNTMTIMERUSB pfnCallback, void *pvUser, uint32_t fFlags, const char *pszDesc, PPTMTIMERR3 ppTimer);
+-VMM_INT_DECL(int)       TMR3TimerCreateDriver(PVM pVM, PPDMDRVINS pDrvIns, TMCLOCK enmClock, PFNTMTIMERDRV pfnCallback, void *pvUser, uint32_t fFlags, const char *pszDesc, PPTMTIMERR3 ppTimer);
+-VMMR3DECL(int)          TMR3TimerCreateInternal(PVM pVM, TMCLOCK enmClock, PFNTMTIMERINT pfnCallback, void *pvUser, const char *pszDesc, PPTMTIMERR3 ppTimer);
+-VMMR3DECL(PTMTIMERR3)   TMR3TimerCreateExternal(PVM pVM, TMCLOCK enmClock, PFNTMTIMEREXT pfnCallback, void *pvUser, const char *pszDesc);
++VMM_INT_DECL(int)       TMR3Init(vbox_PVM pVM);
++VMM_INT_DECL(int)       TMR3InitFinalize(vbox_PVM pVM);
++VMM_INT_DECL(void)      TMR3Relocate(vbox_PVM pVM, RTGCINTPTR offDelta);
++VMM_INT_DECL(int)       TMR3Term(vbox_PVM pVM);
++VMM_INT_DECL(void)      TMR3Reset(vbox_PVM pVM);
++VMM_INT_DECL(int)       TMR3GetImportRC(vbox_PVM pVM, const char *pszSymbol, PRTRCPTR pRCPtrValue);
++VMM_INT_DECL(int)       TMR3TimerCreateDevice(vbox_PVM pVM, PPDMDEVINS pDevIns, TMCLOCK enmClock, PFNTMTIMERDEV pfnCallback, void *pvUser, uint32_t fFlags, const char *pszDesc, PPTMTIMERR3 ppTimer);
++VMM_INT_DECL(int)       TMR3TimerCreateUsb(vbox_PVM pVM, PPDMUSBINS pUsbIns, TMCLOCK enmClock, PFNTMTIMERUSB pfnCallback, void *pvUser, uint32_t fFlags, const char *pszDesc, PPTMTIMERR3 ppTimer);
++VMM_INT_DECL(int)       TMR3TimerCreateDriver(vbox_PVM pVM, PPDMDRVINS pDrvIns, TMCLOCK enmClock, PFNTMTIMERDRV pfnCallback, void *pvUser, uint32_t fFlags, const char *pszDesc, PPTMTIMERR3 ppTimer);
++VMMR3DECL(int)          TMR3TimerCreateInternal(vbox_PVM pVM, TMCLOCK enmClock, PFNTMTIMERINT pfnCallback, void *pvUser, const char *pszDesc, PPTMTIMERR3 ppTimer);
++VMMR3DECL(PTMTIMERR3)   TMR3TimerCreateExternal(vbox_PVM pVM, TMCLOCK enmClock, PFNTMTIMEREXT pfnCallback, void *pvUser, const char *pszDesc);
+ VMMR3DECL(int)          TMR3TimerDestroy(PTMTIMER pTimer);
+-VMM_INT_DECL(int)       TMR3TimerDestroyDevice(PVM pVM, PPDMDEVINS pDevIns);
+-VMM_INT_DECL(int)       TMR3TimerDestroyUsb(PVM pVM, PPDMUSBINS pUsbIns);
+-VMM_INT_DECL(int)       TMR3TimerDestroyDriver(PVM pVM, PPDMDRVINS pDrvIns);
++VMM_INT_DECL(int)       TMR3TimerDestroyDevice(vbox_PVM pVM, PPDMDEVINS pDevIns);
++VMM_INT_DECL(int)       TMR3TimerDestroyUsb(vbox_PVM pVM, PPDMUSBINS pUsbIns);
++VMM_INT_DECL(int)       TMR3TimerDestroyDriver(vbox_PVM pVM, PPDMDRVINS pDrvIns);
+ VMMR3DECL(int)          TMR3TimerSave(PTMTIMERR3 pTimer, PSSMHANDLE pSSM);
+ VMMR3DECL(int)          TMR3TimerLoad(PTMTIMERR3 pTimer, PSSMHANDLE pSSM);
+ VMMR3DECL(int)          TMR3TimerSetCritSect(PTMTIMERR3 pTimer, PPDMCRITSECT pCritSect);
+-VMMR3DECL(void)         TMR3TimerQueuesDo(PVM pVM);
+-VMMR3_INT_DECL(void)    TMR3VirtualSyncFF(PVM pVM, PVMCPU pVCpu);
+-VMMR3_INT_DECL(PRTTIMESPEC) TMR3UtcNow(PVM pVM, PRTTIMESPEC pTime);
+-
+-VMMR3_INT_DECL(int)     TMR3CpuTickParavirtEnable(PVM pVM);
+-VMMR3_INT_DECL(int)     TMR3CpuTickParavirtDisable(PVM pVM);
+-VMMR3_INT_DECL(bool)    TMR3CpuTickIsFixedRateMonotonic(PVM pVM, bool fWithParavirtEnabled);
++VMMR3DECL(void)         TMR3TimerQueuesDo(vbox_PVM pVM);
++VMMR3_INT_DECL(void)    TMR3VirtualSyncFF(vbox_PVM pVM, PVMCPU pVCpu);
++VMMR3_INT_DECL(PRTTIMESPEC) TMR3UtcNow(vbox_PVM pVM, PRTTIMESPEC pTime);
++
++VMMR3_INT_DECL(int)     TMR3CpuTickParavirtEnable(vbox_PVM pVM);
++VMMR3_INT_DECL(int)     TMR3CpuTickParavirtDisable(vbox_PVM pVM);
++VMMR3_INT_DECL(bool)    TMR3CpuTickIsFixedRateMonotonic(vbox_PVM pVM, bool fWithParavirtEnabled);
+ /** @} */
+ #endif /* IN_RING3 */
+ 
+@@ -283,4 +283,3 @@ VMMR3_INT_DECL(bool)    TMR3CpuTickIsFix
+ RT_C_DECLS_END
+ 
+ #endif
+-
diff --git a/virtualbox-svn/patches/patch-include_VBox_vmm_uvm.h b/virtualbox-svn/patches/patch-include_VBox_vmm_uvm.h
new file mode 100644
index 0000000..3c88acd
--- /dev/null
+++ b/virtualbox-svn/patches/patch-include_VBox_vmm_uvm.h
@@ -0,0 +1,27 @@
+$NetBSD$
+
+--- include/VBox/vmm/uvm.h.orig	2016-03-04 19:22:59.000000000 +0000
++++ include/VBox/vmm/uvm.h
+@@ -42,7 +42,7 @@ typedef struct UVMCPU
+     /** Pointer to the UVM structure.  */
+     PUVM                            pUVM;
+     /** Pointer to the VM structure.  */
+-    PVM                             pVM;
++    vbox_PVM                             pVM;
+     /** Pointer to the VMCPU structure.  */
+     PVMCPU                          pVCpu;
+     /** The virtual CPU ID.  */
+@@ -87,7 +87,7 @@ typedef struct UVM
+     /** The number of virtual CPUs. */
+     uint32_t            cCpus;
+     /** The ring-3 mapping of the shared VM structure. */
+-    PVM                 pVM;
++    vbox_PVM                 pVM;
+     /** Pointer to the next VM.
+      * We keep a per process list of VM for the event that a process could
+      * contain more than one VM.
+@@ -180,4 +180,3 @@ AssertCompileMemberAlignment(UVM, aCpus,
+ 
+ /** @} */
+ #endif
+-
diff --git a/virtualbox-svn/patches/patch-include_VBox_vmm_vmapi.h b/virtualbox-svn/patches/patch-include_VBox_vmm_vmapi.h
new file mode 100644
index 0000000..7d03d5a
--- /dev/null
+++ b/virtualbox-svn/patches/patch-include_VBox_vmm_vmapi.h
@@ -0,0 +1,64 @@
+$NetBSD$
+
+--- include/VBox/vmm/vmapi.h.orig	2016-07-10 19:42:15.000000000 +0000
++++ include/VBox/vmm/vmapi.h
+@@ -104,8 +104,8 @@ typedef DECLCALLBACK(void) FNVMATERROR(P
+ /** Pointer to a VM error callback. */
+ typedef FNVMATERROR *PFNVMATERROR;
+ 
+-VMMDECL(int)    VMSetError(PVM pVM, int rc, RT_SRC_POS_DECL, const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(6, 7);
+-VMMDECL(int)    VMSetErrorV(PVM pVM, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list args) RT_IPRT_FORMAT_ATTR(6, 7);
++VMMDECL(int)    VMSetError(vbox_PVM pVM, int rc, RT_SRC_POS_DECL, const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(6, 7);
++VMMDECL(int)    VMSetErrorV(vbox_PVM pVM, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list args) RT_IPRT_FORMAT_ATTR(6, 7);
+ 
+ /** @def VM_SET_ERROR
+  * Macro for setting a simple VM error message.
+@@ -155,9 +155,9 @@ typedef DECLCALLBACK(void) FNVMATRUNTIME
+ /** Pointer to a VM runtime error callback. */
+ typedef FNVMATRUNTIMEERROR *PFNVMATRUNTIMEERROR;
+ 
+-VMMDECL(int) VMSetRuntimeError(PVM pVM, uint32_t fFlags, const char *pszErrorId,
++VMMDECL(int) VMSetRuntimeError(vbox_PVM pVM, uint32_t fFlags, const char *pszErrorId,
+                                const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(4, 5);
+-VMMDECL(int) VMSetRuntimeErrorV(PVM pVM, uint32_t fFlags, const char *pszErrorId,
++VMMDECL(int) VMSetRuntimeErrorV(vbox_PVM pVM, uint32_t fFlags, const char *pszErrorId,
+                                 const char *pszFormat, va_list args) RT_IPRT_FORMAT_ATTR(4, 0);
+ 
+ /** @name VMSetRuntimeError fFlags
+@@ -404,7 +404,7 @@ typedef FNVMPROGRESS *PFNVMPROGRESS;
+ VMMR3DECL(int)          VMR3Create(uint32_t cCpus, PCVMM2USERMETHODS pVm2UserCbs,
+                                    PFNVMATERROR pfnVMAtError, void *pvUserVM,
+                                    PFNCFGMCONSTRUCTOR pfnCFGMConstructor, void *pvUserCFGM,
+-                                   PVM *ppVM, PUVM *ppUVM);
++                                   vbox_PVM *ppVM, PUVM *ppUVM);
+ VMMR3DECL(int)          VMR3PowerOn(PUVM pUVM);
+ VMMR3DECL(int)          VMR3Suspend(PUVM pUVM, VMSUSPENDREASON enmReason);
+ VMMR3DECL(VMSUSPENDREASON) VMR3GetSuspendReason(PUVM);
+@@ -476,16 +476,16 @@ VMMR3_INT_DECL(int)     VMR3ReqProcessU(
+ /** @} */
+ VMMR3_INT_DECL(void)        VMR3NotifyGlobalFFU(PUVM pUVM, uint32_t fFlags);
+ VMMR3_INT_DECL(void)        VMR3NotifyCpuFFU(PUVMCPU pUVMCpu, uint32_t fFlags);
+-VMMR3DECL(int)              VMR3NotifyCpuDeviceReady(PVM pVM, VMCPUID idCpu);
+-VMMR3_INT_DECL(int)         VMR3WaitHalted(PVM pVM, PVMCPU pVCpu, bool fIgnoreInterrupts);
++VMMR3DECL(int)              VMR3NotifyCpuDeviceReady(vbox_PVM pVM, VMCPUID idCpu);
++VMMR3_INT_DECL(int)         VMR3WaitHalted(vbox_PVM pVM, PVMCPU pVCpu, bool fIgnoreInterrupts);
+ VMMR3_INT_DECL(int)         VMR3WaitU(PUVMCPU pUVMCpu);
+-VMMR3DECL(int)              VMR3WaitForDeviceReady(PVM pVM, VMCPUID idCpu);
++VMMR3DECL(int)              VMR3WaitForDeviceReady(vbox_PVM pVM, VMCPUID idCpu);
+ VMMR3_INT_DECL(int)         VMR3AsyncPdmNotificationWaitU(PUVMCPU pUVCpu);
+ VMMR3_INT_DECL(void)        VMR3AsyncPdmNotificationWakeupU(PUVM pUVM);
+-VMMR3_INT_DECL(RTCPUID)     VMR3GetVMCPUId(PVM pVM);
+-VMMR3_INT_DECL(bool)        VMR3IsLongModeAllowed(PVM pVM);
++VMMR3_INT_DECL(RTCPUID)     VMR3GetVMCPUId(vbox_PVM pVM);
++VMMR3_INT_DECL(bool)        VMR3IsLongModeAllowed(vbox_PVM pVM);
+ VMMR3DECL(RTTHREAD)         VMR3GetVMCPUThread(PUVM pUVM);
+-VMMR3DECL(RTNATIVETHREAD)   VMR3GetVMCPUNativeThread(PVM pVM);
++VMMR3DECL(RTNATIVETHREAD)   VMR3GetVMCPUNativeThread(vbox_PVM pVM);
+ VMMR3DECL(RTNATIVETHREAD)   VMR3GetVMCPUNativeThreadU(PUVM pUVM);
+ VMMR3DECL(int)              VMR3GetCpuCoreAndPackageIdFromCpuId(PUVM pUVM, VMCPUID idCpu, uint32_t *pidCpuCore, uint32_t *pidCpuPackage);
+ VMMR3DECL(int)              VMR3HotUnplugCpu(PUVM pUVM, VMCPUID idCpu);
+@@ -509,4 +509,3 @@ RT_C_DECLS_END
+ /** @} */
+ 
+ #endif
+-
diff --git a/virtualbox-svn/patches/patch-include_VBox_vmm_vmm.h b/virtualbox-svn/patches/patch-include_VBox_vmm_vmm.h
new file mode 100644
index 0000000..89a9840
--- /dev/null
+++ b/virtualbox-svn/patches/patch-include_VBox_vmm_vmm.h
@@ -0,0 +1,75 @@
+$NetBSD$
+
+--- include/VBox/vmm/vmm.h.orig	2016-07-10 19:42:15.000000000 +0000
++++ include/VBox/vmm/vmm.h
+@@ -148,7 +148,7 @@ typedef FNVMMR0CALLRING3NOTIFICATION *PF
+  * @param   pVCpu   The cross context virtual CPU structure of the calling EMT.
+  * @param   pvUser  The user argument.
+  */
+-typedef DECLCALLBACK(VBOXSTRICTRC) FNVMMEMTRENDEZVOUS(PVM pVM, PVMCPU pVCpu, void *pvUser);
++typedef DECLCALLBACK(VBOXSTRICTRC) FNVMMEMTRENDEZVOUS(vbox_PVM pVM, PVMCPU pVCpu, void *pvUser);
+ /** Pointer to a rendezvous callback function. */
+ typedef FNVMMEMTRENDEZVOUS *PFNVMMEMTRENDEZVOUS;
+ 
+@@ -262,16 +262,16 @@ typedef struct VMM2USERMETHODS
+ 
+ 
+ VMM_INT_DECL(RTRCPTR)       VMMGetStackRC(PVMCPU pVCpu);
+-VMMDECL(VMCPUID)            VMMGetCpuId(PVM pVM);
+-VMMDECL(PVMCPU)             VMMGetCpu(PVM pVM);
+-VMMDECL(PVMCPU)             VMMGetCpu0(PVM pVM);
+-VMMDECL(PVMCPU)             VMMGetCpuById(PVM pVM, VMCPUID idCpu);
++VMMDECL(VMCPUID)            VMMGetCpuId(vbox_PVM pVM);
++VMMDECL(PVMCPU)             VMMGetCpu(vbox_PVM pVM);
++VMMDECL(PVMCPU)             VMMGetCpu0(vbox_PVM pVM);
++VMMDECL(PVMCPU)             VMMGetCpuById(vbox_PVM pVM, VMCPUID idCpu);
+ VMMR3DECL(PVMCPU)           VMMR3GetCpuByIdU(PUVM pVM, VMCPUID idCpu);
+ VMM_INT_DECL(uint32_t)      VMMGetSvnRev(void);
+-VMM_INT_DECL(VMMSWITCHER)   VMMGetSwitcher(PVM pVM);
++VMM_INT_DECL(VMMSWITCHER)   VMMGetSwitcher(vbox_PVM pVM);
+ VMM_INT_DECL(bool)          VMMIsInRing3Call(PVMCPU pVCpu);
+ VMM_INT_DECL(void)          VMMTrashVolatileXMMRegs(void);
+-VMM_INT_DECL(int)           VMMPatchHypercall(PVM pVM, void *pvBuf, size_t cbBuf, size_t *pcbWritten);
++VMM_INT_DECL(int)           VMMPatchHypercall(vbox_PVM pVM, void *pvBuf, size_t cbBuf, size_t *pcbWritten);
+ VMM_INT_DECL(void)          VMMHypercallsEnable(PVMCPU pVCpu);
+ VMM_INT_DECL(void)          VMMHypercallsDisable(PVMCPU pVCpu);
+ 
+@@ -515,10 +515,10 @@ typedef struct GCFGMVALUEREQ
+ typedef GCFGMVALUEREQ *PGCFGMVALUEREQ;
+ 
+ #if defined(IN_RING0) || defined(DOXYGEN_RUNNING)
+-VMMR0DECL(int)       VMMR0EntryInt(PVM pVM, VMMR0OPERATION enmOperation, void *pvArg);
+-VMMR0DECL(void)      VMMR0EntryFast(PVM pVM, VMCPUID idCpu, VMMR0OPERATION enmOperation);
+-VMMR0DECL(int)       VMMR0EntryEx(PVM pVM, VMCPUID idCpu, VMMR0OPERATION enmOperation, PSUPVMMR0REQHDR pReq, uint64_t u64Arg, PSUPDRVSESSION);
+-VMMR0_INT_DECL(int)  VMMR0TermVM(PVM pVM, PGVM pGVM);
++VMMR0DECL(int)       VMMR0EntryInt(vbox_PVM pVM, VMMR0OPERATION enmOperation, void *pvArg);
++VMMR0DECL(void)      VMMR0EntryFast(vbox_PVM pVM, VMCPUID idCpu, VMMR0OPERATION enmOperation);
++VMMR0DECL(int)       VMMR0EntryEx(vbox_PVM pVM, VMCPUID idCpu, VMMR0OPERATION enmOperation, PSUPVMMR0REQHDR pReq, uint64_t u64Arg, PSUPDRVSESSION);
++VMMR0_INT_DECL(int)  VMMR0TermVM(vbox_PVM pVM, PGVM pGVM);
+ VMMR0_INT_DECL(bool) VMMR0IsLongJumpArmed(PVMCPU pVCpu);
+ VMMR0_INT_DECL(bool) VMMR0IsInRing3LongJump(PVMCPU pVCpu);
+ VMMR0_INT_DECL(int)  VMMR0ThreadCtxHookCreateForEmt(PVMCPU pVCpu);
+@@ -544,9 +544,9 @@ VMMR0_INT_DECL(bool) VMMR0IsLogFlushDisa
+ /** @defgroup grp_vmm_api_rc    The VMM Raw-Mode Context API
+  * @{
+  */
+-VMMRCDECL(int)      VMMRCEntry(PVM pVM, unsigned uOperation, unsigned uArg, ...);
+-VMMRCDECL(void)     VMMRCGuestToHost(PVM pVM, int rc);
+-VMMRCDECL(void)     VMMRCLogFlushIfFull(PVM pVM);
++VMMRCDECL(int)      VMMRCEntry(vbox_PVM pVM, unsigned uOperation, unsigned uArg, ...);
++VMMRCDECL(void)     VMMRCGuestToHost(vbox_PVM pVM, int rc);
++VMMRCDECL(void)     VMMRCLogFlushIfFull(vbox_PVM pVM);
+ /** @} */
+ #endif /* IN_RC */
+ 
+@@ -554,8 +554,8 @@ VMMRCDECL(void)     VMMRCLogFlushIfFull(
+ /** @defgroup grp_vmm_api_rz    The VMM Raw-Mode and Ring-0 Context API
+  * @{
+  */
+-VMMRZDECL(int)      VMMRZCallRing3(PVM pVM, PVMCPU pVCpu, VMMCALLRING3 enmOperation, uint64_t uArg);
+-VMMRZDECL(int)      VMMRZCallRing3NoCpu(PVM pVM, VMMCALLRING3 enmOperation, uint64_t uArg);
++VMMRZDECL(int)      VMMRZCallRing3(vbox_PVM pVM, PVMCPU pVCpu, VMMCALLRING3 enmOperation, uint64_t uArg);
++VMMRZDECL(int)      VMMRZCallRing3NoCpu(vbox_PVM pVM, VMMCALLRING3 enmOperation, uint64_t uArg);
+ VMMRZDECL(void)     VMMRZCallRing3Disable(PVMCPU pVCpu);
+ VMMRZDECL(void)     VMMRZCallRing3Enable(PVMCPU pVCpu);
+ VMMRZDECL(bool)     VMMRZCallRing3IsEnabled(PVMCPU pVCpu);
diff --git a/virtualbox-svn/patches/patch-include_iprt_stdint.h b/virtualbox-svn/patches/patch-include_iprt_stdint.h
new file mode 100644
index 0000000..b333c07
--- /dev/null
+++ b/virtualbox-svn/patches/patch-include_iprt_stdint.h
@@ -0,0 +1,39 @@
+$NetBSD$
+
+--- include/iprt/stdint.h.orig	2016-07-10 19:43:00.000000000 +0000
++++ include/iprt/stdint.h
+@@ -62,7 +62,7 @@
+ #  define UINT32_C(Value)   (Value ## U)
+ # endif /* 64-bit darwin kludge. */
+ 
+-#elif defined(RT_OS_FREEBSD) && defined(_KERNEL)
++#elif (defined(RT_OS_FREEBSD) && defined(_KERNEL)) || (defined(RT_OS_NETBSD) && defined(_KERNEL))
+ 
+ # ifndef __STDC_CONSTANT_MACROS
+ #  define __STDC_CONSTANT_MACROS
+@@ -70,6 +70,10 @@
+ # ifndef __STDC_LIMIT_MACROS
+ #  define __STDC_LIMIT_MACROS
+ # endif
++#ifdef __NetBSD__
++# include <sys/param.h>
++# include <sys/types.h>
++#endif
+ # include <sys/stdint.h>
+ 
+ #else /* No system stdint.h */
+@@ -172,7 +176,8 @@ typedef uint64_t            uintmax_t;
+ # if !defined(_MSC_VER) || defined(DOXYGEN_RUNNING)
+ #  if ARCH_BITS == 32 \
+    || defined(RT_OS_LINUX) \
+-   || defined(RT_OS_FREEBSD)
++   || defined(RT_OS_FREEBSD) \
++   || defined(RT_OS_NETBSD)
+ #   if !defined(_INTPTR_T_DECLARED)  && !defined(_INTPTR_T)
+ typedef signed long         intptr_t;
+ #   endif
+@@ -263,4 +268,3 @@ typedef uint64_t            uintptr_t;
+ #endif
+ 
+ #endif
+-
diff --git a/virtualbox-svn/patches/patch-include_iprt_string.h b/virtualbox-svn/patches/patch-include_iprt_string.h
new file mode 100644
index 0000000..e8328c1
--- /dev/null
+++ b/virtualbox-svn/patches/patch-include_iprt_string.h
@@ -0,0 +1,9 @@
+$NetBSD$
+
+--- include/iprt/string.h.orig	2016-07-10 19:42:34.000000000 +0000
++++ include/iprt/string.h
+@@ -3040,4 +3040,3 @@ RTDECL(uint32_t)    RTStrHash1ExNV(size_
+ RT_C_DECLS_END
+ 
+ #endif
+-
diff --git a/virtualbox-svn/patches/patch-include_iprt_time.h b/virtualbox-svn/patches/patch-include_iprt_time.h
new file mode 100644
index 0000000..639c552
--- /dev/null
+++ b/virtualbox-svn/patches/patch-include_iprt_time.h
@@ -0,0 +1,18 @@
+$NetBSD$
+
+--- include/iprt/time.h.orig	2016-03-04 19:23:02.000000000 +0000
++++ include/iprt/time.h
+@@ -353,7 +353,7 @@ DECLINLINE(void) RTTimeSpecGetSecondsAnd
+ 
+ 
+ /* PORTME: Add struct timeval guard macro here. */
+-#if defined(RTTIME_INCL_TIMEVAL) || defined(_STRUCT_TIMEVAL) || defined(_SYS__TIMEVAL_H_) || defined(_SYS_TIME_H) || defined(_TIMEVAL) || defined(_LINUX_TIME_H)
++#if defined(RTTIME_INCL_TIMEVAL) || defined(_STRUCT_TIMEVAL) || defined(_SYS__TIMEVAL_H_) || defined(_SYS_TIME_H) || defined(_TIMEVAL) || defined(_LINUX_TIME_H) || defined(_SYS_TIME_H_)
+ /**
+  * Gets the time as POSIX timeval.
+  *
+@@ -1031,4 +1031,3 @@ RTDECL(uint64_t) RTTimeProgramStartNanoT
+ RT_C_DECLS_END
+ 
+ #endif
+-
diff --git a/virtualbox-svn/patches/patch-include_iprt_types.h b/virtualbox-svn/patches/patch-include_iprt_types.h
new file mode 100644
index 0000000..e996bca
--- /dev/null
+++ b/virtualbox-svn/patches/patch-include_iprt_types.h
@@ -0,0 +1,24 @@
+$NetBSD$
+
+--- include/iprt/types.h.orig	2016-03-04 19:23:02.000000000 +0000
++++ include/iprt/types.h
+@@ -203,12 +203,12 @@ RT_C_DECLS_END
+ # if defined(__GNUC__)
+ #  if defined(RT_OS_LINUX) && __GNUC__ < 3
+ typedef uint8_t bool;
+-#  elif defined(RT_OS_FREEBSD)
++#  elif defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+ #   ifndef __bool_true_false_are_defined
+ typedef _Bool bool;
+ #   endif
+ #  else
+-#   if (defined(RT_OS_DARWIN) || defined(RT_OS_HAIKU)) && (defined(_STDBOOL_H) || defined(__STDBOOL_H))
++#   if (defined(RT_OS_DARWIN) || defined(RT_OS_HAIKU)) && (defined(_STDBOOL_H) || defined(__STDBOOL_H)) || defined(_SYS_STDBOOL_H_) || defined(_SYS_STDBOOL_H_)
+ #    undef bool
+ #   endif
+ typedef _Bool bool;
+@@ -2617,4 +2617,3 @@ public:
+ /** @} */
+ 
+ #endif
+-
diff --git a/virtualbox-svn/patches/patch-kBuild_header.kmk b/virtualbox-svn/patches/patch-kBuild_header.kmk
new file mode 100644
index 0000000..d6d3e1a
--- /dev/null
+++ b/virtualbox-svn/patches/patch-kBuild_header.kmk
@@ -0,0 +1,92 @@
+$NetBSD$
+
+--- kBuild/header.kmk.orig	2015-09-15 23:36:00.000000000 +0000
++++ kBuild/header.kmk
+@@ -610,10 +610,10 @@ SUFF_OBJ    := .o
+ SUFF_LIB    := .a
+ SUFF_DLL    := .so
+ SUFF_EXE    :=
+- if1of ($(KBUILD_TARGET), dragonfly freebsd linux netbsd openbsd) ## @todo check netbsd and openbsd.
++ if1of ($(KBUILD_TARGET), dragonfly freebsd linux openbsd) ## @todo check openbsd.
+ SUFF_SYS    := .ko
+  else
+-SUFF_SYS    :=
++SUFF_SYS    := .kmod
+  endif
+ SUFF_RES    :=
+ endif
+@@ -1278,66 +1278,9 @@ endif
+ #    KBUILD_LIB_SEARCH_ROOTS - Roots to search for library subdirs.
+ #    KBUILD_LIB_SEARCH_PATHS - ROOTS + SUBS.
+ #
+-ifeq ($(KBUILD_TARGET),darwin)
+- KBUILD_LIB_SEARCH_ROOTS := \
+-	/usr/ \
+-	/Developer/usr/
+- KBUILD_LIB_SEARCH_SUBS  := lib/
+-
+-else if1of ($(KBUILD_TARGET), freebsd netbsd openbsd dragonfly)
+- KBUILD_LIB_SEARCH_ROOTS := \
+-	/ \
+-	/usr/ \
+-	/usr/local/
+- KBUILD_LIB_SEARCH_SUBS := lib/
+-
+-else ifeq ($(KBUILD_TARGET),linux)
+- ifeq ($(realpath /bin),/usr/bin)
+-  KBUILD_LIB_SEARCH_ROOTS := \
+-  	/usr/ \
+-  	/ \
+-  	/usr/local/
+- else
+-  KBUILD_LIB_SEARCH_ROOTS := \
+-  	/ \
+-  	/usr/ \
+-  	/usr/local/
+- endif
+- ifeq ($(KBUILD_TARGET_ARCH),amd64)
+-  KBUILD_LIB_SEARCH_SUBS := \
+-	lib/x86_64-linux-gnu/ \
+-	lib64/ \
+-	lib/
+- else ifeq ($(KBUILD_TARGET_ARCH),x86)
+-  KBUILD_LIB_SEARCH_SUBS := \
+-	lib/i686-linux-gnu/ \
+-	lib/i386-linux-gnu/ \
+-	lib32/ \
+-	lib/
+- else
+-  KBUILD_LIB_SEARCH_SUBS := lib/
+- endif
+-
+-else ifeq ($(KBUILD_TARGET),solaris)
+- KBUILD_LIB_SEARCH_ROOTS := \
+-	/ \
+-	/usr/ \
+-	/usr/sfw/ \
+-	/usr/local/ \
+-	/sw/
+- ifeq ($(KBUILD_TARGET_ARCH),amd64)
+-  KBUILD_LIB_SEARCH_SUBS := lib/amd64/ lib/
+- else ifeq ($(KBUILD_TARGET_ARCH),sparc64)
+-  KBUILD_LIB_SEARCH_SUBS := lib/sparcv9/ lib/
+- else
+-  KBUILD_LIB_SEARCH_SUBS := lib/
+- endif
+-
+-else
+- KBUILD_LIB_SEARCH_SUBS  :=
+- KBUILD_LIB_SEARCH_ROOTS :=
+-endif
+-KBUILD_LIB_SEARCH_PATHS  := $(foreach root, $(KBUILD_LIB_SEARCH_ROOTS), $(addprefix $(root),$(KBUILD_LIB_SEARCH_SUBS)))
++KBUILD_LIB_SEARCH_ROOTS ?= / /usr /usr/local
++KBUILD_LIB_SEARCH_SUBS ?= lib/
++KBUILD_LIB_SEARCH_PATHS  ?= $(foreach root, $(KBUILD_LIB_SEARCH_ROOTS), $(addprefix $(root),$(KBUILD_LIB_SEARCH_SUBS)))
+ 
+ 
+ #
+@@ -1617,4 +1560,3 @@ endif
+ # end-of-file-content
+ __header_kmk__ := 1
+ endif # !__header_kmk__
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_Additions_Makefile.kmk b/virtualbox-svn/patches/patch-src_VBox_Additions_Makefile.kmk
new file mode 100644
index 0000000..8b3b671
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Additions_Makefile.kmk
@@ -0,0 +1,56 @@
+$NetBSD$
+
+--- src/VBox/Additions/Makefile.kmk.orig	2016-03-04 19:23:02.000000000 +0000
++++ src/VBox/Additions/Makefile.kmk
+@@ -55,6 +55,9 @@ ifndef VBOX_ONLY_VALIDATIONKIT
+  ifeq ($(KBUILD_TARGET),freebsd)
+   include $(PATH_SUB_CURRENT)/freebsd/Makefile.kmk
+  endif
++ ifeq ($(KBUILD_TARGET),netbsd)
++  include $(PATH_SUB_CURRENT)/netbsd/Makefile.kmk
++ endif
+  ifeq ($(KBUILD_TARGET),linux)
+   include $(PATH_SUB_CURRENT)/linux/Makefile.kmk
+  endif
+@@ -199,6 +202,18 @@ ifdef VBOX_WITH_ADDITIONS_ISO.freebsd.x8
+ 	VBoxFreeBSDAdditions-x86.tbz=$(VBOX_PATH_ADDITIONS.freebsd.x86)/VBoxFreeBSDAdditions.tbz
+ endif
+ 
++# NetBSD
++ifdef VBOX_WITH_ADDITIONS_ISO.netbsd.amd64
++ VBOX_PATH_ADDITIONS.netbsd.amd64 = $(PATH_OUT_BASE)/netbsd.amd64/$(KBUILD_TYPE)/bin/additions
++ GUESTADDITIONS_FILESPEC.netbsd.amd64 = \
++	VBoxNetBSDAdditions-amd64.tbz=$(VBOX_PATH_ADDITIONS.netbsd.amd64)/VBoxNetBSDAdditions.tbz
++endif
++ifdef VBOX_WITH_ADDITIONS_ISO.netbsd.x86
++ VBOX_PATH_ADDITIONS.netbsd.x86 = $(PATH_OUT_BASE)/netbsd.x86/$(KBUILD_TYPE)/bin/additions
++ GUESTADDITIONS_FILESPEC.netbsd.x86 = \
++	VBoxNetBSDAdditions-x86.tbz=$(VBOX_PATH_ADDITIONS.netbsd.x86)/VBoxNetBSDAdditions.tbz
++endif
++
+ # GNU/Linux
+ ifdef VBOX_WITH_ADDITIONS_ISO.linux.amd64
+  VBOX_PATH_ADDITIONS.linux.amd64 = $(PATH_OUT_BASE)/linux.amd64/$(KBUILD_TYPE)/bin/additions
+@@ -312,6 +327,8 @@ $(VBOX_PATH_ADDITIONS_ISO)/VBoxGuestAddi
+ 				$(GUESTADDITIONS_FILESPEC.linux.amd64) \
+ 				$(GUESTADDITIONS_FILESPEC.freebsd.x86) \
+ 				$(GUESTADDITIONS_FILESPEC.freebsd.amd64) \
++				$(GUESTADDITIONS_FILESPEC.netbsd.x86) \
++				$(GUESTADDITIONS_FILESPEC.netbsd.amd64) \
+ 				$(GUESTADDITIONS_FILESPEC.haiku.x86) \
+ 				$(GUESTADDITIONS_FILESPEC.darwin.x86) \
+ 				$(GUESTADDITIONS_FILESPEC.darwin.amd64) \
+@@ -335,6 +352,8 @@ $(VBOX_PATH_ADDITIONS_ISO)/VBoxGuestAddi
+ 		$(GUESTADDITIONS_FILESPEC.linux.amd64) \
+ 		$(GUESTADDITIONS_FILESPEC.freebsd.x86) \
+ 		$(GUESTADDITIONS_FILESPEC.freebsd.amd64) \
++		$(GUESTADDITIONS_FILESPEC.netbsd.x86) \
++		$(GUESTADDITIONS_FILESPEC.netbsd.amd64) \
+ 		$(GUESTADDITIONS_FILESPEC.haiku.x86) \
+ 		$(GUESTADDITIONS_FILESPEC.darwin.x86) \
+ 		$(GUESTADDITIONS_FILESPEC.darwin.amd64)
+@@ -349,4 +368,3 @@ $(VBOX_PATH_ADDITIONS_ISO)/VBoxGuestAddi
+ additions-iso: $(VBOX_PATH_ADDITIONS_ISO)/VBoxGuestAdditions.zip
+ 
+ endif
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_Additions_common_VBoxGuestLib_VBoxGuestR3Lib.cpp b/virtualbox-svn/patches/patch-src_VBox_Additions_common_VBoxGuestLib_VBoxGuestR3Lib.cpp
new file mode 100644
index 0000000..2c0062c
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Additions_common_VBoxGuestLib_VBoxGuestR3Lib.cpp
@@ -0,0 +1,44 @@
+$NetBSD$
+
+--- src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3Lib.cpp.orig	2016-03-04 19:23:10.000000000 +0000
++++ src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3Lib.cpp
+@@ -38,6 +38,7 @@
+ 
+ #elif defined(RT_OS_DARWIN) \
+    || defined(RT_OS_FREEBSD) \
++   || defined(RT_OS_NETBSD) \
+    || defined(RT_OS_HAIKU) \
+    || defined(RT_OS_LINUX) \
+    || defined(RT_OS_SOLARIS)
+@@ -252,7 +253,7 @@ static int vbglR3Init(const char *pszDev
+ 
+ #else
+ 
+-    /* The default implementation. (linux, solaris, freebsd, haiku) */
++    /* The default implementation. (linux, solaris, freebsd, netbsd, haiku) */
+     RTFILE File;
+     int rc = RTFileOpen(&File, pszDeviceName, RTFILE_O_READWRITE | RTFILE_O_OPEN | RTFILE_O_DENY_NONE);
+     if (RT_FAILURE(rc))
+@@ -394,7 +395,7 @@ int vbglR3DoIOCtl(unsigned iFunction, vo
+     return RTErrConvertFromOS2(rc);
+ 
+ #else
+-# if defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD)
++# if defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+     VBGLBIGREQ Hdr;
+     Hdr.u32Magic = VBGLBIGREQ_MAGIC;
+     Hdr.cbData = cbData;
+@@ -413,7 +414,7 @@ int vbglR3DoIOCtl(unsigned iFunction, vo
+     NOREF(cbData);
+ # endif
+ 
+-# if defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD) || defined(RT_OS_DARWIN) || defined(RT_OS_LINUX)
++# if defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD) || defined(RT_OS_DARWIN) || defined(RT_OS_LINUX) || defined(RT_OS_NETBSD)
+ #  ifdef VBOX_VBGLR3_XSERVER
+     int rc = xf86ioctl((int)g_File, iFunction, pvData);
+ #  else
+@@ -444,4 +445,3 @@ int vbglR3DoIOCtl(unsigned iFunction, vo
+ 
+ #endif
+ }
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_Additions_common_VBoxGuestLib_VBoxGuestR3LibLog.cpp b/virtualbox-svn/patches/patch-src_VBox_Additions_common_VBoxGuestLib_VBoxGuestR3LibLog.cpp
new file mode 100644
index 0000000..583aad0
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Additions_common_VBoxGuestLib_VBoxGuestR3LibLog.cpp
@@ -0,0 +1,18 @@
+$NetBSD$
+
+--- src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibLog.cpp.orig	2016-03-04 19:23:10.000000000 +0000
++++ src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3LibLog.cpp
+@@ -66,7 +66,7 @@ VBGLR3DECL(int) VbglR3WriteLog(const cha
+     RTMemFree(pvTmp);
+     return rc;
+ 
+-#elif 0 /** @todo Several OSes could take this route (solaris and freebsd for instance). */
++#elif 0 /** @todo Several OSes could take this route (solaris, freebsd and netbsd for instance). */
+     /*
+      * Handle the entire request in one go.
+      */
+@@ -88,4 +88,3 @@ VBGLR3DECL(int) VbglR3WriteLog(const cha
+     return rc;
+ #endif
+ }
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_Additions_common_VBoxGuest_Makefile.kmk b/virtualbox-svn/patches/patch-src_VBox_Additions_common_VBoxGuest_Makefile.kmk
new file mode 100644
index 0000000..6b4dd70
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Additions_common_VBoxGuest_Makefile.kmk
@@ -0,0 +1,78 @@
+$NetBSD$
+
+--- src/VBox/Additions/common/VBoxGuest/Makefile.kmk.orig	2016-03-04 19:23:09.000000000 +0000
++++ src/VBox/Additions/common/VBoxGuest/Makefile.kmk
+@@ -19,13 +19,14 @@ SUB_DEPTH = ../../../../..
+ include $(KBUILD_PATH)/subheader.kmk
+ 
+ 
+-if1of ($(KBUILD_TARGET), darwin freebsd haiku $(if $(defined VBOX_WITH_ADDITION_DRIVERS),linux,) os2 solaris win)
++if1of ($(KBUILD_TARGET), darwin freebsd netbsd haiku $(if $(defined VBOX_WITH_ADDITION_DRIVERS),linux,) os2 solaris win)
+  #
+  # VBoxGuest - The Guest Additions Driver.
+  #
+  SYSMODS += VBoxGuest
+  VBoxGuest_TEMPLATE      = VBOXGUESTR0
+  VBoxGuest_NAME.freebsd  = vboxguest
++ VBoxGuest_NAME.netbsd   = vboxguest
+  VBoxGuest_NAME.haiku    = vboxguest
+  VBoxGuest_NAME.linux    = vboxguest
+  VBoxGuest_NAME.solaris  = vboxguest
+@@ -54,10 +55,12 @@ if1of ($(KBUILD_TARGET), darwin freebsd 
+  VBoxGuest_DEPS.linux   += $(VBOX_SVN_REV_HEADER)
+  VBoxGuest_DEPS.haiku   += $(VBOX_SVN_REV_HEADER)
+  VBoxGuest_DEPS.freebsd += $(VBOX_SVN_REV_HEADER)
++ VBoxGuest_DEPS.netbsd  += $(VBOX_SVN_REV_HEADER)
+  VBoxGuest_DEPS.darwin  += $(VBOX_SVN_REV_HEADER)
+  VBoxGuest_DEFS          = VBGL_VBOXGUEST VBOX_WITH_HGCM
+  VBoxGuest_INCS          = .
+  VBoxGuest_INCS.freebsd  = $(VBoxGuest_0_OUTDIR) $(PATH_STAGE)/gen-sys-hdrs
++ VBoxGuest_INCS.netbsd  = $(VBoxGuest_0_OUTDIR) $(PATH_STAGE)/gen-sys-hdrs
+  VBoxGuest_INCS.linux    = ../../../Runtime/r0drv/linux
+  ifeq ($(KBUILD_HOST),solaris)
+   VBoxGuest_LDFLAGS.solaris         += -N misc/ctf
+@@ -80,7 +83,7 @@ if1of ($(KBUILD_TARGET), darwin freebsd 
+     VBoxGuest.cpp_SDKS   = $(VBOX_WINDDK_GST_WLH)
+    endif
+   endif # win
+-  ifn1of ($(KBUILD_TARGET), linux freebsd solaris haiku)
++  ifn1of ($(KBUILD_TARGET), linux freebsd netbsd solaris haiku)
+    VBoxGuest_SOURCES    = VBoxGuest-$(KBUILD_TARGET).cpp
+   else
+    VBoxGuest_SOURCES    = VBoxGuest-$(KBUILD_TARGET).c
+@@ -99,6 +102,10 @@ if1of ($(KBUILD_TARGET), darwin freebsd 
+   	$(PATH_STAGE)/gen-sys-hdrs/pci_if.h \
+   	$(PATH_STAGE)/gen-sys-hdrs/bus_if.h \
+   	$(PATH_STAGE)/gen-sys-hdrs/device_if.h
++  VBoxGuest_ORDERDEPS.netbsd = \
++  	$(PATH_STAGE)/gen-sys-hdrs/pci_if.h \
++  	$(PATH_STAGE)/gen-sys-hdrs/bus_if.h \
++  	$(PATH_STAGE)/gen-sys-hdrs/device_if.h
+   ifeq ($(KBUILD_TARGET),haiku)
+    # Haiku drivers cannot export symbols for other drivers, but modules can.
+    # Therefore vboxguest is a module containing the ring-0 guest lib, and vboxdev/vboxsf
+@@ -244,6 +251,19 @@ ifeq ($(KBUILD_TARGET),freebsd)
+ 
+ endif # FreeBSD
+ 
++ifeq ($(KBUILD_TARGET),netbsd)
++ #
++ # Install the source files and script(s).
++ #
++ include $(PATH_SUB_CURRENT)/netbsd/files_vboxguest
++ # sources and stuff.
++ INSTALLS += vboxguest-src
++ vboxguest-src_INST     = $(INST_ADDITIONS)src/vboxguest/
++ vboxguest-src_MODE     = a+r,u+w
++ vboxguest-src_SOURCES  = $(subst ",,$(FILES_VBOXGUEST_NOBIN))
++
++endif # FreeBSD
++
+ ifeq ($(KBUILD_TARGET),win)
+ #
+ # VBoxGuestInst - The installer.
+@@ -254,4 +274,3 @@ VBoxGuestInst_SOURCES = win/VBoxGuestIns
+ endif
+ 
+ include $(FILE_KBUILD_SUB_FOOTER)
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_Additions_common_VBoxGuest_VBoxGuest-netbsd.c b/virtualbox-svn/patches/patch-src_VBox_Additions_common_VBoxGuest_VBoxGuest-netbsd.c
new file mode 100644
index 0000000..37c99c8
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Additions_common_VBoxGuest_VBoxGuest-netbsd.c
@@ -0,0 +1,636 @@
+$NetBSD$
+
+--- src/VBox/Additions/common/VBoxGuest/VBoxGuest-netbsd.c.orig	2016-07-07 07:08:46.294122795 +0000
++++ src/VBox/Additions/common/VBoxGuest/VBoxGuest-netbsd.c
+@@ -0,0 +1,631 @@
++/*  VBoxGuest-netbsd.c $ */
++/** @file
++ * VirtualBox Guest Additions Driver for NetBSD.
++ */
++
++/*
++ * Copyright (C) 2007-2015 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.
++ */
++
++/** @todo r=bird: This must merge with SUPDrv-netbsd.c before long. The two
++ * source files should only differ on prefixes and the extra bits wrt to the
++ * pci device. I.e. it should be diffable so that fixes to one can easily be
++ * applied to the other. */
++
++
++/*********************************************************************************************************************************
++*   Header Files                                                                                                                 *
++*********************************************************************************************************************************/
++#include <sys/param.h>
++#undef PVM
++#include <sys/types.h>
++#include <sys/module.h>
++#include <sys/systm.h>
++#include <sys/errno.h>
++#include <sys/kernel.h>
++#include <sys/fcntl.h>
++#include <sys/conf.h>
++#include <sys/uio.h>
++#include <sys/bus.h>
++#include <sys/poll.h>
++#include <sys/selinfo.h>
++#include <sys/queue.h>
++#include <sys/lock.h>
++#include <sys/lockmgr.h>
++#include <sys/malloc.h>
++#include <sys/file.h>
++#include <sys/rman.h>
++#include <machine/bus.h>
++#include <machine/resource.h>
++#include <dev/pci/pcivar.h>
++#include <dev/pci/pcireg.h>
++
++#include "VBoxGuestInternal.h"
++#include <VBox/version.h>
++#include <VBox/log.h>
++#include <iprt/assert.h>
++#include <iprt/initterm.h>
++#include <iprt/process.h>
++#include <iprt/mem.h>
++#include <iprt/asm.h>
++
++
++/*********************************************************************************************************************************
++*   Defined Constants And Macros                                                                                                 *
++*********************************************************************************************************************************/
++/** The module name. */
++#define DEVICE_NAME  "vboxguest"
++
++
++/*********************************************************************************************************************************
++*   Structures and Typedefs                                                                                                      *
++*********************************************************************************************************************************/
++struct VBoxGuestDeviceState
++{
++    /** Resource ID of the I/O port */
++    int                iIOPortResId;
++    /** Pointer to the I/O port resource. */
++    struct resource   *pIOPortRes;
++    /** Start address of the IO Port. */
++    uint16_t           uIOPortBase;
++    /** Resource ID of the MMIO area */
++    int                iVMMDevMemResId;
++    /** Pointer to the MMIO resource. */
++    struct resource   *pVMMDevMemRes;
++    /** Handle of the MMIO resource. */
++    bus_space_handle_t VMMDevMemHandle;
++    /** Size of the memory area. */
++    bus_size_t         VMMDevMemSize;
++    /** Mapping of the register space */
++    void              *pMMIOBase;
++    /** IRQ number */
++    int                iIrqResId;
++    /** IRQ resource handle. */
++    struct resource   *pIrqRes;
++    /** Pointer to the IRQ handler. */
++    void              *pfnIrqHandler;
++    /** VMMDev version */
++    uint32_t           u32Version;
++};
++
++
++/*********************************************************************************************************************************
++*   Internal Functions                                                                                                           *
++*********************************************************************************************************************************/
++/*
++ * Character device file handlers.
++ */
++static d_fdopen_t vgdrvNetBSDOpen;
++static d_close_t  vgdrvNetBSDClose;
++static d_ioctl_t  vgdrvNetBSDIOCtl;
++static d_write_t  vgdrvNetBSDWrite;
++static d_read_t   vgdrvNetBSDRead;
++static d_poll_t   vgdrvNetBSDPoll;
++
++/*
++ * IRQ related functions.
++ */
++static void vgdrvNetBSDRemoveIRQ(device_t pDevice, void *pvState);
++static int  vgdrvNetBSDAddIRQ(device_t pDevice, void *pvState);
++static int  vgdrvNetBSDISR(void *pvState);
++
++
++/*********************************************************************************************************************************
++*   Global Variables                                                                                                             *
++*********************************************************************************************************************************/
++static MALLOC_DEFINE(M_VBOXGUEST, "vboxguest", "VirtualBox Guest Device Driver");
++
++#ifndef D_NEEDMINOR
++# define D_NEEDMINOR 0
++#endif
++
++/*
++ * The /dev/vboxguest character device entry points.
++ */
++static struct cdevsw    g_vgdrvNetBSDChrDevSW =
++{
++    .d_version =        D_VERSION,
++    .d_flags =          D_TRACKCLOSE | D_NEEDMINOR,
++    .d_fdopen =         vgdrvNetBSDOpen,
++    .d_close =          vgdrvNetBSDClose,
++    .d_ioctl =          vgdrvNetBSDIOCtl,
++    .d_read =           vgdrvNetBSDRead,
++    .d_write =          vgdrvNetBSDWrite,
++    .d_poll =           vgdrvNetBSDPoll,
++    .d_name =           "vboxguest"
++};
++
++/** Device extention & session data association structure. */
++static VBOXGUESTDEVEXT      g_DevExt;
++
++/** List of cloned device. Managed by the kernel. */
++static struct clonedevs    *g_pvgdrvNetBSDClones;
++/** The dev_clone event handler tag. */
++static eventhandler_tag     g_vgdrvNetBSDEHTag;
++/** Reference counter */
++static volatile uint32_t    cUsers;
++/** selinfo structure used for polling. */
++static struct selinfo       g_SelInfo;
++
++/**
++ * DEVFS event handler.
++ */
++static void vgdrvNetBSDClone(void *pvArg, struct ucred *pCred, char *pszName, int cchName, struct cdev **ppDev)
++{
++    int iUnit;
++    int rc;
++
++    Log(("vgdrvNetBSDClone: 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(("vgdrvNetBSDClone: iUnit=%d >= 256 - rejected\n", iUnit));
++        return;
++    }
++
++    Log(("vgdrvNetBSDClone: pszName=%s iUnit=%d\n", pszName, iUnit));
++
++    rc = clone_create(&g_pvgdrvNetBSDClones, &g_vgdrvNetBSDChrDevSW, &iUnit, ppDev, 0);
++    Log(("vgdrvNetBSDClone: clone_create -> %d; iUnit=%d\n", rc, iUnit));
++    if (rc)
++    {
++        *ppDev = make_dev(&g_vgdrvNetBSDChrDevSW,
++                          iUnit,
++                          UID_ROOT,
++                          GID_WHEEL,
++                          0664,
++                          "vboxguest%d", iUnit);
++        if (*ppDev)
++        {
++            dev_ref(*ppDev);
++            (*ppDev)->si_flags |= SI_CHEAPCLONE;
++            Log(("vgdrvNetBSDClone: 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(("vgdrvNetBSDClone: make_dev iUnit=%d failed\n", iUnit));
++    }
++    else
++        Log(("vgdrvNetBSDClone: Existing *ppDev=%p iUnit=%d si_drv1=%p si_drv2=%p\n",
++             *ppDev, iUnit, (*ppDev)->si_drv1, (*ppDev)->si_drv2));
++}
++
++/**
++ * File open handler
++ *
++ */
++static int vgdrvNetBSDOpen(struct cdev *pDev, int fOpen, struct thread *pTd)
++{
++    int                 rc;
++    PVBOXGUESTSESSION   pSession;
++
++    LogFlow(("vgdrvNetBSDOpen:\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 = VGDrvCommonCreateUserSession(&g_DevExt, &pSession);
++    if (RT_SUCCESS(rc))
++    {
++        if (ASMAtomicCmpXchgPtr(&pDev->si_drv1, pSession, (void *)0x42))
++        {
++            Log(("vgdrvNetBSDOpen: success - g_DevExt=%p pSession=%p rc=%d pid=%d\n", &g_DevExt, pSession, rc, (int)RTProcSelf()));
++            ASMAtomicIncU32(&cUsers);
++            return 0;
++        }
++
++        VGDrvCommonCloseSession(&g_DevExt, pSession);
++    }
++
++    LogRel(("vgdrvNetBSDOpen: failed. rc=%d\n", rc));
++    return RTErrConvertToErrno(rc);
++}
++
++/**
++ * File close handler
++ *
++ */
++static int vgdrvNetBSDClose(struct cdev *pDev, int fFile, int DevType, struct thread *pTd)
++{
++    PVBOXGUESTSESSION pSession = (PVBOXGUESTSESSION)pDev->si_drv1;
++    Log(("vgdrvNetBSDClose: fFile=%#x pSession=%p\n", fFile, pSession));
++
++    /*
++     * Close the session if it's still hanging on to the device...
++     */
++    if (VALID_PTR(pSession))
++    {
++        VGDrvCommonCloseSession(&g_DevExt, pSession);
++        if (!ASMAtomicCmpXchgPtr(&pDev->si_drv1, NULL, pSession))
++            Log(("vgdrvNetBSDClose: 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(("vgdrvNetBSDClose: si_drv1=%p!\n", pSession));
++    return 0;
++}
++
++/**
++ * IOCTL handler
++ *
++ */
++static int vgdrvNetBSDIOCtl(struct cdev *pDev, u_long ulCmd, caddr_t pvData, int fFile, struct thread *pTd)
++{
++    LogFlow(("vgdrvNetBSDIOCtl\n"));
++
++    int rc = 0;
++
++    /*
++     * Validate the input.
++     */
++    PVBOXGUESTSESSION pSession = (PVBOXGUESTSESSION)pDev->si_drv1;
++    if (RT_UNLIKELY(!VALID_PTR(pSession)))
++        return EINVAL;
++
++    /*
++     * Validate the request wrapper.
++     */
++    if (IOCPARM_LEN(ulCmd) != sizeof(VBGLBIGREQ))
++    {
++        Log(("vgdrvNetBSDIOCtl: bad request %lu size=%lu expected=%d\n", ulCmd, IOCPARM_LEN(ulCmd), sizeof(VBGLBIGREQ)));
++        return ENOTTY;
++    }
++
++    PVBGLBIGREQ ReqWrap = (PVBGLBIGREQ)pvData;
++    if (ReqWrap->u32Magic != VBGLBIGREQ_MAGIC)
++    {
++        Log(("vgdrvNetBSDIOCtl: bad magic %#x; pArg=%p Cmd=%lu.\n", ReqWrap->u32Magic, pvData, ulCmd));
++        return EINVAL;
++    }
++    if (RT_UNLIKELY(   ReqWrap->cbData == 0
++                    || ReqWrap->cbData > _1M*16))
++    {
++        printf("vgdrvNetBSDIOCtl: bad size %#x; pArg=%p Cmd=%lu.\n", ReqWrap->cbData, pvData, ulCmd);
++        return EINVAL;
++    }
++
++    /*
++     * Read the request.
++     */
++    void *pvBuf = RTMemTmpAlloc(ReqWrap->cbData);
++    if (RT_UNLIKELY(!pvBuf))
++    {
++        Log(("vgdrvNetBSDIOCtl: 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(("vgdrvNetBSDIOCtl: 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(("vgdrvNetBSDIOCtl: pvBuf invalid pointer %p\n", pvBuf));
++        return EINVAL;
++    }
++    Log(("vgdrvNetBSDIOCtl: pSession=%p pid=%d.\n", pSession, (int)RTProcSelf()));
++
++    /*
++     * Process the IOCtl.
++     */
++    size_t cbDataReturned;
++    rc = VGDrvCommonIoCtl(ulCmd, &g_DevExt, pSession, pvBuf, ReqWrap->cbData, &cbDataReturned);
++    if (RT_SUCCESS(rc))
++    {
++        rc = 0;
++        if (RT_UNLIKELY(cbDataReturned > ReqWrap->cbData))
++        {
++            Log(("vgdrvNetBSDIOCtl: too much output data %d expected %d\n", cbDataReturned, ReqWrap->cbData));
++            cbDataReturned = ReqWrap->cbData;
++        }
++        if (cbDataReturned > 0)
++        {
++            rc = copyout(pvBuf, (void *)(uintptr_t)ReqWrap->pvDataR3, cbDataReturned);
++            if (RT_UNLIKELY(rc))
++            {
++                Log(("vgdrvNetBSDIOCtl: copyout failed; pvBuf=%p pArg=%p Cmd=%lu. rc=%d\n", pvBuf, pvData, ulCmd, rc));
++                rc = EFAULT;
++            }
++        }
++    }
++    else
++    {
++        Log(("vgdrvNetBSDIOCtl: VGDrvCommonIoCtl failed. rc=%d\n", rc));
++        rc = EFAULT;
++    }
++    RTMemTmpFree(pvBuf);
++    return rc;
++}
++
++static int vgdrvNetBSDPoll(struct cdev *pDev, int fEvents, struct thread *td)
++{
++    int fEventsProcessed;
++
++    LogFlow(("vgdrvNetBSDPoll: fEvents=%d\n", fEvents));
++
++    PVBOXGUESTSESSION pSession = (PVBOXGUESTSESSION)pDev->si_drv1;
++    if (RT_UNLIKELY(!VALID_PTR(pSession))) {
++        Log(("vgdrvNetBSDPoll: no state data for %s\n", devtoname(pDev)));
++        return (fEvents & (POLLHUP|POLLIN|POLLRDNORM|POLLOUT|POLLWRNORM));
++    }
++
++    uint32_t u32CurSeq = ASMAtomicUoReadU32(&g_DevExt.u32MousePosChangedSeq);
++    if (pSession->u32MousePosChangedSeq != u32CurSeq)
++    {
++        fEventsProcessed = fEvents & (POLLIN | POLLRDNORM);
++        pSession->u32MousePosChangedSeq = u32CurSeq;
++    }
++    else
++    {
++        fEventsProcessed = 0;
++
++        selrecord(td, &g_SelInfo);
++    }
++
++    return fEventsProcessed;
++}
++
++static int vgdrvNetBSDWrite(struct cdev *pDev, struct uio *pUio, int fIo)
++{
++    return 0;
++}
++
++static int vgdrvNetBSDRead(struct cdev *pDev, struct uio *pUio, int fIo)
++{
++    return 0;
++}
++
++static int vgdrvNetBSDDetach(device_t pDevice)
++{
++    struct VBoxGuestDeviceState *pState = device_get_softc(pDevice);
++
++    if (cUsers > 0)
++        return EBUSY;
++
++    /*
++     * Reverse what we did in vgdrvNetBSDAttach.
++     */
++    if (g_vgdrvNetBSDEHTag != NULL)
++        EVENTHANDLER_DEREGISTER(dev_clone, g_vgdrvNetBSDEHTag);
++
++    clone_cleanup(&g_pvgdrvNetBSDClones);
++
++    vgdrvNetBSDRemoveIRQ(pDevice, pState);
++
++    if (pState->pVMMDevMemRes)
++        bus_release_resource(pDevice, SYS_RES_MEMORY, pState->iVMMDevMemResId, pState->pVMMDevMemRes);
++    if (pState->pIOPortRes)
++        bus_release_resource(pDevice, SYS_RES_IOPORT, pState->iIOPortResId, pState->pIOPortRes);
++
++    VGDrvCommonDeleteDevExt(&g_DevExt);
++
++    RTR0Term();
++
++    return 0;
++}
++
++/**
++ * Interrupt service routine.
++ *
++ * @returns Whether the interrupt was from VMMDev.
++ * @param   pvState Opaque pointer to the device state.
++ */
++static int vgdrvNetBSDISR(void *pvState)
++{
++    LogFlow(("vgdrvNetBSDISR: pvState=%p\n", pvState));
++
++    bool fOurIRQ = VGDrvCommonISR(&g_DevExt);
++
++    return fOurIRQ ? 0 : 1;
++}
++
++void VGDrvNativeISRMousePollEvent(PVBOXGUESTDEVEXT pDevExt)
++{
++    LogFlow(("VGDrvNativeISRMousePollEvent:\n"));
++
++    /*
++     * Wake up poll waiters.
++     */
++    selwakeup(&g_SelInfo);
++}
++
++/**
++ * Sets IRQ for VMMDev.
++ *
++ * @returns NetBSD error code.
++ * @param   pDevice  Pointer to the device info structure.
++ * @param   pvState  Pointer to the state info structure.
++ */
++static int vgdrvNetBSDAddIRQ(device_t pDevice, void *pvState)
++{
++    int iResId = 0;
++    int rc = 0;
++    struct VBoxGuestDeviceState *pState = (struct VBoxGuestDeviceState *)pvState;
++
++    pState->pIrqRes = bus_alloc_resource_any(pDevice, SYS_RES_IRQ, &iResId, RF_SHAREABLE | RF_ACTIVE);
++
++    rc = bus_setup_intr(pDevice, pState->pIrqRes, INTR_TYPE_BIO, (driver_intr_t *)vgdrvNetBSDISR, pState, &pState->pfnIrqHandler);
++
++    if (rc)
++    {
++        pState->pfnIrqHandler = NULL;
++        return VERR_DEV_IO_ERROR;
++    }
++
++    pState->iIrqResId = iResId;
++
++    return VINF_SUCCESS;
++}
++
++/**
++ * Removes IRQ for VMMDev.
++ *
++ * @param   pDevice  Pointer to the device info structure.
++ * @param   pvState  Opaque pointer to the state info structure.
++ */
++static void vgdrvNetBSDRemoveIRQ(device_t pDevice, void *pvState)
++{
++    struct VBoxGuestDeviceState *pState = (struct VBoxGuestDeviceState *)pvState;
++
++    if (pState->pIrqRes)
++    {
++        bus_teardown_intr(pDevice, pState->pIrqRes, pState->pfnIrqHandler);
++        bus_release_resource(pDevice, SYS_RES_IRQ, 0, pState->pIrqRes);
++    }
++}
++
++static int vgdrvNetBSDAttach(device_t pDevice)
++{
++    int rc;
++    int iResId;
++    struct VBoxGuestDeviceState *pState;
++
++    cUsers = 0;
++
++    /*
++     * Initialize IPRT R0 driver, which internally calls OS-specific r0 init.
++     */
++    rc = RTR0Init(0);
++    if (RT_FAILURE(rc))
++    {
++        LogFunc(("RTR0Init failed.\n"));
++        return ENXIO;
++    }
++
++    pState = device_get_softc(pDevice);
++
++    /*
++     * Allocate I/O port resource.
++     */
++    iResId                 = PCIR_BAR(0);
++    pState->pIOPortRes     = bus_alloc_resource_any(pDevice, SYS_RES_IOPORT, &iResId, RF_ACTIVE);
++    pState->uIOPortBase    = rman_get_start(pState->pIOPortRes);
++    pState->iIOPortResId   = iResId;
++    if (pState->uIOPortBase)
++    {
++        /*
++         * Map the MMIO region.
++         */
++        iResId                   = PCIR_BAR(1);
++        pState->pVMMDevMemRes    = bus_alloc_resource_any(pDevice, SYS_RES_MEMORY, &iResId, RF_ACTIVE);
++        pState->VMMDevMemHandle  = rman_get_bushandle(pState->pVMMDevMemRes);
++        pState->VMMDevMemSize    = rman_get_size(pState->pVMMDevMemRes);
++
++        pState->pMMIOBase        = rman_get_virtual(pState->pVMMDevMemRes);
++        pState->iVMMDevMemResId  = iResId;
++        if (pState->pMMIOBase)
++        {
++            /*
++             * Call the common device extension initializer.
++             */
++            rc = VGDrvCommonInitDevExt(&g_DevExt, pState->uIOPortBase,
++                                       pState->pMMIOBase, pState->VMMDevMemSize,
++#if ARCH_BITS == 64
++                                       VBOXOSTYPE_NetBSD_x64,
++#else
++                                       VBOXOSTYPE_NetBSD,
++#endif
++                                       VMMDEV_EVENT_MOUSE_POSITION_CHANGED);
++            if (RT_SUCCESS(rc))
++            {
++                /*
++                 * Add IRQ of VMMDev.
++                 */
++                rc = vgdrvNetBSDAddIRQ(pDevice, pState);
++                if (RT_SUCCESS(rc))
++                {
++                    /*
++                     * Configure device cloning.
++                     */
++                    clone_setup(&g_pvgdrvNetBSDClones);
++                    g_vgdrvNetBSDEHTag = EVENTHANDLER_REGISTER(dev_clone, vgdrvNetBSDClone, 0, 1000);
++                    if (g_vgdrvNetBSDEHTag)
++                    {
++                        printf(DEVICE_NAME ": loaded successfully\n");
++                        return 0;
++                    }
++
++                    printf(DEVICE_NAME ": EVENTHANDLER_REGISTER(dev_clone,,,) failed\n");
++                    clone_cleanup(&g_pvgdrvNetBSDClones);
++                    vgdrvNetBSDRemoveIRQ(pDevice, pState);
++                }
++                else
++                    printf((DEVICE_NAME ": VGDrvCommonInitDevExt failed.\n"));
++                VGDrvCommonDeleteDevExt(&g_DevExt);
++            }
++            else
++                printf((DEVICE_NAME ": vgdrvNetBSDAddIRQ failed.\n"));
++        }
++        else
++            printf((DEVICE_NAME ": MMIO region setup failed.\n"));
++    }
++    else
++        printf((DEVICE_NAME ": IOport setup failed.\n"));
++
++    RTR0Term();
++    return ENXIO;
++}
++
++static int vgdrvNetBSDProbe(device_t pDevice)
++{
++    if ((pci_get_vendor(pDevice) == VMMDEV_VENDORID) && (pci_get_device(pDevice) == VMMDEV_DEVICEID))
++        return 0;
++
++    return ENXIO;
++}
++
++static device_method_t vgdrvNetBSDMethods[] =
++{
++    /* Device interface. */
++    DEVMETHOD(device_probe,  vgdrvNetBSDProbe),
++    DEVMETHOD(device_attach, vgdrvNetBSDAttach),
++    DEVMETHOD(device_detach, vgdrvNetBSDDetach),
++    {0,0}
++};
++
++static driver_t vgdrvNetBSDDriver =
++{
++    DEVICE_NAME,
++    vgdrvNetBSDMethods,
++    sizeof(struct VBoxGuestDeviceState),
++};
++
++static devclass_t vgdrvNetBSDClass;
++
++DRIVER_MODULE(vboxguest, pci, vgdrvNetBSDDriver, vgdrvNetBSDClass, 0, 0);
++MODULE_VERSION(vboxguest, 1);
++
++/* Common code that depend on g_DevExt. */
++#include "VBoxGuestIDC-unix.c.h"
diff --git a/virtualbox-svn/patches/patch-src_VBox_Additions_common_VBoxGuest_VBoxGuest.cpp b/virtualbox-svn/patches/patch-src_VBox_Additions_common_VBoxGuest_VBoxGuest.cpp
new file mode 100644
index 0000000..3c2072c
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Additions_common_VBoxGuest_VBoxGuest.cpp
@@ -0,0 +1,18 @@
+$NetBSD$
+
+--- src/VBox/Additions/common/VBoxGuest/VBoxGuest.cpp.orig	2016-03-04 19:23:09.000000000 +0000
++++ src/VBox/Additions/common/VBoxGuest/VBoxGuest.cpp
+@@ -68,7 +68,7 @@
+ # include <iprt/thread.h>
+ #endif
+ #include "version-generated.h"
+-#if defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD)
++#if defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+ # include "revision-generated.h"
+ #endif
+ #ifdef RT_OS_WINDOWS
+@@ -3745,4 +3745,3 @@ bool VGDrvCommonISR(PVBOXGUESTDEVEXT pDe
+     NOREF(rc);
+     return fOurIrq;
+ }
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_Additions_common_VBoxGuest_VBoxGuestInternal.h b/virtualbox-svn/patches/patch-src_VBox_Additions_common_VBoxGuest_VBoxGuestInternal.h
new file mode 100644
index 0000000..ff9c988
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Additions_common_VBoxGuest_VBoxGuestInternal.h
@@ -0,0 +1,18 @@
+$NetBSD$
+
+--- src/VBox/Additions/common/VBoxGuest/VBoxGuestInternal.h.orig	2016-03-04 19:23:10.000000000 +0000
++++ src/VBox/Additions/common/VBoxGuest/VBoxGuestInternal.h
+@@ -249,7 +249,7 @@ typedef struct VBOXGUESTSESSION
+ {
+     /** The list node. */
+     RTLISTNODE                  ListNode;
+-#if defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD) || defined(RT_OS_OS2) || defined(RT_OS_SOLARIS)
++#if defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD) || defined(RT_OS_OS2) || defined(RT_OS_SOLARIS) || defined(RT_OS_NETBSD)
+     /** Pointer to the next session with the same hash. */
+     PVBOXGUESTSESSION           pNextHash;
+ #endif
+@@ -348,4 +348,3 @@ int VGDrvNtIOCtl_DpcLatencyChecker(void)
+ RT_C_DECLS_END
+ 
+ #endif
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_Additions_common_VBoxGuest_netbsd_Makefile b/virtualbox-svn/patches/patch-src_VBox_Additions_common_VBoxGuest_netbsd_Makefile
new file mode 100644
index 0000000..e7be1f7
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Additions_common_VBoxGuest_netbsd_Makefile
@@ -0,0 +1,171 @@
+$NetBSD$
+
+--- src/VBox/Additions/common/VBoxGuest/netbsd/Makefile.orig	2016-07-06 20:08:38.705500122 +0000
++++ src/VBox/Additions/common/VBoxGuest/netbsd/Makefile
+@@ -0,0 +1,166 @@
++#  Makefile $
++## @file
++# VirtualBox Guest Additions Module Makefile.
++#
++
++#
++# Copyright (C) 2006-2015 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.
++#
++KMOD = vboxguest
++
++CFLAGS += -DRT_OS_NETBSD -DIN_RING0 -DIN_RT_R0 -DIN_SUP_R0 -DVBOX -DRT_WITH_VBOX -Iinclude -I. -Ir0drv -w -DVBGL_VBOXGUEST -DVBOX_WITH_HGCM -DVBOX_WITH_64_BITS_GUESTS
++
++.if (${MACHINE_ARCH} == "i386")
++ CFLAGS += -DRT_ARCH_X86
++.elif (${MACHINE_ARCH} == "amd64")
++ CFLAGS += -DRT_ARCH_AMD64
++.endif
++
++SRCS = \
++	VBoxGuest.c \
++	VBoxGuest-netbsd.c \
++	GenericRequest.c \
++	HGCMInternal.c \
++	Init.c \
++	PhysHeap.c \
++	SysHlp.c \
++	VMMDev.c
++
++# Include needed interface headers so they are created during build
++SRCS += \
++	device_if.h \
++	bus_if.h \
++	pci_if.h \
++
++.PATH:	${.CURDIR}/alloc
++SRCS += \
++	heapsimple.c
++
++.PATH:	${.CURDIR}/common/err
++SRCS += \
++	RTErrConvertFromErrno.c \
++	RTErrConvertToErrno.c
++
++.PATH:	${.CURDIR}/common/log
++SRCS += \
++	log.c \
++	logellipsis.c \
++	logrel.c \
++	logrelellipsis.c \
++	logcom.c \
++	logformat.c
++
++.PATH:	${.CURDIR}/common/misc
++SRCS += \
++	RTAssertMsg1Weak.c \
++	RTAssertMsg2.c \
++	RTAssertMsg2Add.c \
++	RTAssertMsg2AddWeak.c \
++	RTAssertMsg2AddWeakV.c \
++	RTAssertMsg2Weak.c \
++	RTAssertMsg2WeakV.c \
++	assert.c \
++	handletable.c \
++	handletablectx.c \
++	once.c \
++	thread.c
++
++.PATH:	${.CURDIR}/common/string
++SRCS += \
++	RTStrCopy.c \
++	RTStrCopyEx.c \
++	RTStrCopyP.c \
++	strformat.c \
++	strformatrt.c \
++	strformattype.c \
++	strprintf.c \
++	strtonum.c \
++	memchr.c
++
++.PATH:	${.CURDIR}/common/rand
++SRCS += \
++	rand.c \
++	randadv.c \
++	randparkmiller.c
++
++.PATH:	${.CURDIR}/common/path
++SRCS += \
++	RTPathStripFilename.c
++
++.PATH:	${.CURDIR}/common/checksum
++SRCS += \
++	crc32.c \
++	ipv4.c
++
++.PATH:	${.CURDIR}/common/table
++SRCS += \
++	avlpv.c
++
++.PATH:	${.CURDIR}/common/time
++SRCS += \
++	time.c
++
++.PATH:	${.CURDIR}/generic
++SRCS += \
++	uuid-generic.c \
++	RTAssertShouldPanic-generic.c \
++	RTLogWriteDebugger-generic.c \
++	RTLogWriteStdOut-stub-generic.c \
++	RTLogWriteStdErr-stub-generic.c \
++	RTRandAdvCreateSystemFaster-generic.c \
++	RTRandAdvCreateSystemTruer-generic.c \
++	RTSemEventWait-2-ex-generic.c \
++	RTSemEventWaitNoResume-2-ex-generic.c \
++	RTSemEventMultiWait-2-ex-generic.c \
++	RTSemEventMultiWaitNoResume-2-ex-generic.c \
++	RTTimerCreate-generic.c \
++	timer-generic.c \
++	errvars-generic.c \
++	mppresent-generic.c
++
++.PATH:	${.CURDIR}/r0drv
++SRCS += \
++	alloc-r0drv.c \
++	initterm-r0drv.c \
++	memobj-r0drv.c \
++	powernotification-r0drv.c
++
++.PATH:	${.CURDIR}/r0drv/netbsd
++SRCS += \
++	assert-r0drv-netbsd.c \
++	alloc-r0drv-netbsd.c \
++	initterm-r0drv-netbsd.c \
++	memobj-r0drv-netbsd.c \
++	memuserkernel-r0drv-netbsd.c \
++	mp-r0drv-netbsd.c \
++	process-r0drv-netbsd.c \
++	semevent-r0drv-netbsd.c \
++	semeventmulti-r0drv-netbsd.c \
++	semfastmutex-r0drv-netbsd.c \
++	semmutex-r0drv-netbsd.c \
++	spinlock-r0drv-netbsd.c \
++	thread-r0drv-netbsd.c \
++	thread2-r0drv-netbsd.c \
++	time-r0drv-netbsd.c \
++	timer-r0drv-netbsd.c
++
++.PATH:	${.CURDIR}/r0drv/generic
++SRCS += \
++	semspinmutex-r0drv-generic.c \
++	mpnotification-r0drv-generic.c \
++	RTMpIsCpuWorkPending-r0drv-generic.c
++
++.PATH:	${.CURDIR}/VBox
++SRCS += \
++	log-vbox.c \
++	logbackdoor.c
++
++.include <bsd.kmod.mk>
diff --git a/virtualbox-svn/patches/patch-src_VBox_Additions_common_VBoxGuest_netbsd_files__vboxguest b/virtualbox-svn/patches/patch-src_VBox_Additions_common_VBoxGuest_netbsd_files__vboxguest
new file mode 100644
index 0000000..93b1fb6
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Additions_common_VBoxGuest_netbsd_files__vboxguest
@@ -0,0 +1,204 @@
+$NetBSD$
+
+--- src/VBox/Additions/common/VBoxGuest/netbsd/files_vboxguest.orig	2016-07-07 07:08:46.332361686 +0000
++++ src/VBox/Additions/common/VBoxGuest/netbsd/files_vboxguest
+@@ -0,0 +1,199 @@
++#!/bin/sh
++#  files_vboxguest $
++## @file
++# Shared file between Makefile.kmk and export_modules
++#
++
++#
++# Copyright (C) 2007-2015 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.
++#
++
++FILES_VBOXGUEST_NOBIN=" \
++    ${PATH_ROOT}/include/iprt/alloca.h=>include/iprt/alloca.h \
++    ${PATH_ROOT}/include/iprt/alloc.h=>include/iprt/alloc.h \
++    ${PATH_ROOT}/include/iprt/asm.h=>include/iprt/asm.h \
++    ${PATH_ROOT}/include/iprt/asm-amd64-x86.h=>include/iprt/asm-amd64-x86.h \
++    ${PATH_ROOT}/include/iprt/asm-math.h=>include/iprt/asm-math.h \
++    ${PATH_ROOT}/include/iprt/assert.h=>include/iprt/assert.h \
++    ${PATH_ROOT}/include/iprt/avl.h=>include/iprt/avl.h \
++    ${PATH_ROOT}/include/iprt/cdefs.h=>include/iprt/cdefs.h \
++    ${PATH_ROOT}/include/iprt/cpuset.h=>include/iprt/cpuset.h \
++    ${PATH_ROOT}/include/iprt/ctype.h=>include/iprt/ctype.h \
++    ${PATH_ROOT}/include/iprt/err.h=>include/iprt/err.h \
++    ${PATH_ROOT}/include/iprt/errno.h=>include/iprt/errno.h \
++    ${PATH_ROOT}/include/iprt/heap.h=>include/iprt/heap.h \
++    ${PATH_ROOT}/include/iprt/handletable.h=>include/iprt/handletable.h \
++    ${PATH_ROOT}/include/iprt/initterm.h=>include/iprt/initterm.h \
++    ${PATH_ROOT}/include/iprt/latin1.h=>include/iprt/latin1.h \
++    ${PATH_ROOT}/include/iprt/list.h=>include/iprt/list.h \
++    ${PATH_ROOT}/include/iprt/lockvalidator.h=>include/iprt/lockvalidator.h \
++    ${PATH_ROOT}/include/iprt/log.h=>include/iprt/log.h \
++    ${PATH_ROOT}/include/iprt/mangling.h=>include/iprt/mangling.h \
++    ${PATH_ROOT}/include/iprt/mem.h=>include/iprt/mem.h \
++    ${PATH_ROOT}/include/iprt/memobj.h=>include/iprt/memobj.h \
++    ${PATH_ROOT}/include/iprt/mp.h=>include/iprt/mp.h \
++    ${PATH_ROOT}/include/iprt/param.h=>include/iprt/param.h \
++    ${PATH_ROOT}/include/iprt/power.h=>include/iprt/power.h \
++    ${PATH_ROOT}/include/iprt/process.h=>include/iprt/process.h \
++    ${PATH_ROOT}/include/iprt/semaphore.h=>include/iprt/semaphore.h \
++    ${PATH_ROOT}/include/iprt/spinlock.h=>include/iprt/spinlock.h \
++    ${PATH_ROOT}/include/iprt/stdarg.h=>include/iprt/stdarg.h \
++    ${PATH_ROOT}/include/iprt/stdint.h=>include/iprt/stdint.h \
++    ${PATH_ROOT}/include/iprt/string.h=>include/iprt/string.h \
++    ${PATH_ROOT}/include/iprt/thread.h=>include/iprt/thread.h \
++    ${PATH_ROOT}/include/iprt/time.h=>include/iprt/time.h \
++    ${PATH_ROOT}/include/iprt/timer.h=>include/iprt/timer.h \
++    ${PATH_ROOT}/include/iprt/types.h=>include/iprt/types.h \
++    ${PATH_ROOT}/include/iprt/utf16.h=>include/iprt/utf16.h \
++    ${PATH_ROOT}/include/iprt/uuid.h=>include/iprt/uuid.h \
++    ${PATH_ROOT}/include/iprt/crc.h=>include/iprt/crc.h \
++    ${PATH_ROOT}/include/iprt/net.h=>include/iprt/net.h \
++    ${PATH_ROOT}/include/iprt/rand.h=>include/iprt/rand.h \
++    ${PATH_ROOT}/include/iprt/path.h=>include/iprt/path.h \
++    ${PATH_ROOT}/include/iprt/once.h=>include/iprt/once.h \
++    ${PATH_ROOT}/include/iprt/critsect.h=>include/iprt/critsect.h \
++    ${PATH_ROOT}/include/iprt/x86.h=>include/iprt/x86.h \
++    ${PATH_ROOT}/include/iprt/nocrt/limits.h=>include/iprt/nocrt/limits.h \
++    ${PATH_ROOT}/include/VBox/cdefs.h=>include/VBox/cdefs.h \
++    ${PATH_ROOT}/include/VBox/err.h=>include/VBox/err.h \
++    ${PATH_ROOT}/include/VBox/log.h=>include/VBox/log.h \
++    ${PATH_ROOT}/include/VBox/param.h=>include/VBox/param.h \
++    ${PATH_ROOT}/include/VBox/types.h=>include/VBox/types.h \
++    ${PATH_ROOT}/include/VBox/ostypes.h=>include/VBox/ostypes.h \
++    ${PATH_ROOT}/include/VBox/VMMDev.h=>include/VBox/VMMDev.h \
++    ${PATH_ROOT}/include/VBox/VMMDev2.h=>include/VBox/VMMDev2.h \
++    ${PATH_ROOT}/include/VBox/VBoxGuest.h=>include/VBox/VBoxGuest.h \
++    ${PATH_ROOT}/include/VBox/VBoxGuest2.h=>include/VBox/VBoxGuest2.h \
++    ${PATH_ROOT}/include/VBox/VBoxGuestLib.h=>include/VBox/VBoxGuestLib.h \
++    ${PATH_ROOT}/include/VBox/VBoxGuestMangling.h=>include/VBox/VBoxGuestMangling.h \
++    ${PATH_ROOT}/include/VBox/version.h=>include/VBox/version.h \
++    ${PATH_ROOT}/src/VBox/Additions/common/VBoxGuest/VBoxGuest.cpp=>VBoxGuest.c \
++    ${PATH_ROOT}/src/VBox/Additions/common/VBoxGuest/VBoxGuest-netbsd.c=>VBoxGuest-netbsd.c \
++    ${PATH_ROOT}/src/VBox/Additions/common/VBoxGuest/VBoxGuestIDC-unix.c.h=>VBoxGuestIDC-unix.c.h \
++    ${PATH_ROOT}/src/VBox/Additions/common/VBoxGuest/VBoxGuestInternal.h=>VBoxGuestInternal.h \
++    ${PATH_ROOT}/src/VBox/Additions/common/VBoxGuest/netbsd/Makefile=>Makefile \
++    ${PATH_ROOT}/src/VBox/Additions/common/VBoxGuestLib/GenericRequest.cpp=>GenericRequest.c \
++    ${PATH_ROOT}/src/VBox/Additions/common/VBoxGuestLib/HGCMInternal.cpp=>HGCMInternal.c \
++    ${PATH_ROOT}/src/VBox/Additions/common/VBoxGuestLib/Init.cpp=>Init.c \
++    ${PATH_ROOT}/src/VBox/Additions/common/VBoxGuestLib/PhysHeap.cpp=>PhysHeap.c \
++    ${PATH_ROOT}/src/VBox/Additions/common/VBoxGuestLib/SysHlp.h=>SysHlp.h \
++    ${PATH_ROOT}/src/VBox/Additions/common/VBoxGuestLib/SysHlp.cpp=>SysHlp.c \
++    ${PATH_ROOT}/src/VBox/Additions/common/VBoxGuestLib/VBGLInternal.h=>VBGLInternal.h \
++    ${PATH_ROOT}/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestLog.h=>VBoxGuestLog.h \
++    ${PATH_ROOT}/src/VBox/Additions/common/VBoxGuestLib/VMMDev.cpp=>VMMDev.c \
++    ${PATH_ROOT}/src/VBox/Runtime/common/alloc/heapsimple.cpp=>alloc/heapsimple.c \
++    ${PATH_ROOT}/src/VBox/Runtime/common/err/RTErrConvertFromErrno.cpp=>common/err/RTErrConvertFromErrno.c \
++    ${PATH_ROOT}/src/VBox/Runtime/common/err/RTErrConvertToErrno.cpp=>common/err/RTErrConvertToErrno.c \
++    ${PATH_ROOT}/src/VBox/Runtime/common/log/log.cpp=>common/log/log.c \
++    ${PATH_ROOT}/src/VBox/Runtime/common/log/logellipsis.cpp=>common/log/logellipsis.c \
++    ${PATH_ROOT}/src/VBox/Runtime/common/log/logrel.cpp=>common/log/logrel.c \
++    ${PATH_ROOT}/src/VBox/Runtime/common/log/logrelellipsis.cpp=>common/log/logrelellipsis.c \
++    ${PATH_ROOT}/src/VBox/Runtime/common/log/logcom.cpp=>common/log/logcom.c \
++    ${PATH_ROOT}/src/VBox/Runtime/common/log/logformat.cpp=>common/log/logformat.c \
++    ${PATH_ROOT}/src/VBox/Runtime/common/misc/handletable.cpp=>common/misc/handletable.c \
++    ${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/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 \
++    ${PATH_ROOT}/src/VBox/Runtime/common/misc/RTAssertMsg2Add.cpp=>common/misc/RTAssertMsg2Add.c \
++    ${PATH_ROOT}/src/VBox/Runtime/common/misc/RTAssertMsg2AddWeak.cpp=>common/misc/RTAssertMsg2AddWeak.c \
++    ${PATH_ROOT}/src/VBox/Runtime/common/misc/RTAssertMsg2AddWeakV.cpp=>common/misc/RTAssertMsg2AddWeakV.c \
++    ${PATH_ROOT}/src/VBox/Runtime/common/misc/RTAssertMsg2Weak.cpp=>common/misc/RTAssertMsg2Weak.c \
++    ${PATH_ROOT}/src/VBox/Runtime/common/misc/RTAssertMsg2WeakV.cpp=>common/misc/RTAssertMsg2WeakV.c \
++    ${PATH_ROOT}/src/VBox/Runtime/common/misc/assert.cpp=>common/misc/assert.c \
++    ${PATH_ROOT}/src/VBox/Runtime/common/string/RTStrCopy.cpp=>common/string/RTStrCopy.c \
++    ${PATH_ROOT}/src/VBox/Runtime/common/string/RTStrCopyEx.cpp=>common/string/RTStrCopyEx.c \
++    ${PATH_ROOT}/src/VBox/Runtime/common/string/RTStrCopyP.cpp=>common/string/RTStrCopyP.c \
++    ${PATH_ROOT}/src/VBox/Runtime/common/string/strformat.cpp=>common/string/strformat.c \
++    ${PATH_ROOT}/src/VBox/Runtime/common/string/strformatrt.cpp=>common/string/strformatrt.c \
++    ${PATH_ROOT}/src/VBox/Runtime/common/string/strformattype.cpp=>common/string/strformattype.c \
++    ${PATH_ROOT}/src/VBox/Runtime/common/string/strprintf.cpp=>common/string/strprintf.c \
++    ${PATH_ROOT}/src/VBox/Runtime/common/string/strtonum.cpp=>common/string/strtonum.c \
++    ${PATH_ROOT}/src/VBox/Runtime/common/string/memchr.cpp=>common/string/memchr.c \
++    ${PATH_ROOT}/src/VBox/Runtime/common/rand/rand.cpp=>common/rand/rand.c \
++    ${PATH_ROOT}/src/VBox/Runtime/common/rand/randadv.cpp=>common/rand/randadv.c \
++    ${PATH_ROOT}/src/VBox/Runtime/common/rand/randparkmiller.cpp=>common/rand/randparkmiller.c \
++    ${PATH_ROOT}/src/VBox/Runtime/common/path/RTPathStripFilename.cpp=>common/path/RTPathStripFilename.c \
++    ${PATH_ROOT}/src/VBox/Runtime/common/checksum/crc32.cpp=>common/checksum/crc32.c \
++    ${PATH_ROOT}/src/VBox/Runtime/common/checksum/ipv4.cpp=>common/checksum/ipv4.c \
++    ${PATH_ROOT}/src/VBox/Runtime/common/table/avlpv.cpp=>common/table/avlpv.c \
++    ${PATH_ROOT}/src/VBox/Runtime/common/table/avl_Base.cpp.h=>common/table/avl_Base.cpp.h \
++    ${PATH_ROOT}/src/VBox/Runtime/common/table/avl_Get.cpp.h=>common/table/avl_Get.cpp.h \
++    ${PATH_ROOT}/src/VBox/Runtime/common/table/avl_GetBestFit.cpp.h=>common/table/avl_GetBestFit.cpp.h \
++    ${PATH_ROOT}/src/VBox/Runtime/common/table/avl_RemoveBestFit.cpp.h=>common/table/avl_RemoveBestFit.cpp.h \
++    ${PATH_ROOT}/src/VBox/Runtime/common/table/avl_DoWithAll.cpp.h=>common/table/avl_DoWithAll.cpp.h \
++    ${PATH_ROOT}/src/VBox/Runtime/common/table/avl_Destroy.cpp.h=>common/table/avl_Destroy.cpp.h \
++    ${PATH_ROOT}/src/VBox/Runtime/common/time/time.cpp=>common/time/time.c \
++    ${PATH_ROOT}/src/VBox/Runtime/include/internal/assert.h=>include/internal/assert.h \
++    ${PATH_ROOT}/src/VBox/Runtime/include/internal/initterm.h=>include/internal/initterm.h \
++    ${PATH_ROOT}/src/VBox/Runtime/include/internal/iprt.h=>include/internal/iprt.h \
++    ${PATH_ROOT}/src/VBox/Runtime/include/internal/lockvalidator.h=>include/internal/lockvalidator.h \
++    ${PATH_ROOT}/src/VBox/Runtime/include/internal/magics.h=>include/internal/magics.h \
++    ${PATH_ROOT}/src/VBox/Runtime/include/internal/memobj.h=>include/internal/memobj.h \
++    ${PATH_ROOT}/src/VBox/Runtime/include/internal/string.h=>include/internal/string.h \
++    ${PATH_ROOT}/src/VBox/Runtime/include/internal/thread.h=>include/internal/thread.h \
++    ${PATH_ROOT}/src/VBox/Runtime/include/internal/time.h=>include/internal/time.h \
++    ${PATH_ROOT}/src/VBox/Runtime/include/internal/rand.h=>include/internal/rand.h \
++    ${PATH_ROOT}/src/VBox/Runtime/include/internal/sched.h=>include/internal/sched.h \
++    ${PATH_ROOT}/src/VBox/Runtime/include/internal/process.h=>include/internal/process.h \
++    ${PATH_ROOT}/src/VBox/Runtime/generic/RTAssertShouldPanic-generic.cpp=>generic/RTAssertShouldPanic-generic.c \
++    ${PATH_ROOT}/src/VBox/Runtime/generic/RTLogWriteStdErr-stub-generic.cpp=>generic/RTLogWriteStdErr-stub-generic.c \
++    ${PATH_ROOT}/src/VBox/Runtime/generic/RTLogWriteStdOut-stub-generic.cpp=>generic/RTLogWriteStdOut-stub-generic.c \
++    ${PATH_ROOT}/src/VBox/Runtime/generic/RTLogWriteDebugger-generic.cpp=>generic/RTLogWriteDebugger-generic.c \
++    ${PATH_ROOT}/src/VBox/Runtime/generic/RTRandAdvCreateSystemFaster-generic.cpp=>generic/RTRandAdvCreateSystemFaster-generic.c \
++    ${PATH_ROOT}/src/VBox/Runtime/generic/RTRandAdvCreateSystemTruer-generic.cpp=>generic/RTRandAdvCreateSystemTruer-generic.c \
++    ${PATH_ROOT}/src/VBox/Runtime/generic/uuid-generic.cpp=>generic/uuid-generic.c \
++    ${PATH_ROOT}/src/VBox/Runtime/generic/RTSemEventWait-2-ex-generic.cpp=>generic/RTSemEventWait-2-ex-generic.c \
++    ${PATH_ROOT}/src/VBox/Runtime/generic/RTSemEventWaitNoResume-2-ex-generic.cpp=>generic/RTSemEventWaitNoResume-2-ex-generic.c \
++    ${PATH_ROOT}/src/VBox/Runtime/generic/RTSemEventMultiWait-2-ex-generic.cpp=>generic/RTSemEventMultiWait-2-ex-generic.c \
++    ${PATH_ROOT}/src/VBox/Runtime/generic/RTSemEventMultiWaitNoResume-2-ex-generic.cpp=>generic/RTSemEventMultiWaitNoResume-2-ex-generic.c \
++    ${PATH_ROOT}/src/VBox/Runtime/generic/RTTimerCreate-generic.cpp=>generic/RTTimerCreate-generic.c \
++    ${PATH_ROOT}/src/VBox/Runtime/generic/errvars-generic.cpp=>generic/errvars-generic.c \
++    ${PATH_ROOT}/src/VBox/Runtime/generic/timer-generic.cpp=>generic/timer-generic.c \
++    ${PATH_ROOT}/src/VBox/Runtime/generic/mppresent-generic.cpp=>generic/mppresent-generic.c \
++    ${PATH_ROOT}/src/VBox/Runtime/r0drv/alloc-r0drv.cpp=>r0drv/alloc-r0drv.c \
++    ${PATH_ROOT}/src/VBox/Runtime/r0drv/alloc-r0drv.h=>r0drv/alloc-r0drv.h \
++    ${PATH_ROOT}/src/VBox/Runtime/r0drv/initterm-r0drv.cpp=>r0drv/initterm-r0drv.c \
++    ${PATH_ROOT}/src/VBox/Runtime/r0drv/mp-r0drv.h=>r0drv/mp-r0drv.h \
++    ${PATH_ROOT}/src/VBox/Runtime/r0drv/power-r0drv.h=>r0drv/power-r0drv.h \
++    ${PATH_ROOT}/src/VBox/Runtime/r0drv/powernotification-r0drv.c=>r0drv/powernotification-r0drv.c \
++    ${PATH_ROOT}/src/VBox/Runtime/r0drv/netbsd/assert-r0drv-netbsd.c=>r0drv/netbsd/assert-r0drv-netbsd.c \
++    ${PATH_ROOT}/src/VBox/Runtime/r0drv/netbsd/alloc-r0drv-netbsd.c=>r0drv/netbsd/alloc-r0drv-netbsd.c \
++    ${PATH_ROOT}/src/VBox/Runtime/r0drv/netbsd/initterm-r0drv-netbsd.c=>r0drv/netbsd/initterm-r0drv-netbsd.c \
++    ${PATH_ROOT}/src/VBox/Runtime/r0drv/netbsd/memobj-r0drv-netbsd.c=>r0drv/netbsd/memobj-r0drv-netbsd.c \
++    ${PATH_ROOT}/src/VBox/Runtime/r0drv/netbsd/memuserkernel-r0drv-netbsd.c=>r0drv/netbsd/memuserkernel-r0drv-netbsd.c \
++    ${PATH_ROOT}/src/VBox/Runtime/r0drv/netbsd/mp-r0drv-netbsd.c=>r0drv/netbsd/mp-r0drv-netbsd.c \
++    ${PATH_ROOT}/src/VBox/Runtime/r0drv/netbsd/process-r0drv-netbsd.c=>r0drv/netbsd/process-r0drv-netbsd.c \
++    ${PATH_ROOT}/src/VBox/Runtime/r0drv/netbsd/semevent-r0drv-netbsd.c=>r0drv/netbsd/semevent-r0drv-netbsd.c \
++    ${PATH_ROOT}/src/VBox/Runtime/r0drv/netbsd/semeventmulti-r0drv-netbsd.c=>r0drv/netbsd/semeventmulti-r0drv-netbsd.c \
++    ${PATH_ROOT}/src/VBox/Runtime/r0drv/netbsd/semfastmutex-r0drv-netbsd.c=>r0drv/netbsd/semfastmutex-r0drv-netbsd.c \
++    ${PATH_ROOT}/src/VBox/Runtime/r0drv/netbsd/semmutex-r0drv-netbsd.c=>r0drv/netbsd/semmutex-r0drv-netbsd.c \
++    ${PATH_ROOT}/src/VBox/Runtime/r0drv/netbsd/spinlock-r0drv-netbsd.c=>r0drv/netbsd/spinlock-r0drv-netbsd.c \
++    ${PATH_ROOT}/src/VBox/Runtime/r0drv/netbsd/the-netbsd-kernel.h=>r0drv/netbsd/the-netbsd-kernel.h \
++    ${PATH_ROOT}/src/VBox/Runtime/r0drv/netbsd/thread-r0drv-netbsd.c=>r0drv/netbsd/thread-r0drv-netbsd.c \
++    ${PATH_ROOT}/src/VBox/Runtime/r0drv/netbsd/thread2-r0drv-netbsd.c=>r0drv/netbsd/thread2-r0drv-netbsd.c \
++    ${PATH_ROOT}/src/VBox/Runtime/r0drv/netbsd/time-r0drv-netbsd.c=>r0drv/netbsd/time-r0drv-netbsd.c \
++    ${PATH_ROOT}/src/VBox/Runtime/r0drv/netbsd/sleepqueue-r0drv-netbsd.h=>r0drv/netbsd/sleepqueue-r0drv-netbsd.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/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 \
++    ${PATH_ROOT}/src/VBox/Runtime/VBox/logbackdoor.cpp=>VBox/logbackdoor.c \
++    ${PATH_OUT}/version-generated.h=>version-generated.h \
++    ${PATH_OUT}/product-generated.h=>product-generated.h \
++    ${PATH_OUT}/revision-generated.h=>revision-generated.h \
++"
++
++FILES_VBOXGUEST_BIN=" \
++"
diff --git a/virtualbox-svn/patches/patch-src_VBox_Additions_common_VBoxService_VBoxService.cpp b/virtualbox-svn/patches/patch-src_VBox_Additions_common_VBoxService_VBoxService.cpp
new file mode 100644
index 0000000..bc74dc1
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Additions_common_VBoxService_VBoxService.cpp
@@ -0,0 +1,18 @@
+$NetBSD$
+
+--- src/VBox/Additions/common/VBoxService/VBoxService.cpp.orig	2016-03-04 19:23:11.000000000 +0000
++++ src/VBox/Additions/common/VBoxService/VBoxService.cpp
+@@ -62,7 +62,7 @@
+ #  define pthread_sigmask sigprocmask
+ # endif
+ #endif
+-#ifdef RT_OS_FREEBSD
++#if defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+ # include <pthread.h>
+ #endif
+ 
+@@ -1259,4 +1259,3 @@ int main(int argc, char **argv)
+ 
+     return rcExit;
+ }
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_Additions_common_VBoxService_VBoxServiceVMInfo.cpp b/virtualbox-svn/patches/patch-src_VBox_Additions_common_VBoxService_VBoxServiceVMInfo.cpp
new file mode 100644
index 0000000..1d9048c
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Additions_common_VBoxService_VBoxServiceVMInfo.cpp
@@ -0,0 +1,65 @@
+$NetBSD$
+
+--- src/VBox/Additions/common/VBoxService/VBoxServiceVMInfo.cpp.orig	2016-03-04 19:23:11.000000000 +0000
++++ src/VBox/Additions/common/VBoxService/VBoxServiceVMInfo.cpp
+@@ -71,7 +71,7 @@
+ # include <net/if.h>
+ # include <pwd.h> /* getpwuid */
+ # include <unistd.h>
+-# if !defined(RT_OS_OS2) && !defined(RT_OS_FREEBSD) && !defined(RT_OS_HAIKU)
++# if !defined(RT_OS_OS2) && !defined(RT_OS_FREEBSD) && !defined(RT_OS_HAIKU) 
+ #  include <utmpx.h> /* @todo FreeBSD 9 should have this. */
+ # endif
+ # ifdef RT_OS_OS2
+@@ -81,7 +81,7 @@
+ #  include <sys/sockio.h>
+ #  include <net/if_arp.h>
+ # endif
+-# if defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD)
++# if defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+ #  include <ifaddrs.h> /* getifaddrs, freeifaddrs */
+ #  include <net/if_dl.h> /* LLADDR */
+ #  include <netdb.h> /* getnameinfo */
+@@ -568,6 +568,10 @@ static int vgsvcVMInfoWriteUsers(void)
+      *                 block below (?). */
+     rc = VERR_NOT_IMPLEMENTED;
+ 
++#elif defined(RT_OS_NETBSD)
++    /** @todo NetBSD: */
++    rc = VERR_NOT_IMPLEMENTED;
++
+ #elif defined(RT_OS_HAIKU)
+     /** @todo Haiku: Port logged on user info retrieval. */
+     rc = VERR_NOT_IMPLEMENTED;
+@@ -874,7 +878,7 @@ static int vgsvcVMInfoWriteUsers(void)
+     RTMemFree(papszUsers);
+ 
+     endutxent(); /* Close utmpx file. */
+-#endif /* !RT_OS_WINDOWS && !RT_OS_FREEBSD && !RT_OS_HAIKU && !RT_OS_OS2 */
++#endif /* !RT_OS_WINDOWS && !RT_OS_FREEBSD && !RT_OS_HAIKU && !RT_OS_OS2 && !RT_OS_NETBSD */
+ 
+     Assert(RT_FAILURE(rc) || cUsersInList == 0 || (pszUserList && *pszUserList));
+ 
+@@ -1090,7 +1094,7 @@ static int vgsvcVMInfoWriteNetwork(void)
+     /** @todo Haiku: implement network info. retreival */
+     return VERR_NOT_IMPLEMENTED;
+ 
+-#elif defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD)
++#elif defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+     struct ifaddrs *pIfHead = NULL;
+ 
+     /* Get all available interfaces */
+@@ -1162,7 +1166,7 @@ static int vgsvcVMInfoWriteNetwork(void)
+     /* Free allocated resources. */
+     freeifaddrs(pIfHead);
+ 
+-#else /* !RT_OS_WINDOWS && !RT_OS_FREEBSD */
++#else /* !RT_OS_WINDOWS && !RT_OS_FREEBSD && !RT_OS_NETBSD */
+     /*
+      * Use SIOCGIFCONF to get a list of interface/protocol configurations.
+      *
+@@ -1685,4 +1689,3 @@ VBOXSERVICE g_VMInfo =
+     vbsvcVMInfoStop,
+     vbsvcVMInfoTerm
+ };
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_Additions_common_crOpenGL_Makefile.kmk b/virtualbox-svn/patches/patch-src_VBox_Additions_common_crOpenGL_Makefile.kmk
new file mode 100644
index 0000000..aa5ff16
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Additions_common_crOpenGL_Makefile.kmk
@@ -0,0 +1,169 @@
+$NetBSD$
+
+--- src/VBox/Additions/common/crOpenGL/Makefile.kmk.orig	2016-07-10 21:02:17.000000000 +0000
++++ src/VBox/Additions/common/crOpenGL/Makefile.kmk
+@@ -24,7 +24,7 @@ include $(KBUILD_PATH)/subheader.kmk
+ BLDDIRS += \
+ 	$(VBOX_PATH_CROGL_GENFILES)/
+ 
+-if1of ($(KBUILD_TARGET), win linux solaris freebsd)
++if1of ($(KBUILD_TARGET), win linux solaris freebsd netbsd)
+  DLLS += \
+     VBoxOGL \
+     VBoxOGLarrayspu \
+@@ -54,7 +54,7 @@ if1of ($(KBUILD_TARGET), linux solaris f
+  # Only Solaris right now needs C stubs because I can't figure out how to
+  # generate the GOT based relocation ASM yet.
+  ifdef VBoxOGL_FAKEDRI
+-  if1of ($(KBUILD_TARGET).$(KBUILD_TARGET_ARCH),solaris.x86 solaris.amd64 linux.x86 linux.amd64 freebsd.x86 freebsd.amd64)
++  if1of ($(KBUILD_TARGET).$(KBUILD_TARGET_ARCH),solaris.x86 solaris.amd64 linux.x86 linux.amd64 freebsd.x86 freebsd.amd64 netbsd.x86 netbsd.amd64)
+    VBOX_OGL_GLX_USE_CSTUBS = 1
+   endif
+  endif
+@@ -66,7 +66,7 @@ endif
+ #
+ VBoxOGL_TEMPLATE       = VBOXCROGLR3GUESTDLL
+ VBoxOGL_INCS           = .
+-if1of ($(KBUILD_TARGET), linux solaris freebsd)
++if1of ($(KBUILD_TARGET), linux solaris freebsd netbsd)
+  VBoxOGL_INCS     += \
+ 	$(VBOX_PATH_X11_ROOT)/libXdamage-1.1 \
+ 	$(VBOX_PATH_X11_ROOT)/libXcomposite-0.4.0 \
+@@ -121,7 +121,7 @@ VBoxOGL_SOURCES       += \
+ 	$(VBOX_PATH_CROGL_GENFILES)/NULLfuncs.c \
+ 	$(VBOX_PATH_CROGL_GENFILES)/tsfuncs.c
+ 
+-if1of ($(KBUILD_TARGET), linux solaris freebsd)
++if1of ($(KBUILD_TARGET), linux solaris freebsd netbsd)
+  VBoxOGL_SOURCES += \
+ 	glx.c \
+ 	xfont.c
+@@ -139,6 +139,8 @@ if1of ($(KBUILD_TARGET), linux solaris f
+  	$(VBOX_PATH_CROGL_GENFILES)/solaris_exports_dri.asm
+   VBoxOGL_SOURCES.freebsd += \
+  	$(VBOX_PATH_CROGL_GENFILES)/freebsd_exports_dri.asm
++  VBoxOGL_SOURCES.netbsd += \
++ 	$(VBOX_PATH_CROGL_GENFILES)/netbsd_exports_dri.asm
+  else ifdef VBoxOGL_FAKEDRI
+   VBoxOGL_SOURCES += \
+  	fakedri_drv.c
+@@ -152,6 +154,9 @@ if1of ($(KBUILD_TARGET), linux solaris f
+    VBoxOGL_SOURCES.freebsd += \
+  	$(VBOX_PATH_CROGL_GENFILES)/freebsd_glxapi_exports.asm \
+  	$(VBOX_PATH_CROGL_GENFILES)/freebsd_exports_dri.asm
++   VBoxOGL_SOURCES.netbsd += \
++ 	$(VBOX_PATH_CROGL_GENFILES)/netbsd_glxapi_exports.asm \
++ 	$(VBOX_PATH_CROGL_GENFILES)/netbsd_exports_dri.asm
+   else
+    VBoxOGL_SOURCES.solaris += \
+   	$(VBOX_PATH_CROGL_GENFILES)/solaris_exports.c
+@@ -159,6 +164,8 @@ if1of ($(KBUILD_TARGET), linux solaris f
+   	$(VBOX_PATH_CROGL_GENFILES)/linux_exports.c
+   VBoxOGL_SOURCES.freebsd += \
+   	$(VBOX_PATH_CROGL_GENFILES)/freebsd_exports.c
++  VBoxOGL_SOURCES.netbsd += \
++  	$(VBOX_PATH_CROGL_GENFILES)/netbsd_exports.c
+   endif
+  else
+   VBoxOGL_SOURCES.linux += \
+@@ -167,6 +174,8 @@ if1of ($(KBUILD_TARGET), linux solaris f
+   	$(VBOX_PATH_CROGL_GENFILES)/solaris_exports.c
+   VBoxOGL_SOURCES.freebsd += \
+   	$(VBOX_PATH_CROGL_GENFILES)/freebsd_exports.c
++  VBoxOGL_SOURCES.netbsd += \
++  	$(VBOX_PATH_CROGL_GENFILES)/netbsd_exports.c
+  endif
+ endif
+ 
+@@ -212,14 +221,14 @@ VBoxOGL_LIBS.win += \
+ 	$(PATH_STAGE_LIB)/additions/VBoxDispMpLogger$(VBOX_SUFF_LIB) \
+ 	$(PATH_STAGE_LIB)/additions/VBoxCrHgsmi$(VBOX_SUFF_LIB)
+ 
+-if1of ($(KBUILD_TARGET), linux solaris freebsd)
++if1of ($(KBUILD_TARGET), linux solaris freebsd netbsd)
+  VBoxOGL_LIBS += \
+  	$(PATH_STAGE_LIB)/libXcomposite.so \
+  	$(PATH_STAGE_LIB)/libXdamage.so \
+  	$(PATH_STAGE_LIB)/libXfixes.so \
+  	$(PATH_STAGE_LIB)/libXext.so
+  ifdef VBoxOGL_FAKEDRI
+-  ifeq ($(KBUILD_TARGET), freebsd)
++  ifeq ($(KBUILD_TARGET), freebsd netbsd)
+     VBoxOGL_LIBS += \
+         elf
+   else
+@@ -309,7 +318,7 @@ $(VBOX_PATH_CROGL_GENFILES)/cropengl-x86
+  endif #ifdef VBOX_WITH_WDDM
+ 
+ 
+-else if1of ($(KBUILD_TARGET), freebsd linux solaris)
++else if1of ($(KBUILD_TARGET), freebsd netbsd linux solaris)
+  # FreeBSD, Linux, Solaris
+ $(VBOX_PATH_CROGL_GENFILES)/getprocaddress.c: $(PATH_SUB_CURRENT)/getprocaddress.py $(VBOX_CROGL_API_FILES) | $$(dir $$@)
+ 	$(call MSG_GENERATE,python,$@,$<)
+@@ -370,6 +379,14 @@ $(VBOX_PATH_CROGL_GENFILES)/freebsd_expo
+ 	$(call MSG_GENERATE,python,$@,$<)
+ 	$(QUIET)$(call VBOX_CROGL_PYTHON_ENV,$(VBOX_PATH_CROGL_PYTHON_INCLUDE),$@) $(VBOX_BLD_PYTHON) $< $(VBOX_PATH_CROGL_GLAPI)
+ 
++  else ifeq ($(KBUILD_TARGET),netbsd)
++$(VBOX_PATH_CROGL_GENFILES)/netbsd_exports_dri.asm: \
++		$(PATH_SUB_CURRENT)/NetBSD_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)
++
+   else
+ $(VBOX_PATH_CROGL_GENFILES)/linux_exports_dri.asm: \
+ 		$(PATH_SUB_CURRENT)/Linux_i386_exports_dri.py \
+@@ -424,6 +441,14 @@ $(VBOX_PATH_CROGL_GENFILES)/freebsd_expo
+ 		| $$(dir $$@)
+ 	$(call MSG_GENERATE,python,$@,$<)
+ 	$(QUIET)$(call VBOX_CROGL_PYTHON_ENV,$(VBOX_PATH_CROGL_PYTHON_INCLUDE),$@) $(VBOX_BLD_PYTHON) $< $(VBOX_PATH_CROGL_GLAPI)
++
++  else ifeq ($(KBUILD_TARGET),netbsd)
++$(VBOX_PATH_CROGL_GENFILES)/netbsd_exports.c: \
++		$(PATH_SUB_CURRENT)/NetBSD_exports.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)
+   else
+ $(VBOX_PATH_CROGL_GENFILES)/linux_exports.c: \
+ 		$(PATH_SUB_CURRENT)/Linux_exports.py \
+@@ -443,7 +468,7 @@ endif
+ VBoxOGLarrayspu_TEMPLATE      = VBOXCROGLR3GUESTDLL
+ VBoxOGLarrayspu_INCS          = \
+ 	array
+-if1of ($(KBUILD_TARGET), linux solaris freebsd)
++if1of ($(KBUILD_TARGET), linux solaris freebsd metbsd)
+  VBoxOGLarrayspu_INCS += \
+         $(VBOX_MESA_INCS)
+ endif
+@@ -491,7 +516,7 @@ endif
+ VBoxOGLpassthroughspu_TEMPLATE    = VBOXCROGLR3GUESTDLL
+ VBoxOGLpassthroughspu_INCS        = \
+ 	passthrough
+-if1of ($(KBUILD_TARGET), linux solaris freebsd)
++if1of ($(KBUILD_TARGET), linux solaris freebsd netbsd)
+  VBoxOGLpassthroughspu_INCS += \
+         $(VBOX_MESA_INCS)
+ endif
+@@ -540,7 +565,7 @@ VBoxOGLpackspu_TEMPLATE      = VBOXCROGL
+ VBoxOGLpackspu_DEFS          = TRACKS_STATE=1 PACKS=1
+ VBoxOGLpackspu_INCS          = \
+ 	pack
+-if1of ($(KBUILD_TARGET), linux solaris freebsd)
++if1of ($(KBUILD_TARGET), linux solaris freebsd netbsd)
+  VBoxOGLpackspu_INCS += \
+         $(VBOX_MESA_INCS)
+ endif
+@@ -646,7 +671,7 @@ $(VBOX_PATH_CROGL_GENFILES)/packspu_prot
+ VBoxOGLfeedbackspu_TEMPLATE    = VBOXCROGLR3GUESTDLL
+ VBoxOGLfeedbackspu_INCS        = \
+ 	feedback
+-if1of ($(KBUILD_TARGET), linux solaris freebsd)
++if1of ($(KBUILD_TARGET), linux solaris freebsd netbsd)
+  VBoxOGLfeedbackspu_INCS += \
+         $(VBOX_MESA_INCS)
+ endif
diff --git a/virtualbox-svn/patches/patch-src_VBox_Additions_common_crOpenGL_NetBSD__exports.py b/virtualbox-svn/patches/patch-src_VBox_Additions_common_crOpenGL_NetBSD__exports.py
new file mode 100644
index 0000000..e9db8af
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Additions_common_crOpenGL_NetBSD__exports.py
@@ -0,0 +1,16 @@
+$NetBSD$
+
+--- src/VBox/Additions/common/crOpenGL/NetBSD_exports.py.orig	2016-07-06 19:36:20.413032855 +0000
++++ src/VBox/Additions/common/crOpenGL/NetBSD_exports.py
+@@ -0,0 +1,11 @@
++# Copyright (c) 2001, Stanford University
++# All rights reserved.
++#
++# See the file LICENSE.txt for information on redistributing this software.
++
++import entrypoints
++
++hacks = []
++
++entrypoints.GenerateEntrypoints(hacks)
++
diff --git a/virtualbox-svn/patches/patch-src_VBox_Additions_common_crOpenGL_fakedri__drv.c b/virtualbox-svn/patches/patch-src_VBox_Additions_common_crOpenGL_fakedri__drv.c
new file mode 100644
index 0000000..1fcfc3d
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Additions_common_crOpenGL_fakedri__drv.c
@@ -0,0 +1,42 @@
+$NetBSD$
+
+--- src/VBox/Additions/common/crOpenGL/fakedri_drv.c.orig	2016-03-04 19:23:12.000000000 +0000
++++ src/VBox/Additions/common/crOpenGL/fakedri_drv.c
+@@ -30,7 +30,7 @@
+ #include <elf.h>
+ #include <unistd.h>
+ 
+-#if defined(RT_OS_FREEBSD)
++#if defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+ #include <sys/param.h>
+ #include <fcntl.h>
+ #include <gelf.h>
+@@ -62,6 +62,9 @@ typedef enum {
+ # ifdef RT_OS_FREEBSD
+ #  define DRI_DEFAULT_DRIVER_DIR "/usr/local/lib/dri"
+ #  define DRI_XORG_DRV_DIR "/usr/local/lib/xorg/modules/drivers/"
++# elif defined(RT_OS_NETBSD)
++#  define DRI_DEFAULT_DRIVER_DIR "/usr/X11R7/lib/modules/dri"
++#  define DRI_XORG_DRV_DIR "/usr/X11R7/lib/modules/drivers/"
+ # else
+ #  define DRI_DEFAULT_DRIVER_DIR "/usr/lib64/dri:/usr/lib/dri:/usr/lib/x86_64-linux-gnu/dri:/usr/lib/xorg/modules/dri"
+ #  define DRI_XORG_DRV_DIR "/usr/lib/xorg/modules/drivers/"
+@@ -70,6 +73,9 @@ typedef enum {
+ # ifdef RT_OS_FREEBSD
+ #  define DRI_DEFAULT_DRIVER_DIR "/usr/local/lib/dri"
+ #  define DRI_XORG_DRV_DIR "/usr/local/lib/xorg/modules/drivers/"
++# elif defined(RT_OS_NETBSD)
++#  define DRI_DEFAULT_DRIVER_DIR "/usr/X11R7/lib/modules/dri"
++#  define DRI_XORG_DRV_DIR "/usr/X11R7/lib/modules/drivers/"
+ # else
+ #  define DRI_DEFAULT_DRIVER_DIR "/usr/lib/dri:/usr/lib/i386-linux-gnu/dri:/usr/lib/xorg/modules/dri"
+ #  define DRI_XORG_DRV_DIR "/usr/lib/xorg/modules/drivers/"
+@@ -228,7 +234,7 @@ vboxApplyPatch(const char* psFuncName, v
+ 
+ #define FAKEDRI_JMP64_PATCH_SIZE 13
+ 
+-#if defined(RT_OS_FREEBSD)
++#if defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+ /* Provide basic dladdr1 flags */
+ enum {
+ 	RTLD_DL_SYMENT	= 1
diff --git a/virtualbox-svn/patches/patch-src_VBox_Additions_netbsd_Installer_pkg-descr b/virtualbox-svn/patches/patch-src_VBox_Additions_netbsd_Installer_pkg-descr
new file mode 100644
index 0000000..df78364
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Additions_netbsd_Installer_pkg-descr
@@ -0,0 +1,8 @@
+$NetBSD$
+
+--- src/VBox/Additions/netbsd/Installer/pkg-descr.orig	2016-07-07 07:08:46.360554883 +0000
++++ src/VBox/Additions/netbsd/Installer/pkg-descr
+@@ -0,0 +1,3 @@
++VirtualBox guest additions for the NETBSD operating system
++
++WWW: http://www.virtualbox.org
diff --git a/virtualbox-svn/patches/patch-src_VBox_Additions_netbsd_Installer_vboxguest.sh b/virtualbox-svn/patches/patch-src_VBox_Additions_netbsd_Installer_vboxguest.sh
new file mode 100644
index 0000000..17d3307
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Additions_netbsd_Installer_vboxguest.sh
@@ -0,0 +1,140 @@
+$NetBSD$
+
+--- src/VBox/Additions/netbsd/Installer/vboxguest.sh.orig	2016-07-07 07:08:46.369610770 +0000
++++ src/VBox/Additions/netbsd/Installer/vboxguest.sh
+@@ -0,0 +1,135 @@
++#!/bin/bash
++#
++# VirtualBox Guest Additions kernel module control script for NetBSD.
++#
++# Copyright (C) 2008-2010 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.
++#
++
++VBOXGUESTFILE=""
++SILENTUNLOAD=""
++
++abort()
++{
++    echo 1>&2 "$1"
++    exit 1
++}
++
++info()
++{
++    echo 1>&2 "$1"
++}
++
++get_module_path()
++{
++    moduledir="/stand/$(uname -m)/$(uname -r)/modules/";
++    modulepath=$moduledir/vboxguest/vboxguest.kmod
++    if test -f "$modulepath"; then
++        VBOXGUESTFILE="$modulepath"
++    else
++        VBOXGUESTFILE=""
++    fi
++}
++
++check_if_installed()
++{
++    if test "$VBOXGUESTFILE" -a -f "$VBOXGUESTFILE"; then
++        return 0
++    fi
++    abort "VirtualBox kernel module (vboxguest) not installed."
++}
++
++module_loaded()
++{
++    loadentry=`kldstat | grep vboxguest`
++    if test -z "$loadentry"; then
++        return 1
++    fi
++    return 0
++}
++
++check_root()
++{
++    if test `id -u` -ne 0; then
++        abort "This program must be run with administrator privileges.  Aborting"
++    fi
++}
++
++start()
++{
++    if module_loaded; then
++        info "vboxguest already loaded..."
++    else
++        /sbin/kldload vboxguest.ko
++        if ! module_loaded; then
++            abort "Failed to load vboxguest."
++        elif test -c "/dev/vboxguest"; then
++            info "Loaded vboxguest."
++        else
++            stop
++            abort "Aborting due to attach failure."
++        fi
++    fi
++}
++
++stop()
++{
++    if module_loaded; then
++        /sbin/kldunload vboxguest.ko
++        info "Unloaded vboxguest."
++    elif test -z "$SILENTUNLOAD"; then
++        info "vboxguest not loaded."
++    fi
++}
++
++restart()
++{
++    stop
++    sync
++    start
++    return 0
++}
++
++status()
++{
++    if module_loaded; then
++        info "vboxguest running."
++    else
++        info "vboxguest stopped."
++    fi
++}
++
++check_root
++get_module_path
++check_if_installed
++
++if test "$2" = "silentunload"; then
++    SILENTUNLOAD="$2"
++fi
++
++case "$1" in
++start)
++    start
++    ;;
++stop)
++    stop
++    ;;
++restart)
++    restart
++    ;;
++status)
++    status
++    ;;
++*)
++    echo "Usage: $0 {start|stop|restart|status}"
++    exit 1
++esac
++
++exit
diff --git a/virtualbox-svn/patches/patch-src_VBox_Additions_netbsd_Makefile b/virtualbox-svn/patches/patch-src_VBox_Additions_netbsd_Makefile
new file mode 100644
index 0000000..680bbd9
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Additions_netbsd_Makefile
@@ -0,0 +1,58 @@
+$NetBSD$
+
+--- src/VBox/Additions/netbsd/Makefile.orig	2016-07-07 07:08:46.378102526 +0000
++++ src/VBox/Additions/netbsd/Makefile
+@@ -0,0 +1,53 @@
++#
++# Makefile for the VirtualBox NetBSD Guest Drivers.
++#
++
++#
++#
++# Copyright (C) 2009-2010 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.
++#
++
++KBUILD_VERBOSE =
++
++all:
++	@echo "*** Building 'vboxguest' module ***"
++	@$(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) -C vboxguest
++	@if [ -f vboxguest/vboxguest.ko ]; then \
++	    cp vboxguest/vboxguest.ko .; \
++	 fi
++	@echo
++	@if [ -d vboxvfs ]; then \
++	    echo "*** Building 'vboxvfs' module ***"; \
++	    $(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) -C vboxvfs; \
++	    if [ -f vboxvfs/vboxvfs.ko ]; then \
++	        cp vboxvfs/vboxvfs.ko .; \
++	    fi; \
++	fi
++
++
++install:
++	@$(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) -C vboxguest install
++	@if [ -d vboxvfs ]; then \
++	    $(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) -C vboxvfs install; \
++	fi
++
++clean:
++	@$(MAKE) -C vboxguest clean
++	@if [ -d vboxvfs ]; then \
++	    $(MAKE) -C vboxvfs clean; \
++	fi
++	rm -f vboxguest.*o vboxvfs.*o
++
++load:
++	@/sbin/kldunload vboxvfs || true
++	@/sbin/kldunload vboxguest || true
++	@/sbin/kldload ./vboxguest.ko
++	@if [ -f vboxvfs.ko ]; then /sbin/kldload ./vboxvfs.ko; fi
diff --git a/virtualbox-svn/patches/patch-src_VBox_Additions_netbsd_Makefile.kmk b/virtualbox-svn/patches/patch-src_VBox_Additions_netbsd_Makefile.kmk
new file mode 100644
index 0000000..4eb5a71
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Additions_netbsd_Makefile.kmk
@@ -0,0 +1,196 @@
+$NetBSD$
+
+--- src/VBox/Additions/netbsd/Makefile.kmk.orig	2016-07-08 22:38:39.547935183 +0000
++++ src/VBox/Additions/netbsd/Makefile.kmk
+@@ -0,0 +1,191 @@
++#  Makefile.kmk $
++## @file
++# Sub-Makefile for the NetBSD guest additions base directory.
++#
++
++#
++# Copyright (C) 2008-2015 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.
++#
++
++SUB_DEPTH = ../../../..
++include $(KBUILD_PATH)/subheader.kmk
++
++ifneq ($(KBUILD_HOST),netbsd)
++$(error "The NetBSD guest additions installer can only be built on NetBSD!")
++endif
++
++# Include sub-makefiles.
++#include $(PATH_SUB_CURRENT)/vboxvfs/Makefile.kmk
++include $(PATH_SUB_CURRENT)/drm/Makefile.kmk
++
++#
++# Globals
++#
++VBOX_NBSD_ADD_INS_OUT_DIR          := $(PATH_TARGET)/Additions/Installer/netbsd
++BLDDIRS                            += \
++		$(VBOX_NBSD_ADD_INS_OUT_DIR) \
++		$(VBOX_NBSD_ADD_INS_OUT_DIR)/module
++VBOX_PATH_NETBSD_ADDITION_INSTALLER := $(PATH_SUB_CURRENT)/Installer
++VBOX_PATH_X11_ADDITION_INSTALLER     := $(PATH_ROOT)/src/VBox/Additions/x11/Installer
++
++
++#
++# Targets
++#
++ifndef VBOX_OSE
++ BLDDIRS     += $(VBOX_NBSD_ADD_INS_OUT_DIR) $(VBOX_NBSD_ADD_INS_OUT_DIR)/module
++ PACKING     += $(PATH_STAGE_BIN)/additions/VBoxNetBSDAdditions.tbz
++ OTHER_CLEAN += $(PACKING)
++endif
++
++
++#
++# Files to install
++#
++VBOX_NBSD_ADD_STRIP_BIN = \
++	VBoxService \
++	VBoxClient \
++	VBoxControl \
++	vboxmouse_drv_70.so \
++	vboxmouse_drv_71.so \
++	vboxmouse_drv_14.so \
++	vboxmouse_drv_15.so \
++	vboxmouse_drv_16.so \
++	vboxmouse_drv_17.so \
++	vboxvideo_drv_70.so \
++	vboxvideo_drv_71.so \
++	vboxvideo_drv_13.so \
++	vboxvideo_drv_14.so \
++	vboxvideo_drv_15.so \
++	vboxvideo_drv_16.so \
++	vboxvideo_drv_17.so \
++	VBoxOGLarrayspu.so \
++	VBoxOGLcrutil.so \
++	VBoxOGLerrorspu.so \
++	VBoxOGLfeedbackspu.so \
++	VBoxOGLpackspu.so \
++	VBoxOGLpassthroughspu.so \
++	VBoxOGL.so
++
++VBOX_NBSD_ADD_MODULES = \
++	vboxguest \
++	vboxvideo_drm
++
++#
++# All the bin files that go into the archives.
++#
++VBOX_NBSD_ADD_DBG_SYM_FILES := $(addsuffix .dbgsym,$(VBOX_NBSD_ADD_STRIP_BIN))
++VBOX_NBSD_ADD_INS_FILES := $(addprefix $(VBOX_NBSD_ADD_INS_OUT_DIR)/,$(VBOX_NBSD_ADD_STRIP_BIN) $(VBOX_NBSD_ADD_STRIP_OBJ) $(VBOX_NBSD_ADD_DBG_SYM_FILES))
++VBOX_NBSD_ADD_INS_MODULES := $(addprefix $(VBOX_NBSD_ADD_INS_OUT_DIR)/module/,$(VBOX_NBSD_ADD_MODULES))
++
++# Cleanup of the the installer directory files
++OTHER_CLEAN += $(VBOX_NBSD_ADD_INS_FILES)) $(VBOX_NBSD_ADD_INS_MODULES)
++
++# pattern rule for copying the debug info from the VBOX_NBSD_ADD_STRIP_BIN files to the installation directory
++$(addprefix $(VBOX_NBSD_ADD_INS_OUT_DIR)/,$(VBOX_NBSD_ADD_DBG_SYM_FILES)): \
++		$(VBOX_NBSD_ADD_INS_OUT_DIR)/%.dbgsym : $(PATH_STAGE_BIN)/additions/% | $$(dir $$@)
++	$(call MSG_TOOL,copydbg,$<,$@)
++	$(QUIET)objcopy --only-keep-debug $< $@
++
++# pattern rule for stripping and copying the VBOX_NBSD_ADD_STRIP_BIN files to the installation directory
++$(addprefix $(VBOX_NBSD_ADD_INS_OUT_DIR)/,$(VBOX_NBSD_ADD_STRIP_BIN)): \
++		$(VBOX_NBSD_ADD_INS_OUT_DIR)/% : $(PATH_STAGE_BIN)/additions/% \
++		$(VBOX_NBSD_ADD_INS_OUT_DIR)/%.dbgsym \
++		| $$(dir $$@)
++	$(call MSG_INST_FILE,$<,$@)
++	$(QUIET)$(INSTALL) -m 0755 $(if $(VBOX_DO_STRIP),-s,) $< $@
++	$(QUIET)objcopy --add-gnu-debuglink=$(addsuffix .dbgsym,$@) $@
++
++# pattern rule for stripping and copying the VBOX_NBSD_ADD_STRIP_OBJ files to the installation directory
++$(addprefix $(VBOX_NBSD_ADD_INS_OUT_DIR)/,$(VBOX_NBSD_ADD_STRIP_OBJ)): \
++		$(VBOX_NBSD_ADD_INS_OUT_DIR)/% : $(PATH_STAGE_BIN)/additions/% | $$(dir $$@)
++	$(call MSG_INST_FILE,$<,$@)
++ifeq ($(VBOX_DO_STRIP),)
++	$(QUIET)$(INSTALL) -m 0644 $< $@
++else # strip to temp file because of umask.
++	$(QUIET)objcopy --strip-unneeded -R .comment $< $@.tmp
++	$(QUIET)$(INSTALL) -m 0644 $@.tmp $@
++	$(QUIET)$(RM) -f -- $@.tmp
++endif
++
++# pattern rule for copying the VBOX_NBSD_ADD_MODULES files to the installation directory
++$(VBOX_NBSD_ADD_INS_MODULES): \
++		$(VBOX_NBSD_ADD_INS_OUT_DIR)/module/% : $(PATH_STAGE_BIN)/additions/src/% | $(VBOX_NBSD_ADD_INS_OUT_DIR)/module/
++	$(call MSG_INST_FILE,$<,$@)
++# Remove target directories first, otherwise the behaviour of cp will not be
++# what we want if it already exists. See the cp manual page for more details.
++	$(QUIET)$(RM) -Rf $@
++	$(QUIET)cp -af $< $(VBOX_NBSD_ADD_INS_OUT_DIR)/module
++
++
++INSTALLS += $(if $(VBOX_OSE),, fbsd_add_inst-nobin)
++fbsd_add_inst-nobin_INST = obj/Additions/Installer/netbsd
++fbsd_add_inst-nobin_MODE = a+r,u+w
++fbsd_add_inst-nobin_SOURCES = \
++		../x11/Installer/98vboxadd-xclient \
++		../x11/Installer/vboxclient.desktop \
++		../x11/Installer/vboxvideo.ids \
++		../x11/Installer/x11config.pl \
++		../x11/Installer/x11config15.pl
++
++
++INSTALLS += GuestDrivers-src
++GuestDrivers-src_INST = bin/additions/src/
++GuestDrivers-src_MODE = a+r,u+w
++GuestDrivers-src_SOURCES = Makefile
++
++# this file needs editing before it can be included in the generic installer.
++$(VBOX_NBSD_ADD_INS_OUT_DIR)/install.sh: \
++	$(VBOX_PATH_NETBSD_ADDITION_INSTALLER)/install.sh | $$(dir $$@)
++	$(QUIET)$(SED) \
++	    -e "s;_VERSION_;$(VBOX_VERSION_STRING);g" \
++	    -e "s;_BUILD_;$(shell date);g" \
++	    -e "s;_OSE_;$(VBOX_OSE);g" \
++	    -e "s;_BUILDTYPE_;$(KBUILD_TYPE);g" \
++	    -e "s;_ARCH_;$(KBUILD_TARGET_ARCH);g" \
++	    --output $(VBOX_NBSD_ADD_INS_OUT_DIR)/install_.sh \
++	    $<
++	$(QUIET)$(INSTALL) -m 0755 $(VBOX_NBSD_ADD_INS_OUT_DIR)/install_.sh $@
++	$(QUIET)$(RM) $(VBOX_NBSD_ADD_INS_OUT_DIR)/install_.sh
++OTHERS_CLEAN += $(VBOX_NBSD_ADD_INS_OUT_DIR)/install.sh
++
++
++include $(FILE_KBUILD_SUB_FOOTER)
++
++
++#
++# Build the NetBSD Guest Additions installer package.
++#
++# Note that $(PATH_SUB_CURRENT) was changed by subfooter.kmk above and
++# any references should be made via variables assigned a know value via := .
++#
++# We need to depend on all source files for the additions and shared
++# folders kernel modules.
++## @todo Replace the wildcard stuff by the correct file lists now that
++#        we've got everything included.
++#
++$(PATH_STAGE_BIN)/additions/VBoxNetBSDAdditions.tbz: \
++		$$(fbsd_add_inst-nobin_2_STAGE_TARGETS) \
++		$$(fbsd_add_inst-bin_2_STAGE_TARGETS) \
++		$(VBOX_NBSD_ADD_INS_FILES) \
++		$(VBOX_NBSD_ADD_INS_MODULES) \
++		$(VBOX_NBSD_ADD_INS_OUT_DIR)/install.sh \
++		$(wildcard $(PATH_STAGE_BIN)/additions/src/*) \
++		$(wildcard $(PATH_STAGE_BIN)/additions/src/*/*) \
++		$(wildcard $(PATH_STAGE_BIN)/additions/src/*/*/*) \
++		$(wildcard $(PATH_STAGE_BIN)/additions/src/*/*/*/*) \
++		$(VBOX_VERSION_STAMP) $(VBOX_SVN_REV_HEADER)
++	pkg_create \
++		-I $(VBOX_PATH_NETBSD_ADDITION_INSTALLER)/install.sh \
++		-c $(VBOX_PATH_NETBSD_ADDITION_INSTALLER)/pkg-comment \
++		-d $(VBOX_PATH_NETBSD_ADDITION_INSTALLER)/pkg-descr \
++		-f $(VBOX_PATH_NETBSD_ADDITION_INSTALLER)/pkg-plist \
++		$@
diff --git a/virtualbox-svn/patches/patch-src_VBox_Additions_netbsd_drm_Makefile b/virtualbox-svn/patches/patch-src_VBox_Additions_netbsd_drm_Makefile
new file mode 100644
index 0000000..7ae7275
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Additions_netbsd_drm_Makefile
@@ -0,0 +1,31 @@
+$NetBSD$
+
+--- src/VBox/Additions/netbsd/drm/Makefile.orig	2016-07-07 07:08:46.395472943 +0000
++++ src/VBox/Additions/netbsd/drm/Makefile
+@@ -0,0 +1,26 @@
++#  Makefile $
++## @file
++# Makefile for the VirtualBox NetBSD Host Driver.
++#
++
++#
++#
++# Copyright (C) 2006-2010 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.
++#
++
++KMOD = vboxvideo
++
++SRCS = \
++	vboxvideo_drm.c
++
++SRCS += device_if.h bus_if.h pci_if.h opt_drm.h
++
++.include <bsd.kmod.mk>
diff --git a/virtualbox-svn/patches/patch-src_VBox_Additions_netbsd_drm_Makefile.kmk b/virtualbox-svn/patches/patch-src_VBox_Additions_netbsd_drm_Makefile.kmk
new file mode 100644
index 0000000..4583542
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Additions_netbsd_drm_Makefile.kmk
@@ -0,0 +1,76 @@
+$NetBSD$
+
+--- src/VBox/Additions/netbsd/drm/Makefile.kmk.orig	2016-07-07 07:08:46.404285508 +0000
++++ src/VBox/Additions/netbsd/drm/Makefile.kmk
+@@ -0,0 +1,71 @@
++#  Makefile.kmk $
++## @file
++# Sub-Makefile for the vboxvideo DRM module (NetBSD kernel OpenGL module).
++#
++
++#
++# Copyright (C) 2009-2015 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.
++#
++
++
++SUB_DEPTH = ../../../../..
++include $(KBUILD_PATH)/subheader.kmk
++
++INSTALLS += vboxvideo-mod
++
++ifdef VBOX_WITH_ADDITION_DRIVERS
++ SYSMODS  += vboxvideo_drm
++endif
++ifneq ($(KBUILD_HOST),netbsd)
++$(error "The NetBSD guest additions can only be built on NetBSD!")
++endif
++
++#
++# Populate FILES_VBOXVIDEO_DRM_NOBIN
++#
++include $(PATH_SUB_CURRENT)/files_vboxvideo_drm
++
++# vboxvideo source
++vboxvideo-mod_INST        = $(INST_ADDITIONS)src/vboxvideo_drm/
++vboxvideo-mod_MODE        = a+r,u+w
++vboxvideo-mod_SOURCES     = $(subst ",,$(FILES_VBOXVIDEO_DRM_NOBIN))
++
++#
++# vboxvideo - The Video DRM (Direct Rendering Module) kernel module
++#
++# Note! Syntax checking only.
++#
++vboxvideo_drm_TEMPLATE      = VBOXGUESTR0
++vboxvideo_drm_NAME          = vboxvideo
++vboxvideo_drm_DEFS          = VBOX_WITH_HGCM VBOX_SVN_REV=$(VBOX_SVN_REV)
++vboxvideo_drm_DEPS         += $(VBOX_SVN_REV_KMK)
++vboxvideo_drm_INCS.netbsd  = \
++	$(vboxvideo_drm_0_OUTDIR) \
++	$(PATH_STAGE)/gen-sys-hdrs
++vboxvideo_drm_SOURCES       = vboxvideo_drm.c
++vboxvideo_drm_LIBS          = \
++	$(VBOX_LIB_VBGL_R0) \
++	$(VBOX_LIB_IPRT_GUEST_R0)
++vboxvideo_drm_ORDERDEPS.netbsd = \
++	$(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_CLEAN.netbsd = $(vboxvideo_drm_DEPS)
++
++#
++# Header for DRM not included by us.
++#
++$$(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)
diff --git a/virtualbox-svn/patches/patch-src_VBox_Additions_netbsd_drm_files__vboxvideo__drm b/virtualbox-svn/patches/patch-src_VBox_Additions_netbsd_drm_files__vboxvideo__drm
new file mode 100644
index 0000000..26e63e2
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Additions_netbsd_drm_files__vboxvideo__drm
@@ -0,0 +1,30 @@
+$NetBSD$
+
+--- src/VBox/Additions/netbsd/drm/files_vboxvideo_drm.orig	2016-07-07 07:08:46.413493808 +0000
++++ src/VBox/Additions/netbsd/drm/files_vboxvideo_drm
+@@ -0,0 +1,25 @@
++#!/bin/sh
++#  files_vboxvideo_drm $
++## @file
++# Shared file between Makefile.kmk and export_modules
++#
++
++#
++# Copyright (C) 2007-2010 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.
++#
++
++FILES_VBOXVIDEO_DRM_NOBIN=" \
++    ${PATH_ROOT}/src/VBox/Additions/netbsd/drm/vboxvideo_drm.c=>vboxvideo_drm.c \
++    ${PATH_ROOT}/src/VBox/Additions/netbsd/drm/Makefile=>Makefile \
++"
++
++FILES_VBOXVIDEO_DRM_BIN=" \
++"
diff --git a/virtualbox-svn/patches/patch-src_VBox_Additions_netbsd_drm_vboxvideo__drm.c b/virtualbox-svn/patches/patch-src_VBox_Additions_netbsd_drm_vboxvideo__drm.c
new file mode 100644
index 0000000..f701732
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Additions_netbsd_drm_vboxvideo__drm.c
@@ -0,0 +1,144 @@
+$NetBSD$
+
+--- src/VBox/Additions/netbsd/drm/vboxvideo_drm.c.orig	2016-07-07 07:08:46.422526448 +0000
++++ src/VBox/Additions/netbsd/drm/vboxvideo_drm.c
+@@ -0,0 +1,139 @@
++/*  vboxvideo_drm.c $ */
++/** @file
++ * VirtualBox Guest Additions - vboxvideo DRM module.
++ * NetBSD kernel OpenGL module.
++ */
++
++/*
++ * Copyright (C) 2006-2010 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.
++ * --------------------------------------------------------------------
++ *
++ * This code is based on:
++ *
++ * tdfx_drv.c -- tdfx driver -*- linux-c -*-
++ * Created: Thu Oct  7 10:38:32 1999 by faith%precisioninsight.com@localhost
++ *
++ * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
++ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
++ * All Rights Reserved.
++ *
++ * Permission is hereby granted, free of charge, to any person obtaining a
++ * copy of this software and associated documentation files (the "Software"),
++ * to deal in the Software without restriction, including without limitation
++ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
++ * and/or sell copies of the Software, and to permit persons to whom the
++ * Software is furnished to do so, subject to the following conditions:
++ *
++ * The above copyright notice and this permission notice (including the next
++ * paragraph) shall be included in all copies or substantial portions of the
++ * Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
++ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
++ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
++ * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
++ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
++ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
++ * DEALINGS IN THE SOFTWARE.
++ *
++ * Authors:
++ *    Rickard E. (Rik) Faith <faith%valinux.com@localhost>
++ *    Daryll Strauss <daryll%valinux.com@localhost>
++ *    Gareth Hughes <gareth%valinux.com@localhost>
++ *
++ */
++
++#include <sys/cdefs.h>
++
++#include "dev/drm/drmP.h"
++#include "dev/drm/drm_pciids.h"
++
++#define DRIVER_AUTHOR                   "Oracle Corporation"
++#define DRIVER_NAME                     "vboxvideo"
++#define DRIVER_DESC                     "VirtualBox DRM"
++#define DRIVER_DATE                     "20090317"
++#define DRIVER_MAJOR                    1
++#define DRIVER_MINOR                    0
++#define DRIVER_PATCHLEVEL               0
++
++/** @todo Take PCI IDs from VBox/param.h; VBOX_VESA_VENDORID,
++ *        VBOX_VESA_DEVICEID. */
++#define vboxvideo_PCI_IDS           { 0x80ee, 0xbeef, 0, "VirtualBox Video" }, \
++                                    { 0, 0, 0, NULL }
++
++static drm_pci_id_list_t vboxvideo_pciidlist[] = {
++	vboxvideo_PCI_IDS
++};
++
++static void vboxvideo_configure(struct drm_device *dev)
++{
++	dev->driver->buf_priv_size	= 1; /* No dev_priv */
++
++	dev->driver->max_ioctl		= 0;
++
++	dev->driver->name		= DRIVER_NAME;
++	dev->driver->desc		= DRIVER_DESC;
++	dev->driver->date		= DRIVER_DATE;
++	dev->driver->major		= DRIVER_MAJOR;
++	dev->driver->minor		= DRIVER_MINOR;
++	dev->driver->patchlevel		= DRIVER_PATCHLEVEL;
++}
++
++static int
++vboxvideo_probe(device_t kdev)
++{
++	return drm_probe(kdev, vboxvideo_pciidlist);
++}
++
++static int
++vboxvideo_attach(device_t kdev)
++{
++	struct drm_device *dev = device_get_softc(kdev);
++
++	dev->driver = malloc(sizeof(struct drm_driver_info), DRM_MEM_DRIVER,
++	    M_WAITOK | M_ZERO);
++
++	vboxvideo_configure(dev);
++
++	return drm_attach(kdev, vboxvideo_pciidlist);
++}
++
++static int
++vboxvideo_detach(device_t kdev)
++{
++	struct drm_device *dev = device_get_softc(kdev);
++	int ret;
++
++	ret = drm_detach(kdev);
++
++	free(dev->driver, DRM_MEM_DRIVER);
++
++	return ret;
++}
++
++static device_method_t vboxvideo_methods[] = {
++	/* Device interface */
++	DEVMETHOD(device_probe,		vboxvideo_probe),
++	DEVMETHOD(device_attach,	vboxvideo_attach),
++	DEVMETHOD(device_detach,	vboxvideo_detach),
++
++	{ 0, 0 }
++};
++
++static driver_t vboxvideo_driver = {
++	"drm",
++	vboxvideo_methods,
++	sizeof(struct drm_device)
++};
++
++extern devclass_t drm_devclass;
++DRIVER_MODULE(vboxvideo, vgapci, vboxvideo_driver, drm_devclass, 0, 0);
++MODULE_DEPEND(vboxvideo, drm, 1, 1, 1);
diff --git a/virtualbox-svn/patches/patch-src_VBox_Additions_netbsd_vboxvfs_Makefile.kmk b/virtualbox-svn/patches/patch-src_VBox_Additions_netbsd_vboxvfs_Makefile.kmk
new file mode 100644
index 0000000..6678eb2
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Additions_netbsd_vboxvfs_Makefile.kmk
@@ -0,0 +1,68 @@
+$NetBSD$
+
+--- src/VBox/Additions/netbsd/vboxvfs/Makefile.kmk.orig	2016-07-07 07:08:46.431560014 +0000
++++ src/VBox/Additions/netbsd/vboxvfs/Makefile.kmk
+@@ -0,0 +1,63 @@
++# Id: Makefile.kmk $
++## @file
++# Sub-Makefile for the NetBSD Shared folder kernel module.
++#
++
++#
++# Copyright (C) 2007-2015 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.
++#
++
++SUB_DEPTH = ../../../../..
++include $(KBUILD_PATH)/subheader.kmk
++
++ifneq ($(KBUILD_HOST),netbsd)
++$(error "The NetBSD guest additions can only be built on NetBSD!")
++endif
++
++#
++# vboxvfs - The Shared Folder Driver
++#
++SYSMODS.netbsd      += vboxvfs
++vboxvfs_TEMPLATE      = VBOXGUESTR0
++vboxvfs_DEFS          = VBOX_WITH_HGCM
++vboxvfs_INCS          = \
++        . \
++       $(vboxvfs_0_OUTDIR)
++vboxvfs_SOURCES       = \
++	vboxvfs_vfsops.c \
++	vboxvfs_vnops.c
++vboxvfs_LIBS          = \
++	$(VBOX_LIB_VBGL_R0) \
++	$(VBOX_LIB_IPRT_GUEST_R0)
++vboxvfs_DEPS          = \
++       $$(vboxvfs_0_OUTDIR)/vnode_if.h \
++       $$(vboxvfs_0_OUTDIR)/vnode_if_newproto.h \
++       $$(vboxvfs_0_OUTDIR)/vnode_if_typedef.h
++vboxvfs_CLEAN        += $(vboxvfs_DEPS)
++
++VBOX_AWK := /usr/bin/awk
++
++$$(vboxvfs_0_OUTDIR)/vnode_if.h: $(VBOX_NETBSD_SRC)/kern/vnode_if.src
++	$(call MSG_TOOL,awk,VBoxGuest,$<,$@)
++	$(QUIET)$(VBOX_AWK) -f $(VBOX_NETBSD_SRC)/tools/vnode_if.awk $(VBOX_NETBSD_SRC)/kern/vnode_if.src -h
++	$(QUIET)$(MV) $(vboxvfs_0_OUTDIR)/vnode_if.h $(vboxvfs_0_OUTDIR)/vnode_if.h
++
++$$(vboxvfs_0_OUTDIR)/vnode_if_newproto.h: $(VBOX_NETBSD_SRC)/kern/vnode_if.src
++	$(call MSG_TOOL,awk,VBoxGuest,$<,$@)
++	$(QUIET)$(VBOX_AWK) -f $(VBOX_NETBSD_SRC)/tools/vnode_if.awk $(VBOX_NETBSD_SRC)/kern/vnode_if.src -p
++	$(QUIET)$(MV) $(vboxvfs_0_OUTDIR)/vnode_if_newproto.h $(vboxvfs_0_OUTDIR)/vnode_if_newproto.h
++
++$$(vboxvfs_0_OUTDIR)/vnode_if_typedef.h: $(VBOX_NETBSD_SRC)/kern/vnode_if.src
++	$(call MSG_TOOL,awk,VBoxGuest,$<,$@)
++	$(QUIET)$(VBOX_AWK) -f $(VBOX_NETBSD_SRC)/tools/vnode_if.awk $(VBOX_NETBSD_SRC)/kern/vnode_if.src -q
++	$(QUIET)$(MV) $(vboxvfs_0_OUTDIR)/vnode_if_typedef.h $(vboxvfs_0_OUTDIR)/vnode_if_typedef.h
++
++include $(FILE_KBUILD_SUB_FOOTER)
diff --git a/virtualbox-svn/patches/patch-src_VBox_Additions_netbsd_vboxvfs_vboxvfs.h b/virtualbox-svn/patches/patch-src_VBox_Additions_netbsd_vboxvfs_vboxvfs.h
new file mode 100644
index 0000000..c0b1f67
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Additions_netbsd_vboxvfs_vboxvfs.h
@@ -0,0 +1,97 @@
+$NetBSD$
+
+--- src/VBox/Additions/netbsd/vboxvfs/vboxvfs.h.orig	2016-07-06 19:39:01.675495646 +0000
++++ src/VBox/Additions/netbsd/vboxvfs/vboxvfs.h
+@@ -0,0 +1,92 @@
++/*  vboxvfs.h $ */
++/** @file
++ * Description.
++ */
++
++/*
++ * Copyright (C) 2010 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.
++ */
++
++#ifndef ___VBOXVFS_H___
++#define ___VBOXVFS_H___
++
++#define VBOXVFS_VFSNAME "vboxvfs"
++#define VBOXVFS_VERSION 1
++
++#define MAX_HOST_NAME 256
++#define MAX_NLS_NAME 32
++
++struct vboxvfs_mount_info {
++    char name[MAX_HOST_NAME];
++    char nls_name[MAX_NLS_NAME];
++    int uid;
++    int gid;
++    int ttl;
++};
++
++#ifdef _KERNEL
++
++#include <VBox/VBoxGuestLibSharedFolders.h>
++#include <sys/mount.h>
++#include <sys/vnode.h>
++
++struct vboxvfsmount {
++    uid_t           uid;
++    gid_t           gid;
++    mode_t          file_mode;
++    mode_t          dir_mode;
++    struct mount   *mp;
++    struct ucred   *owner;
++    u_int           flags;
++    long            nextino;
++    int             caseopt;
++    int             didrele;
++};
++
++/* structs - stolen from the linux shared module code */
++struct sf_glob_info {
++    VBGLSFMAP map;
++/*    struct nls_table *nls;*/
++    int ttl;
++    int uid;
++    int gid;
++    struct vnode *vnode_root;
++};
++
++struct sf_inode_info {
++    SHFLSTRING *path;
++    int force_restat;
++};
++
++#if 0
++struct sf_dir_info {
++    struct list_head info_list;
++};
++#endif
++
++struct sf_dir_buf {
++    size_t nb_entries;
++    size_t free_bytes;
++    size_t used_bytes;
++    void *buf;
++#if 0
++   struct list_head head;
++#endif
++};
++
++struct sf_reg_info {
++    SHFLHANDLE handle;
++};
++
++#endif  /* KERNEL */
++
++#endif /* !___VBOXVFS_H___ */
++
diff --git a/virtualbox-svn/patches/patch-src_VBox_Additions_netbsd_vboxvfs_vboxvfs__vfsops.c b/virtualbox-svn/patches/patch-src_VBox_Additions_netbsd_vboxvfs_vboxvfs__vfsops.c
new file mode 100644
index 0000000..8f9c9b7
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Additions_netbsd_vboxvfs_vboxvfs__vfsops.c
@@ -0,0 +1,263 @@
+$NetBSD$
+
+--- src/VBox/Additions/netbsd/vboxvfs/vboxvfs_vfsops.c.orig	2016-07-06 19:39:01.675500224 +0000
++++ src/VBox/Additions/netbsd/vboxvfs/vboxvfs_vfsops.c
+@@ -0,0 +1,258 @@
++/*  vboxvfs_vfsops.c $ */
++/** @file
++ * Description.
++ */
++
++/*
++ * Copyright (C) 2008-2010 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.
++ */
++
++#include "vboxvfs.h"
++#include <sys/param.h>
++#include <sys/systm.h>
++#include <sys/proc.h>
++#include <sys/bio.h>
++#include <sys/buf.h>
++#include <sys/kernel.h>
++#include <sys/sysctl.h>
++#include <sys/vnode.h>
++#include <sys/mount.h>
++#include <sys/stat.h>
++#include <sys/malloc.h>
++#include <sys/module.h>
++
++#include <iprt/mem.h>
++
++#define VFSMP2SFGLOBINFO(mp) ((struct sf_glob_info *)mp->mnt_data)
++
++static int vboxvfs_version = VBOXVFS_VERSION;
++
++SYSCTL_NODE(_vfs, OID_AUTO, vboxvfs, CTLFLAG_RW, 0, "VirtualBox shared filesystem");
++SYSCTL_INT(_vfs_vboxvfs, OID_AUTO, version, CTLFLAG_RD, &vboxvfs_version, 0, "");
++
++/* global connection to the host service. */
++static VBGLSFCLIENT g_vboxSFClient;
++
++static vfs_init_t       vboxvfs_init;
++static vfs_uninit_t     vboxvfs_uninit;
++static vfs_cmount_t     vboxvfs_cmount;
++static vfs_mount_t      vboxvfs_mount;
++static vfs_root_t       vboxvfs_root;
++static vfs_quotactl_t   vboxvfs_quotactl;
++static vfs_statfs_t     vboxvfs_statfs;
++static vfs_unmount_t    vboxvfs_unmount;
++
++static struct vfsops vboxvfs_vfsops = {
++    .vfs_init     =    vboxvfs_init,
++    .vfs_cmount   =    vboxvfs_cmount,
++    .vfs_mount    =    vboxvfs_mount,
++    .vfs_quotactl =    vboxvfs_quotactl,
++    .vfs_root     =    vboxvfs_root,
++    .vfs_statfs   =    vboxvfs_statfs,
++    .vfs_sync     =    vfs_stdsync,
++    .vfs_uninit   =    vboxvfs_uninit,
++    .vfs_unmount  =    vboxvfs_unmount,
++};
++
++
++VFS_SET(vboxvfs_vfsops, vboxvfs, VFCF_NETWORK);
++MODULE_DEPEND(vboxvfs, vboxguest, 1, 1, 1);
++
++static int vboxvfs_cmount(struct mntarg *ma, void * data, int flags, struct thread *td)
++{
++    struct vboxvfs_mount_info args;
++    int rc = 0;
++
++    printf("%s: Enter\n", __FUNCTION__);
++
++    rc = copyin(data, &args, sizeof(struct vboxvfs_mount_info));
++    if (rc)
++        return rc;
++
++    ma = mount_argf(ma, "uid", "%d", args.uid);
++    ma = mount_argf(ma, "gid", "%d", args.gid);
++    ma = mount_arg(ma, "from", args.name, -1);
++
++    rc = kernel_mount(ma, flags);
++
++    printf("%s: Leave rc=%d\n", __FUNCTION__, rc);
++
++    return rc;
++}
++
++static const char *vboxvfs_opts[] = {
++    "uid", "gid", "from", "fstype", "fspath", "errmsg", NULL
++};
++
++static int vboxvfs_mount(struct mount *mp, struct thread *td)
++{
++    int rc;
++    char *pszShare;
++    int  cbShare, cbOption;
++    int uid = 0, gid = 0;
++    struct sf_glob_info *pShFlGlobalInfo;
++    SHFLSTRING *pShFlShareName = NULL;
++    int cbShFlShareName;
++
++    printf("%s: Enter\n", __FUNCTION__);
++
++    if (mp->mnt_flag & (MNT_UPDATE | MNT_ROOTFS))
++        return EOPNOTSUPP;
++
++    if (vfs_filteropt(mp->mnt_optnew, vboxvfs_opts))
++    {
++        vfs_mount_error(mp, "%s", "Invalid option");
++        return EINVAL;
++    }
++
++    rc = vfs_getopt(mp->mnt_optnew, "from", (void **)&pszShare, &cbShare);
++    if (rc || pszShare[cbShare-1] != '\0' || cbShare > 0xfffe)
++        return EINVAL;
++
++    rc = vfs_getopt(mp->mnt_optnew, "gid", (void **)&gid, &cbOption);
++    if ((rc != ENOENT) && (rc || cbOption != sizeof(gid)))
++        return EINVAL;
++
++    rc = vfs_getopt(mp->mnt_optnew, "uid", (void **)&uid, &cbOption);
++    if ((rc != ENOENT) && (rc || cbOption != sizeof(uid)))
++        return EINVAL;
++
++    pShFlGlobalInfo = RTMemAllocZ(sizeof(struct sf_glob_info));
++    if (!pShFlGlobalInfo)
++        return ENOMEM;
++
++    cbShFlShareName = offsetof (SHFLSTRING, String.utf8) + cbShare + 1;
++    pShFlShareName  = RTMemAllocZ(cbShFlShareName);
++    if (!pShFlShareName)
++        return VERR_NO_MEMORY;
++
++    pShFlShareName->u16Length = cbShare;
++    pShFlShareName->u16Size   = cbShare + 1;
++    memcpy (pShFlShareName->String.utf8, pszShare, cbShare + 1);
++
++    rc = VbglR0SfMapFolder (&g_vboxSFClient, pShFlShareName, &pShFlGlobalInfo->map);
++    RTMemFree(pShFlShareName);
++
++    if (RT_FAILURE (rc))
++    {
++        RTMemFree(pShFlGlobalInfo);
++        printf("VbglR0SfMapFolder failed rc=%d\n", rc);
++        return EPROTO;
++    }
++
++    pShFlGlobalInfo->uid = uid;
++    pShFlGlobalInfo->gid = gid;
++
++    mp->mnt_data = pShFlGlobalInfo;
++
++    /* @todo root vnode. */
++
++    vfs_getnewfsid(mp);
++    vfs_mountedfrom(mp, pszShare);
++
++    printf("%s: Leave rc=0\n", __FUNCTION__);
++
++    return 0;
++}
++
++static int vboxvfs_unmount(struct mount *mp, int mntflags, struct thread *td)
++{
++    struct sf_glob_info *pShFlGlobalInfo = VFSMP2SFGLOBINFO(mp);
++    int rc;
++    int flags = 0;
++
++    rc = VbglR0SfUnmapFolder(&g_vboxSFClient, &pShFlGlobalInfo->map);
++    if (RT_FAILURE(rc))
++        printf("Failed to unmap shared folder\n");
++
++    if (mntflags & MNT_FORCE)
++        flags |= FORCECLOSE;
++
++    /* There is 1 extra root vnode reference (vnode_root). */
++    rc = vflush(mp, 1, flags, td);
++    if (rc)
++        return rc;
++
++
++    RTMemFree(pShFlGlobalInfo);
++    mp->mnt_data = NULL;
++
++    return 0;
++}
++
++static int vboxvfs_root(struct mount *mp, int flags, struct vnode **vpp, struct thread *td)
++{
++    int rc = 0;
++    struct sf_glob_info *pShFlGlobalInfo = VFSMP2SFGLOBINFO(mp);
++    struct vnode *vp;
++
++    printf("%s: Enter\n", __FUNCTION__);
++
++    vp = pShFlGlobalInfo->vnode_root;
++    VREF(vp);
++
++    vn_lock(vp, flags | LK_RETRY, td);
++    *vpp = vp;
++
++    printf("%s: Leave\n", __FUNCTION__);
++
++    return rc;
++}
++
++static int vboxvfs_quotactl(struct mount *mp, int cmd, uid_t uid, void *arg, struct thread *td)
++{
++    return EOPNOTSUPP;
++}
++
++int vboxvfs_init(struct vfsconf *vfsp)
++{
++    int rc;
++
++    /* Initialize the R0 guest library. */
++    rc = VbglR0SfInit();
++    if (RT_FAILURE(rc))
++        return ENXIO;
++
++    /* Connect to the host service. */
++    rc = VbglR0SfConnect(&g_vboxSFClient);
++    if (RT_FAILURE(rc))
++    {
++        printf("Failed to get connection to host! rc=%d\n", rc);
++        VbglR0SfTerm();
++        return ENXIO;
++    }
++
++    rc = VbglR0SfSetUtf8(&g_vboxSFClient);
++    if (RT_FAILURE (rc))
++    {
++        printf("VbglR0SfSetUtf8 failed, rc=%d\n", rc);
++        VbglR0SfDisconnect(&g_vboxSFClient);
++        VbglR0SfTerm();
++        return EPROTO;
++    }
++
++    printf("Successfully loaded shared folder module\n");
++
++    return 0;
++}
++
++int vboxvfs_uninit(struct vfsconf *vfsp)
++{
++    VbglR0SfDisconnect(&g_vboxSFClient);
++    VbglR0SfTerm();
++
++    return 0;
++}
++
++int vboxvfs_statfs(struct mount *mp, struct statfs *sbp, struct thread *td)
++{
++    return 0;
++}
diff --git a/virtualbox-svn/patches/patch-src_VBox_Additions_netbsd_vboxvfs_vboxvfs__vnops.c b/virtualbox-svn/patches/patch-src_VBox_Additions_netbsd_vboxvfs_vboxvfs__vnops.c
new file mode 100644
index 0000000..977ca9f
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Additions_netbsd_vboxvfs_vboxvfs__vnops.c
@@ -0,0 +1,246 @@
+$NetBSD$
+
+--- src/VBox/Additions/netbsd/vboxvfs/vboxvfs_vnops.c.orig	2016-07-06 19:39:01.675503997 +0000
++++ src/VBox/Additions/netbsd/vboxvfs/vboxvfs_vnops.c
+@@ -0,0 +1,241 @@
++/*  vboxvfs_vnops.c $ */
++/** @file
++ * Description.
++ */
++
++/*
++ * Copyright (C) 2008-2010 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.
++ */
++
++#include "vboxvfs.h"
++#include <sys/param.h>
++#include <sys/systm.h>
++#include <sys/namei.h>
++#include <sys/kernel.h>
++#include <sys/proc.h>
++#include <sys/bio.h>
++#include <sys/buf.h>
++#include <sys/fcntl.h>
++#include <sys/mount.h>
++#include <sys/unistd.h>
++#include <sys/vnode.h>
++#include <sys/limits.h>
++#include <sys/lockf.h>
++#include <sys/stat.h>
++
++#include <vm/vm.h>
++#include <vm/vm_extern.h>
++
++/*
++ * Prototypes for VBOXVFS vnode operations
++ */
++static vop_create_t     vboxvfs_create;
++static vop_mknod_t      vboxvfs_mknod;
++static vop_open_t       vboxvfs_open;
++static vop_close_t      vboxvfs_close;
++static vop_access_t     vboxvfs_access;
++static vop_getattr_t    vboxvfs_getattr;
++static vop_setattr_t    vboxvfs_setattr;
++static vop_read_t       vboxvfs_read;
++static vop_write_t      vboxvfs_write;
++static vop_fsync_t      vboxvfs_fsync;
++static vop_remove_t     vboxvfs_remove;
++static vop_link_t       vboxvfs_link;
++static vop_lookup_t     vboxvfs_lookup;
++static vop_rename_t     vboxvfs_rename;
++static vop_mkdir_t      vboxvfs_mkdir;
++static vop_rmdir_t      vboxvfs_rmdir;
++static vop_symlink_t    vboxvfs_symlink;
++static vop_readdir_t    vboxvfs_readdir;
++static vop_strategy_t   vboxvfs_strategy;
++static vop_print_t      vboxvfs_print;
++static vop_pathconf_t   vboxvfs_pathconf;
++static vop_advlock_t    vboxvfs_advlock;
++static vop_getextattr_t vboxvfs_getextattr;
++static vop_ioctl_t      vboxvfs_ioctl;
++static vop_getpages_t   vboxvfs_getpages;
++static vop_inactive_t   vboxvfs_inactive;
++static vop_putpages_t   vboxvfs_putpages;
++static vop_reclaim_t    vboxvfs_reclaim;
++
++struct vop_vector vboxvfs_vnodeops = {
++    .vop_default    =   &default_vnodeops,
++
++    .vop_access     =   vboxvfs_access,
++    .vop_advlock    =   vboxvfs_advlock,
++    .vop_close      =   vboxvfs_close,
++    .vop_create     =   vboxvfs_create,
++    .vop_fsync      =   vboxvfs_fsync,
++    .vop_getattr    =   vboxvfs_getattr,
++    .vop_getextattr =   vboxvfs_getextattr,
++    .vop_getpages   =   vboxvfs_getpages,
++    .vop_inactive   =   vboxvfs_inactive,
++    .vop_ioctl      =   vboxvfs_ioctl,
++    .vop_link       =   vboxvfs_link,
++    .vop_lookup     =   vboxvfs_lookup,
++    .vop_mkdir      =   vboxvfs_mkdir,
++    .vop_mknod      =   vboxvfs_mknod,
++    .vop_open       =   vboxvfs_open,
++    .vop_pathconf   =   vboxvfs_pathconf,
++    .vop_print      =   vboxvfs_print,
++    .vop_putpages   =   vboxvfs_putpages,
++    .vop_read       =   vboxvfs_read,
++    .vop_readdir    =   vboxvfs_readdir,
++    .vop_reclaim    =   vboxvfs_reclaim,
++    .vop_remove     =   vboxvfs_remove,
++    .vop_rename     =   vboxvfs_rename,
++    .vop_rmdir      =   vboxvfs_rmdir,
++    .vop_setattr    =   vboxvfs_setattr,
++    .vop_strategy   =   vboxvfs_strategy,
++    .vop_symlink    =   vboxvfs_symlink,
++    .vop_write      =   vboxvfs_write,
++};
++
++static int vboxvfs_access(struct vop_access_args *ap)
++{
++    return 0;
++}
++
++static int vboxvfs_open(struct vop_open_args *ap)
++{
++    return 0;
++}
++
++static int vboxvfs_close(struct vop_close_args *ap)
++{
++    return 0;
++}
++
++static int vboxvfs_getattr(struct vop_getattr_args *ap)
++{
++    return 0;
++}
++
++static int vboxvfs_setattr(struct vop_setattr_args *ap)
++{
++    return 0;
++}
++
++static int vboxvfs_read(struct vop_read_args *ap)
++{
++    return 0;
++}
++
++static int vboxvfs_write(struct vop_write_args *ap)
++{
++    return 0;
++}
++
++static int vboxvfs_create(struct vop_create_args *ap)
++{
++    return 0;
++}
++
++static int vboxvfs_remove(struct vop_remove_args *ap)
++{
++    return 0;
++}
++
++static int vboxvfs_rename(struct vop_rename_args *ap)
++{
++    return 0;
++}
++
++static int vboxvfs_link(struct vop_link_args *ap)
++{
++    return EOPNOTSUPP;
++}
++
++static int vboxvfs_symlink(struct vop_symlink_args *ap)
++{
++    return EOPNOTSUPP;
++}
++
++static int vboxvfs_mknod(struct vop_mknod_args *ap)
++{
++    return EOPNOTSUPP;
++}
++
++static int vboxvfs_mkdir(struct vop_mkdir_args *ap)
++{
++    return 0;
++}
++
++static int vboxvfs_rmdir(struct vop_rmdir_args *ap)
++{
++    return 0;
++}
++
++static int vboxvfs_readdir(struct vop_readdir_args *ap)
++{
++    return 0;
++}
++
++static int vboxvfs_fsync(struct vop_fsync_args *ap)
++{
++    return 0;
++}
++
++static int vboxvfs_print (struct vop_print_args *ap)
++{
++    return 0;
++}
++
++static int vboxvfs_pathconf (struct vop_pathconf_args *ap)
++{
++    return 0;
++}
++
++static int vboxvfs_strategy (struct vop_strategy_args *ap)
++{
++    return 0;
++}
++
++static int vboxvfs_ioctl(struct vop_ioctl_args *ap)
++{
++    return ENOTTY;
++}
++
++static int vboxvfs_getextattr(struct vop_getextattr_args *ap)
++{
++    return 0;
++}
++
++static int vboxvfs_advlock(struct vop_advlock_args *ap)
++{
++    return 0;
++}
++
++static int vboxvfs_lookup(struct vop_lookup_args *ap)
++{
++    return 0;
++}
++
++static int vboxvfs_inactive(struct vop_inactive_args *ap)
++{
++    return 0;
++}
++
++static int vboxvfs_reclaim(struct vop_reclaim_args *ap)
++{
++    return 0;
++}
++
++static int vboxvfs_getpages(struct vop_getpages_args *ap)
++{
++    return 0;
++}
++
++static int vboxvfs_putpages(struct vop_putpages_args *ap)
++{
++    return 0;
++}
++
diff --git a/virtualbox-svn/patches/patch-src_VBox_Debugger_DBGCCommands.cpp b/virtualbox-svn/patches/patch-src_VBox_Debugger_DBGCCommands.cpp
new file mode 100644
index 0000000..1cad603
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Debugger_DBGCCommands.cpp
@@ -0,0 +1,18 @@
+$NetBSD$
+
+--- src/VBox/Debugger/DBGCCommands.cpp.orig	2016-03-04 19:25:46.000000000 +0000
++++ src/VBox/Debugger/DBGCCommands.cpp
+@@ -1847,7 +1847,7 @@ static DECLCALLBACK(int) dbgcCmdWriteCor
+ /**
+  * @callback_method_impl{FNDBGCFUNC, The randu32() function implementation.}
+  */
+-static DECLCALLBACK(int) dbgcFuncRandU32(PCDBGCFUNC pFunc, PDBGCCMDHLP pCmdHlp, PVM pUVM, PCDBGCVAR paArgs, uint32_t cArgs,
++static DECLCALLBACK(int) dbgcFuncRandU32(PCDBGCFUNC pFunc, PDBGCCMDHLP pCmdHlp, vbox_PVM pUVM, PCDBGCVAR paArgs, uint32_t cArgs,
+                                          PDBGCVAR pResult)
+ {
+     AssertReturn(cArgs == 0, VERR_DBGC_PARSE_BUG);
+@@ -1856,4 +1856,3 @@ static DECLCALLBACK(int) dbgcFuncRandU32
+     NOREF(pFunc); NOREF(pCmdHlp); NOREF(pUVM); NOREF(paArgs);
+     return VINF_SUCCESS;
+ }
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_Debugger_DBGCInternal.h b/virtualbox-svn/patches/patch-src_VBox_Debugger_DBGCInternal.h
new file mode 100644
index 0000000..a8ed40b
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Debugger_DBGCInternal.h
@@ -0,0 +1,18 @@
+$NetBSD$
+
+--- src/VBox/Debugger/DBGCInternal.h.orig	2016-03-04 19:25:46.000000000 +0000
++++ src/VBox/Debugger/DBGCInternal.h
+@@ -89,7 +89,7 @@ typedef struct DBGC
+     PDBGCBACK           pBack;
+ 
+     /** Pointer to the current VM. */
+-    PVM                 pVM;
++    vbox_PVM                 pVM;
+     /** The user mode handle of the current VM. */
+     PUVM                pUVM;
+     /** The ID of current virtual CPU. */
+@@ -410,4 +410,3 @@ extern const uint32_t   g_cDbgcOps;
+ 
+ 
+ #endif
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_Debugger_DBGConsole.cpp b/virtualbox-svn/patches/patch-src_VBox_Debugger_DBGConsole.cpp
new file mode 100644
index 0000000..16c08a8
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Debugger_DBGConsole.cpp
@@ -0,0 +1,18 @@
+$NetBSD$
+
+--- src/VBox/Debugger/DBGConsole.cpp.orig	2016-03-04 19:25:46.000000000 +0000
++++ src/VBox/Debugger/DBGConsole.cpp
+@@ -1004,7 +1004,7 @@ DBGDECL(int) DBGCCreate(PUVM pUVM, PDBGC
+      * Validate input.
+      */
+     AssertPtrNullReturn(pUVM, VERR_INVALID_VM_HANDLE);
+-    PVM pVM = NULL;
++    vbox_PVM pVM = NULL;
+     if (pUVM)
+     {
+         pVM = VMR3GetVM(pUVM);
+@@ -1100,4 +1100,3 @@ DBGDECL(int) DBGCCreate(PUVM pUVM, PDBGC
+     dbgcDestroy(pDbgc);
+     return rc == VERR_DBGC_QUIT ? VINF_SUCCESS : rc;
+ }
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_Debugger_DBGPlugInDiggers.cpp b/virtualbox-svn/patches/patch-src_VBox_Debugger_DBGPlugInDiggers.cpp
new file mode 100644
index 0000000..abf73f1
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Debugger_DBGPlugInDiggers.cpp
@@ -0,0 +1,17 @@
+$NetBSD$
+
+--- src/VBox/Debugger/DBGPlugInDiggers.cpp.orig	2016-03-04 19:25:46.000000000 +0000
++++ src/VBox/Debugger/DBGPlugInDiggers.cpp
+@@ -33,6 +33,7 @@ DECLEXPORT(int) DbgPlugInEntry(DBGFPLUGI
+     {
+         &g_DBGDiggerDarwin,
+         //&g_DBGDiggerFreeBSD,
++        //&g_DBGDiggerNetBSD,
+         &g_DBGDiggerLinux,
+         &g_DBGDiggerOS2,
+         &g_DBGDiggerSolaris,
+@@ -74,4 +75,3 @@ DECLEXPORT(int) DbgPlugInEntry(DBGFPLUGI
+             return VERR_NOT_SUPPORTED;
+     }
+ }
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_Debugger_DBGPlugIns.h b/virtualbox-svn/patches/patch-src_VBox_Debugger_DBGPlugIns.h
new file mode 100644
index 0000000..790957a
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Debugger_DBGPlugIns.h
@@ -0,0 +1,17 @@
+$NetBSD$
+
+--- src/VBox/Debugger/DBGPlugIns.h.orig	2016-03-04 19:25:46.000000000 +0000
++++ src/VBox/Debugger/DBGPlugIns.h
+@@ -26,6 +26,7 @@
+ RT_C_DECLS_BEGIN
+ 
+ //extern const DBGFOSREG g_DBGDiggerFreeBSD;
++//extern const DBGFOSREG g_DBGDiggerNetBSD;
+ extern const DBGFOSREG g_DBGDiggerDarwin;
+ extern const DBGFOSREG g_DBGDiggerLinux;
+ extern const DBGFOSREG g_DBGDiggerOS2;
+@@ -35,4 +36,3 @@ extern const DBGFOSREG g_DBGDiggerWinNt;
+ RT_C_DECLS_END
+ 
+ #endif
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_Devices_Bus_SrvPciRawR0.cpp b/virtualbox-svn/patches/patch-src_VBox_Devices_Bus_SrvPciRawR0.cpp
new file mode 100644
index 0000000..506df25
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Devices_Bus_SrvPciRawR0.cpp
@@ -0,0 +1,40 @@
+$NetBSD$
+
+--- src/VBox/Devices/Bus/SrvPciRawR0.cpp.orig	2016-03-04 19:25:48.000000000 +0000
++++ src/VBox/Devices/Bus/SrvPciRawR0.cpp
+@@ -169,7 +169,7 @@ PCIRAWR0DECL(void) PciRawR0Term(void)
+ /**
+  * Per-VM R0 module init.
+  */
+-PCIRAWR0DECL(int)  PciRawR0InitVM(PVM pVM)
++PCIRAWR0DECL(int)  PciRawR0InitVM(vbox_PVM pVM)
+ {
+     PRAWPCIFACTORY pFactory = NULL;
+     int            rc;
+@@ -194,7 +194,7 @@ PCIRAWR0DECL(int)  PciRawR0InitVM(PVM pV
+ /**
+  * Per-VM R0 module termination routine.
+  */
+-PCIRAWR0DECL(void)  PciRawR0TermVM(PVM pVM)
++PCIRAWR0DECL(void)  PciRawR0TermVM(vbox_PVM pVM)
+ {
+     PRAWPCIFACTORY pFactory = NULL;
+     int            rc;
+@@ -518,7 +518,7 @@ static DECLCALLBACK(void) pcirawr0DevObj
+ 
+ 
+ static int pcirawr0OpenDevice(PSUPDRVSESSION   pSession,
+-                              PVM              pVM,
++                              vbox_PVM              pVM,
+                               uint32_t         HostDevice,
+                               uint32_t         fFlags,
+                               PCIRAWDEVHANDLE *pHandle,
+@@ -925,7 +925,7 @@ static int pcirawr0PowerStateChange(PSUP
+  *
+  * @returns VBox status code.
+  */
+-PCIRAWR0DECL(int) PciRawR0ProcessReq(PSUPDRVSESSION pSession, PVM pVM, PPCIRAWSENDREQ pReq)
++PCIRAWR0DECL(int) PciRawR0ProcessReq(PSUPDRVSESSION pSession, vbox_PVM pVM, PPCIRAWSENDREQ pReq)
+ {
+     LogFlow(("PciRawR0ProcessReq: %d for %x\n", pReq->iRequest, pReq->TargetDevice));
+     int rc = VINF_SUCCESS;
diff --git a/virtualbox-svn/patches/patch-src_VBox_Devices_EFI_Firmware_AppPkg_Applications_Python_PyMod-2.7.2_Include_pyport.h b/virtualbox-svn/patches/patch-src_VBox_Devices_EFI_Firmware_AppPkg_Applications_Python_PyMod-2.7.2_Include_pyport.h
new file mode 100644
index 0000000..845fdd7
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Devices_EFI_Firmware_AppPkg_Applications_Python_PyMod-2.7.2_Include_pyport.h
@@ -0,0 +1,23 @@
+$NetBSD$
+
+--- src/VBox/Devices/EFI/Firmware/AppPkg/Applications/Python/PyMod-2.7.2/Include/pyport.h.orig	2016-07-10 20:08:09.000000000 +0000
++++ src/VBox/Devices/EFI/Firmware/AppPkg/Applications/Python/PyMod-2.7.2/Include/pyport.h
+@@ -468,7 +468,7 @@ extern "C" {
+  *    This isn't reliable.  See Py_OVERFLOWED comments.
+  *    X is evaluated more than once.
+  */
+-#if defined(__FreeBSD__) || defined(__OpenBSD__) || (defined(__hpux) && defined(__ia64))
++#if defined(__FreeBSD__) || defined(__OpenBSD__) || (defined(__hpux) && defined(__ia64)) || defined(__NetBSD__)
+ #define _Py_SET_EDOM_FOR_NAN(X) if (isnan(X)) errno = EDOM;
+ #else
+ #define _Py_SET_EDOM_FOR_NAN(X) ;
+@@ -684,6 +684,9 @@ extern int fdatasync(int);
+ #endif
+ #endif
+ 
++#ifdef __NetBSD__
++# define _PY_PORT_CTYPE_UTF8_ISSUE
++#endif
+ 
+ #if defined(__APPLE__)
+ # define _PY_PORT_CTYPE_UTF8_ISSUE
diff --git a/virtualbox-svn/patches/patch-src_VBox_Devices_EFI_Firmware_StdLib_Include_dirent.h b/virtualbox-svn/patches/patch-src_VBox_Devices_EFI_Firmware_StdLib_Include_dirent.h
new file mode 100644
index 0000000..296f993
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Devices_EFI_Firmware_StdLib_Include_dirent.h
@@ -0,0 +1,23 @@
+$NetBSD$
+
+--- src/VBox/Devices/EFI/Firmware/StdLib/Include/dirent.h.orig	2016-03-04 19:27:22.000000000 +0000
++++ src/VBox/Devices/EFI/Firmware/StdLib/Include/dirent.h
+@@ -83,14 +83,14 @@ __BEGIN_DECLS
+   int             closedir(DIR *);
+   void            rewinddir(DIR *);
+ 
+-  DIR            *opendir(const char *)                                       __RENAME(__opendir30);
+-  struct dirent  *readdir(DIR *)                                              __RENAME(__readdir30);
++  DIR            *opendir(const char *)                                       ;//__RENAME(__opendir30);
++  struct dirent  *readdir(DIR *)                                              ;//__RENAME(__readdir30);
+   int             readdir_r(DIR * __restrict, struct dirent * __restrict,
+-                            struct dirent ** __restrict)                      __RENAME(__readdir_r30);
++                            struct dirent ** __restrict)                      ;//__RENAME(__readdir_r30);
+ 
+   void            seekdir(DIR *, long);
+   long            telldir(DIR *);
+-  DIR            *__opendir2(const char *, int)                               __RENAME(__opendir230);
++  DIR            *__opendir2(const char *, int)                               ;//__RENAME(__opendir230);
+ 
+   //#ifndef __LIBC12_SOURCE__
+   //int             scandir(const char *, struct dirent ***,
diff --git a/virtualbox-svn/patches/patch-src_VBox_Devices_EFI_Firmware_StdLib_Include_glob.h b/virtualbox-svn/patches/patch-src_VBox_Devices_EFI_Firmware_StdLib_Include_glob.h
new file mode 100644
index 0000000..d90fbfd
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Devices_EFI_Firmware_StdLib_Include_glob.h
@@ -0,0 +1,15 @@
+$NetBSD$
+
+--- src/VBox/Devices/EFI/Firmware/StdLib/Include/glob.h.orig	2016-03-04 19:27:22.000000000 +0000
++++ src/VBox/Devices/EFI/Firmware/StdLib/Include/glob.h
+@@ -101,8 +101,8 @@ typedef struct {
+ __BEGIN_DECLS
+ #ifndef __LIBC12_SOURCE__
+ int	glob(const char * __restrict, int,
+-    int (*)(const char *, int), glob_t * __restrict)	 __RENAME(__glob30);
+-void	globfree(glob_t *)				 __RENAME(__globfree30);
++    int (*)(const char *, int), glob_t * __restrict)	 ;//__RENAME(__glob30);
++void	globfree(glob_t *)				 ;//__RENAME(__globfree30);
+ #endif
+ __END_DECLS
+ 
diff --git a/virtualbox-svn/patches/patch-src_VBox_Devices_EFI_Firmware_StdLib_Include_locale.h b/virtualbox-svn/patches/patch-src_VBox_Devices_EFI_Firmware_StdLib_Include_locale.h
new file mode 100644
index 0000000..8eb1263
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Devices_EFI_Firmware_StdLib_Include_locale.h
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- src/VBox/Devices/EFI/Firmware/StdLib/Include/locale.h.orig	2016-03-04 19:27:22.000000000 +0000
++++ src/VBox/Devices/EFI/Firmware/StdLib/Include/locale.h
+@@ -185,7 +185,7 @@ __BEGIN_DECLS
+   char    *setlocale(int category, const char *locale);
+   char    *__setlocale(int category, const char *locale);
+ #else /* !__SETLOCALE_SOURCE__ */
+-  char    *setlocale(int category, const char *locale) __RENAME(__setlocale_mb_len_max_32);
++  char    *setlocale(int category, const char *locale) ;//__RENAME(__setlocale_mb_len_max_32);
+ #endif /* !__SETLOCALE_SOURCE__ */
+ struct lconv  *localeconv(void);
+   char    *__setlocale_mb_len_max_32(int category, const char *locale);
diff --git a/virtualbox-svn/patches/patch-src_VBox_Devices_EFI_Firmware_StdLib_Include_sys_EfiCdefs.h b/virtualbox-svn/patches/patch-src_VBox_Devices_EFI_Firmware_StdLib_Include_sys_EfiCdefs.h
new file mode 100644
index 0000000..c91c5e2
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Devices_EFI_Firmware_StdLib_Include_sys_EfiCdefs.h
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- src/VBox/Devices/EFI/Firmware/StdLib/Include/sys/EfiCdefs.h.orig	2016-03-04 19:27:23.000000000 +0000
++++ src/VBox/Devices/EFI/Firmware/StdLib/Include/sys/EfiCdefs.h
+@@ -262,7 +262,7 @@
+   #endif
+ #endif /* !(__STDC_VERSION__ >= 199901L) */
+ 
+-#define __RENAME(x)
++//#define __RENAME(x)
+ 
+   /*
+   * A barrier to stop the optimizer from moving code or assume live
diff --git a/virtualbox-svn/patches/patch-src_VBox_Devices_EFI_Firmware_StdLib_Include_sys_bswap.h b/virtualbox-svn/patches/patch-src_VBox_Devices_EFI_Firmware_StdLib_Include_sys_bswap.h
new file mode 100644
index 0000000..1976dce
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Devices_EFI_Firmware_StdLib_Include_sys_bswap.h
@@ -0,0 +1,15 @@
+$NetBSD$
+
+--- src/VBox/Devices/EFI/Firmware/StdLib/Include/sys/bswap.h.orig	2016-03-04 19:27:23.000000000 +0000
++++ src/VBox/Devices/EFI/Firmware/StdLib/Include/sys/bswap.h
+@@ -17,8 +17,8 @@ __BEGIN_DECLS
+ uint16_t bswap16(uint16_t) __attribute__((__const__));
+ uint32_t bswap32(uint32_t) __attribute__((__const__));
+ #else
+-uint16_t bswap16(uint16_t) __RENAME(__bswap16) __attribute__((__const__));
+-uint32_t bswap32(uint32_t) __RENAME(__bswap32) __attribute__((__const__));
++uint16_t bswap16(uint16_t) /*__RENAME(__bswap16)*/ __attribute__((__const__));
++uint32_t bswap32(uint32_t) /*__RENAME(__bswap32)*/ __attribute__((__const__));
+ #endif
+ uint64_t bswap64(uint64_t) __attribute__((__const__));
+ __END_DECLS
diff --git a/virtualbox-svn/patches/patch-src_VBox_Devices_EFI_Firmware_StdLib_Include_sys_cdefs__aout.h b/virtualbox-svn/patches/patch-src_VBox_Devices_EFI_Firmware_StdLib_Include_sys_cdefs__aout.h
new file mode 100644
index 0000000..ffef7ff
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Devices_EFI_Firmware_StdLib_Include_sys_cdefs__aout.h
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- src/VBox/Devices/EFI/Firmware/StdLib/Include/sys/cdefs_aout.h.orig	2016-03-04 19:27:23.000000000 +0000
++++ src/VBox/Devices/EFI/Firmware/StdLib/Include/sys/cdefs_aout.h
+@@ -11,7 +11,7 @@
+ #define _C_LABEL(x)   __CONCAT(_,x)
+ #define _C_LABEL_STRING(x)  "_"x
+ 
+-#define ___RENAME(x)
++//#define ___RENAME(x)
+ 
+ #define __indr_reference(sym,alias) /* nada, since we do weak refs */
+ 
diff --git a/virtualbox-svn/patches/patch-src_VBox_Devices_EFI_Firmware_StdLib_Include_sys_socket.h b/virtualbox-svn/patches/patch-src_VBox_Devices_EFI_Firmware_StdLib_Include_sys_socket.h
new file mode 100644
index 0000000..8733632
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Devices_EFI_Firmware_StdLib_Include_sys_socket.h
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- src/VBox/Devices/EFI/Firmware/StdLib/Include/sys/socket.h.orig	2016-03-04 19:27:24.000000000 +0000
++++ src/VBox/Devices/EFI/Firmware/StdLib/Include/sys/socket.h
+@@ -561,7 +561,7 @@ int shutdown(int, int);
+ int sockatmark(int);
+ int socket(int, int, int)
+ #if !defined(__LIBC12_SOURCE__) && !defined(_STANDALONE)
+-__RENAME(__socket30)
++/*__RENAME(__socket30)*/
+ #endif
+            ;
+ int socketpair(int, int, int, int *);
diff --git a/virtualbox-svn/patches/patch-src_VBox_Devices_EFI_Firmware_StdLib_Include_unistd.h b/virtualbox-svn/patches/patch-src_VBox_Devices_EFI_Firmware_StdLib_Include_unistd.h
new file mode 100644
index 0000000..1f88e7b
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Devices_EFI_Firmware_StdLib_Include_unistd.h
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- src/VBox/Devices/EFI/Firmware/StdLib/Include/unistd.h.orig	2016-03-04 19:27:24.000000000 +0000
++++ src/VBox/Devices/EFI/Firmware/StdLib/Include/unistd.h
+@@ -193,7 +193,7 @@ void            swab(const void *, void 
+ int             symlink(const char *, const char *);
+ void            sync(void);
+ useconds_t      ualarm(useconds_t, useconds_t);
+-pid_t           vfork(void) __RENAME(__vfork14);
++pid_t           vfork(void) ;//__RENAME(__vfork14);
+ 
+ /*
+  * Implementation-defined extensions
diff --git a/virtualbox-svn/patches/patch-src_VBox_Devices_Makefile.kmk b/virtualbox-svn/patches/patch-src_VBox_Devices_Makefile.kmk
new file mode 100644
index 0000000..6b17ff7
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Devices_Makefile.kmk
@@ -0,0 +1,51 @@
+$NetBSD$
+
+--- src/VBox/Devices/Makefile.kmk.orig	2016-07-10 19:58:34.000000000 +0000
++++ src/VBox/Devices/Makefile.kmk
+@@ -182,7 +182,7 @@ if !defined(VBOX_ONLY_EXTPACKS)         
+  ifn1of ($(KBUILD_TARGET), os2)
+   VBoxDD_SOURCES += Storage/DrvHostDVD.cpp
+  endif
+- ifn1of ($(KBUILD_TARGET), darwin freebsd os2 solaris)
++ ifn1of ($(KBUILD_TARGET), darwin freebsd os2 solaris netbsd)
+   VBoxDD_SOURCES += Storage/DrvHostFloppy.cpp
+  endif
+ 
+@@ -350,6 +350,11 @@ if !defined(VBOX_ONLY_EXTPACKS)         
+  	USB/USBProxyDevice.cpp \
+  	USB/freebsd/USBProxyDevice-freebsd.cpp
+ 
++  VBoxDD_DEFS.netbsd   += VUSB_HAVE_USBPROXY_DEVICE
++  VBoxDD_SOURCES.netbsd+= \
++ 	USB/USBProxyDevice.cpp \
++ 	USB/netbsd/USBProxyDevice-netbsd.cpp
++
+   ifdef VBOX_WITH_SCSI
+    VBoxDD_SOURCES       += \
+    	Storage/UsbMsd.cpp
+@@ -729,6 +734,11 @@ if !defined(VBOX_ONLY_EXTPACKS)         
+   VBoxDD_SOURCES.freebsd += Network/DrvTAP.cpp
+  endif # freebsd
+ 
++ ifeq ($(KBUILD_TARGET),netbsd)
++  VBoxDD_SOURCES += Serial/DrvHostSerial.cpp
++  VBoxDD_SOURCES.netbsd += Network/DrvTAP.cpp
++ endif # netbsd
++
+  VBoxDD_SOURCES.linux += \
+  	Network/DrvTAP.cpp \
+  	Parallel/DrvHostParallel.cpp \
+@@ -1505,7 +1515,7 @@ if defined(VBOX_WITH_VMSVGA3D) && !defin
+  	Graphics/shaderlib/libWineStub/debug.c
+  VBoxSVGA3D_LIBS        = $(LIB_RUNTIME)
+  VBoxSVGA3D_LIBS.win   += $(PATH_SDK_$(VBOX_WINPSDK)_LIB)/Opengl32.lib
+- if1of ($(KBUILD_TARGET), solaris linux freebsd)
++ if1of ($(KBUILD_TARGET), solaris linux freebsd netbsd)
+   VBoxSVGA3D_LIBS      += GL
+  endif
+  VBoxSVGA3D_LDFLAGS.darwin += \
+@@ -1544,4 +1554,3 @@ if defined(VBOX_WITH_VMSVGA3D) && !defin
+ endif # defined(VBOX_WITH_VMSVGA3D) && !defined(VBOX_ONLY_EXTPACKS)
+ 
+ include $(FILE_KBUILD_SUB_FOOTER)
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_Devices_Network_DrvNAT.cpp b/virtualbox-svn/patches/patch-src_VBox_Devices_Network_DrvNAT.cpp
new file mode 100644
index 0000000..5845ef8
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Devices_Network_DrvNAT.cpp
@@ -0,0 +1,18 @@
+$NetBSD$
+
+--- src/VBox/Devices/Network/DrvNAT.cpp.orig	2016-03-04 19:27:54.000000000 +0000
++++ src/VBox/Devices/Network/DrvNAT.cpp
+@@ -51,7 +51,7 @@ extern "C" {
+ # include <poll.h>
+ # include <errno.h>
+ #endif
+-#ifdef RT_OS_FREEBSD
++#if defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+ # include <netinet/in.h>
+ #endif
+ #include <iprt/semaphore.h>
+@@ -1752,4 +1752,3 @@ const PDMDRVREG g_DrvNAT =
+     /* u32EndVersion */
+     PDM_DRVREG_VERSION
+ };
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_Devices_Network_slirp_resolv__conf__parser.c b/virtualbox-svn/patches/patch-src_VBox_Devices_Network_slirp_resolv__conf__parser.c
new file mode 100644
index 0000000..afc7651
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Devices_Network_slirp_resolv__conf__parser.c
@@ -0,0 +1,2 @@
+$NetBSD$
+
diff --git a/virtualbox-svn/patches/patch-src_VBox_Devices_Network_slirp_udp.c b/virtualbox-svn/patches/patch-src_VBox_Devices_Network_slirp_udp.c
new file mode 100644
index 0000000..c2e058e
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Devices_Network_slirp_udp.c
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- src/VBox/Devices/Network/slirp/udp.c.orig	2016-03-04 19:28:00.000000000 +0000
++++ src/VBox/Devices/Network/slirp/udp.c
+@@ -327,7 +327,7 @@ udp_input(PNATState pData, register stru
+         const char * const dfoptname = #_Optname;
+ #if   defined(IP_MTU_DISCOVER)
+         USE_DF_OPTION(IP_MTU_DISCOVER);
+-#elif defined(IP_DONTFRAG)      /* Solaris 11+, FreeBSD */
++#elif defined(IP_DONTFRAG)      /* Solaris 11+, FreeBSD, NetBSD */
+         USE_DF_OPTION(IP_DONTFRAG);
+ #elif defined(IP_DONTFRAGMENT)  /* Windows */
+         USE_DF_OPTION(IP_DONTFRAGMENT);
diff --git a/virtualbox-svn/patches/patch-src_VBox_Devices_PC_DrvACPI.cpp b/virtualbox-svn/patches/patch-src_VBox_Devices_PC_DrvACPI.cpp
new file mode 100644
index 0000000..c91cc50
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Devices_PC_DrvACPI.cpp
@@ -0,0 +1,15 @@
+$NetBSD$
+
+--- src/VBox/Devices/PC/DrvACPI.cpp.orig	2016-07-10 20:05:45.000000000 +0000
++++ src/VBox/Devices/PC/DrvACPI.cpp
+@@ -222,6 +222,10 @@ static DECLCALLBACK(int) drvACPIQueryPow
+         AssertMsg(errno == ENOENT, ("rc=%d (%s)\n", rc, strerror(errno)));
+         *pPowerSource = PDM_ACPI_POWER_SOURCE_OUTLET;
+     }
++
++#elif defined(RT_OS_NETBSD)
++    // TODO
++    *pPowerSource = PDM_ACPI_POWER_SOURCE_OUTLET;
+ #else /* !RT_OS_FREEBSD either - what could this be? */
+     *pPowerSource = PDM_ACPI_POWER_SOURCE_OUTLET;
+ 
diff --git a/virtualbox-svn/patches/patch-src_VBox_Devices_Serial_DrvHostSerial.cpp b/virtualbox-svn/patches/patch-src_VBox_Devices_Serial_DrvHostSerial.cpp
new file mode 100644
index 0000000..78cc37c
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Devices_Serial_DrvHostSerial.cpp
@@ -0,0 +1,135 @@
+$NetBSD$
+
+--- src/VBox/Devices/Serial/DrvHostSerial.cpp.orig	2016-03-04 19:28:24.000000000 +0000
++++ src/VBox/Devices/Serial/DrvHostSerial.cpp
+@@ -33,7 +33,7 @@
+ #include <iprt/semaphore.h>
+ #include <iprt/uuid.h>
+ 
+-#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD)
++#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+ # include <errno.h>
+ # ifdef RT_OS_SOLARIS
+ #  include <sys/termios.h>
+@@ -101,7 +101,7 @@ typedef struct DRVHOSTSERIAL
+     /** the device path */
+     char                        *pszDevicePath;
+ 
+-#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD)
++#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+     /** the device handle */
+     RTFILE                      hDeviceFile;
+ # ifdef RT_OS_DARWIN
+@@ -194,7 +194,7 @@ static DECLCALLBACK(int) drvHostSerialWr
+ static DECLCALLBACK(int) drvHostSerialSetParameters(PPDMICHARCONNECTOR pInterface, unsigned Bps, char chParity, unsigned cDataBits, unsigned cStopBits)
+ {
+     PDRVHOSTSERIAL pThis = PDMICHAR_2_DRVHOSTSERIAL(pInterface);
+-#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD)
++#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+     struct termios *termiosSetup;
+     int baud_rate;
+ #elif defined(RT_OS_WINDOWS)
+@@ -482,7 +482,7 @@ static DECLCALLBACK(int) drvHostSerialSe
+         {
+             /* copy the send queue so we get a linear buffer with the maximal size. */
+             uint8_t ch = pThis->u8SendByte;
+-#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD)
++#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+ 
+             size_t cbWritten;
+             rc = RTFileWrite(pThis->hDeviceFile, &ch, 1, &cbWritten);
+@@ -679,7 +679,7 @@ static DECLCALLBACK(int) drvHostSerialRe
+             }
+             cbRemaining = cbRead;
+ 
+-#elif defined(RT_OS_LINUX) || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD)
++#elif defined(RT_OS_LINUX) || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+ 
+             size_t cbRead;
+             struct pollfd aFDs[2];
+@@ -865,7 +865,7 @@ static DECLCALLBACK(int) drvHostSerialRe
+ static DECLCALLBACK(int) drvHostSerialWakeupRecvThread(PPDMDRVINS pDrvIns, PPDMTHREAD /*pThread*/)
+ {
+     PDRVHOSTSERIAL pThis = PDMINS_2_DATA(pDrvIns, PDRVHOSTSERIAL);
+-#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD)
++#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+     size_t cbIgnored;
+     return RTPipeWrite(pThis->hWakeupPipeW, "", 1, &cbIgnored);
+ 
+@@ -878,7 +878,7 @@ static DECLCALLBACK(int) drvHostSerialWa
+ #endif
+ }
+ 
+-#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD)
++#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+ /* -=-=-=-=- Monitor thread -=-=-=-=- */
+ 
+ /**
+@@ -998,7 +998,7 @@ static DECLCALLBACK(int) drvHostSerialSe
+ {
+     PDRVHOSTSERIAL pThis = PDMICHAR_2_DRVHOSTSERIAL(pInterface);
+ 
+-#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD)
++#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+     int modemStateSet = 0;
+     int modemStateClear = 0;
+ 
+@@ -1046,7 +1046,7 @@ static DECLCALLBACK(int) drvHostSerialSe
+ {
+     PDRVHOSTSERIAL pThis = PDMICHAR_2_DRVHOSTSERIAL(pInterface);
+ 
+-#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD)
++#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+     if (fBreak)
+         ioctl(RTFileToNative(pThis->hDeviceFile), TIOCSBRK);
+     else
+@@ -1085,7 +1085,7 @@ static DECLCALLBACK(void) drvHostSerialD
+         pThis->SendSem = NIL_RTSEMEVENT;
+     }
+ 
+-#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD)
++#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+ 
+     int rc = RTPipeClose(pThis->hWakeupPipeW); AssertRC(rc);
+     pThis->hWakeupPipeW = NIL_RTPIPE;
+@@ -1138,7 +1138,7 @@ static DECLCALLBACK(int) drvHostSerialCo
+     /*
+      * Init basic data members and interfaces.
+      */
+-#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD)
++#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+     pThis->hDeviceFile  = NIL_RTFILE;
+ # ifdef RT_OS_DARWIN
+     pThis->hDeviceFileR = NIL_RTFILE;
+@@ -1233,7 +1233,7 @@ static DECLCALLBACK(int) drvHostSerialCo
+         {
+             case VERR_ACCESS_DENIED:
+                 return PDMDrvHlpVMSetError(pDrvIns, rc, RT_SRC_POS,
+-#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD)
++#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+                                            N_("Cannot open host device '%s' for read/write access. Check the permissions "
+                                               "of that device ('/bin/ls -l %s'): Most probably you need to be member "
+                                               "of the device group. Make sure that you logout/login after changing "
+@@ -1251,7 +1251,7 @@ static DECLCALLBACK(int) drvHostSerialCo
+     }
+ 
+     /* Set to non blocking I/O */
+-#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD)
++#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+ 
+     fcntl(RTFileToNative(pThis->hDeviceFile), F_SETFL, O_NONBLOCK);
+ # ifdef RT_OS_DARWIN
+@@ -1296,7 +1296,7 @@ static DECLCALLBACK(int) drvHostSerialCo
+     if (RT_FAILURE(rc))
+         return PDMDrvHlpVMSetError(pDrvIns, rc, RT_SRC_POS, N_("HostSerial#%d cannot create send thread"), pDrvIns->iInstance);
+ 
+-#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD)
++#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+     /* Linux & darwin needs a separate thread which monitors the status lines. */
+ # ifndef RT_OS_LINUX
+     ioctl(RTFileToNative(pThis->hDeviceFile), TIOCMGET, &pThis->fStatusLines);
+@@ -1368,4 +1368,3 @@ const PDMDRVREG g_DrvHostSerial =
+     /* u32EndVersion */
+     PDM_DRVREG_VERSION
+ };
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_Devices_Storage_DrvHostBase.cpp b/virtualbox-svn/patches/patch-src_VBox_Devices_Storage_DrvHostBase.cpp
new file mode 100644
index 0000000..4bc3fe1
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Devices_Storage_DrvHostBase.cpp
@@ -0,0 +1,89 @@
+$NetBSD$
+
+--- src/VBox/Devices/Storage/DrvHostBase.cpp.orig	2016-03-04 19:28:24.000000000 +0000
++++ src/VBox/Devices/Storage/DrvHostBase.cpp
+@@ -96,7 +96,7 @@ NTSTATUS __stdcall NtQueryVolumeInformat
+         /*IN*/ ULONG                Length,
+         /*IN*/ FS_INFORMATION_CLASS FileSystemInformationClass );
+ 
+-#elif defined(RT_OS_FREEBSD)
++#elif defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+ # include <sys/cdefs.h>
+ # include <sys/param.h>
+ # include <errno.h>
+@@ -147,14 +147,14 @@ static DECLCALLBACK(int) drvHostBaseRead
+     if (    pThis->fMediaPresent
+         &&  pThis->ppScsiTaskDI
+         &&  pThis->cbBlock)
+-#elif RT_OS_FREEBSD
++#elif RT_OS_FREEBSD || defined(RT_OS_NETBSD)
+     if (    pThis->fMediaPresent
+         &&  pThis->cbBlock)
+ #else
+     if (pThis->fMediaPresent)
+ #endif
+     {
+-#if defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD)
++#if defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+         /*
+          * Issue a READ(12) request.
+          */
+@@ -226,7 +226,7 @@ static DECLCALLBACK(int) drvHostBaseWrit
+     {
+         if (pThis->fMediaPresent)
+         {
+-#if defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD)
++#if defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+             /** @todo write support... */
+             rc = VERR_WRITE_PROTECT;
+ 
+@@ -264,7 +264,7 @@ static DECLCALLBACK(int) drvHostBaseFlus
+ 
+     if (pThis->fMediaPresent)
+     {
+-#if defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD)
++#if defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+         rc = VINF_SUCCESS;
+         /** @todo scsi device buffer flush... */
+ #else
+@@ -991,7 +991,7 @@ static int drvHostBaseOpen(PDRVHOSTBASE 
+     IOObjectRelease(DVDServices);
+     return rc;
+ 
+-#elif defined(RT_OS_FREEBSD)
++#elif defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+     RTFILE hFileDevice;
+     int rc = RTFileOpen(&hFileDevice, pThis->pszDeviceOpen, RTFILE_O_READWRITE | RTFILE_O_OPEN | RTFILE_O_DENY_NONE);
+     if (RT_FAILURE(rc))
+@@ -1176,7 +1176,7 @@ static int drvHostBaseReopen(PDRVHOSTBAS
+  */
+ static DECLCALLBACK(int) drvHostBaseGetMediaSize(PDRVHOSTBASE pThis, uint64_t *pcb)
+ {
+-#if defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD)
++#if defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+     /*
+      * Try a READ_CAPACITY command...
+      */
+@@ -1254,7 +1254,7 @@ static DECLCALLBACK(int) drvHostBaseGetM
+ }
+ 
+ 
+-#if defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD)
++#if defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+ /**
+  * Execute a SCSI command.
+  *
+@@ -1365,7 +1365,7 @@ DECLCALLBACK(int) DRVHostBaseScsiCmd(PDR
+ 
+     (*ppScsiTaskI)->Release(ppScsiTaskI);
+ 
+-# elif defined(RT_OS_FREEBSD)
++# elif defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+     int rc = VINF_SUCCESS;
+     int rcBSD = 0;
+     union ccb DeviceCCB;
+@@ -2265,4 +2265,3 @@ int DRVHostBaseInitFinish(PDRVHOSTBASE p
+         return src;
+     return rc;
+ }
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_Devices_Storage_DrvHostBase.h b/virtualbox-svn/patches/patch-src_VBox_Devices_Storage_DrvHostBase.h
new file mode 100644
index 0000000..489ddf2
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Devices_Storage_DrvHostBase.h
@@ -0,0 +1,22 @@
+$NetBSD$
+
+--- src/VBox/Devices/Storage/DrvHostBase.h.orig	2016-07-10 20:21:49.000000000 +0000
++++ src/VBox/Devices/Storage/DrvHostBase.h
+@@ -145,6 +145,17 @@ typedef struct DRVHOSTBASE
+     lun_id_t                ScsiLunID;
+ #endif
+ 
++#ifdef RT_OS_NETBSD
++    /** The block size. Set when querying the media size. */
++    uint32_t                cbBlock;
++    /** SCSI bus number. */
++    path_id_t               ScsiBus;
++    /** target ID of the passthrough device. */
++    target_id_t             ScsiTargetID;
++    /** LUN of the passthrough device. */
++    lun_id_t                ScsiLunID;
++#endif
++
+     /**
+      * Performs the locking / unlocking of the device.
+      *
diff --git a/virtualbox-svn/patches/patch-src_VBox_Devices_Storage_DrvHostDVD.cpp b/virtualbox-svn/patches/patch-src_VBox_Devices_Storage_DrvHostDVD.cpp
new file mode 100644
index 0000000..5c605a3
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Devices_Storage_DrvHostDVD.cpp
@@ -0,0 +1,63 @@
+$NetBSD$
+
+--- src/VBox/Devices/Storage/DrvHostDVD.cpp.orig	2016-03-04 19:28:24.000000000 +0000
++++ src/VBox/Devices/Storage/DrvHostDVD.cpp
+@@ -86,7 +86,7 @@
+ # undef _interlockedbittestandreset64
+ # undef USE_MEDIA_POLLING
+ 
+-#elif defined(RT_OS_FREEBSD)
++#elif defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+ # include <sys/cdefs.h>
+ # include <sys/param.h>
+ # include <stdio.h>
+@@ -144,7 +144,7 @@ static DECLCALLBACK(int) drvHostDvdUnmou
+             /*
+              * Eject the disc.
+              */
+-#if defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD)
++#if defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+             uint8_t abCmd[16] =
+             {
+                 SCSI_START_STOP_UNIT, 0, 0, 0, 2 /*eject+stop*/, 0,
+@@ -234,7 +234,7 @@ static DECLCALLBACK(int) drvHostDvdUnmou
+  */
+ static DECLCALLBACK(int) drvHostDvdDoLock(PDRVHOSTBASE pThis, bool fLock)
+ {
+-#if defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD)
++#if defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+     uint8_t abCmd[16] =
+     {
+         SCSI_PREVENT_ALLOW_MEDIUM_REMOVAL, 0, 0, 0, fLock, 0,
+@@ -322,7 +322,7 @@ static DECLCALLBACK(int) drvHostDvdPoll(
+     /*
+      * Poll for media change.
+      */
+-#if defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD)
++#if defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+ #ifdef RT_OS_DARWIN
+     AssertReturn(pThis->ppScsiTaskDI, VERR_INTERNAL_ERROR);
+ #endif
+@@ -392,7 +392,7 @@ static DECLCALLBACK(int) drvHostDvdPoll(
+         /*
+          * Poll for media change.
+          */
+-#if defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD)
++#if defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+         /* taken care of above. */
+ #elif defined(RT_OS_LINUX)
+         bool fMediaChanged = ioctl(RTFileToNative(pThis->hFileDevice), CDROM_MEDIA_CHANGED, CDSL_CURRENT) == 1;
+@@ -422,7 +422,7 @@ static DECLCALLBACK(int) drvHostDvdSendC
+     int rc;
+     LogFlow(("%s: cmd[0]=%#04x txdir=%d pcbBuf=%d timeout=%d\n", __FUNCTION__, pbCmd[0], enmTxDir, *pcbBuf, cTimeoutMillies));
+ 
+-#if defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD)
++#if defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+     /*
+      * Pass the request on to the internal scsi command interface.
+      * The command seems to be 12 bytes long, the docs a bit copy&pasty on the command length point...
+@@ -878,4 +878,3 @@ const PDMDRVREG g_DrvHostDVD =
+     /* u32EndVersion */
+     PDM_DRVREG_VERSION
+ };
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_Devices_USB_netbsd_USBProxyDevice-netbsd.cpp b/virtualbox-svn/patches/patch-src_VBox_Devices_USB_netbsd_USBProxyDevice-netbsd.cpp
new file mode 100644
index 0000000..b90f531
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Devices_USB_netbsd_USBProxyDevice-netbsd.cpp
@@ -0,0 +1,1066 @@
+$NetBSD$
+
+--- src/VBox/Devices/USB/netbsd/USBProxyDevice-netbsd.cpp.orig	2016-07-08 22:38:39.836808295 +0000
++++ src/VBox/Devices/USB/netbsd/USBProxyDevice-netbsd.cpp
+@@ -0,0 +1,1061 @@
++/*  USBProxyDevice-netbsd.cpp $ */
++/** @file
++ * USB device proxy - the NetBSD backend.
++ */
++
++/*
++ * Includes contributions from Hans Petter Selasky
++ *
++ * Copyright (C) 2006-2015 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.
++ */
++
++
++/*********************************************************************************************************************************
++*   Header Files                                                                                                                 *
++*********************************************************************************************************************************/
++#define LOG_GROUP LOG_GROUP_DRV_USBPROXY
++#ifdef VBOX
++# include <iprt/stdint.h>
++#endif
++#include <sys/types.h>
++#include <sys/stat.h>
++#include <sys/ioctl.h>
++#include <sys/poll.h>
++#include <stdint.h>
++#include <stdio.h>
++#include <string.h>
++#include <stdlib.h>
++#include <limits.h>
++#include <unistd.h>
++#include <fcntl.h>
++#include <errno.h>
++#include <dev/usb/usb.h>
++#include <dev/usb/usbdi.h>
++#include <dev/usb/usb_ioctl.h>
++
++#include <VBox/vmm/pdm.h>
++#include <VBox/err.h>
++#include <VBox/log.h>
++#include <VBox/vusb.h>
++#include <iprt/assert.h>
++#include <iprt/stream.h>
++#include <iprt/alloc.h>
++#include <iprt/thread.h>
++#include <iprt/time.h>
++#include <iprt/asm.h>
++#include <iprt/string.h>
++#include <iprt/file.h>
++#include <iprt/pipe.h>
++#include "../USBProxyDevice.h"
++
++/** Maximum endpoints supported. */
++#define USBNBSD_MAXENDPOINTS 127
++#define USBNBSD_MAXFRAMES 56
++
++/** This really needs to be defined in vusb.h! */
++#ifndef VUSB_DIR_TO_DEV
++# define VUSB_DIR_TO_DEV        0x00
++#endif
++
++
++/*********************************************************************************************************************************
++*   Structures and Typedefs                                                                                                      *
++*********************************************************************************************************************************/
++typedef struct USBENDPOINTNBSD
++{
++    /** Flag whether it is opened. */
++    bool     fOpen;
++    /** Flag whether it is cancelling. */
++    bool     fCancelling;
++    /** Buffer pointers. */
++    void    *apvData[USBNBSD_MAXFRAMES];
++    /** Buffer lengths. */
++    uint32_t acbData[USBNBSD_MAXFRAMES];
++    /** Initial buffer length. */
++    uint32_t cbData0;
++    /** Pointer to the URB. */
++    PVUSBURB pUrb;
++    /** Copy of endpoint number. */
++    unsigned iEpNum;
++    /** Maximum transfer length. */
++    unsigned cMaxIo;
++    /** Maximum frame count. */
++    unsigned cMaxFrames;
++} USBENDPOINTNBSD, *PUSBENDPOINTNBSD;
++
++/**
++ * Data for the NetBSD usb proxy backend.
++ */
++typedef struct USBPROXYDEVNBSD
++{
++    /** The open file. */
++    RTFILE                 hFile;
++    /** 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 */
++    USBENDPOINTNBSD        aSwEndpoint[USBNBSD_MAXENDPOINTS];
++    /** Kernel endpoint structures */
++    struct usb_fs_endpoint aHwEndpoint[USBNBSD_MAXENDPOINTS];
++} USBPROXYDEVNBSD, *PUSBPROXYDEVNBSD;
++
++
++/*********************************************************************************************************************************
++*   Internal Functions                                                                                                           *
++*********************************************************************************************************************************/
++static int usbProxyNetBSDEndpointClose(PUSBPROXYDEV pProxyDev, int Endpoint);
++
++/**
++ * Wrapper for the ioctl call.
++ *
++ * This wrapper will repeat the call if we get an EINTR or EAGAIN. It can also
++ * handle ENODEV (detached device) errors.
++ *
++ * @returns whatever ioctl returns.
++ * @param   pProxyDev       The proxy device.
++ * @param   iCmd            The ioctl command / function.
++ * @param   pvArg           The ioctl argument / data.
++ * @param   fHandleNoDev    Whether to handle ENXIO.
++ * @internal
++ */
++static int usbProxyNetBSDDoIoCtl(PUSBPROXYDEV pProxyDev, unsigned long iCmd,
++                                  void *pvArg, bool fHandleNoDev)
++{
++    int rc = VINF_SUCCESS;
++    PUSBPROXYDEVNBSD pDevNBSD = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVNBSD);
++
++    LogFlow(("usbProxyNetBSDDoIoCtl: iCmd=%#x\n", iCmd));
++
++    do
++    {
++        rc = ioctl(RTFileToNative(pDevNBSD->hFile), iCmd, pvArg);
++        if (rc >= 0)
++            return VINF_SUCCESS;
++    } while (errno == EINTR);
++
++    if (errno == ENXIO && fHandleNoDev)
++    {
++        Log(("usbProxyNetBSDDoIoCtl: ENXIO -> unplugged. pProxyDev=%s\n",
++             pProxyDev->pUsbIns->pszName));
++        errno = ENODEV;
++    }
++    else if (errno != EAGAIN)
++    {
++        LogFlow(("usbProxyNetBSDDoIoCtl: Returned %d. pProxyDev=%s\n",
++                 errno, pProxyDev->pUsbIns->pszName));
++    }
++    return RTErrConvertFromErrno(errno);
++}
++
++/**
++ * Init USB subsystem.
++ */
++static int usbProxyNetBSDFsInit(PUSBPROXYDEV pProxyDev)
++{
++    struct usb_fs_init UsbFsInit;
++    PUSBPROXYDEVNBSD pDevNBSD = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVNBSD);
++    int rc;
++
++    LogFlow(("usbProxyNetBSDFsInit: pProxyDev=%p\n", (void *)pProxyDev));
++
++    /* Sanity check */
++    AssertPtrReturn(pDevNBSD, VERR_INVALID_PARAMETER);
++
++    if (pDevNBSD->fInit == true)
++        return VINF_SUCCESS;
++
++    /* Zero default */
++    memset(&UsbFsInit, 0, sizeof(UsbFsInit));
++
++    UsbFsInit.pEndpoints = pDevNBSD->aHwEndpoint;
++    UsbFsInit.ep_index_max = USBNBSD_MAXENDPOINTS;
++
++    /* Init USB subsystem */
++    rc = usbProxyNetBSDDoIoCtl(pProxyDev, USB_FS_INIT, &UsbFsInit, false);
++    if (RT_SUCCESS(rc))
++        pDevNBSD->fInit = true;
++
++    return rc;
++}
++
++/**
++ * Uninit USB subsystem.
++ */
++static int usbProxyNetBSDFsUnInit(PUSBPROXYDEV pProxyDev)
++{
++    struct usb_fs_uninit UsbFsUninit;
++    PUSBPROXYDEVNBSD pDevNBSD = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVNBSD);
++    int rc;
++
++    LogFlow(("usbProxyNetBSDFsUnInit: ProxyDev=%p\n", (void *)pProxyDev));
++
++    /* Sanity check */
++    AssertPtrReturn(pDevNBSD, VERR_INVALID_PARAMETER);
++
++    if (pDevNBSD->fInit != true)
++        return VINF_SUCCESS;
++
++    /* Close any open endpoints. */
++    for (unsigned n = 0; n != USBNBSD_MAXENDPOINTS; n++)
++        usbProxyNetBSDEndpointClose(pProxyDev, n);
++
++    /* Zero default */
++    memset(&UsbFsUninit, 0, sizeof(UsbFsUninit));
++
++    /* Uninit USB subsystem */
++    rc = usbProxyNetBSDDoIoCtl(pProxyDev, USB_FS_UNINIT, &UsbFsUninit, false);
++    if (RT_SUCCESS(rc))
++        pDevNBSD->fInit = false;
++
++    return rc;
++}
++
++/**
++ * Setup a USB request packet.
++ */
++static void usbProxyNetBSDSetupReq(struct usb_device_request *pSetupData,
++                                    uint8_t bmRequestType, uint8_t bRequest, uint16_t wValue,
++                                    uint16_t wIndex, uint16_t wLength)
++{
++    LogFlow(("usbProxyNetBSDSetupReq: pSetupData=%p bmRequestType=%x "
++             "bRequest=%x wValue=%x wIndex=%x wLength=%x\n", (void *)pSetupData,
++             bmRequestType, bRequest, wValue, wIndex, wLength));
++
++    pSetupData->bmRequestType = bmRequestType;
++    pSetupData->bRequest = bRequest;
++
++    /* Handle endianess here. Currently no swapping is needed. */
++    pSetupData->wValue[0] = wValue & 0xff;
++    pSetupData->wValue[1] = (wValue >> 8) & 0xff;
++    pSetupData->wIndex[0] = wIndex & 0xff;
++    pSetupData->wIndex[1] = (wIndex >> 8) & 0xff;
++    pSetupData->wLength[0] = wLength & 0xff;
++    pSetupData->wLength[1] = (wLength >> 8) & 0xff;
++}
++
++static int usbProxyNetBSDEndpointOpen(PUSBPROXYDEV pProxyDev, int Endpoint, bool fIsoc, int index)
++{
++    PUSBPROXYDEVNBSD pDevNBSD = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVNBSD);
++    PUSBENDPOINTNBSD pEndpointNBSD = NULL; /* shut up gcc */
++    struct usb_fs_endpoint *pXferEndpoint;
++    struct usb_fs_open UsbFsOpen;
++    int rc;
++
++    LogFlow(("usbProxyNetBSDEndpointOpen: pProxyDev=%p Endpoint=%d\n",
++             (void *)pProxyDev, Endpoint));
++
++    for (; index < USBNBSD_MAXENDPOINTS; index++)
++    {
++        pEndpointNBSD = &pDevNBSD->aSwEndpoint[index];
++        if (pEndpointNBSD->fCancelling)
++            continue;
++        if (   pEndpointNBSD->fOpen
++            && !pEndpointNBSD->pUrb
++            && (int)pEndpointNBSD->iEpNum == Endpoint)
++            return index;
++    }
++
++    if (index == USBNBSD_MAXENDPOINTS)
++    {
++        for (index = 0; index != USBNBSD_MAXENDPOINTS; index++)
++        {
++            pEndpointNBSD = &pDevNBSD->aSwEndpoint[index];
++            if (pEndpointNBSD->fCancelling)
++                continue;
++            if (!pEndpointNBSD->fOpen)
++                break;
++        }
++        if (index == USBNBSD_MAXENDPOINTS)
++            return -1;
++    }
++    /* set ppBuffer and pLength */
++
++    pXferEndpoint = &pDevNBSD->aHwEndpoint[index];
++    pXferEndpoint->ppBuffer = &pEndpointNBSD->apvData[0];
++    pXferEndpoint->pLength = &pEndpointNBSD->acbData[0];
++
++    LogFlow(("usbProxyNetBSDEndpointOpen: ep_index=%d ep_num=%d\n",
++             index, Endpoint));
++
++    memset(&UsbFsOpen, 0, sizeof(UsbFsOpen));
++
++    UsbFsOpen.ep_index = index;
++    UsbFsOpen.ep_no = Endpoint;
++    UsbFsOpen.max_bufsize = 256 * 1024;
++    /* Hardcoded assumption about the URBs we get. */
++
++    UsbFsOpen.max_frames = fIsoc ? USBNBSD_MAXFRAMES : 2;
++
++    rc = usbProxyNetBSDDoIoCtl(pProxyDev, USB_FS_OPEN, &UsbFsOpen, true);
++    if (RT_FAILURE(rc))
++    {
++        if (rc == VERR_RESOURCE_BUSY)
++            LogFlow(("usbProxyNetBSDEndpointOpen: EBUSY\n"));
++
++        return -1;
++    }
++    pEndpointNBSD->fOpen = true;
++    pEndpointNBSD->pUrb = NULL;
++    pEndpointNBSD->iEpNum = Endpoint;
++    pEndpointNBSD->cMaxIo = UsbFsOpen.max_bufsize;
++    pEndpointNBSD->cMaxFrames = UsbFsOpen.max_frames;
++
++    return index;
++}
++
++/**
++ * Close an endpoint.
++ *
++ * @returns VBox status code.
++ */
++static int usbProxyNetBSDEndpointClose(PUSBPROXYDEV pProxyDev, int Endpoint)
++{
++    PUSBPROXYDEVNBSD pDevNBSD = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVNBSD);
++    PUSBENDPOINTNBSD pEndpointNBSD = &pDevNBSD->aSwEndpoint[Endpoint];
++    struct usb_fs_close UsbFsClose;
++    int rc = VINF_SUCCESS;
++
++    LogFlow(("usbProxyNetBSDEndpointClose: pProxyDev=%p Endpoint=%d\n",
++             (void *)pProxyDev, Endpoint));
++
++    /* check for cancelling */
++    if (pEndpointNBSD->pUrb != NULL)
++    {
++        pEndpointNBSD->fCancelling = true;
++        pDevNBSD->fCancelling = true;
++    }
++
++    /* check for opened */
++    if (pEndpointNBSD->fOpen)
++    {
++        pEndpointNBSD->fOpen = false;
++
++        /* Zero default */
++        memset(&UsbFsClose, 0, sizeof(UsbFsClose));
++
++        /* Set endpoint index */
++        UsbFsClose.ep_index = Endpoint;
++
++        /* Close endpoint */
++        rc = usbProxyNetBSDDoIoCtl(pProxyDev, USB_FS_CLOSE, &UsbFsClose, true);
++    }
++    return rc;
++}
++
++/**
++ * Opens the device file.
++ *
++ * @returns VBox status code.
++ * @param   pProxyDev       The device instance.
++ * @param   pszAddress      If we are using usbfs, this is the path to the
++ *                          device.  If we are using sysfs, this is a string of
++ *                          the form "sysfs:<sysfs path>//device:<device node>".
++ *                          In the second case, the two paths are guaranteed
++ *                          not to contain the substring "//".
++ * @param   pvBackend       Backend specific pointer, unused for the linux backend.
++ */
++static DECLCALLBACK(int) usbProxyNetBSDOpen(PUSBPROXYDEV pProxyDev, const char *pszAddress,
++                                             void *pvBackend)
++{
++    PUSBPROXYDEVNBSD pDevNBSD = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVNBSD);
++    int rc;
++
++    LogFlow(("usbProxyNetBSDOpen: pProxyDev=%p pszAddress=%s\n", pProxyDev, pszAddress));
++
++    NOREF(pvBackend);
++
++    /*
++     * Try open the device node.
++     */
++    RTFILE hFile;
++    rc = RTFileOpen(&hFile, pszAddress, RTFILE_O_READWRITE | RTFILE_O_OPEN | RTFILE_O_DENY_NONE);
++    if (RT_SUCCESS(rc))
++    {
++        /*
++         * Initialize the NetBSD backend data.
++         */
++        pDevNBSD->hFile = hFile;
++        rc = usbProxyNetBSDFsInit(pProxyDev);
++        if (RT_SUCCESS(rc))
++        {
++            /*
++             * Create wakeup pipe.
++             */
++            rc = RTPipeCreate(&pDevNBSD->hPipeWakeupR, &pDevNBSD->hPipeWakeupW, 0);
++            if (RT_SUCCESS(rc))
++            {
++                LogFlow(("usbProxyNetBSDOpen(%p, %s): returns successfully hFile=%RTfile iActiveCfg=%d\n",
++                         pProxyDev, pszAddress, pDevNBSD->hFile, pProxyDev->iActiveCfg));
++
++                return VINF_SUCCESS;
++            }
++        }
++
++        RTFileClose(hFile);
++    }
++    else if (rc == VERR_ACCESS_DENIED)
++        rc = VERR_VUSB_USBFS_PERMISSION;
++
++    Log(("usbProxyNetBSDOpen(%p, %s) failed, rc=%d!\n",
++         pProxyDev, pszAddress, rc));
++
++    return rc;
++}
++
++
++/**
++ * Claims all the interfaces and figures out the
++ * current configuration.
++ *
++ * @returns VINF_SUCCESS.
++ * @param   pProxyDev       The proxy device.
++ */
++static DECLCALLBACK(int) usbProxyNetBSDInit(PUSBPROXYDEV pProxyDev)
++{
++    PUSBPROXYDEVNBSD pDevNBSD = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVNBSD);
++    int rc;
++
++    LogFlow(("usbProxyNetBSDInit: pProxyDev=%s\n",
++             pProxyDev->pUsbIns->pszName));
++
++    /* Retrieve current active configuration. */
++    rc = usbProxyNetBSDDoIoCtl(pProxyDev, USB_GET_CONFIG,
++                                &pProxyDev->iActiveCfg, true);
++    if (RT_FAILURE(rc) || pProxyDev->iActiveCfg == 255)
++    {
++        pProxyDev->cIgnoreSetConfigs = 0;
++        pProxyDev->iActiveCfg = -1;
++    }
++    else
++    {
++        pProxyDev->cIgnoreSetConfigs = 1;
++        pProxyDev->iActiveCfg++;
++    }
++
++    Log(("usbProxyNetBSDInit: iActiveCfg=%d\n", pProxyDev->iActiveCfg));
++
++    return rc;
++}
++
++/**
++ * Closes the proxy device.
++ */
++static DECLCALLBACK(void) usbProxyNetBSDClose(PUSBPROXYDEV pProxyDev)
++{
++    PUSBPROXYDEVNBSD pDevNBSD = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVNBSD);
++
++    LogFlow(("usbProxyNetBSDClose: pProxyDev=%s\n", pProxyDev->pUsbIns->pszName));
++
++    /* sanity check */
++    AssertPtrReturnVoid(pDevNBSD);
++
++    usbProxyNetBSDFsUnInit(pProxyDev);
++
++    RTPipeClose(pDevNBSD->hPipeWakeupR);
++    RTPipeClose(pDevNBSD->hPipeWakeupW);
++
++    RTFileClose(pDevNBSD->hFile);
++    pDevNBSD->hFile = NIL_RTFILE;
++
++    LogFlow(("usbProxyNetBSDClose: returns\n"));
++}
++
++/**
++ * Reset a device.
++ *
++ * @returns VBox status code.
++ * @param   pDev    The device to reset.
++ */
++static DECLCALLBACK(int) usbProxyNetBSDReset(PUSBPROXYDEV pProxyDev, bool fResetOnNetBSD)
++{
++    PUSBPROXYDEVNBSD pDevNBSD = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVNBSD);
++    int iParm;
++    int rc = VINF_SUCCESS;
++
++    LogFlow(("usbProxyNetBSDReset: pProxyDev=%s\n",
++             pProxyDev->pUsbIns->pszName));
++
++    if (!fResetOnNetBSD)
++        goto done;
++
++    /* We need to release kernel ressources first. */
++    rc = usbProxyNetBSDFsUnInit(pProxyDev);
++    if (RT_FAILURE(rc))
++        goto done;
++
++    /* Resetting is only possible as super-user, ignore any failures: */
++    iParm = 0;
++    rc = usbProxyNetBSDDoIoCtl(pProxyDev, USB_DEVICEENUMERATE, &iParm, true);
++    if (RT_FAILURE(rc))
++    {
++        /* Set the config instead of bus reset */
++        iParm = 255;
++        rc = usbProxyNetBSDDoIoCtl(pProxyDev, USB_SET_CONFIG, &iParm, true);
++        if (RT_SUCCESS(rc))
++        {
++            iParm = 0;
++            rc = usbProxyNetBSDDoIoCtl(pProxyDev, USB_SET_CONFIG, &iParm, true);
++        }
++    }
++    usleep(10000); /* nice it! */
++
++    /* Allocate kernel ressources again. */
++    rc = usbProxyNetBSDFsInit(pProxyDev);
++    if (RT_FAILURE(rc))
++        goto done;
++
++    /* Retrieve current active configuration. */
++    rc = usbProxyNetBSDInit(pProxyDev);
++
++done:
++    pProxyDev->cIgnoreSetConfigs = 2;
++
++    return rc;
++}
++
++/**
++ * SET_CONFIGURATION.
++ *
++ * The caller makes sure that it's not called first time after open or reset
++ * with the active interface.
++ *
++ * @returns success indicator.
++ * @param   pProxyDev       The device instance data.
++ * @param   iCfg            The configuration to set.
++ */
++static DECLCALLBACK(int) usbProxyNetBSDSetConfig(PUSBPROXYDEV pProxyDev, int iCfg)
++{
++    PUSBPROXYDEVNBSD pDevNBSD = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVNBSD);
++    int iCfgIndex;
++    int rc;
++
++    LogFlow(("usbProxyNetBSDSetConfig: pProxyDev=%s cfg=%x\n",
++             pProxyDev->pUsbIns->pszName, iCfg));
++
++    /* We need to release kernel ressources first. */
++    rc = usbProxyNetBSDFsUnInit(pProxyDev);
++    if (RT_FAILURE(rc))
++    {
++        LogFlow(("usbProxyNetBSDSetInterface: Freeing kernel resources "
++                 "failed failed rc=%d\n", rc));
++        return rc;
++    }
++
++    if (iCfg == 0)
++    {
++        /* Unconfigure */
++        iCfgIndex = 255;
++    }
++    else
++    {
++        /* Get the configuration index matching the value. */
++        for (iCfgIndex = 0; iCfgIndex < pProxyDev->DevDesc.bNumConfigurations; iCfgIndex++)
++        {
++            if (pProxyDev->paCfgDescs[iCfgIndex].Core.bConfigurationValue == iCfg)
++                break;
++        }
++
++        if (iCfgIndex == pProxyDev->DevDesc.bNumConfigurations)
++        {
++            LogFlow(("usbProxyNetBSDSetConfig: configuration "
++                     "%d not found\n", iCfg));
++            return VERR_NOT_FOUND;
++        }
++    }
++
++    /* Set the config */
++    rc = usbProxyNetBSDDoIoCtl(pProxyDev, USB_SET_CONFIG, &iCfgIndex, true);
++    if (RT_FAILURE(rc))
++        return rc;
++
++    /* Allocate kernel ressources again. */
++    return usbProxyNetBSDFsInit(pProxyDev);
++}
++
++/**
++ * Claims an interface.
++ * @returns success indicator.
++ */
++static DECLCALLBACK(int) usbProxyNetBSDClaimInterface(PUSBPROXYDEV pProxyDev, int iIf)
++{
++    int rc;
++
++    LogFlow(("usbProxyNetBSDClaimInterface: pProxyDev=%s "
++             "ifnum=%x\n", pProxyDev->pUsbIns->pszName, iIf));
++
++    /*
++     * Try to detach kernel driver on this interface, ignore any
++     * failures
++     */
++    usbProxyNetBSDDoIoCtl(pProxyDev, USB_IFACE_DRIVER_DETACH, &iIf, true);
++
++    /* Try to claim interface */
++    return usbProxyNetBSDDoIoCtl(pProxyDev, USB_CLAIM_INTERFACE, &iIf, true);
++}
++
++/**
++ * Releases an interface.
++ * @returns success indicator.
++ */
++static DECLCALLBACK(int) usbProxyNetBSDReleaseInterface(PUSBPROXYDEV pProxyDev, int iIf)
++{
++    int rc;
++
++    LogFlow(("usbProxyNetBSDReleaseInterface: pProxyDev=%s "
++        "ifnum=%x\n", pProxyDev->pUsbIns->pszName, iIf));
++
++    return usbProxyNetBSDDoIoCtl(pProxyDev, USB_RELEASE_INTERFACE, &iIf, true);
++}
++
++/**
++ * SET_INTERFACE.
++ *
++ * @returns success indicator.
++ */
++static DECLCALLBACK(int) usbProxyNetBSDSetInterface(PUSBPROXYDEV pProxyDev, int iIf, int iAlt)
++{
++    PUSBPROXYDEVNBSD pDevNBSD = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVNBSD);
++    struct usb_alt_interface UsbIntAlt;
++    int rc;
++
++    LogFlow(("usbProxyNetBSDSetInterface: pProxyDev=%p iIf=%x iAlt=%x\n",
++             pProxyDev, iIf, iAlt));
++
++    /* We need to release kernel ressources first. */
++    rc = usbProxyNetBSDFsUnInit(pProxyDev);
++    if (RT_FAILURE(rc))
++    {
++        LogFlow(("usbProxyNetBSDSetInterface: Freeing kernel resources "
++                 "failed failed rc=%d\n", rc));
++        return rc;
++    }
++    memset(&UsbIntAlt, 0, sizeof(UsbIntAlt));
++    UsbIntAlt.uai_interface_index = iIf;
++    UsbIntAlt.uai_alt_index = iAlt;
++
++    rc = usbProxyNetBSDDoIoCtl(pProxyDev, USB_SET_ALTINTERFACE, &UsbIntAlt, true);
++    if (RT_FAILURE(rc))
++    {
++        LogFlow(("usbProxyNetBSDSetInterface: Setting interface %d %d "
++                 "failed rc=%d\n", iIf, iAlt, rc));
++        return rc;
++    }
++
++    return usbProxyNetBSDFsInit(pProxyDev);
++}
++
++/**
++ * Clears the halted endpoint 'ep_num'.
++ */
++static DECLCALLBACK(int) usbProxyNetBSDClearHaltedEp(PUSBPROXYDEV pProxyDev, unsigned int ep_num)
++{
++    LogFlow(("usbProxyNetBSDClearHaltedEp: pProxyDev=%s ep_num=%u\n",
++             pProxyDev->pUsbIns->pszName, ep_num));
++
++    /*
++     * Clearing the zero control pipe doesn't make sense.
++     * Just ignore it.
++     */
++    if ((ep_num & 0xF) == 0)
++        return VINF_SUCCESS;
++
++    struct usb_ctl_request Req;
++    memset(&Req, 0, sizeof(Req));
++    usbProxyNetBSDSetupReq(&Req.ucr_request,
++                            VUSB_DIR_TO_DEV | VUSB_TO_ENDPOINT,
++                            VUSB_REQ_CLEAR_FEATURE, 0, ep_num, 0);
++
++    int rc = usbProxyNetBSDDoIoCtl(pProxyDev, USB_DO_REQUEST, &Req, true);
++
++    LogFlow(("usbProxyNetBSDClearHaltedEp: rc=%Rrc\n", rc));
++    return rc;
++}
++
++/**
++ * @copydoc USBPROXYBACK::pfnUrbQueue
++ */
++static DECLCALLBACK(int) usbProxyNetBSDUrbQueue(PUSBPROXYDEV pProxyDev, PVUSBURB pUrb)
++{
++    PUSBPROXYDEVNBSD pDevNBSD = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVNBSD);
++    PUSBENDPOINTNBSD pEndpointNBSD;
++    struct usb_fs_endpoint *pXferEndpoint;
++    struct usb_fs_start UsbFsStart;
++    unsigned cFrames;
++    uint8_t *pbData;
++    int index;
++    int ep_num;
++    int rc;
++
++    LogFlow(("usbProxyNetBSDUrbQueue: pUrb=%p EndPt=%u Dir=%u\n",
++             pUrb, (unsigned)pUrb->EndPt, (unsigned)pUrb->enmDir));
++
++    ep_num = pUrb->EndPt;
++    if ((pUrb->enmType != VUSBXFERTYPE_MSG) && (pUrb->enmDir == VUSBDIRECTION_IN)) {
++        /* set IN-direction bit */
++        ep_num |= 0x80;
++    }
++
++    index = 0;
++
++retry:
++
++    index = usbProxyNetBSDEndpointOpen(pProxyDev, ep_num,
++                                        (pUrb->enmType == VUSBXFERTYPE_ISOC),
++                                        index);
++
++    if (index < 0)
++        return VERR_INVALID_PARAMETER;
++
++    pEndpointNBSD = &pDevNBSD->aSwEndpoint[index];
++    pXferEndpoint = &pDevNBSD->aHwEndpoint[index];
++
++    pbData = pUrb->abData;
++
++    switch (pUrb->enmType)
++    {
++        case VUSBXFERTYPE_MSG:
++        {
++            pEndpointNBSD->apvData[0] = pbData;
++            pEndpointNBSD->acbData[0] = 8;
++
++            /* check wLength */
++            if (pbData[6] || pbData[7])
++            {
++                pEndpointNBSD->apvData[1] = pbData + 8;
++                pEndpointNBSD->acbData[1] = pbData[6] | (pbData[7] << 8);
++                cFrames = 2;
++            }
++            else
++            {
++                pEndpointNBSD->apvData[1] = NULL;
++                pEndpointNBSD->acbData[1] = 0;
++                cFrames = 1;
++            }
++
++            LogFlow(("usbProxyNetBSDUrbQueue: pUrb->cbData=%u, 0x%02x, "
++                     "0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x\n",
++                     pUrb->cbData, pbData[0], pbData[1], pbData[2], pbData[3],
++                     pbData[4], pbData[5], pbData[6], pbData[7]));
++
++            pXferEndpoint->timeout = USB_FS_TIMEOUT_NONE;
++            pXferEndpoint->flags = USB_FS_FLAG_MULTI_SHORT_OK;
++            break;
++        }
++        case VUSBXFERTYPE_ISOC:
++        {
++            unsigned i;
++
++            for (i = 0; i < pUrb->cIsocPkts; i++)
++            {
++                if (i >= pEndpointNBSD->cMaxFrames)
++                    break;
++                pEndpointNBSD->apvData[i] = pbData + pUrb->aIsocPkts[i].off;
++                pEndpointNBSD->acbData[i] = pUrb->aIsocPkts[i].cb;
++            }
++            /* Timeout handling will be done during reap. */
++            pXferEndpoint->timeout = USB_FS_TIMEOUT_NONE;
++            pXferEndpoint->flags = USB_FS_FLAG_MULTI_SHORT_OK;
++            cFrames = i;
++            break;
++        }
++        default:
++        {
++            pEndpointNBSD->apvData[0] = pbData;
++            pEndpointNBSD->cbData0 = pUrb->cbData;
++
++            /* XXX maybe we have to loop */
++            if (pUrb->cbData > pEndpointNBSD->cMaxIo)
++                pEndpointNBSD->acbData[0] = pEndpointNBSD->cMaxIo;
++            else
++                pEndpointNBSD->acbData[0] = pUrb->cbData;
++
++            /* Timeout handling will be done during reap. */
++            pXferEndpoint->timeout = USB_FS_TIMEOUT_NONE;
++            pXferEndpoint->flags = pUrb->fShortNotOk ? 0 : USB_FS_FLAG_MULTI_SHORT_OK;
++            cFrames = 1;
++            break;
++        }
++    }
++
++    /* store number of frames */
++    pXferEndpoint->nFrames = cFrames;
++
++    /* zero-default */
++    memset(&UsbFsStart, 0, sizeof(UsbFsStart));
++
++    /* Start the transfer */
++    UsbFsStart.ep_index = index;
++
++    rc = usbProxyNetBSDDoIoCtl(pProxyDev, USB_FS_START, &UsbFsStart, true);
++
++    LogFlow(("usbProxyNetBSDUrbQueue: USB_FS_START returned rc=%d "
++             "len[0]=%u len[1]=%u cbData=%u index=%u ep_num=%u\n", rc,
++             (unsigned)pEndpointNBSD->acbData[0],
++             (unsigned)pEndpointNBSD->acbData[1],
++             (unsigned)pUrb->cbData,
++             (unsigned)index, (unsigned)ep_num));
++
++    if (RT_FAILURE(rc))
++    {
++        if (rc == VERR_RESOURCE_BUSY)
++        {
++            index++;
++            goto retry;
++        }
++        return rc;
++    }
++    pUrb->Dev.pvPrivate = (void *)(long)(index + 1);
++    pEndpointNBSD->pUrb = pUrb;
++
++    return rc;
++}
++
++/**
++ * Reap URBs in-flight on a device.
++ *
++ * @returns Pointer to a completed URB.
++ * @returns NULL if no URB was completed.
++ * @param   pProxyDev   The device.
++ * @param   cMillies    Number of milliseconds to wait. Use 0 to not wait at all.
++ */
++static DECLCALLBACK(PVUSBURB) usbProxyNetBSDUrbReap(PUSBPROXYDEV pProxyDev, RTMSINTERVAL cMillies)
++{
++    struct usb_fs_endpoint *pXferEndpoint;
++    PUSBPROXYDEVNBSD pDevNBSD = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVNBSD);
++    PUSBENDPOINTNBSD pEndpointNBSD;
++    PVUSBURB pUrb;
++    struct usb_fs_complete UsbFsComplete;
++    struct pollfd pfd[2];
++    int rc;
++
++    LogFlow(("usbProxyNetBSDUrbReap: pProxyDev=%p, cMillies=%u\n",
++             pProxyDev, cMillies));
++
++repeat:
++
++    pUrb = NULL;
++
++    /* check for cancelled transfers */
++    if (pDevNBSD->fCancelling)
++    {
++        for (unsigned n = 0; n < USBNBSD_MAXENDPOINTS; n++)
++        {
++            pEndpointNBSD = &pDevNBSD->aSwEndpoint[n];
++            if (pEndpointNBSD->fCancelling)
++            {
++                pEndpointNBSD->fCancelling = false;
++                pUrb = pEndpointNBSD->pUrb;
++                pEndpointNBSD->pUrb = NULL;
++
++                if (pUrb != NULL)
++                    break;
++            }
++        }
++
++        if (pUrb != NULL)
++        {
++            pUrb->enmStatus = VUSBSTATUS_INVALID;
++            pUrb->Dev.pvPrivate = NULL;
++
++            switch (pUrb->enmType)
++            {
++                case VUSBXFERTYPE_MSG:
++                    pUrb->cbData = 0;
++                    break;
++                case VUSBXFERTYPE_ISOC:
++                    pUrb->cbData = 0;
++                    for (int n = 0; n < (int)pUrb->cIsocPkts; n++)
++                        pUrb->aIsocPkts[n].cb = 0;
++                    break;
++                default:
++                    pUrb->cbData = 0;
++                    break;
++            }
++            return pUrb;
++        }
++        pDevNBSD->fCancelling = false;
++    }
++    /* Zero default */
++
++    memset(&UsbFsComplete, 0, sizeof(UsbFsComplete));
++
++    /* Check if any endpoints are complete */
++    rc = usbProxyNetBSDDoIoCtl(pProxyDev, USB_FS_COMPLETE, &UsbFsComplete, true);
++    if (RT_SUCCESS(rc))
++    {
++        pXferEndpoint = &pDevNBSD->aHwEndpoint[UsbFsComplete.ep_index];
++        pEndpointNBSD = &pDevNBSD->aSwEndpoint[UsbFsComplete.ep_index];
++
++        LogFlow(("usbProxyNetBSDUrbReap: Reaped "
++                 "URB %#p\n", pEndpointNBSD->pUrb));
++
++        if (pXferEndpoint->status == USB_ERR_CANCELLED)
++            goto repeat;
++
++        pUrb = pEndpointNBSD->pUrb;
++        pEndpointNBSD->pUrb = NULL;
++        if (pUrb == NULL)
++            goto repeat;
++
++        switch (pXferEndpoint->status)
++        {
++            case USB_ERR_NORMAL_COMPLETION:
++                pUrb->enmStatus = VUSBSTATUS_OK;
++                break;
++            case USB_ERR_STALLED:
++                pUrb->enmStatus = VUSBSTATUS_STALL;
++                break;
++            default:
++                pUrb->enmStatus = VUSBSTATUS_INVALID;
++                break;
++        }
++
++        pUrb->Dev.pvPrivate = NULL;
++
++        switch (pUrb->enmType)
++        {
++            case VUSBXFERTYPE_MSG:
++                pUrb->cbData = pEndpointNBSD->acbData[0] + pEndpointNBSD->acbData[1];
++                break;
++            case VUSBXFERTYPE_ISOC:
++            {
++                int n;
++
++                if (pUrb->enmDir == VUSBDIRECTION_OUT)
++                    break;
++                pUrb->cbData = 0;
++                for (n = 0; n < (int)pUrb->cIsocPkts; n++)
++                {
++                    if (n >= (int)pEndpointNBSD->cMaxFrames)
++                        break;
++                    pUrb->cbData += pEndpointNBSD->acbData[n];
++                    pUrb->aIsocPkts[n].cb = pEndpointNBSD->acbData[n];
++                }
++                for (; n < (int)pUrb->cIsocPkts; n++)
++                    pUrb->aIsocPkts[n].cb = 0;
++
++                break;
++            }
++            default:
++                pUrb->cbData = pEndpointNBSD->acbData[0];
++                break;
++        }
++
++        LogFlow(("usbProxyNetBSDUrbReap: Status=%d epindex=%u "
++                 "len[0]=%d len[1]=%d\n",
++                 (int)pXferEndpoint->status,
++                 (unsigned)UsbFsComplete.ep_index,
++                 (unsigned)pEndpointNBSD->acbData[0],
++                 (unsigned)pEndpointNBSD->acbData[1]));
++
++    }
++    else if (cMillies != 0 && rc == VERR_RESOURCE_BUSY)
++    {
++        for (;;)
++        {
++            pfd[0].fd = RTFileToNative(pDevNBSD->hFile);
++            pfd[0].events = POLLIN | POLLRDNORM;
++            pfd[0].revents = 0;
++
++            pfd[1].fd = RTPipeToNative(pDevNBSD->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(pDevNBSD->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;
++}
++
++/**
++ * Cancels the URB.
++ * The URB requires reaping, so we don't change its state.
++ */
++static DECLCALLBACK(int) usbProxyNetBSDUrbCancel(PUSBPROXYDEV pProxyDev, PVUSBURB pUrb)
++{
++    int index;
++
++    index = (int)(long)pUrb->Dev.pvPrivate - 1;
++
++    if (index < 0 || index >= USBNBSD_MAXENDPOINTS)
++        return VINF_SUCCESS; /* invalid index, pretend success. */
++
++    LogFlow(("usbProxyNetBSDUrbCancel: epindex=%u\n", (unsigned)index));
++    return usbProxyNetBSDEndpointClose(pProxyDev, index);
++}
++
++static DECLCALLBACK(int) usbProxyNetBSDWakeup(PUSBPROXYDEV pProxyDev)
++{
++    PUSBPROXYDEVNBSD pDevNBSD = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVNBSD);
++    size_t cbIgnored;
++
++    LogFlowFunc(("pProxyDev=%p\n", pProxyDev));
++
++    return RTPipeWrite(pDevNBSD->hPipeWakeupW, "", 1, &cbIgnored);
++}
++
++/**
++ * The NetBSD USB Proxy Backend.
++ */
++extern const USBPROXYBACK g_USBProxyDeviceHost =
++{
++    /* pszName */
++    "host",
++    /* cbBackend */
++    sizeof(USBPROXYDEVNBSD),
++    usbProxyNetBSDOpen,
++    usbProxyNetBSDInit,
++    usbProxyNetBSDClose,
++    usbProxyNetBSDReset,
++    usbProxyNetBSDSetConfig,
++    usbProxyNetBSDClaimInterface,
++    usbProxyNetBSDReleaseInterface,
++    usbProxyNetBSDSetInterface,
++    usbProxyNetBSDClearHaltedEp,
++    usbProxyNetBSDUrbQueue,
++    usbProxyNetBSDUrbCancel,
++    usbProxyNetBSDUrbReap,
++    usbProxyNetBSDWakeup,
++    0
++};
++
++/*
++ * Local Variables:
++ *  mode: c
++ *  c-file-style: "bsd"
++ *  c-basic-offset: 4
++ *  tab-width: 4
++ *  indent-tabs-mode: s
++ * End:
++ */
diff --git a/virtualbox-svn/patches/patch-src_VBox_Devices_build_VBoxDD.cpp b/virtualbox-svn/patches/patch-src_VBox_Devices_build_VBoxDD.cpp
new file mode 100644
index 0000000..9dcbab0
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Devices_build_VBoxDD.cpp
@@ -0,0 +1,31 @@
+$NetBSD$
+
+--- src/VBox/Devices/build/VBoxDD.cpp.orig	2016-07-10 19:58:34.000000000 +0000
++++ src/VBox/Devices/build/VBoxDD.cpp
+@@ -229,7 +229,7 @@ extern "C" DECLEXPORT(int) VBoxDriversRe
+     rc = pCallbacks->pfnRegister(pCallbacks, &g_DrvVD);
+     if (RT_FAILURE(rc))
+         return rc;
+-#if defined(RT_OS_DARWIN) || defined(RT_OS_LINUX) || defined(RT_OS_SOLARIS) || defined(RT_OS_WINDOWS) || defined(RT_OS_FREEBSD)
++#if defined(RT_OS_DARWIN) || defined(RT_OS_LINUX) || defined(RT_OS_SOLARIS) || defined(RT_OS_WINDOWS) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+     rc = pCallbacks->pfnRegister(pCallbacks, &g_DrvHostDVD);
+     if (RT_FAILURE(rc))
+         return rc;
+@@ -242,7 +242,7 @@ extern "C" DECLEXPORT(int) VBoxDriversRe
+     rc = pCallbacks->pfnRegister(pCallbacks, &g_DrvNAT);
+     if (RT_FAILURE(rc))
+         return rc;
+-#if defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD)
++#if defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+     rc = pCallbacks->pfnRegister(pCallbacks, &g_DrvHostInterface);
+     if (RT_FAILURE(rc))
+         return rc;
+@@ -354,7 +354,7 @@ extern "C" DECLEXPORT(int) VBoxDriversRe
+     if (RT_FAILURE(rc))
+         return rc;
+ #endif
+-#if defined(RT_OS_DARWIN) || defined(RT_OS_LINUX) || defined(RT_OS_SOLARIS) || defined(RT_OS_WINDOWS) || defined(RT_OS_FREEBSD)
++#if defined(RT_OS_DARWIN) || defined(RT_OS_LINUX) || defined(RT_OS_SOLARIS) || defined(RT_OS_WINDOWS) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+     rc = pCallbacks->pfnRegister(pCallbacks, &g_DrvHostSerial);
+     if (RT_FAILURE(rc))
+         return rc;
diff --git a/virtualbox-svn/patches/patch-src_VBox_Devices_build_VBoxDD.h b/virtualbox-svn/patches/patch-src_VBox_Devices_build_VBoxDD.h
new file mode 100644
index 0000000..00b0cf9
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Devices_build_VBoxDD.h
@@ -0,0 +1,9 @@
+$NetBSD$
+
+--- src/VBox/Devices/build/VBoxDD.h.orig	2016-07-10 19:58:34.000000000 +0000
++++ src/VBox/Devices/build/VBoxDD.h
+@@ -183,4 +183,3 @@ int acpiCleanupSsdt(PPDMDEVINS pDevIns, 
+ RT_C_DECLS_END
+ 
+ #endif
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_ExtPacks_BusMouseSample_Makefile.kmk b/virtualbox-svn/patches/patch-src_VBox_ExtPacks_BusMouseSample_Makefile.kmk
new file mode 100644
index 0000000..693c8ef
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_ExtPacks_BusMouseSample_Makefile.kmk
@@ -0,0 +1,22 @@
+$NetBSD$
+
+--- src/VBox/ExtPacks/BusMouseSample/Makefile.kmk.orig	2016-03-04 19:28:27.000000000 +0000
++++ src/VBox/ExtPacks/BusMouseSample/Makefile.kmk
+@@ -133,6 +133,12 @@ endif
+ if1of (freebsd.x86, $(VBOX_WITH_EXTPACK_OS_ARCHS))
+  VBOX_BUSMOUSE_FILES += $(call VBOX_BUSMOUSE_FILES_MACRO,freebsd.x86,bin,so)
+ endif
++if1of (netbsd.amd64, $(VBOX_WITH_EXTPACK_OS_ARCHS))
++ VBOX_BUSMOUSE_FILES += $(call VBOX_BUSMOUSE_FILES_MACRO,netbsd.amd64,bin,so)
++endif
++if1of (netbsd.x86, $(VBOX_WITH_EXTPACK_OS_ARCHS))
++ VBOX_BUSMOUSE_FILES += $(call VBOX_BUSMOUSE_FILES_MACRO,netbsd.x86,bin,so)
++endif
+ if1of (linux.amd64, $(VBOX_WITH_EXTPACK_OS_ARCHS))
+  VBOX_BUSMOUSE_FILES += $(call VBOX_BUSMOUSE_FILES_MACRO,linux.amd64,bin,so)
+ endif
+@@ -184,4 +190,3 @@ $(VBOX_PATH_PACKAGES)/$(VBOX_BUSMOUSE_MA
+ BLDDIRS += $(VBOX_PATH_PACKAGES)/
+ 
+ include $(FILE_KBUILD_SUB_FOOTER)
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_ExtPacks_Skeleton_Makefile.kmk b/virtualbox-svn/patches/patch-src_VBox_ExtPacks_Skeleton_Makefile.kmk
new file mode 100644
index 0000000..86f70b2
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_ExtPacks_Skeleton_Makefile.kmk
@@ -0,0 +1,22 @@
+$NetBSD$
+
+--- src/VBox/ExtPacks/Skeleton/Makefile.kmk.orig	2016-03-04 19:28:27.000000000 +0000
++++ src/VBox/ExtPacks/Skeleton/Makefile.kmk
+@@ -108,6 +108,12 @@ endif
+ if1of (freebsd.x86, $(VBOX_WITH_EXTPACK_OS_ARCHS))
+  VBOX_SKELETON_FILES += $(call VBOX_SKELETON_FILES_MACRO,freebsd.x86,bin,so)
+ endif
++if1of (netbsd.amd64, $(VBOX_WITH_EXTPACK_OS_ARCHS))
++ VBOX_SKELETON_FILES += $(call VBOX_SKELETON_FILES_MACRO,netbsd.amd64,bin,so)
++endif
++if1of (netbsd.x86, $(VBOX_WITH_EXTPACK_OS_ARCHS))
++ VBOX_SKELETON_FILES += $(call VBOX_SKELETON_FILES_MACRO,netbsd.x86,bin,so)
++endif
+ if1of (linux.amd64, $(VBOX_WITH_EXTPACK_OS_ARCHS))
+  VBOX_SKELETON_FILES += $(call VBOX_SKELETON_FILES_MACRO,linux.amd64,bin,so)
+ endif
+@@ -159,4 +165,3 @@ $(VBOX_PATH_PACKAGES)/$(VBOX_SKELETON_MA
+ BLDDIRS += $(VBOX_PATH_PACKAGES)/
+ 
+ include $(FILE_KBUILD_SUB_FOOTER)
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_ExtPacks_VBoxDTrace_Makefile.kmk b/virtualbox-svn/patches/patch-src_VBox_ExtPacks_VBoxDTrace_Makefile.kmk
new file mode 100644
index 0000000..c71c1bf
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_ExtPacks_VBoxDTrace_Makefile.kmk
@@ -0,0 +1,22 @@
+$NetBSD$
+
+--- src/VBox/ExtPacks/VBoxDTrace/Makefile.kmk.orig	2016-03-04 19:28:27.000000000 +0000
++++ src/VBox/ExtPacks/VBoxDTrace/Makefile.kmk
+@@ -292,6 +292,12 @@ if defined(VBOX_WITH_EXTPACK_VBOXDTRACE)
+  if1of (freebsd.x86, $(VBOX_WITH_EXTPACK_OS_ARCHS))
+   VBOX_VBOXDTRACE_FILES += $(call VBOX_VBOXDTRACE_FILES_MACRO,freebsd.x86,bin,so)
+  endif
++ if1of (netbsd.amd64, $(VBOX_WITH_EXTPACK_OS_ARCHS))
++  VBOX_VBOXDTRACE_FILES += $(call VBOX_VBOXDTRACE_FILES_MACRO,netbsd.amd64,bin,so)
++ endif
++ if1of (netbsd.x86, $(VBOX_WITH_EXTPACK_OS_ARCHS))
++  VBOX_VBOXDTRACE_FILES += $(call VBOX_VBOXDTRACE_FILES_MACRO,netbsd.x86,bin,so)
++ endif
+  if1of (linux.amd64, $(VBOX_WITH_EXTPACK_OS_ARCHS))
+   VBOX_VBOXDTRACE_FILES += $(call VBOX_VBOXDTRACE_FILES_MACRO,linux.amd64,bin,so)
+  endif
+@@ -346,4 +352,3 @@ endif # VBOX_WITH_EXTPACK_VBOXDTRACE
+ 
+ 
+ include $(FILE_KBUILD_SUB_FOOTER)
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_ExtPacks_VBoxDTrace_VBoxDTraceWrapper.cpp b/virtualbox-svn/patches/patch-src_VBox_ExtPacks_VBoxDTrace_VBoxDTraceWrapper.cpp
new file mode 100644
index 0000000..36cadc5
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_ExtPacks_VBoxDTrace_VBoxDTraceWrapper.cpp
@@ -0,0 +1,18 @@
+$NetBSD$
+
+--- src/VBox/ExtPacks/VBoxDTrace/VBoxDTraceWrapper.cpp.orig	2016-03-04 19:28:27.000000000 +0000
++++ src/VBox/ExtPacks/VBoxDTrace/VBoxDTraceWrapper.cpp
+@@ -68,7 +68,7 @@ int main(int argc, char **argv)
+     char szDTraceCmd[RTPATH_MAX];
+     szDTraceCmd[0] = '\0';
+ 
+-#if defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD) || defined(RT_OS_LINUX) || defined(RT_OS_SOLARIS)
++#if defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD) || defined(RT_OS_LINUX) || defined(RT_OS_SOLARIS) || defined(RT_OS_NETBSD)
+     /*
+      * 1. Try native first on platforms where it's applicable.
+      */
+@@ -199,4 +199,3 @@ int main(int argc, char **argv)
+     }
+     return rcExit;
+ }
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_ExtPacks_VNC_Makefile.kmk b/virtualbox-svn/patches/patch-src_VBox_ExtPacks_VNC_Makefile.kmk
new file mode 100644
index 0000000..1d4a5f0
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_ExtPacks_VNC_Makefile.kmk
@@ -0,0 +1,22 @@
+$NetBSD$
+
+--- src/VBox/ExtPacks/VNC/Makefile.kmk.orig	2016-03-04 19:28:58.000000000 +0000
++++ src/VBox/ExtPacks/VNC/Makefile.kmk
+@@ -110,6 +110,12 @@ endif
+ if1of (freebsd.x86, $(VBOX_WITH_EXTPACK_OS_ARCHS))
+  VBOX_VNC_FILES += $(call VBOX_VNC_FILES_MACRO,freebsd.x86,bin,so)
+ endif
++if1of (netbsd.amd64, $(VBOX_WITH_EXTPACK_OS_ARCHS))
++ VBOX_VNC_FILES += $(call VBOX_VNC_FILES_MACRO,netbsd.amd64,bin,so)
++endif
++if1of (netbsd.x86, $(VBOX_WITH_EXTPACK_OS_ARCHS))
++ VBOX_VNC_FILES += $(call VBOX_VNC_FILES_MACRO,netbsd.x86,bin,so)
++endif
+ if1of (linux.amd64, $(VBOX_WITH_EXTPACK_OS_ARCHS))
+  VBOX_VNC_FILES += $(call VBOX_VNC_FILES_MACRO,linux.amd64,bin,so)
+ endif
+@@ -161,4 +167,3 @@ $(VBOX_PATH_PACKAGES)/$(VBOX_VNC_MANGLED
+ BLDDIRS += $(VBOX_PATH_PACKAGES)/
+ 
+ include $(FILE_KBUILD_SUB_FOOTER)
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_Frontends_VBoxAutostart_VBoxAutostart-posix.cpp b/virtualbox-svn/patches/patch-src_VBox_Frontends_VBoxAutostart_VBoxAutostart-posix.cpp
new file mode 100644
index 0000000..eb4f93b
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Frontends_VBoxAutostart_VBoxAutostart-posix.cpp
@@ -0,0 +1,18 @@
+$NetBSD$
+
+--- src/VBox/Frontends/VBoxAutostart/VBoxAutostart-posix.cpp.orig	2016-03-04 19:28:58.000000000 +0000
++++ src/VBox/Frontends/VBoxAutostart/VBoxAutostart-posix.cpp
+@@ -61,7 +61,7 @@
+ 
+ using namespace com;
+ 
+-#if defined(RT_OS_LINUX) || defined (RT_OS_SOLARIS) || defined(RT_OS_FREEBSD) || defined(RT_OS_DARWIN)
++#if defined(RT_OS_LINUX) || defined (RT_OS_SOLARIS) || defined(RT_OS_FREEBSD) || defined(RT_OS_DARWIN) || defined(RT_OS_NETBSD)
+ # define VBOXAUTOSTART_DAEMONIZE
+ #endif
+ 
+@@ -564,4 +564,3 @@ int main(int argc, char *argv[])
+     autostartShutdown();
+     return rcExit;
+ }
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_Frontends_VBoxBalloonCtrl_VBoxWatchdog.cpp b/virtualbox-svn/patches/patch-src_VBox_Frontends_VBoxBalloonCtrl_VBoxWatchdog.cpp
new file mode 100644
index 0000000..f9aa88b
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Frontends_VBoxBalloonCtrl_VBoxWatchdog.cpp
@@ -0,0 +1,45 @@
+$NetBSD$
+
+--- src/VBox/Frontends/VBoxBalloonCtrl/VBoxWatchdog.cpp.orig	2016-03-04 19:28:59.000000000 +0000
++++ src/VBox/Frontends/VBoxBalloonCtrl/VBoxWatchdog.cpp
+@@ -112,7 +112,7 @@ enum GETOPTDEF_WATCHDOG
+  * Command line arguments.
+  */
+ static const RTGETOPTDEF g_aOptions[] = {
+-#if defined(RT_OS_DARWIN) || defined(RT_OS_LINUX) || defined (RT_OS_SOLARIS) || defined(RT_OS_FREEBSD)
++#if defined(RT_OS_DARWIN) || defined(RT_OS_LINUX) || defined (RT_OS_SOLARIS) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+     { "--background",           'b',                                       RTGETOPT_REQ_NOTHING },
+ #endif
+     /** For displayHelp(). */
+@@ -854,7 +854,7 @@ static void displayHelp(const char *pszI
+                 pcszDescr = "Print this help message and exit.";
+                 break;
+ 
+-#if defined(RT_OS_DARWIN) || defined(RT_OS_LINUX) || defined (RT_OS_SOLARIS) || defined(RT_OS_FREEBSD)
++#if defined(RT_OS_DARWIN) || defined(RT_OS_LINUX) || defined (RT_OS_SOLARIS) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+             case 'b':
+                 pcszDescr = "Run in background (daemon mode).";
+                 break;
+@@ -992,7 +992,7 @@ int main(int argc, char *argv[])
+                 g_fVerbose = true;
+                 break;
+ 
+-#if defined(RT_OS_DARWIN) || defined(RT_OS_LINUX) || defined (RT_OS_SOLARIS) || defined(RT_OS_FREEBSD)
++#if defined(RT_OS_DARWIN) || defined(RT_OS_LINUX) || defined (RT_OS_SOLARIS) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+             case 'b':
+                 g_fDaemonize = true;
+                 break;
+@@ -1072,7 +1072,7 @@ int main(int argc, char *argv[])
+     if (RT_FAILURE(rc))
+         return RTMsgErrorExit(RTEXITCODE_FAILURE, "failed to open release log (%s, %Rrc)", szError, rc);
+ 
+-#if defined(RT_OS_DARWIN) || defined(RT_OS_LINUX) || defined (RT_OS_SOLARIS) || defined(RT_OS_FREEBSD)
++#if defined(RT_OS_DARWIN) || defined(RT_OS_LINUX) || defined (RT_OS_SOLARIS) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+     if (g_fDaemonize)
+     {
+         /* prepare release logging */
+@@ -1160,4 +1160,3 @@ int main(int argc, char *argv[])
+     return RTEXITCODE_SUCCESS;
+ #endif /* VBOX_ONLY_DOCS */
+ }
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_Frontends_VBoxManage_VBoxInternalManage.cpp b/virtualbox-svn/patches/patch-src_VBox_Frontends_VBoxManage_VBoxInternalManage.cpp
new file mode 100644
index 0000000..184f9ee
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Frontends_VBoxManage_VBoxInternalManage.cpp
@@ -0,0 +1,54 @@
+$NetBSD$
+
+--- src/VBox/Frontends/VBoxManage/VBoxInternalManage.cpp.orig	2016-07-10 20:58:44.000000000 +0000
++++ src/VBox/Frontends/VBoxManage/VBoxInternalManage.cpp
+@@ -52,7 +52,7 @@
+ # include <windows.h>
+ # include <winioctl.h>
+ #elif defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) \
+-    || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD)
++    || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+ # include <errno.h>
+ # include <sys/ioctl.h>
+ # include <sys/types.h>
+@@ -74,9 +74,9 @@
+ # include <sys/dkio.h>
+ # include <sys/vtoc.h>
+ #endif /* RT_OS_SOLARIS */
+-#ifdef RT_OS_FREEBSD
++#if defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+ # include <sys/disk.h>
+-#endif /* RT_OS_FREEBSD */
++#endif /* RT_OS_FREEBSD || RT_OS_NETBSD */
+ 
+ using namespace com;
+ 
+@@ -1193,12 +1193,12 @@ static RTEXITCODE CmdCreateRawVMDK(int a
+             i++;
+             pszPartitions = argv[i];
+         }
+-#if defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD) || defined(RT_OS_WINDOWS)
++#if defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD) || defined(RT_OS_WINDOWS) || defined(RT_OS_NETBSD)
+         else if (strcmp(argv[i], "-relative") == 0)
+         {
+             fRelative = true;
+         }
+-#endif /* RT_OS_LINUX || RT_OS_FREEBSD */
++#endif /* RT_OS_LINUX || RT_OS_FREEBSD || RT_OS_NETBSD */
+         else
+             return errorSyntax(USAGE_CREATERAWVMDK, "Invalid parameter '%s'", argv[i]);
+     }
+@@ -1438,7 +1438,7 @@ static RTEXITCODE CmdCreateRawVMDK(int a
+         RTMsgError("Failed to get file informtation for raw disk '%s': %Rrc",
+                    rawdisk.c_str(), vrc);
+     }
+-#elif defined(RT_OS_FREEBSD)
++#elif defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+     struct stat DevStat;
+     if (!fstat(RTFileToNative(hRawFile), &DevStat))
+     {
+@@ -2580,4 +2580,3 @@ RTEXITCODE handleInternalCommands(Handle
+     /* default: */
+     return errorSyntax(USAGE_ALL, "Invalid command '%s'", a->argv[0]);
+ }
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_Frontends_VBoxManage_VBoxManageHelp.cpp b/virtualbox-svn/patches/patch-src_VBox_Frontends_VBoxManage_VBoxManageHelp.cpp
new file mode 100644
index 0000000..4a0e0ce
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Frontends_VBoxManage_VBoxManageHelp.cpp
@@ -0,0 +1,50 @@
+$NetBSD$
+
+--- src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp.orig	2016-03-04 19:28:59.000000000 +0000
++++ src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp
+@@ -570,6 +570,11 @@ void printUsage(USAGECATEGORY fCategory,
+ #else
+     bool fFreeBSD = false;
+ #endif
++#ifdef RT_OS_NETBSD
++    bool fNetBSD = true;
++#else
++    bool fNetBSD = false;
++#endif
+ #ifdef RT_OS_DARWIN
+     bool fDarwin = true;
+ #else
+@@ -588,6 +593,7 @@ void printUsage(USAGECATEGORY fCategory,
+         fWin = true;
+         fSolaris = true;
+         fFreeBSD = true;
++        fNetBSD = true;
+         fDarwin = true;
+         fVBoxSDL = true;
+         fCategory = USAGE_ALL;
+@@ -824,6 +830,20 @@ void printUsage(USAGECATEGORY fCategory,
+             RTStrmPrintf(pStrm, "|pulse");
+ #endif
+         }
++        if (fNetBSD)
++        {
++            /* Get the line break sorted when dumping all option variants. */
++            if (fDumpOpts)
++            {
++                RTStrmPrintf(pStrm, "|\n"
++                     "                                     oss");
++            }
++            else
++                RTStrmPrintf(pStrm, "|oss");
++#ifdef VBOX_WITH_PULSE
++            RTStrmPrintf(pStrm, "|pulse");
++#endif
++        }
+         if (fDarwin)
+         {
+             RTStrmPrintf(pStrm, "|coreaudio");
+@@ -1523,4 +1543,3 @@ RTEXITCODE errorArgument(const char *psz
+     va_end(args);
+     return RTEXITCODE_SYNTAX;
+ }
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_Frontends_VBoxManage_VBoxManageModifyVM.cpp b/virtualbox-svn/patches/patch-src_VBox_Frontends_VBoxManage_VBoxManageModifyVM.cpp
new file mode 100644
index 0000000..afc7651
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Frontends_VBoxManage_VBoxManageModifyVM.cpp
@@ -0,0 +1,2 @@
+$NetBSD$
+
diff --git a/virtualbox-svn/patches/patch-src_VBox_Frontends_VBoxSDL_Makefile.kmk b/virtualbox-svn/patches/patch-src_VBox_Frontends_VBoxSDL_Makefile.kmk
new file mode 100644
index 0000000..cd2d263
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Frontends_VBoxSDL_Makefile.kmk
@@ -0,0 +1,17 @@
+$NetBSD$
+
+--- src/VBox/Frontends/VBoxSDL/Makefile.kmk.orig	2016-03-04 19:29:00.000000000 +0000
++++ src/VBox/Frontends/VBoxSDL/Makefile.kmk
+@@ -59,6 +59,7 @@ else
+  endif
+ endif
+ VBoxSDL_DEFS.freebsd = VBOXSDL_WITH_X11
++VBoxSDL_DEFS.netbsd  = VBOXSDL_WITH_X11
+ VBoxSDL_DEFS.linux = _GNU_SOURCE VBOXSDL_WITH_X11
+ VBoxSDL_DEFS.solaris = VBOXSDL_WITH_X11
+ ifdef VBOX_OPENGL
+@@ -157,4 +158,3 @@ tstSDL_CXXFLAGS.linux = -O -Wall -Wno-no
+ 
+ endif # !VBOX_WITH_HARDENING || "$(KBUILD_TARGET)" != "darwin"
+ include $(FILE_KBUILD_SUB_FOOTER)
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_Frontends_VirtualBox_Makefile.kmk b/virtualbox-svn/patches/patch-src_VBox_Frontends_VirtualBox_Makefile.kmk
new file mode 100644
index 0000000..394860a
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Frontends_VirtualBox_Makefile.kmk
@@ -0,0 +1,33 @@
+$NetBSD$
+
+--- src/VBox/Frontends/VirtualBox/Makefile.kmk.orig	2016-07-10 20:58:24.000000000 +0000
++++ src/VBox/Frontends/VirtualBox/Makefile.kmk
+@@ -108,6 +108,7 @@ VirtualBox_DEFS.debug     = VBOX_CHECK_S
+ VirtualBox_DEFS.linux     = VBOX_WITH_MASKED_SEAMLESS VBOX_WITH_TRANSLUCENT_SEAMLESS
+ VirtualBox_DEFS.solaris   = VBOX_WITH_MASKED_SEAMLESS VBOX_WITH_TRANSLUCENT_SEAMLESS
+ VirtualBox_DEFS.freebsd   = VBOX_WITH_MASKED_SEAMLESS VBOX_WITH_TRANSLUCENT_SEAMLESS
++VirtualBox_DEFS.netbsd    = VBOX_WITH_MASKED_SEAMLESS VBOX_WITH_TRANSLUCENT_SEAMLESS
+ VirtualBox_DEFS.darwin    = VBOX_WITH_TRANSLUCENT_SEAMLESS # VBOX_WITH_MASKED_SEAMLESS
+ VirtualBox_DEFS.win       = VBOX_WITH_MASKED_SEAMLESS # VBOX_WITH_TRANSLUCENT_SEAMLESS
+ VirtualBox_DEFS.win       += UNICODE QT_DLL
+@@ -280,6 +281,7 @@ if defined(VBOX_WITH_VIDEOHWACCEL) || de
+  VirtualBox_LIBS.solaris   += GL
+  VirtualBox_LIBS.linux     += GL
+  VirtualBox_LIBS.freebsd   += GL
++ VirtualBox_LIBS.netbsd    += GL
+  VirtualBox_LDFLAGS.darwin += -framework OpenGL
+ endif
+ ifdef VBOX_WITH_CROGL
+@@ -1050,6 +1052,7 @@ endif
+  VirtualBoxPch_SOURCES.darwin  = $(NO_SUCH_VARIABLE)
+  VirtualBoxPch_SOURCES.solaris = $(NO_SUCH_VARIABLE)
+  VirtualBoxPch_SOURCES.freebsd = $(NO_SUCH_VARIABLE)
++ VirtualBoxPch_SOURCES.netbsd  = $(NO_SUCH_VARIABLE)
+  VirtualBoxPch_SOURCES.linux   = $(NO_SUCH_VARIABLE)
+  VirtualBoxPch_SOURCES.win     = $(NO_SUCH_VARIABLE)
+  VirtualBoxPch_QT_MODULES      = $(VirtualBox_QT_MODULES) # "bug" - not inherited.
+@@ -1331,4 +1334,3 @@ nls/VirtualBox_en.ts: \
+ 	$(QUIET)$(SED) -n -i -e \
+ 		'/<context>/,/<\/context>/!p;/<context>/h;/<name>/H;/<message numerus="yes">/,/<\/message>/H;/<\/context>/{H;x;/<message/p}' \
+ 	$@
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_Frontends_VirtualBox_src_VBoxGLSupportInfo.cpp b/virtualbox-svn/patches/patch-src_VBox_Frontends_VirtualBox_src_VBoxGLSupportInfo.cpp
new file mode 100644
index 0000000..39b11da
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Frontends_VirtualBox_src_VBoxGLSupportInfo.cpp
@@ -0,0 +1,18 @@
+$NetBSD$
+
+--- src/VBox/Frontends/VirtualBox/src/VBoxGLSupportInfo.cpp.orig	2016-03-04 19:29:07.000000000 +0000
++++ src/VBox/Frontends/VirtualBox/src/VBoxGLSupportInfo.cpp
+@@ -605,7 +605,7 @@ bool VBoxVHWAInfo::isVHWASupported() con
+ /* static */
+ bool VBoxVHWAInfo::checkVHWASupport()
+ {
+-#if defined(RT_OS_WINDOWS) || defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD)
++#if defined(RT_OS_WINDOWS) || defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+     static char pszVBoxPath[RTPATH_MAX];
+     const char *papszArgs[] = { NULL, "-test", "2D", NULL};
+     int rc;
+@@ -702,4 +702,3 @@ const class QGLContext * VBoxGLTmpContex
+     }
+     return NULL;
+ }
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_Frontends_VirtualBox_src_net_UIUpdateManager.cpp b/virtualbox-svn/patches/patch-src_VBox_Frontends_VirtualBox_src_net_UIUpdateManager.cpp
new file mode 100644
index 0000000..588b104
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Frontends_VirtualBox_src_net_UIUpdateManager.cpp
@@ -0,0 +1,18 @@
+$NetBSD$
+
+--- src/VBox/Frontends/VirtualBox/src/net/UIUpdateManager.cpp.orig	2016-03-04 19:29:10.000000000 +0000
++++ src/VBox/Frontends/VirtualBox/src/net/UIUpdateManager.cpp
+@@ -249,6 +249,8 @@ private:
+         strPlatform = "os2";
+ #elif defined (Q_OS_FREEBSD)
+         strPlatform = "freebsd";
++#elif defined (Q_OS_NETBSD)
++        strPlatform = "netbsd";
+ #elif defined (Q_OS_SOLARIS)
+         strPlatform = "solaris";
+ #else
+@@ -514,4 +516,3 @@ void UIUpdateManager::sltHandleUpdateFin
+ }
+ 
+ #include "UIUpdateManager.moc"
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_Frontends_VirtualBox_src_settings_machine_UIMachineSettingsAudio.cpp b/virtualbox-svn/patches/patch-src_VBox_Frontends_VirtualBox_src_settings_machine_UIMachineSettingsAudio.cpp
new file mode 100644
index 0000000..7359a29
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Frontends_VirtualBox_src_settings_machine_UIMachineSettingsAudio.cpp
@@ -0,0 +1,9 @@
+$NetBSD$
+
+--- src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsAudio.cpp.orig	2016-07-10 20:54:24.000000000 +0000
++++ src/VBox/Frontends/VirtualBox/src/settings/machine/UIMachineSettingsAudio.cpp
+@@ -232,4 +232,3 @@ void UIMachineSettingsAudio::prepareComb
+     m_pComboAudioController->insertItem(++iIndex, "", KAudioControllerType_AC97);
+     m_pComboAudioController->insertItem(++iIndex, "", KAudioControllerType_SB16);
+ }
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_GuestHost_OpenGL_Makefile.kmk b/virtualbox-svn/patches/patch-src_VBox_GuestHost_OpenGL_Makefile.kmk
new file mode 100644
index 0000000..510089e
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_GuestHost_OpenGL_Makefile.kmk
@@ -0,0 +1,54 @@
+$NetBSD$
+
+--- src/VBox/GuestHost/OpenGL/Makefile.kmk.orig	2016-03-04 19:29:19.000000000 +0000
++++ src/VBox/GuestHost/OpenGL/Makefile.kmk
+@@ -52,7 +52,7 @@ if defined(VBOX_SIGNING_MODE) && defined
+ endif
+ VBoxOGLcrutil_SDKS.win      = ReorderCompilerIncs $(VBOX_WINPSDK) $(VBOX_WINDDK)
+ VBoxOGLcrutil_INTERMEDIATES = $(VBOX_PATH_CROGL_GENFILES)/cr_opcodes.h
+-if1of ($(KBUILD_TARGET), linux solaris freebsd)
++if1of ($(KBUILD_TARGET), linux solaris freebsd netbsd)
+  VBoxOGLcrutil_INCS += \
+ 	$(VBOX_MESA_INCS)
+ endif
+@@ -197,7 +197,7 @@ endif
+ VBoxOGLcrpacker_TEMPLATE = VBOXCROGLR3GUESTLIB
+ VBoxOGLcrpacker_INCS = \
+ 	packer
+-if1of ($(KBUILD_TARGET), linux solaris freebsd)
++if1of ($(KBUILD_TARGET), linux solaris freebsd netbsd)
+  VBoxOGLcrpacker_INCS += \
+ 	$(VBOX_MESA_INCS)
+ endif
+@@ -348,7 +348,7 @@ $(VBOX_PATH_CROGL_GENFILES)/%_swap.c: $(
+ VBoxOGLspuload_TEMPLATE = VBOXCROGLR3GUESTLIB
+ VBoxOGLspuload_INTERMEDIATES = \
+ 	$(VBOX_PATH_CROGL_GENFILES)/spu_dispatch_table.h
+-if1of ($(KBUILD_TARGET), linux solaris freebsd)
++if1of ($(KBUILD_TARGET), linux solaris freebsd netbsd)
+  VBoxOGLspuload_INCS += \
+ 	$(VBOX_MESA_INCS)
+ endif
+@@ -421,7 +421,7 @@ $(VBOX_PATH_CROGL_GENFILES)/spu_dispatch
+ VBoxOGLcrstate_TEMPLATE = VBOXCROGLR3GUESTLIB
+ VBoxOGLcrstate_INCS = \
+ 	state_tracker
+-if1of ($(KBUILD_TARGET), linux solaris freebsd)
++if1of ($(KBUILD_TARGET), linux solaris freebsd netbsd)
+  VBoxOGLcrstate_INCS += \
+ 	$(VBOX_MESA_INCS)
+ endif
+@@ -619,7 +619,7 @@ if defined(VBOX_SIGNING_MODE) && defined
+ endif
+ VBoxOGLerrorspu_INTERMEDIATES = \
+ 	$(VBOX_PATH_CROGL_GENFILES)/spu_dispatch_table.h
+-if1of ($(KBUILD_TARGET), linux solaris freebsd)
++if1of ($(KBUILD_TARGET), linux solaris freebsd netbsd)
+  VBoxOGLerrorspu_INCS += \
+ 	$(VBOX_MESA_INCS)
+ endif
+@@ -676,4 +676,3 @@ $(VBOX_PATH_CROGL_GENFILES)/errorspu.c: 
+ 	$(call MSG_GENERATE,python,$@,$<)
+ 	$(QUIET)$(call VBOX_CROGL_PYTHON_ENV,$(VBOX_PATH_CROGL_PYTHON_INCLUDE),$@) $(VBOX_BLD_PYTHON) $< $(VBOX_PATH_CROGL_GLAPI)
+ include $(FILE_KBUILD_SUB_FOOTER)
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_GuestHost_OpenGL_include_chromium.h b/virtualbox-svn/patches/patch-src_VBox_GuestHost_OpenGL_include_chromium.h
new file mode 100644
index 0000000..b158a9a
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_GuestHost_OpenGL_include_chromium.h
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- src/VBox/GuestHost/OpenGL/include/chromium.h.orig	2016-03-04 19:29:19.000000000 +0000
++++ src/VBox/GuestHost/OpenGL/include/chromium.h
+@@ -67,7 +67,7 @@
+ 
+ #ifdef DARWIN
+ # include <stddef.h>
+-#elif !defined(FreeBSD)
++#elif !defined(FreeBSD) && !defined(__NetBSD__)
+ #  include <malloc.h>  /* to get ptrdiff_t used below */
+ #endif
+ 
diff --git a/virtualbox-svn/patches/patch-src_VBox_GuestHost_OpenGL_include_cr__dll.h b/virtualbox-svn/patches/patch-src_VBox_GuestHost_OpenGL_include_cr__dll.h
new file mode 100644
index 0000000..e6baf6b
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_GuestHost_OpenGL_include_cr__dll.h
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- src/VBox/GuestHost/OpenGL/include/cr_dll.h.orig	2016-03-04 19:29:19.000000000 +0000
++++ src/VBox/GuestHost/OpenGL/include/cr_dll.h
+@@ -22,7 +22,7 @@ typedef struct {
+ 	char *name;
+ #if defined(WINDOWS)
+ 	HINSTANCE hinstLib;
+-#elif defined(IRIX) || defined(IRIX64) || defined(Linux) || defined(FreeBSD) || defined(AIX) || defined(SunOS) || defined(OSF1)
++#elif defined(IRIX) || defined(IRIX64) || defined(Linux) || defined(FreeBSD) || defined(AIX) || defined(SunOS) || defined(OSF1) || defined(__NetBSD__)
+ 	void *hinstLib;
+ #elif defined(DARWIN)
+ 	void *hinstLib;		/* void to avoid including the headers */
diff --git a/virtualbox-svn/patches/patch-src_VBox_GuestHost_OpenGL_include_cr__timer.h b/virtualbox-svn/patches/patch-src_VBox_GuestHost_OpenGL_include_cr__timer.h
new file mode 100644
index 0000000..413500f
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_GuestHost_OpenGL_include_cr__timer.h
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- src/VBox/GuestHost/OpenGL/include/cr_timer.h.orig	2016-03-04 19:29:19.000000000 +0000
++++ src/VBox/GuestHost/OpenGL/include/cr_timer.h
+@@ -35,7 +35,7 @@ typedef struct Timer 
+ #elif defined(WINDOWS)
+ 	LARGE_INTEGER performance_counter, performance_frequency;
+ 	double one_over_frequency;
+-#elif defined( Linux ) || defined( FreeBSD ) || defined(DARWIN) || defined(AIX) || defined (SunOS) || defined(OSF1)
++#elif defined( Linux ) || defined( FreeBSD ) || defined(DARWIN) || defined(AIX) || defined (SunOS) || defined(OSF1) || defined(__NetBSD__)
+ 	struct timeval timeofday;
+ #endif
+ } CRTimer;
diff --git a/virtualbox-svn/patches/patch-src_VBox_GuestHost_OpenGL_spu__loader_glloader.py b/virtualbox-svn/patches/patch-src_VBox_GuestHost_OpenGL_spu__loader_glloader.py
new file mode 100644
index 0000000..f512609
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_GuestHost_OpenGL_spu__loader_glloader.py
@@ -0,0 +1,32 @@
+$NetBSD$
+
+--- src/VBox/GuestHost/OpenGL/spu_loader/glloader.py.orig	2016-03-04 19:29:21.000000000 +0000
++++ src/VBox/GuestHost/OpenGL/spu_loader/glloader.py
+@@ -34,10 +34,12 @@ print """
+ #  define SYSTEM_AGL "AGL"
+ # endif
+ #include <string.h> /* VBOX */
+-#elif defined(IRIX) || defined(IRIX64) || defined(Linux) || defined(FreeBSD) || defined(AIX) || defined(SunOS) || defined(OSF1)
++#elif defined(IRIX) || defined(IRIX64) || defined(Linux) || defined(FreeBSDOB) || defined(AIX) || defined(SunOS) || defined(OSF1) || defined(__NetBSD__)
+ #include <string.h>
+ #if defined(AIX)
+ #define SYSTEM_GL "libGL.o"
++#elif defined(__NetBSD__)
++#define SYSTEM_GL "libGL.so.2"
+ #else
+ #define SYSTEM_GL "libGL.so.1"
+ #endif
+@@ -150,7 +152,7 @@ __findSystemLib( const char *provided_sy
+ 		}*/
+ #endif
+ 	}
+-#if !defined(__linux__) && !defined(SunOS) && !defined(__FreeBSD__)
++#if !defined(__linux__) && !defined(SunOS) && !defined(__FreeBSD__) && !defined(__NetBSD__)
+ 	crStrcat( system_path, "/" );
+ #endif
+ #if !defined(CR_NO_GL_SYSTEM_PATH)
+@@ -601,4 +603,3 @@ int crLoadOSMesa( OSMesaContext (**creat
+ #endif
+ 
+ """
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_GuestHost_OpenGL_util_dll.c b/virtualbox-svn/patches/patch-src_VBox_GuestHost_OpenGL_util_dll.c
new file mode 100644
index 0000000..557f3b3
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_GuestHost_OpenGL_util_dll.c
@@ -0,0 +1,40 @@
+$NetBSD$
+
+--- src/VBox/GuestHost/OpenGL/util/dll.c.orig	2016-03-04 19:29:23.000000000 +0000
++++ src/VBox/GuestHost/OpenGL/util/dll.c
+@@ -14,7 +14,7 @@
+ #include <string.h>
+ #endif
+ 
+-#if defined(IRIX) || defined(IRIX64) || defined(Linux) || defined(FreeBSD) || defined(AIX) || defined(DARWIN) || defined(SunOS) || defined(OSF1)
++#if defined(IRIX) || defined(IRIX64) || defined(Linux) || defined(FreeBSD) || defined(AIX) || defined(DARWIN) || defined(SunOS) || defined(OSF1) || defined(__NetBSD__)
+ #include <dlfcn.h>
+ #endif
+ 
+@@ -269,7 +269,7 @@ CRDLL *crDLLOpen( const char *dllname, i
+ 		dll_err = "Unknown DLL type";
+ 		break;
+ 	};
+-#elif defined(IRIX) || defined(IRIX64) || defined(Linux) || defined(FreeBSD) || defined(AIX) || defined(SunOS) || defined(OSF1)
++#elif defined(IRIX) || defined(IRIX64) || defined(Linux) || defined(FreeBSD) || defined(AIX) || defined(SunOS) || defined(OSF1) || defined(__NetBSD__)
+ 	if (resolveGlobal)
+ 		dll->hinstLib = dlopen( dllname, RTLD_LAZY | RTLD_GLOBAL );
+ 	else
+@@ -322,7 +322,7 @@ CRDLLFunc crDLLGetNoError( CRDLL *dll, c
+ 
+ 	return (CRDLLFunc) NSAddressOfSymbol( nssym );
+ 
+-#elif defined(IRIX) || defined(IRIX64) || defined(Linux) || defined(FreeBSD) || defined(AIX) || defined(SunOS) || defined(OSF1)
++#elif defined(IRIX) || defined(IRIX64) || defined(Linux) || defined(FreeBSD) || defined(AIX) || defined(SunOS) || defined(OSF1) || defined(__NetBSD__)
+ 	return (CRDLLFunc) dlsym( dll->hinstLib, symname );
+ #else
+ #error CR DLL ARCHITETECTURE
+@@ -366,7 +366,7 @@ void crDLLClose( CRDLL *dll )
+ 		NSUnLinkModule( (NSModule) dll->hinstLib, 0L );
+ 		break;
+ 	}
+-#elif defined(IRIX) || defined(IRIX64) || defined(Linux) || defined(FreeBSD) || defined(AIX) || defined(SunOS) || defined(OSF1)
++#elif defined(IRIX) || defined(IRIX64) || defined(Linux) || defined(FreeBSD) || defined(AIX) || defined(SunOS) || defined(OSF1) || defined(__NetBSD__)
+ 	/*
+ 	 * Unloading Nvidia's libGL will crash VirtualBox later during shutdown.
+ 	 * Therefore we will skip unloading it. It will be unloaded later anway
diff --git a/virtualbox-svn/patches/patch-src_VBox_GuestHost_OpenGL_util_environment.c b/virtualbox-svn/patches/patch-src_VBox_GuestHost_OpenGL_util_environment.c
new file mode 100644
index 0000000..c5e19da
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_GuestHost_OpenGL_util_environment.c
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- src/VBox/GuestHost/OpenGL/util/environment.c.orig	2016-03-04 19:29:23.000000000 +0000
++++ src/VBox/GuestHost/OpenGL/util/environment.c
+@@ -12,7 +12,7 @@
+ 
+ void crSetenv( const char *var, const char *value )
+ {
+-#if defined(LINUX) || defined(FREEBSD) || defined(DARWIN)
++#if defined(LINUX) || defined(FREEBSD) || defined(DARWIN) || defined(__NetBSD__)
+ 	setenv( var, value, 1 /* replace */ );
+ #else
+ 	unsigned long len;
diff --git a/virtualbox-svn/patches/patch-src_VBox_GuestHost_OpenGL_util_timer.c b/virtualbox-svn/patches/patch-src_VBox_GuestHost_OpenGL_util_timer.c
new file mode 100644
index 0000000..329c602
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_GuestHost_OpenGL_util_timer.c
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- src/VBox/GuestHost/OpenGL/util/timer.c.orig	2016-03-04 19:29:23.000000000 +0000
++++ src/VBox/GuestHost/OpenGL/util/timer.c
+@@ -35,7 +35,7 @@ static double crTimerGetTime( CRTimer *t
+ #elif defined( WINDOWS )
+ 	QueryPerformanceCounter( &t->performance_counter );
+ 	return ((double) t->performance_counter.QuadPart)*t->one_over_frequency;
+-#elif defined( Linux ) || defined( FreeBSD ) || defined(DARWIN) || defined(AIX) || defined(SunOS) || defined(OSF1)
++#elif defined( Linux ) || defined( FreeBSD ) || defined(DARWIN) || defined(AIX) || defined(SunOS) || defined(OSF1) || defined(__NetBSD__)
+ 	gettimeofday( &t->timeofday, NULL );	
+ 	return t->timeofday.tv_sec + t->timeofday.tv_usec / 1000000.0;
+ #else
diff --git a/virtualbox-svn/patches/patch-src_VBox_GuestHost_OpenGL_util_vboxhgcm.c b/virtualbox-svn/patches/patch-src_VBox_GuestHost_OpenGL_util_vboxhgcm.c
new file mode 100644
index 0000000..62472c0
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_GuestHost_OpenGL_util_vboxhgcm.c
@@ -0,0 +1,31 @@
+$NetBSD$
+
+--- src/VBox/GuestHost/OpenGL/util/vboxhgcm.c.orig	2016-03-04 19:29:23.000000000 +0000
++++ src/VBox/GuestHost/OpenGL/util/vboxhgcm.c
+@@ -623,7 +623,7 @@ static int crVBoxHGCMCall(CRConnection *
+     }
+ # else
+     int rc;
+-#  if defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD)
++#  if defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+     VBGLBIGREQ Hdr;
+     Hdr.u32Magic = VBGLBIGREQ_MAGIC;
+     Hdr.cbData = cbData;
+@@ -1405,7 +1405,7 @@ static int crVBoxHGCMDoConnect( CRConnec
+                         &info, sizeof (info),
+                         &cbReturned,
+                         NULL))
+-#elif defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD)
++#elif defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+     VBGLBIGREQ Hdr;
+     Hdr.u32Magic = VBGLBIGREQ_MAGIC;
+     Hdr.cbData = sizeof(info);
+@@ -1567,7 +1567,7 @@ static void crVBoxHGCMDoDisconnect( CRCo
+         {
+             crDebug("Disconnect failed with %x\n", GetLastError());
+         }
+-# elif defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD)
++# elif defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+         VBGLBIGREQ Hdr;
+         Hdr.u32Magic = VBGLBIGREQ_MAGIC;
+         Hdr.cbData = sizeof(info);
diff --git a/virtualbox-svn/patches/patch-src_VBox_GuestHost_OpenGL_util_vboxhgsmi.c b/virtualbox-svn/patches/patch-src_VBox_GuestHost_OpenGL_util_vboxhgsmi.c
new file mode 100644
index 0000000..2416f28
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_GuestHost_OpenGL_util_vboxhgsmi.c
@@ -0,0 +1,31 @@
+$NetBSD$
+
+--- src/VBox/GuestHost/OpenGL/util/vboxhgsmi.c.orig	2016-03-04 19:29:23.000000000 +0000
++++ src/VBox/GuestHost/OpenGL/util/vboxhgsmi.c
+@@ -255,7 +255,7 @@ static int crVBoxHGCMCall(void *pvData, 
+     return VERR_NOT_SUPPORTED;
+ # else
+     int rc;
+-#  if defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD)
++#  if defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+     VBGLBIGREQ Hdr;
+     Hdr.u32Magic = VBGLBIGREQ_MAGIC;
+     Hdr.cbData = cbData;
+@@ -1258,7 +1258,7 @@ static int crVBoxHGSMIDoConnect( CRConne
+                         &info, sizeof (info),
+                         &cbReturned,
+                         NULL))
+-#elif defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD)
++#elif defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+     VBGLBIGREQ Hdr;
+     Hdr.u32Magic = VBGLBIGREQ_MAGIC;
+     Hdr.cbData = sizeof(info);
+@@ -1370,7 +1370,7 @@ static void crVBoxHGSMIDoDisconnect( CRC
+         {
+             crDebug("Disconnect failed with %x\n", GetLastError());
+         }
+-# elif defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD)
++# elif defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+         VBGLBIGREQ Hdr;
+         Hdr.u32Magic = VBGLBIGREQ_MAGIC;
+         Hdr.cbData = sizeof(info);
diff --git a/virtualbox-svn/patches/patch-src_VBox_GuestHost_SharedClipboard_Makefile.kmk b/virtualbox-svn/patches/patch-src_VBox_GuestHost_SharedClipboard_Makefile.kmk
new file mode 100644
index 0000000..bac735e
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_GuestHost_SharedClipboard_Makefile.kmk
@@ -0,0 +1,9 @@
+$NetBSD$
+
+--- src/VBox/GuestHost/SharedClipboard/Makefile.kmk.orig	2016-03-04 19:29:23.000000000 +0000
++++ src/VBox/GuestHost/SharedClipboard/Makefile.kmk
+@@ -53,4 +53,3 @@ $$(tstClipboardX11Smoke_0_OUTDIR)/tstCli
+ endif
+ 
+ include $(FILE_KBUILD_SUB_FOOTER)
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_HostDrivers_Makefile.kmk b/virtualbox-svn/patches/patch-src_VBox_HostDrivers_Makefile.kmk
new file mode 100644
index 0000000..3cea366
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_HostDrivers_Makefile.kmk
@@ -0,0 +1,31 @@
+$NetBSD$
+
+--- src/VBox/HostDrivers/Makefile.kmk.orig	2016-03-04 19:29:23.000000000 +0000
++++ src/VBox/HostDrivers/Makefile.kmk
+@@ -30,18 +30,18 @@ if  !defined(VBOX_ONLY_DOCS) \
+  ifdef VBOX_WITH_USB
+   include $(PATH_SUB_CURRENT)/VBoxUSB/Makefile.kmk
+  endif
+- if1of ($(KBUILD_TARGET), darwin solaris win linux freebsd)
++ if1of ($(KBUILD_TARGET), darwin solaris win linux freebsd netbsd)
+   ifdef VBOX_WITH_NETFLT
+    include $(PATH_SUB_CURRENT)/VBoxNetFlt/Makefile.kmk
+   endif
+  endif
+- if1of ($(KBUILD_TARGET), darwin solaris win linux freebsd)
++ if1of ($(KBUILD_TARGET), darwin solaris win linux freebsd netbsd)
+   ifdef VBOX_WITH_NETADP
+    include $(PATH_SUB_CURRENT)/VBoxNetAdp/Makefile.kmk
+   else
+   endif
+  endif
+- if1of ($(KBUILD_TARGET), darwin freebsd linux)
++ if1of ($(KBUILD_TARGET), darwin freebsd linux netbsd)
+   include $(PATH_SUB_CURRENT)/$(KBUILD_TARGET)/Makefile.kmk
+  endif
+ 
+@@ -55,4 +55,3 @@ endif # !defined(VBOX_ONLY_DOCS) && !def
+ 
+ # Let kBuild generate the rules.
+ include $(FILE_KBUILD_SUB_FOOTER)
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_HostDrivers_Support_Makefile.kmk b/virtualbox-svn/patches/patch-src_VBox_HostDrivers_Support_Makefile.kmk
new file mode 100644
index 0000000..565c640
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_HostDrivers_Support_Makefile.kmk
@@ -0,0 +1,69 @@
+$NetBSD$
+
+--- src/VBox/HostDrivers/Support/Makefile.kmk.orig	2016-03-04 19:29:24.000000000 +0000
++++ src/VBox/HostDrivers/Support/Makefile.kmk
+@@ -58,6 +58,7 @@ if  !defined(VBOX_ONLY_DOCS) \
+  endif
+  INSTALLS.linux   += vboxdrv-mod
+  INSTALLS.freebsd += vboxdrv-mod
++ INSTALLS.netbsd += vboxdrv-mod
+ 
+  #
+  # Include sub-makefile(s).
+@@ -73,6 +74,9 @@ if  !defined(VBOX_ONLY_DOCS) \
+  ifeq ($(KBUILD_TARGET),freebsd)
+   include $(PATH_SUB_CURRENT)/freebsd/files_vboxdrv
+  endif
++ ifeq ($(KBUILD_TARGET),netbsd)
++  include $(PATH_SUB_CURRENT)/netbsd/files_vboxdrv
++ endif
+ endif # !VBOX_ONLY_DOCS && !VBOX_ONLY_EXTPACKS && !VBOX_ONLY_VALIDATIONKIT
+ 
+ #
+@@ -533,12 +537,13 @@ endif # os2
+ #
+ # New VBoxDrv target. TODO: Convert all the above to use this!
+ #
+-if1of ($(KBUILD_TARGET), darwin freebsd linux solaris win)
++if1of ($(KBUILD_TARGET), darwin freebsd netbsd linux solaris win)
+  ifdef VBOX_WITH_VBOXDRV
+   SYSMODS += VBoxDrv
+  endif
+  VBoxDrv_TEMPLATE         = VBOXR0DRV
+  VBoxDrv_NAME.freebsd     = vboxdrv
++ VBoxDrv_NAME.netbsd      = vboxdrv
+  VBoxDrv_NAME.linux       = vboxdrv
+  VBoxDrv_NAME.solaris     = vboxdrv
+  ifdef VBOX_SIGNING_MODE
+@@ -637,7 +642,7 @@ if1of ($(KBUILD_TARGET), darwin freebsd 
+   	SUPDrv-dtrace.cpp
+   SUPDrv-dtrace.cpp_DEFS.darwin += VBOX_PATH_MACOSX_DTRACE_H=\"$(VBOX_PATH_MACOSX_SDK)/usr/include/sys/dtrace.h\"
+  endif
+- ifn1of ($(KBUILD_TARGET), linux freebsd)
++ ifn1of ($(KBUILD_TARGET), linux freebsd netbsd)
+   VBoxDrv_SOURCES        += \
+  	SUPDrvTracerA.asm
+  endif
+@@ -687,7 +692,7 @@ if1of ($(KBUILD_TARGET), darwin solaris)
+ endif
+ 
+ 
+-if1of ($(KBUILD_TARGET), linux freebsd)
++if1of ($(KBUILD_TARGET), linux freebsd netbsd)
+  #
+  # Targets for installing the linux sources.
+  #
+@@ -717,7 +722,7 @@ if1of ($(KBUILD_TARGET), linux freebsd)
+ 		--output $@ $<
+ 	%$(QUIET2)$(APPEND) -t '$(PATH_TARGET)/vboxdrv-mod-1.dep' \
+ 		'Support/$(KBUILD_TARGET)/Makefile_VBOX_HARDENED=$(VBOX_WITH_HARDENING)'
+-endif # linux freebsd
++endif # linux freebsd netbsd
+ 
+ 
+ ifeq ($(KBUILD_TARGET), win)
+@@ -752,4 +757,3 @@ endif # win
+ 
+ endif # !VBOX_ONLY_DOCS && !VBOX_ONLY_EXTPACKS && !VBOX_ONLY_VALIDATIONKIT
+ include $(FILE_KBUILD_SUB_FOOTER)
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_HostDrivers_Support_SUPDrv.cpp b/virtualbox-svn/patches/patch-src_VBox_HostDrivers_Support_SUPDrv.cpp
new file mode 100644
index 0000000..2392ae7
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_HostDrivers_Support_SUPDrv.cpp
@@ -0,0 +1,27 @@
+$NetBSD$
+
+--- src/VBox/HostDrivers/Support/SUPDrv.cpp.orig	2016-07-10 21:00:02.000000000 +0000
++++ src/VBox/HostDrivers/Support/SUPDrv.cpp
+@@ -54,7 +54,7 @@
+ #include <iprt/crc.h>
+ #include <iprt/string.h>
+ #include <iprt/timer.h>
+-#if defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD)
++#if defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+ # include <iprt/rand.h>
+ # include <iprt/path.h>
+ #endif
+@@ -456,7 +456,7 @@ static SUPFUNC g_aFunctions[] =
+ /* SED: END */
+ };
+ 
+-#if defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD)
++#if defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+ /**
+  * Drag in the rest of IRPT since we share it with the
+  * rest of the kernel modules on darwin.
+@@ -5724,4 +5724,3 @@ static int supdrvIOCtl_ResumeSuspendedKb
+     return VERR_NOT_IMPLEMENTED;
+ #endif
+ }
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_HostDrivers_Support_SUPDrvGip.cpp b/virtualbox-svn/patches/patch-src_VBox_HostDrivers_Support_SUPDrvGip.cpp
new file mode 100644
index 0000000..d928235
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_HostDrivers_Support_SUPDrvGip.cpp
@@ -0,0 +1,18 @@
+$NetBSD$
+
+--- src/VBox/HostDrivers/Support/SUPDrvGip.cpp.orig	2016-03-04 19:29:24.000000000 +0000
++++ src/VBox/HostDrivers/Support/SUPDrvGip.cpp
+@@ -51,7 +51,7 @@
+ #include <iprt/crc.h>
+ #include <iprt/string.h>
+ #include <iprt/timer.h>
+-#if defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD)
++#if defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+ # include <iprt/rand.h>
+ # include <iprt/path.h>
+ #endif
+@@ -4894,4 +4894,3 @@ int VBOXCALL supdrvIOCtl_GipSetFlags(PSU
+ #endif
+     return rc;
+ }
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_HostDrivers_Support_SUPDrvIDC.h b/virtualbox-svn/patches/patch-src_VBox_HostDrivers_Support_SUPDrvIDC.h
new file mode 100644
index 0000000..0360e0a
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_HostDrivers_Support_SUPDrvIDC.h
@@ -0,0 +1,19 @@
+$NetBSD$
+
+--- src/VBox/HostDrivers/Support/SUPDrvIDC.h.orig	2016-03-04 19:29:24.000000000 +0000
++++ src/VBox/HostDrivers/Support/SUPDrvIDC.h
+@@ -233,6 +233,9 @@ extern DECLIMPORT(int) VBOXCALL SUPDrvDa
+ #elif defined(RT_OS_FREEBSD)
+ extern int VBOXCALL SUPDrvFreeBSDIDC(uint32_t iReq, PSUPDRVIDCREQHDR pReq);
+ 
++#elif defined(RT_OS_NETBSD)
++extern int VBOXCALL SUPDrvNetBSDIDC(uint32_t iReq, PSUPDRVIDCREQHDR pReq);
++
+ #elif defined(RT_OS_LINUX)
+ extern int VBOXCALL SUPDrvLinuxIDC(uint32_t iReq, PSUPDRVIDCREQHDR pReq);
+ 
+@@ -272,4 +275,3 @@ typedef DECLCALLBACK(int) FNSUPDRVIDCENT
+ #pragma pack()                          /* paranoia */
+ 
+ #endif
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_HostDrivers_Support_SUPDrvInternal.h b/virtualbox-svn/patches/patch-src_VBox_HostDrivers_Support_SUPDrvInternal.h
new file mode 100644
index 0000000..0681c2a
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_HostDrivers_Support_SUPDrvInternal.h
@@ -0,0 +1,18 @@
+$NetBSD$
+
+--- src/VBox/HostDrivers/Support/SUPDrvInternal.h.orig	2016-03-04 19:29:24.000000000 +0000
++++ src/VBox/HostDrivers/Support/SUPDrvInternal.h
+@@ -115,7 +115,7 @@
+ 
+ #elif defined(RT_OS_OS2)
+ 
+-#elif defined(RT_OS_FREEBSD)
++#elif defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+ #   define memset  libkern_memset /** @todo these are just hacks to get it compiling, check out later. */
+ #   define memcmp  libkern_memcmp
+ #   define strchr  libkern_strchr
+@@ -995,4 +995,3 @@ const SUPDRVTRACERREG * VBOXCALL supdrvD
+ RT_C_DECLS_END
+ 
+ #endif
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_HostDrivers_Support_SUPDrvTracer.cpp b/virtualbox-svn/patches/patch-src_VBox_HostDrivers_Support_SUPDrvTracer.cpp
new file mode 100644
index 0000000..e62fa87
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_HostDrivers_Support_SUPDrvTracer.cpp
@@ -0,0 +1,18 @@
+$NetBSD$
+
+--- src/VBox/HostDrivers/Support/SUPDrvTracer.cpp.orig	2016-03-04 19:29:24.000000000 +0000
++++ src/VBox/HostDrivers/Support/SUPDrvTracer.cpp
+@@ -1466,7 +1466,7 @@ SUPR0DECL(int) SUPR0TracerDeregisterImpl
+  * rebuilding of the kernel module from scratch at install time, we have to
+  * deploy some ugly gcc inline assembly here.
+  */
+-#if defined(__GNUC__) && (defined(RT_OS_FREEBSD) || defined(RT_OS_LINUX))
++#if defined(__GNUC__) && (defined(RT_OS_FREEBSD) || defined(RT_OS_LINUX) || defined(RT_OS_NETBSD))
+ __asm__("\
+         .section .text                                                  \n\
+                                                                         \n\
+@@ -2468,4 +2468,3 @@ void VBOXCALL supdrvTracerTerm(PSUPDRVDE
+     pDevExt->mtxTracer = NIL_RTSEMFASTMUTEX;
+     LOG_TRACER(("supdrvTracerTerm: Done\n"));
+ }
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_HostDrivers_Support_SUPR3HardenedMain.cpp b/virtualbox-svn/patches/patch-src_VBox_HostDrivers_Support_SUPR3HardenedMain.cpp
new file mode 100644
index 0000000..6b06af2
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_HostDrivers_Support_SUPR3HardenedMain.cpp
@@ -0,0 +1,65 @@
+$NetBSD$
+
+--- src/VBox/HostDrivers/Support/SUPR3HardenedMain.cpp.orig	2016-03-04 19:29:24.000000000 +0000
++++ src/VBox/HostDrivers/Support/SUPR3HardenedMain.cpp
+@@ -63,7 +63,7 @@
+ #  ifndef CAP_TO_MASK
+ #   define CAP_TO_MASK(cap) RT_BIT(cap)
+ #  endif
+-# elif defined(RT_OS_FREEBSD)
++# elif defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+ #  include <sys/param.h>
+ #  include <sys/sysctl.h>
+ # elif defined(RT_OS_SOLARIS)
+@@ -859,7 +859,7 @@ static void supR3HardenedGetFullExePath(
+      *
+      * Darwin, OS/2 and Windows all have proper APIs for getting the program file name.
+      */
+-#if defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD) || defined(RT_OS_SOLARIS)
++#if defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD) || defined(RT_OS_SOLARIS) || defined(RT_OS_NETBSD)
+ # ifdef RT_OS_LINUX
+     int cchLink = readlink("/proc/self/exe", &g_szSupLibHardenedExePath[0], sizeof(g_szSupLibHardenedExePath) - 1);
+ 
+@@ -868,7 +868,7 @@ static void supR3HardenedGetFullExePath(
+     sprintf(szFileBuf, "/proc/%ld/path/a.out", (long)getpid());
+     int cchLink = readlink(szFileBuf, &g_szSupLibHardenedExePath[0], sizeof(g_szSupLibHardenedExePath) - 1);
+ 
+-# else /* RT_OS_FREEBSD */
++# elif defined(RT_OS_FREEBSD)
+     int aiName[4];
+     aiName[0] = CTL_KERN;
+     aiName[1] = KERN_PROC;
+@@ -881,6 +881,19 @@ static void supR3HardenedGetFullExePath(
+     g_szSupLibHardenedExePath[sizeof(g_szSupLibHardenedExePath) - 1] = '\0';
+     int cchLink = suplibHardenedStrLen(g_szSupLibHardenedExePath); /* paranoid? can't we use cbPath? */
+ 
++# else /* RT_OS_NETBSD */
++    int aiName[4];
++    aiName[0] = CTL_KERN;
++    aiName[1] = KERN_PROC_ARGS;
++    aiName[2] = getpid();
++    aiName[3] = KERN_PROC_PATHNAME;
++
++    size_t cbPath = sizeof(g_szSupLibHardenedExePath);
++    if (sysctl(aiName, RT_ELEMENTS(aiName), g_szSupLibHardenedExePath, &cbPath, NULL, 0) < 0)
++        supR3HardenedFatal("supR3HardenedExecDir: sysctl failed\n");
++    g_szSupLibHardenedExePath[sizeof(g_szSupLibHardenedExePath) - 1] = '\0';
++    int cchLink = suplibHardenedStrLen(g_szSupLibHardenedExePath); /* paranoid? can't we use cbPath? */
++
+ # endif
+     if (cchLink < 0 || cchLink == sizeof(g_szSupLibHardenedExePath) - 1)
+         supR3HardenedFatal("supR3HardenedExecDir: couldn't read \"%s\", errno=%d cchLink=%d\n",
+@@ -1558,7 +1571,7 @@ static void supR3HardenedMainDropPrivile
+     egid = getegid();
+     rgid = sgid = getgid();
+ 
+-# elif defined(RT_OS_SOLARIS)
++# elif defined(RT_OS_SOLARIS) || defined(RT_OS_NETBSD)
+     /* Solaris doesn't have setresuid, but the setreuid interface is BSD
+        compatible and will set the saved uid to euid when we pass it a ruid
+        that isn't -1 (which we do). */
+@@ -2025,4 +2038,3 @@ DECLHIDDEN(int) SUPR3HardenedMain(const 
+     g_enmSupR3HardenedMainState = SUPR3HARDENEDMAINSTATE_CALLED_TRUSTED_MAIN;
+     return pfnTrustedMain(argc, argv, envp);
+ }
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_HostDrivers_Support_netbsd_Makefile b/virtualbox-svn/patches/patch-src_VBox_HostDrivers_Support_netbsd_Makefile
new file mode 100644
index 0000000..a07a528
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_HostDrivers_Support_netbsd_Makefile
@@ -0,0 +1,189 @@
+$NetBSD$
+
+--- src/VBox/HostDrivers/Support/netbsd/Makefile.orig	2016-07-07 07:08:46.477818725 +0000
++++ src/VBox/HostDrivers/Support/netbsd/Makefile
+@@ -0,0 +1,184 @@
++#  Makefile $
++## @file
++# Makefile for the VirtualBox NetBSD Host Driver.
++#
++
++#
++# Copyright (C) 2006-2015 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.
++#
++
++KMOD = vboxdrv
++
++CFLAGS += -DRT_OS_NETBSD -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
++
++.if (${MACHINE_ARCH} == "i386")
++ CFLAGS += -DRT_ARCH_X86
++.elif (${MACHINE_ARCH} == "amd64")
++ CFLAGS += -DRT_ARCH_AMD64
++.endif
++
++SRCS = \
++	SUPDrv.c \
++	SUPDrvGip.c \
++	SUPDrvSem.c \
++	SUPDrvTracer.c \
++	SUPLibAll.c \
++
++# Include needed interface headers so they are created during build
++SRCS += \
++	device_if.h \
++	bus_if.h
++
++.PATH:	${.CURDIR}/netbsd
++SRCS += \
++	SUPDrv-netbsd.c
++
++.PATH:	${.CURDIR}/alloc
++SRCS += \
++	heapsimple.c \
++	alloc.c
++
++.PATH:	${.CURDIR}/common/err
++SRCS += \
++	RTErrConvertFromErrno.c \
++	RTErrConvertToErrno.c
++
++.PATH:	${.CURDIR}/common/log
++SRCS += \
++	log.c \
++	logellipsis.c \
++	logrel.c \
++	logrelellipsis.c \
++	logcom.c \
++	logformat.c
++
++.PATH:	${.CURDIR}/common/misc
++SRCS += \
++	RTAssertMsg1Weak.c \
++	RTAssertMsg2.c \
++	RTAssertMsg2Add.c \
++	RTAssertMsg2AddWeak.c \
++	RTAssertMsg2AddWeakV.c \
++	RTAssertMsg2Weak.c \
++	RTAssertMsg2WeakV.c \
++	assert.c \
++	handletable.c \
++	handletablectx.c \
++	once.c \
++	term.c \
++	thread.c
++
++.PATH:	${.CURDIR}/common/string
++SRCS += \
++	RTStrNCmp.c \
++	RTStrNLen.c \
++	RTStrCopy.c \
++	RTStrCopyEx.c \
++	RTStrCopyP.c \
++	strformat.c \
++	strformatrt.c \
++	strformattype.c \
++	strprintf.c \
++	strtonum.c \
++	memchr.c \
++	stringalloc.c
++
++.PATH:	${.CURDIR}/common/rand
++SRCS += \
++	rand.c \
++	randadv.c \
++	randparkmiller.c
++
++.PATH:	${.CURDIR}/common/path
++SRCS += \
++	RTPathStripFilename.c
++
++.PATH:	${.CURDIR}/common/checksum
++SRCS += \
++	crc32.c \
++	ipv4.c \
++	ipv6.c
++
++.PATH:	${.CURDIR}/common/table
++SRCS += \
++	avlpv.c
++
++.PATH:	${.CURDIR}/common/time
++SRCS += \
++	time.c
++
++.PATH:	${.CURDIR}/generic
++SRCS += \
++	uuid-generic.c \
++	RTAssertShouldPanic-generic.c \
++	RTLogWriteDebugger-generic.c \
++	RTLogWriteStdOut-stub-generic.c \
++	RTLogWriteStdErr-stub-generic.c \
++	RTLogWriteUser-generic.c \
++	RTMpGetArraySize-generic.c \
++	RTMpOnPair-generic.c \
++	RTRandAdvCreateSystemFaster-generic.c \
++	RTRandAdvCreateSystemTruer-generic.c \
++	RTSemEventWait-2-ex-generic.c \
++	RTSemEventWaitNoResume-2-ex-generic.c \
++	RTSemEventMultiWait-2-ex-generic.c \
++	RTSemEventMultiWaitNoResume-2-ex-generic.c \
++	RTTimerCreate-generic.c \
++	errvars-generic.c \
++	mppresent-generic.c \
++	timer-generic.c
++
++.PATH:	${.CURDIR}/r0drv
++SRCS += \
++	alloc-r0drv.c \
++	initterm-r0drv.c \
++	memobj-r0drv.c \
++	powernotification-r0drv.c
++
++.PATH:	${.CURDIR}/r0drv/netbsd
++SRCS += \
++	assert-r0drv-netbsd.c \
++	alloc-r0drv-netbsd.c \
++	initterm-r0drv-netbsd.c \
++	memobj-r0drv-netbsd.c \
++	memuserkernel-r0drv-netbsd.c \
++	mp-r0drv-netbsd.c \
++	process-r0drv-netbsd.c \
++	semevent-r0drv-netbsd.c \
++	semeventmulti-r0drv-netbsd.c \
++	semfastmutex-r0drv-netbsd.c \
++	semmutex-r0drv-netbsd.c \
++	spinlock-r0drv-netbsd.c \
++	thread-r0drv-netbsd.c \
++	thread2-r0drv-netbsd.c \
++	time-r0drv-netbsd.c
++
++.PATH:	${.CURDIR}/r0drv/generic
++SRCS += \
++	semspinmutex-r0drv-generic.c \
++	mpnotification-r0drv-generic.c \
++	threadctxhooks-r0drv-generic.c \
++	RTMpIsCpuWorkPending-r0drv-generic.c
++
++.PATH:	${.CURDIR}/VBox
++SRCS += \
++	log-vbox.c
++
++.include <bsd.kmod.mk>
diff --git a/virtualbox-svn/patches/patch-src_VBox_HostDrivers_Support_netbsd_SUPDrv-netbsd.c b/virtualbox-svn/patches/patch-src_VBox_HostDrivers_Support_netbsd_SUPDrv-netbsd.c
new file mode 100644
index 0000000..669f713
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_HostDrivers_Support_netbsd_SUPDrv-netbsd.c
@@ -0,0 +1,637 @@
+$NetBSD$
+
+--- src/VBox/HostDrivers/Support/netbsd/SUPDrv-netbsd.c.orig	2016-07-07 07:08:46.487236799 +0000
++++ src/VBox/HostDrivers/Support/netbsd/SUPDrv-netbsd.c
+@@ -0,0 +1,632 @@
++/*  SUPDrv-netbsd.c $ */
++/** @file
++ * VBoxDrv - The VirtualBox Support Driver - NetBSD specifics.
++ */
++
++/*
++ * Copyright (c) 2007 knut st. osmundsen <bird-src-spam%anduin.net@localhost>
++ *
++ * Permission is hereby granted, free of charge, to any person
++ * obtaining a copy of this software and associated documentation
++ * files (the "Software"), to deal in the Software without
++ * restriction, including without limitation the rights to use,
++ * copy, modify, merge, publish, distribute, sublicense, and/or sell
++ * copies of the Software, and to permit persons to whom the
++ * Software is furnished to do so, subject to the following
++ * conditions:
++ *
++ * The above copyright notice and this permission notice shall be
++ * included in all copies or substantial portions of the Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
++ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
++ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
++ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
++ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
++ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
++ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
++ * OTHER DEALINGS IN THE SOFTWARE.
++ */
++
++
++/*********************************************************************************************************************************
++*   Header Files                                                                                                                 *
++*********************************************************************************************************************************/
++#define LOG_GROUP LOG_GROUP_SUP_DRV
++/* Deal with conflicts first. */
++#include <sys/param.h>
++#undef PVM
++#include <sys/types.h>
++#include <sys/module.h>
++#include <sys/systm.h>
++#include <sys/errno.h>
++#include <sys/kernel.h>
++#include <sys/fcntl.h>
++#include <sys/conf.h>
++#include <sys/uio.h>
++
++#include "../SUPDrvInternal.h"
++#include <VBox/version.h>
++#include <iprt/initterm.h>
++#include <iprt/string.h>
++#include <iprt/spinlock.h>
++#include <iprt/process.h>
++#include <iprt/assert.h>
++#include <iprt/uuid.h>
++#include <VBox/log.h>
++#include <iprt/alloc.h>
++#include <iprt/err.h>
++#include <iprt/asm.h>
++
++#ifdef VBOX_WITH_HARDENING
++# define VBOXDRV_PERM 0600
++#else
++# define VBOXDRV_PERM 0666
++#endif
++
++
++/*********************************************************************************************************************************
++*   Internal Functions                                                                                                           *
++*********************************************************************************************************************************/
++static int VBoxDrvNetBSDModuleEvent(struct module *pMod, int enmEventType, void *pvArg);
++static int VBoxDrvNetBSDLoad(void);
++static int VBoxDrvNetBSDUnload(void);
++
++static d_open_t     VBoxDrvNetBSDOpenUsr;
++static d_open_t     VBoxDrvNetBSDOpenSys;
++static void         vboxdrvNetBSDDtr(void *pvData);
++static d_ioctl_t    VBoxDrvNetBSDIOCtl;
++static int          VBoxDrvNetBSDIOCtlSlow(PSUPDRVSESSION pSession, u_long ulCmd, caddr_t pvData, struct thread *pTd);
++
++
++/*********************************************************************************************************************************
++*   Global Variables                                                                                                             *
++*********************************************************************************************************************************/
++/**
++ * Module info structure used by the kernel.
++ */
++static moduledata_t         g_VBoxDrvNetBSDModule =
++{
++    "vboxdrv",
++    VBoxDrvNetBSDModuleEvent,
++    NULL
++};
++
++/** Declare the module as a pseudo device. */
++DECLARE_MODULE(vboxdrv,     g_VBoxDrvNetBSDModule, SI_SUB_PSEUDO, SI_ORDER_ANY);
++MODULE_VERSION(vboxdrv, 1);
++
++/**
++ * The /dev/vboxdrv character device entry points.
++ */
++static struct cdevsw        g_VBoxDrvNetBSDChrDevSwSys =
++{
++    .d_version =        D_VERSION,
++    .d_open =           VBoxDrvNetBSDOpenSys,
++    .d_ioctl =          VBoxDrvNetBSDIOCtl,
++    .d_name =           "vboxdrv"
++};
++/** The /dev/vboxdrv character device. */
++static struct cdev         *g_pVBoxDrvNetBSDChrDevSys;
++
++/**
++ * The /dev/vboxdrvu character device entry points.
++ */
++static struct cdevsw        g_VBoxDrvNetBSDChrDevSwUsr =
++{
++    .d_version =        D_VERSION,
++    .d_open =           VBoxDrvNetBSDOpenUsr,
++    .d_ioctl =          VBoxDrvNetBSDIOCtl,
++    .d_name =           "vboxdrvu"
++};
++/** The /dev/vboxdrvu character device. */
++static struct cdev         *g_pVBoxDrvNetBSDChrDevUsr;
++
++/** Reference counter. */
++static volatile uint32_t    g_cUsers;
++
++/** The device extention. */
++static SUPDRVDEVEXT         g_VBoxDrvNetBSDDevExt;
++
++/**
++ * Module event handler.
++ *
++ * @param   pMod            The module structure.
++ * @param   enmEventType    The event type (modeventtype_t).
++ * @param   pvArg           Module argument. NULL.
++ *
++ * @return  0 on success, errno.h status code on failure.
++ */
++static int VBoxDrvNetBSDModuleEvent(struct module *pMod, int enmEventType, void *pvArg)
++{
++    int rc;
++    switch (enmEventType)
++    {
++        case MOD_LOAD:
++            rc = VBoxDrvNetBSDLoad();
++            break;
++
++        case MOD_UNLOAD:
++            mtx_unlock(&Giant);
++            rc = VBoxDrvNetBSDUnload();
++            mtx_lock(&Giant);
++            break;
++
++        case MOD_SHUTDOWN:
++        case MOD_QUIESCE:
++        default:
++            return EOPNOTSUPP;
++    }
++
++    if (RT_SUCCESS(rc))
++        return 0;
++    return RTErrConvertToErrno(rc);
++}
++
++
++static int VBoxDrvNetBSDLoad(void)
++{
++    g_cUsers = 0;
++
++    /*
++     * Initialize the runtime.
++     */
++    int rc = RTR0Init(0);
++    if (RT_SUCCESS(rc))
++    {
++        Log(("VBoxDrvNetBSDLoad:\n"));
++
++        /*
++         * Initialize the device extension.
++         */
++        rc = supdrvInitDevExt(&g_VBoxDrvNetBSDDevExt, sizeof(SUPDRVSESSION));
++        if (RT_SUCCESS(rc))
++        {
++            /*
++             * Configure character devices. Add symbolic links for compatibility.
++             */
++            g_pVBoxDrvNetBSDChrDevSys = make_dev(&g_VBoxDrvNetBSDChrDevSwSys, 0, UID_ROOT, GID_WHEEL, VBOXDRV_PERM, "vboxdrv");
++            g_pVBoxDrvNetBSDChrDevUsr = make_dev(&g_VBoxDrvNetBSDChrDevSwUsr, 1, UID_ROOT, GID_WHEEL, 0666,         "vboxdrvu");
++            return VINF_SUCCESS;
++        }
++
++        printf("vboxdrv: supdrvInitDevExt failed, rc=%d\n", rc);
++        RTR0Term();
++    }
++    else
++        printf("vboxdrv: RTR0Init failed, rc=%d\n", rc);
++    return rc;
++}
++
++static int VBoxDrvNetBSDUnload(void)
++{
++    Log(("VBoxDrvNetBSDUnload:\n"));
++
++    if (g_cUsers > 0)
++        return VERR_RESOURCE_BUSY;
++
++    /*
++     * Reserve what we did in VBoxDrvNetBSDInit.
++     */
++    destroy_dev(g_pVBoxDrvNetBSDChrDevUsr);
++    destroy_dev(g_pVBoxDrvNetBSDChrDevSys);
++
++    supdrvDeleteDevExt(&g_VBoxDrvNetBSDDevExt);
++
++    RTR0TermForced();
++
++    memset(&g_VBoxDrvNetBSDDevExt, 0, sizeof(g_VBoxDrvNetBSDDevExt));
++    return VINF_SUCCESS;
++}
++
++
++/**
++ *
++ * @returns 0 on success, errno on failure.
++ *          EBUSY if the device is used by someone else.
++ * @param   pDev            The device node.
++ * @param   fOpen           The open flags.
++ * @param   iDevType        Some device type thing we don't use.
++ * @param   pTd             The thread.
++ * @param   fUnrestricted   Set if opening /dev/vboxdrv, clear if /dev/vboxdrvu.
++ */
++static int vboxdrvNetBSDOpenCommon(struct cdev *pDev, int fOpen, int iDevType, struct thread *pTd, bool fUnrestricted)
++{
++    PSUPDRVSESSION pSession;
++    int rc;
++
++    /*
++     * Let's be a bit picky about the flags...
++     */
++    if (fOpen != (FREAD | FWRITE /*=O_RDWR*/))
++    {
++        Log(("VBoxDrvNetBSDOpen: fOpen=%#x expected %#x\n", fOpen, O_RDWR));
++        return EINVAL;
++    }
++
++    /*
++     * Create a new session.
++     */
++    rc = supdrvCreateSession(&g_VBoxDrvNetBSDDevExt, true /* fUser */, fUnrestricted, &pSession);
++    if (RT_SUCCESS(rc))
++    {
++        /** @todo get (r)uid and (r)gid.
++        pSession->Uid = stuff;
++        pSession->Gid = stuff; */
++        rc = devfs_set_cdevpriv(pSession, vboxdrvNetBSDDtr); Assert(rc == 0);
++        Log(("VBoxDrvNetBSDOpen: pSession=%p\n", pSession));
++        ASMAtomicIncU32(&g_cUsers);
++        return 0;
++    }
++
++    return RTErrConvertToErrno(rc);
++}
++
++
++/** For vboxdrv. */
++static int VBoxDrvNetBSDOpenSys(struct cdev *pDev, int fOpen, int iDevType, struct thread *pTd)
++{
++    return vboxdrvNetBSDOpenCommon(pDev, fOpen, iDevType, pTd, true);
++}
++
++
++/** For vboxdrvu. */
++static int VBoxDrvNetBSDOpenUsr(struct cdev *pDev, int fOpen, int iDevType, struct thread *pTd)
++{
++    return vboxdrvNetBSDOpenCommon(pDev, fOpen, iDevType, pTd, false);
++}
++
++
++/**
++ * Close a file device previously opened by VBoxDrvNetBSDOpen.
++ *
++ * @returns 0 on success.
++ * @param   pvData      The session being closed.
++ */
++static void vboxdrvNetBSDDtr(void *pvData)
++{
++    PSUPDRVSESSION pSession = pvData;
++    Log(("vboxdrvNetBSDDtr: pSession=%p\n", pSession));
++
++    /*
++     * Close the session.
++     */
++    supdrvSessionRelease(pSession);
++    ASMAtomicDecU32(&g_cUsers);
++}
++
++
++/**
++ * I/O control request.
++ *
++ * @returns depends...
++ * @param   pDev        The device.
++ * @param   ulCmd       The command.
++ * @param   pvData      Pointer to the data.
++ * @param   fFile       The file descriptor flags.
++ * @param   pTd         The calling thread.
++ */
++static int VBoxDrvNetBSDIOCtl(struct cdev *pDev, u_long ulCmd, caddr_t pvData, int fFile, struct thread *pTd)
++{
++    PSUPDRVSESSION pSession;
++    devfs_get_cdevpriv((void **)&pSession);
++
++    /*
++     * Deal with the fast ioctl path first.
++     */
++    if (   (   ulCmd == SUP_IOCTL_FAST_DO_RAW_RUN
++            || ulCmd == SUP_IOCTL_FAST_DO_HM_RUN
++            || ulCmd == SUP_IOCTL_FAST_DO_NOP)
++        && pSession->fUnrestricted == true)
++        return supdrvIOCtlFast(ulCmd, *(uint32_t *)pvData, &g_VBoxDrvNetBSDDevExt, pSession);
++
++    return VBoxDrvNetBSDIOCtlSlow(pSession, ulCmd, pvData, pTd);
++}
++
++
++/**
++ * Deal with the 'slow' I/O control requests.
++ *
++ * @returns 0 on success, appropriate errno on failure.
++ * @param   pSession    The session.
++ * @param   ulCmd       The command.
++ * @param   pvData      The request data.
++ * @param   pTd         The calling thread.
++ */
++static int VBoxDrvNetBSDIOCtlSlow(PSUPDRVSESSION pSession, u_long ulCmd, caddr_t pvData, struct thread *pTd)
++{
++    PSUPREQHDR  pHdr;
++    uint32_t    cbReq = IOCPARM_LEN(ulCmd);
++    void       *pvUser = NULL;
++
++    /*
++     * Buffered request?
++     */
++    if ((IOC_DIRMASK & ulCmd) == IOC_INOUT)
++    {
++        pHdr = (PSUPREQHDR)pvData;
++        if (RT_UNLIKELY(cbReq < sizeof(*pHdr)))
++        {
++            OSDBGPRINT(("VBoxDrvNetBSDIOCtlSlow: cbReq=%#x < %#x; ulCmd=%#lx\n", cbReq, (int)sizeof(*pHdr), ulCmd));
++            return EINVAL;
++        }
++        if (RT_UNLIKELY((pHdr->fFlags & SUPREQHDR_FLAGS_MAGIC_MASK) != SUPREQHDR_FLAGS_MAGIC))
++        {
++            OSDBGPRINT(("VBoxDrvNetBSDIOCtlSlow: bad magic fFlags=%#x; ulCmd=%#lx\n", pHdr->fFlags, ulCmd));
++            return EINVAL;
++        }
++        if (RT_UNLIKELY(    RT_MAX(pHdr->cbIn, pHdr->cbOut) != cbReq
++                        ||  pHdr->cbIn < sizeof(*pHdr)
++                        ||  pHdr->cbOut < sizeof(*pHdr)))
++        {
++            OSDBGPRINT(("VBoxDrvNetBSDIOCtlSlow: max(%#x,%#x) != %#x; ulCmd=%#lx\n", pHdr->cbIn, pHdr->cbOut, cbReq, ulCmd));
++            return EINVAL;
++        }
++    }
++    /*
++     * Big unbuffered request?
++     */
++    else if ((IOC_DIRMASK & ulCmd) == IOC_VOID && !cbReq)
++    {
++        /*
++         * Read the header, validate it and figure out how much that needs to be buffered.
++         */
++        SUPREQHDR Hdr;
++        pvUser = *(void **)pvData;
++        int rc = copyin(pvUser, &Hdr, sizeof(Hdr));
++        if (RT_UNLIKELY(rc))
++        {
++            OSDBGPRINT(("VBoxDrvNetBSDIOCtlSlow: copyin(%p,Hdr,) -> %#x; ulCmd=%#lx\n", pvUser, rc, ulCmd));
++            return rc;
++        }
++        if (RT_UNLIKELY((Hdr.fFlags & SUPREQHDR_FLAGS_MAGIC_MASK) != SUPREQHDR_FLAGS_MAGIC))
++        {
++            OSDBGPRINT(("VBoxDrvNetBSDIOCtlSlow: bad magic fFlags=%#x; ulCmd=%#lx\n", Hdr.fFlags, ulCmd));
++            return EINVAL;
++        }
++        cbReq = RT_MAX(Hdr.cbIn, Hdr.cbOut);
++        if (RT_UNLIKELY(    Hdr.cbIn < sizeof(Hdr)
++                        ||  Hdr.cbOut < sizeof(Hdr)
++                        ||  cbReq > _1M*16))
++        {
++            OSDBGPRINT(("VBoxDrvNetBSDIOCtlSlow: max(%#x,%#x); ulCmd=%#lx\n", Hdr.cbIn, Hdr.cbOut, ulCmd));
++            return EINVAL;
++        }
++
++        /*
++         * Allocate buffer and copy in the data.
++         */
++        pHdr = (PSUPREQHDR)RTMemTmpAlloc(cbReq);
++        if (RT_UNLIKELY(!pHdr))
++        {
++            OSDBGPRINT(("VBoxDrvNetBSDIOCtlSlow: failed to allocate buffer of %d bytes; ulCmd=%#lx\n", cbReq, ulCmd));
++            return ENOMEM;
++        }
++        rc = copyin(pvUser, pHdr, Hdr.cbIn);
++        if (RT_UNLIKELY(rc))
++        {
++            OSDBGPRINT(("VBoxDrvNetBSDIOCtlSlow: copyin(%p,%p,%#x) -> %#x; ulCmd=%#lx\n",
++                        pvUser, pHdr, Hdr.cbIn, rc, ulCmd));
++            RTMemTmpFree(pHdr);
++            return rc;
++        }
++        if (Hdr.cbIn < cbReq)
++            RT_BZERO((uint8_t *)pHdr + Hdr.cbIn, cbReq - Hdr.cbIn);
++    }
++    else
++    {
++        Log(("VBoxDrvNetBSDIOCtlSlow: huh? cbReq=%#x ulCmd=%#lx\n", cbReq, ulCmd));
++        return EINVAL;
++    }
++
++    /*
++     * Process the IOCtl.
++     */
++    int rc = supdrvIOCtl(ulCmd, &g_VBoxDrvNetBSDDevExt, pSession, pHdr, cbReq);
++    if (RT_LIKELY(!rc))
++    {
++        /*
++         * If unbuffered, copy back the result before returning.
++         */
++        if (pvUser)
++        {
++            uint32_t cbOut = pHdr->cbOut;
++            if (cbOut > cbReq)
++            {
++                OSDBGPRINT(("VBoxDrvNetBSDIOCtlSlow: too much output! %#x > %#x; uCmd=%#lx!\n", cbOut, cbReq, ulCmd));
++                cbOut = cbReq;
++            }
++            rc = copyout(pHdr, pvUser, cbOut);
++            if (RT_UNLIKELY(rc))
++                OSDBGPRINT(("VBoxDrvNetBSDIOCtlSlow: copyout(%p,%p,%#x) -> %d; uCmd=%#lx!\n", pHdr, pvUser, cbOut, rc, ulCmd));
++
++            Log(("VBoxDrvNetBSDIOCtlSlow: returns %d / %d ulCmd=%lx\n", 0, pHdr->rc, ulCmd));
++
++            /* cleanup */
++            RTMemTmpFree(pHdr);
++        }
++    }
++    else
++    {
++        /*
++         * The request failed, just clean up.
++         */
++        if (pvUser)
++            RTMemTmpFree(pHdr);
++
++        Log(("VBoxDrvNetBSDIOCtlSlow: ulCmd=%lx pData=%p failed, rc=%d\n", ulCmd, pvData, rc));
++        rc = EINVAL;
++    }
++
++    return rc;
++}
++
++
++/**
++ * The SUPDRV IDC entry point.
++ *
++ * @returns VBox status code, see supdrvIDC.
++ * @param   uReq        The request code.
++ * @param   pReq        The request.
++ */
++int VBOXCALL SUPDrvNetBSDIDC(uint32_t uReq, PSUPDRVIDCREQHDR pReq)
++{
++    PSUPDRVSESSION  pSession;
++
++    /*
++     * Some quick validations.
++     */
++    if (RT_UNLIKELY(!VALID_PTR(pReq)))
++        return VERR_INVALID_POINTER;
++
++    pSession = pReq->pSession;
++    if (pSession)
++    {
++        if (RT_UNLIKELY(!VALID_PTR(pReq->pSession)))
++            return VERR_INVALID_PARAMETER;
++        if (RT_UNLIKELY(pSession->pDevExt != &g_VBoxDrvNetBSDDevExt))
++            return VERR_INVALID_PARAMETER;
++    }
++    else if (RT_UNLIKELY(uReq != SUPDRV_IDC_REQ_CONNECT))
++        return VERR_INVALID_PARAMETER;
++
++    /*
++     * Do the job.
++     */
++    return supdrvIDC(uReq, &g_VBoxDrvNetBSDDevExt, pSession, pReq);
++}
++
++
++void VBOXCALL supdrvOSCleanupSession(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession)
++{
++    NOREF(pDevExt);
++    NOREF(pSession);
++}
++
++
++void VBOXCALL supdrvOSSessionHashTabInserted(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, void *pvUser)
++{
++    NOREF(pDevExt); NOREF(pSession); NOREF(pvUser);
++}
++
++
++void VBOXCALL supdrvOSSessionHashTabRemoved(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, void *pvUser)
++{
++    NOREF(pDevExt); NOREF(pSession); NOREF(pvUser);
++}
++
++
++void VBOXCALL   supdrvOSObjInitCreator(PSUPDRVOBJ pObj, PSUPDRVSESSION pSession)
++{
++    NOREF(pObj);
++    NOREF(pSession);
++}
++
++
++bool VBOXCALL   supdrvOSObjCanAccess(PSUPDRVOBJ pObj, PSUPDRVSESSION pSession, const char *pszObjName, int *prc)
++{
++    NOREF(pObj);
++    NOREF(pSession);
++    NOREF(pszObjName);
++    NOREF(prc);
++    return false;
++}
++
++
++bool VBOXCALL  supdrvOSGetForcedAsyncTscMode(PSUPDRVDEVEXT pDevExt)
++{
++    return false;
++}
++
++
++bool VBOXCALL  supdrvOSAreCpusOfflinedOnSuspend(void)
++{
++    /** @todo verify this. */
++    return false;
++}
++
++
++bool VBOXCALL  supdrvOSAreTscDeltasInSync(void)
++{
++    return false;
++}
++
++
++int  VBOXCALL   supdrvOSLdrOpen(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage, const char *pszFilename)
++{
++    NOREF(pDevExt); NOREF(pImage); NOREF(pszFilename);
++    return VERR_NOT_SUPPORTED;
++}
++
++
++void VBOXCALL   supdrvOSLdrNotifyOpened(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage)
++{
++    NOREF(pDevExt); NOREF(pImage);
++}
++
++
++int  VBOXCALL   supdrvOSLdrValidatePointer(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage, void *pv, const uint8_t *pbImageBits)
++{
++    NOREF(pDevExt); NOREF(pImage); NOREF(pv); NOREF(pbImageBits);
++    return VERR_NOT_SUPPORTED;
++}
++
++
++int  VBOXCALL   supdrvOSLdrLoad(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage, const uint8_t *pbImageBits, PSUPLDRLOAD pReq)
++{
++    NOREF(pDevExt); NOREF(pImage); NOREF(pbImageBits); NOREF(pReq);
++    return VERR_NOT_SUPPORTED;
++}
++
++
++void VBOXCALL   supdrvOSLdrUnload(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage)
++{
++    NOREF(pDevExt); NOREF(pImage);
++}
++
++
++#ifdef SUPDRV_WITH_MSR_PROBER
++
++int VBOXCALL    supdrvOSMsrProberRead(uint32_t uMsr, RTCPUID idCpu, uint64_t *puValue)
++{
++    NOREF(uMsr); NOREF(idCpu); NOREF(puValue);
++    return VERR_NOT_SUPPORTED;
++}
++
++
++int VBOXCALL    supdrvOSMsrProberWrite(uint32_t uMsr, RTCPUID idCpu, uint64_t uValue)
++{
++    NOREF(uMsr); NOREF(idCpu); NOREF(uValue);
++    return VERR_NOT_SUPPORTED;
++}
++
++
++int VBOXCALL    supdrvOSMsrProberModify(RTCPUID idCpu, PSUPMSRPROBER pReq)
++{
++    NOREF(idCpu); NOREF(pReq);
++    return VERR_NOT_SUPPORTED;
++}
++
++#endif /* SUPDRV_WITH_MSR_PROBER */
++
++
++SUPR0DECL(int) SUPR0Printf(const char *pszFormat, ...)
++{
++    va_list va;
++    char szMsg[256];
++    int cch;
++
++    va_start(va, pszFormat);
++    cch = RTStrPrintfV(szMsg, sizeof(szMsg), pszFormat, va);
++    va_end(va);
++
++    printf("%s", szMsg);
++
++    return cch;
++}
++
++
++SUPR0DECL(uint32_t) SUPR0GetKernelFeatures(void)
++{
++    return 0;
++}
diff --git a/virtualbox-svn/patches/patch-src_VBox_HostDrivers_Support_netbsd_SUPDrv-netbsd.def b/virtualbox-svn/patches/patch-src_VBox_HostDrivers_Support_netbsd_SUPDrv-netbsd.def
new file mode 100644
index 0000000..346e5c8
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_HostDrivers_Support_netbsd_SUPDrv-netbsd.def
@@ -0,0 +1,6 @@
+$NetBSD$
+
+--- src/VBox/HostDrivers/Support/netbsd/SUPDrv-netbsd.def.orig	2016-07-07 07:08:46.496688121 +0000
++++ src/VBox/HostDrivers/Support/netbsd/SUPDrv-netbsd.def
+@@ -0,0 +1 @@
++SUPDrvNetBSDIDC
diff --git a/virtualbox-svn/patches/patch-src_VBox_HostDrivers_Support_netbsd_SUPLib-netbsd.cpp b/virtualbox-svn/patches/patch-src_VBox_HostDrivers_Support_netbsd_SUPLib-netbsd.cpp
new file mode 100644
index 0000000..985b7a4
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_HostDrivers_Support_netbsd_SUPLib-netbsd.cpp
@@ -0,0 +1,190 @@
+$NetBSD$
+
+--- src/VBox/HostDrivers/Support/netbsd/SUPLib-netbsd.cpp.orig	2016-07-07 07:08:46.506033890 +0000
++++ src/VBox/HostDrivers/Support/netbsd/SUPLib-netbsd.cpp
+@@ -0,0 +1,185 @@
++/*  SUPLib-netbsd.cpp $ */
++/** @file
++ * VirtualBox Support Library - NetBSD specific parts.
++ */
++
++/*
++ * Copyright (C) 2006-2015 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                                                                                                                 *
++*********************************************************************************************************************************/
++#define LOG_GROUP LOG_GROUP_SUP
++#ifdef IN_SUP_HARDENED_R3
++# undef DEBUG /* Warning: disables RT_STRICT */
++# define LOG_DISABLED
++# define RTLOG_REL_DISABLED
++# include <iprt/log.h>
++#endif
++
++#include <VBox/types.h>
++#include <VBox/sup.h>
++#include <VBox/param.h>
++#include <VBox/err.h>
++#include <VBox/log.h>
++#include <iprt/path.h>
++#include <iprt/assert.h>
++#include <iprt/mem.h>
++#include <iprt/err.h>
++#include <iprt/string.h>
++#include "../SUPLibInternal.h"
++#include "../SUPDrvIOC.h"
++
++#include <sys/fcntl.h>
++#include <sys/ioctl.h>
++#include <errno.h>
++#include <unistd.h>
++#include <stdlib.h>
++#include <stdio.h>
++
++
++/*********************************************************************************************************************************
++*   Defined Constants And Macros                                                                                                 *
++*********************************************************************************************************************************/
++/** System device name. */
++#define DEVICE_NAME_SYS "/dev/vboxdrv"
++/** User device name. */
++#define DEVICE_NAME_USR "/dev/vboxdrvu"
++
++
++
++int suplibOsInit(PSUPLIBDATA pThis, bool fPreInited, bool fUnrestricted, SUPINITOP *penmWhat, PRTERRINFO pErrInfo)
++{
++    /*
++     * Nothing to do if pre-inited.
++     */
++    if (fPreInited)
++        return VINF_SUCCESS;
++
++    /*
++     * Try open the BSD device.
++     */
++    int hDevice = open(fUnrestricted ? DEVICE_NAME_SYS : DEVICE_NAME_USR, O_RDWR, 0);
++    if (hDevice < 0)
++    {
++        int rc;
++        switch (errno)
++        {
++            case ENODEV:    rc = VERR_VM_DRIVER_LOAD_ERROR; break;
++            case EPERM:
++            case EACCES:    rc = VERR_VM_DRIVER_NOT_ACCESSIBLE; break;
++            case ENOENT:    rc = VERR_VM_DRIVER_NOT_INSTALLED; break;
++            default:        rc = VERR_VM_DRIVER_OPEN_ERROR; break;
++        }
++        LogRel(("Failed to open \"%s\", errno=%d, rc=%Rrc\n", fUnrestricted ? DEVICE_NAME_SYS : DEVICE_NAME_USR, errno, rc));
++        return rc;
++    }
++
++    /*
++     * Mark the file handle close on exec.
++     */
++    if (fcntl(hDevice, F_SETFD, FD_CLOEXEC) != 0)
++    {
++#ifdef IN_SUP_HARDENED_R3
++        int rc = VERR_INTERNAL_ERROR;
++#else
++        int err = errno;
++        int rc = RTErrConvertFromErrno(err);
++        LogRel(("suplibOSInit: setting FD_CLOEXEC failed, errno=%d (%Rrc)\n", err, rc));
++#endif
++        close(hDevice);
++        return rc;
++    }
++
++    /*
++     * We're done.
++     */
++    pThis->hDevice       = hDevice;
++    pThis->fUnrestricted = fUnrestricted;
++    return VINF_SUCCESS;
++}
++
++
++#ifndef IN_SUP_HARDENED_R3
++
++int suplibOsTerm(PSUPLIBDATA pThis)
++{
++    /*
++     * Check if we're inited at all.
++     */
++    if (pThis->hDevice != (intptr_t)NIL_RTFILE)
++    {
++        if (close(pThis->hDevice))
++            AssertFailed();
++        pThis->hDevice = (intptr_t)NIL_RTFILE;
++    }
++    return VINF_SUCCESS;
++}
++
++
++int suplibOsInstall(void)
++{
++    return VERR_NOT_IMPLEMENTED;
++}
++
++
++int suplibOsUninstall(void)
++{
++    return VERR_NOT_IMPLEMENTED;
++}
++
++
++int suplibOsIOCtl(PSUPLIBDATA pThis, uintptr_t uFunction, void *pvReq, size_t cbReq)
++{
++    if (RT_LIKELY(ioctl(pThis->hDevice, uFunction, pvReq) >= 0))
++        return VINF_SUCCESS;
++    return RTErrConvertFromErrno(errno);
++}
++
++
++int suplibOsIOCtlFast(PSUPLIBDATA pThis, uintptr_t uFunction, uintptr_t idCpu)
++{
++    int rc = ioctl(pThis->hDevice, uFunction, idCpu);
++    if (rc == -1)
++        rc = errno;
++    return rc;
++}
++
++
++int suplibOsPageAlloc(PSUPLIBDATA pThis, size_t cPages, void **ppvPages)
++{
++    NOREF(pThis);
++    *ppvPages = RTMemPageAllocZ(cPages << PAGE_SHIFT);
++    if (*ppvPages)
++        return VINF_SUCCESS;
++    return RTErrConvertFromErrno(errno);
++}
++
++
++int suplibOsPageFree(PSUPLIBDATA pThis, void *pvPages, size_t cPages)
++{
++    NOREF(pThis);
++    RTMemPageFree(pvPages, cPages * PAGE_SIZE);
++    return VINF_SUCCESS;
++}
++
++#endif /* !IN_SUP_HARDENED_R3 */
diff --git a/virtualbox-svn/patches/patch-src_VBox_HostDrivers_Support_netbsd_SUPR0IdcClient-netbsd.c b/virtualbox-svn/patches/patch-src_VBox_HostDrivers_Support_netbsd_SUPR0IdcClient-netbsd.c
new file mode 100644
index 0000000..c4634a5
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_HostDrivers_Support_netbsd_SUPR0IdcClient-netbsd.c
@@ -0,0 +1,60 @@
+$NetBSD$
+
+--- src/VBox/HostDrivers/Support/netbsd/SUPR0IdcClient-netbsd.c.orig	2016-07-07 07:08:46.515663297 +0000
++++ src/VBox/HostDrivers/Support/netbsd/SUPR0IdcClient-netbsd.c
+@@ -0,0 +1,55 @@
++/*  SUPR0IdcClient-netbsd.c $ */
++/** @file
++ * VirtualBox Support Driver - IDC Client Lib, NetBSD Specific Code.
++ */
++
++/*
++ * Copyright (C) 2008-2015 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 "../SUPR0IdcClientInternal.h"
++#include <VBox/err.h>
++
++
++int VBOXCALL supR0IdcNativeOpen(PSUPDRVIDCHANDLE pHandle, PSUPDRVIDCREQCONNECT pReq)
++{
++    return supR0IdcNativeCall(pHandle, SUPDRV_IDC_REQ_CONNECT, &pReq->Hdr);
++}
++
++
++int VBOXCALL supR0IdcNativeClose(PSUPDRVIDCHANDLE pHandle, PSUPDRVIDCREQHDR pReq)
++{
++    return supR0IdcNativeCall(pHandle, SUPDRV_IDC_REQ_DISCONNECT, pReq);
++}
++
++
++int VBOXCALL supR0IdcNativeCall(PSUPDRVIDCHANDLE pHandle, uint32_t iReq, PSUPDRVIDCREQHDR pReq)
++{
++    int rc = SUPDrvNetBSDIDC(iReq, pReq);
++    if (RT_SUCCESS(rc))
++        rc = pReq->rc;
++
++    NOREF(pHandle);
++    return rc;
++}
diff --git a/virtualbox-svn/patches/patch-src_VBox_HostDrivers_Support_netbsd_files__vboxdrv b/virtualbox-svn/patches/patch-src_VBox_HostDrivers_Support_netbsd_files__vboxdrv
new file mode 100644
index 0000000..9f6ca18
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_HostDrivers_Support_netbsd_files__vboxdrv
@@ -0,0 +1,216 @@
+$NetBSD$
+
+--- src/VBox/HostDrivers/Support/netbsd/files_vboxdrv.orig	2016-07-08 15:09:53.340402555 +0000
++++ src/VBox/HostDrivers/Support/netbsd/files_vboxdrv
+@@ -0,0 +1,211 @@
++#!/bin/sh
++#  files_vboxdrv $
++## @file
++# Shared file between Makefile.kmk and export_modules
++#
++
++#
++# Copyright (C) 2007-2015 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.
++#
++
++FILES_VBOXDRV_NOBIN=" \
++    ${PATH_ROOT}/include/iprt/alloc.h=>include/iprt/alloc.h \
++    ${PATH_ROOT}/include/iprt/alloca.h=>include/iprt/alloca.h \
++    ${PATH_ROOT}/include/iprt/asm.h=>include/iprt/asm.h \
++    ${PATH_ROOT}/include/iprt/asm-amd64-x86.h=>include/iprt/asm-amd64-x86.h \
++    ${PATH_ROOT}/include/iprt/asm-math.h=>include/iprt/asm-math.h \
++    ${PATH_ROOT}/include/iprt/assert.h=>include/iprt/assert.h \
++    ${PATH_ROOT}/include/iprt/avl.h=>include/iprt/avl.h \
++    ${PATH_ROOT}/include/iprt/cdefs.h=>include/iprt/cdefs.h \
++    ${PATH_ROOT}/include/iprt/cpuset.h=>include/iprt/cpuset.h \
++    ${PATH_ROOT}/include/iprt/crc.h=>include/iprt/crc.h \
++    ${PATH_ROOT}/include/iprt/ctype.h=>include/iprt/ctype.h \
++    ${PATH_ROOT}/include/iprt/err.h=>include/iprt/err.h \
++    ${PATH_ROOT}/include/iprt/errno.h=>include/iprt/errno.h \
++    ${PATH_ROOT}/include/iprt/heap.h=>include/iprt/heap.h \
++    ${PATH_ROOT}/include/iprt/handletable.h=>include/iprt/handletable.h \
++    ${PATH_ROOT}/include/iprt/initterm.h=>include/iprt/initterm.h \
++    ${PATH_ROOT}/include/iprt/latin1.h=>include/iprt/latin1.h \
++    ${PATH_ROOT}/include/iprt/list.h=>include/iprt/list.h \
++    ${PATH_ROOT}/include/iprt/log.h=>include/iprt/log.h \
++    ${PATH_ROOT}/include/iprt/mangling.h=>include/iprt/mangling.h \
++    ${PATH_ROOT}/include/iprt/mem.h=>include/iprt/mem.h \
++    ${PATH_ROOT}/include/iprt/memobj.h=>include/iprt/memobj.h \
++    ${PATH_ROOT}/include/iprt/mp.h=>include/iprt/mp.h \
++    ${PATH_ROOT}/include/iprt/param.h=>include/iprt/param.h \
++    ${PATH_ROOT}/include/iprt/power.h=>include/iprt/power.h \
++    ${PATH_ROOT}/include/iprt/process.h=>include/iprt/process.h \
++    ${PATH_ROOT}/include/iprt/semaphore.h=>include/iprt/semaphore.h \
++    ${PATH_ROOT}/include/iprt/spinlock.h=>include/iprt/spinlock.h \
++    ${PATH_ROOT}/include/iprt/stdarg.h=>include/iprt/stdarg.h \
++    ${PATH_ROOT}/include/iprt/stdint.h=>include/iprt/stdint.h \
++    ${PATH_ROOT}/include/iprt/string.h=>include/iprt/string.h \
++    ${PATH_ROOT}/include/iprt/thread.h=>include/iprt/thread.h \
++    ${PATH_ROOT}/include/iprt/time.h=>include/iprt/time.h \
++    ${PATH_ROOT}/include/iprt/timer.h=>include/iprt/timer.h \
++    ${PATH_ROOT}/include/iprt/types.h=>include/iprt/types.h \
++    ${PATH_ROOT}/include/iprt/uint128.h=>include/iprt/uint128.h \
++    ${PATH_ROOT}/include/iprt/uni.h=>include/iprt/uni.h \
++    ${PATH_ROOT}/include/iprt/utf16.h=>include/iprt/utf16.h \
++    ${PATH_ROOT}/include/iprt/uuid.h=>include/iprt/uuid.h \
++    ${PATH_ROOT}/include/iprt/net.h=>include/iprt/net.h \
++    ${PATH_ROOT}/include/iprt/rand.h=>include/iprt/rand.h \
++    ${PATH_ROOT}/include/iprt/path.h=>include/iprt/path.h \
++    ${PATH_ROOT}/include/iprt/once.h=>include/iprt/once.h \
++    ${PATH_ROOT}/include/iprt/critsect.h=>include/iprt/critsect.h \
++    ${PATH_ROOT}/include/iprt/x86.h=>include/iprt/x86.h \
++    ${PATH_ROOT}/include/iprt/lockvalidator.h=>include/iprt/lockvalidator.h \
++    ${PATH_ROOT}/include/iprt/nocrt/limits.h=>include/iprt/nocrt/limits.h \
++    ${PATH_ROOT}/include/VBox/cdefs.h=>include/VBox/cdefs.h \
++    ${PATH_ROOT}/include/VBox/err.h=>include/VBox/err.h \
++    ${PATH_ROOT}/include/VBox/log.h=>include/VBox/log.h \
++    ${PATH_ROOT}/include/VBox/param.h=>include/VBox/param.h \
++    ${PATH_ROOT}/include/VBox/sup.h=>include/VBox/sup.h \
++    ${PATH_ROOT}/include/VBox/types.h=>include/VBox/types.h \
++    ${PATH_ROOT}/include/VBox/version.h=>include/VBox/version.h \
++    ${PATH_ROOT}/include/VBox/SUPDrvMangling.h=>include/VBox/SUPDrvMangling.h \
++    ${PATH_ROOT}/include/VBox/VBoxTpG.h=>include/VBox/VBoxTpG.h \
++    ${PATH_ROOT}/include/VBox/vmm/hm_vmx.h=>include/VBox/vmm/hm_vmx.h \
++    ${PATH_ROOT}/include/VBox/vmm/hm_svm.h=>include/VBox/vmm/hm_svm.h \
++    ${PATH_ROOT}/src/VBox/HostDrivers/Support/netbsd/SUPDrv-netbsd.c=>netbsd/SUPDrv-netbsd.c \
++    ${PATH_ROOT}/src/VBox/HostDrivers/Support/SUPDrv.cpp=>SUPDrv.c \
++    ${PATH_ROOT}/src/VBox/HostDrivers/Support/SUPDrvGip.cpp=>SUPDrvGip.c \
++    ${PATH_ROOT}/src/VBox/HostDrivers/Support/SUPDrvSem.cpp=>SUPDrvSem.c \
++    ${PATH_ROOT}/src/VBox/HostDrivers/Support/SUPDrvTracer.cpp=>SUPDrvTracer.c \
++    ${PATH_ROOT}/src/VBox/HostDrivers/Support/SUPDrvIDC.h=>SUPDrvIDC.h \
++    ${PATH_ROOT}/src/VBox/HostDrivers/Support/SUPDrvIOC.h=>SUPDrvIOC.h \
++    ${PATH_ROOT}/src/VBox/HostDrivers/Support/SUPDrvInternal.h=>SUPDrvInternal.h \
++    ${PATH_ROOT}/src/VBox/HostDrivers/Support/SUPLibAll.cpp=>SUPLibAll.c \
++    ${PATH_ROOT}/src/VBox/Runtime/common/alloc/heapsimple.cpp=>alloc/heapsimple.c \
++    ${PATH_ROOT}/src/VBox/Runtime/common/alloc/alloc.cpp=>alloc/alloc.c \
++    ${PATH_ROOT}/src/VBox/Runtime/common/err/RTErrConvertFromErrno.cpp=>common/err/RTErrConvertFromErrno.c \
++    ${PATH_ROOT}/src/VBox/Runtime/common/err/RTErrConvertToErrno.cpp=>common/err/RTErrConvertToErrno.c \
++    ${PATH_ROOT}/src/VBox/Runtime/common/log/log.cpp=>common/log/log.c \
++    ${PATH_ROOT}/src/VBox/Runtime/common/log/logellipsis.cpp=>common/log/logellipsis.c \
++    ${PATH_ROOT}/src/VBox/Runtime/common/log/logrel.cpp=>common/log/logrel.c \
++    ${PATH_ROOT}/src/VBox/Runtime/common/log/logrelellipsis.cpp=>common/log/logrelellipsis.c \
++    ${PATH_ROOT}/src/VBox/Runtime/common/log/logcom.cpp=>common/log/logcom.c \
++    ${PATH_ROOT}/src/VBox/Runtime/common/log/logformat.cpp=>common/log/logformat.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 \
++    ${PATH_ROOT}/src/VBox/Runtime/common/misc/RTAssertMsg2Add.cpp=>common/misc/RTAssertMsg2Add.c \
++    ${PATH_ROOT}/src/VBox/Runtime/common/misc/RTAssertMsg2AddWeak.cpp=>common/misc/RTAssertMsg2AddWeak.c \
++    ${PATH_ROOT}/src/VBox/Runtime/common/misc/RTAssertMsg2AddWeakV.cpp=>common/misc/RTAssertMsg2AddWeakV.c \
++    ${PATH_ROOT}/src/VBox/Runtime/common/misc/RTAssertMsg2Weak.cpp=>common/misc/RTAssertMsg2Weak.c \
++    ${PATH_ROOT}/src/VBox/Runtime/common/misc/RTAssertMsg2WeakV.cpp=>common/misc/RTAssertMsg2WeakV.c \
++    ${PATH_ROOT}/src/VBox/Runtime/common/misc/assert.cpp=>common/misc/assert.c \
++    ${PATH_ROOT}/src/VBox/Runtime/common/misc/handletable.cpp=>common/misc/handletable.c \
++    ${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 \
++    ${PATH_ROOT}/src/VBox/Runtime/common/string/RTStrCopyEx.cpp=>common/string/RTStrCopyEx.c \
++    ${PATH_ROOT}/src/VBox/Runtime/common/string/RTStrNCmp.cpp=>common/string/RTStrNCmp.c \
++    ${PATH_ROOT}/src/VBox/Runtime/common/string/RTStrNLen.cpp=>common/string/RTStrNLen.c \
++    ${PATH_ROOT}/src/VBox/Runtime/common/string/strformat.cpp=>common/string/strformat.c \
++    ${PATH_ROOT}/src/VBox/Runtime/common/string/strformatrt.cpp=>common/string/strformatrt.c \
++    ${PATH_ROOT}/src/VBox/Runtime/common/string/strformattype.cpp=>common/string/strformattype.c \
++    ${PATH_ROOT}/src/VBox/Runtime/common/string/strprintf.cpp=>common/string/strprintf.c \
++    ${PATH_ROOT}/src/VBox/Runtime/common/string/strtonum.cpp=>common/string/strtonum.c \
++    ${PATH_ROOT}/src/VBox/Runtime/common/string/memchr.cpp=>common/string/memchr.c \
++    ${PATH_ROOT}/src/VBox/Runtime/common/string/stringalloc.cpp=>common/string/stringalloc.c \
++    ${PATH_ROOT}/src/VBox/Runtime/common/rand/rand.cpp=>common/rand/rand.c \
++    ${PATH_ROOT}/src/VBox/Runtime/common/rand/randadv.cpp=>common/rand/randadv.c \
++    ${PATH_ROOT}/src/VBox/Runtime/common/rand/randparkmiller.cpp=>common/rand/randparkmiller.c \
++    ${PATH_ROOT}/src/VBox/Runtime/common/path/RTPathStripFilename.cpp=>common/path/RTPathStripFilename.c \
++    ${PATH_ROOT}/src/VBox/Runtime/common/checksum/crc32.cpp=>common/checksum/crc32.c \
++    ${PATH_ROOT}/src/VBox/Runtime/common/checksum/ipv4.cpp=>common/checksum/ipv4.c \
++    ${PATH_ROOT}/src/VBox/Runtime/common/checksum/ipv6.cpp=>common/checksum/ipv6.c \
++    ${PATH_ROOT}/src/VBox/Runtime/common/table/avlpv.cpp=>common/table/avlpv.c \
++    ${PATH_ROOT}/src/VBox/Runtime/common/table/avl_Base.cpp.h=>common/table/avl_Base.cpp.h \
++    ${PATH_ROOT}/src/VBox/Runtime/common/table/avl_Get.cpp.h=>common/table/avl_Get.cpp.h \
++    ${PATH_ROOT}/src/VBox/Runtime/common/table/avl_GetBestFit.cpp.h=>common/table/avl_GetBestFit.cpp.h \
++    ${PATH_ROOT}/src/VBox/Runtime/common/table/avl_RemoveBestFit.cpp.h=>common/table/avl_RemoveBestFit.cpp.h \
++    ${PATH_ROOT}/src/VBox/Runtime/common/table/avl_DoWithAll.cpp.h=>common/table/avl_DoWithAll.cpp.h \
++    ${PATH_ROOT}/src/VBox/Runtime/common/table/avl_Destroy.cpp.h=>common/table/avl_Destroy.cpp.h \
++    ${PATH_ROOT}/src/VBox/Runtime/common/time/time.cpp=>common/time/time.c \
++    ${PATH_ROOT}/src/VBox/Runtime/include/internal/assert.h=>include/internal/assert.h \
++    ${PATH_ROOT}/src/VBox/Runtime/include/internal/initterm.h=>include/internal/initterm.h \
++    ${PATH_ROOT}/src/VBox/Runtime/include/internal/iprt.h=>include/internal/iprt.h \
++    ${PATH_ROOT}/src/VBox/Runtime/include/internal/lockvalidator.h=>include/internal/lockvalidator.h \
++    ${PATH_ROOT}/src/VBox/Runtime/include/internal/magics.h=>include/internal/magics.h \
++    ${PATH_ROOT}/src/VBox/Runtime/include/internal/memobj.h=>include/internal/memobj.h \
++    ${PATH_ROOT}/src/VBox/Runtime/include/internal/string.h=>include/internal/string.h \
++    ${PATH_ROOT}/src/VBox/Runtime/include/internal/thread.h=>include/internal/thread.h \
++    ${PATH_ROOT}/src/VBox/Runtime/include/internal/rand.h=>include/internal/rand.h \
++    ${PATH_ROOT}/src/VBox/Runtime/include/internal/sched.h=>include/internal/sched.h \
++    ${PATH_ROOT}/src/VBox/Runtime/include/internal/process.h=>include/internal/process.h \
++    ${PATH_ROOT}/src/VBox/Runtime/include/internal/time.h=>include/internal/time.h \
++    ${PATH_ROOT}/src/VBox/Runtime/generic/RTAssertShouldPanic-generic.cpp=>generic/RTAssertShouldPanic-generic.c \
++    ${PATH_ROOT}/src/VBox/Runtime/generic/RTLogWriteStdErr-stub-generic.cpp=>generic/RTLogWriteStdErr-stub-generic.c \
++    ${PATH_ROOT}/src/VBox/Runtime/generic/RTLogWriteStdOut-stub-generic.cpp=>generic/RTLogWriteStdOut-stub-generic.c \
++    ${PATH_ROOT}/src/VBox/Runtime/generic/RTLogWriteUser-generic.cpp=>generic/RTLogWriteUser-generic.c \
++    ${PATH_ROOT}/src/VBox/Runtime/generic/RTLogWriteDebugger-generic.cpp=>generic/RTLogWriteDebugger-generic.c \
++    ${PATH_ROOT}/src/VBox/Runtime/generic/RTRandAdvCreateSystemFaster-generic.cpp=>generic/RTRandAdvCreateSystemFaster-generic.c \
++    ${PATH_ROOT}/src/VBox/Runtime/generic/RTRandAdvCreateSystemTruer-generic.cpp=>generic/RTRandAdvCreateSystemTruer-generic.c \
++    ${PATH_ROOT}/src/VBox/Runtime/generic/RTSemEventWait-2-ex-generic.cpp=>generic/RTSemEventWait-2-ex-generic.c \
++    ${PATH_ROOT}/src/VBox/Runtime/generic/RTSemEventWaitNoResume-2-ex-generic.cpp=>generic/RTSemEventWaitNoResume-2-ex-generic.c \
++    ${PATH_ROOT}/src/VBox/Runtime/generic/RTSemEventMultiWait-2-ex-generic.cpp=>generic/RTSemEventMultiWait-2-ex-generic.c \
++    ${PATH_ROOT}/src/VBox/Runtime/generic/RTSemEventMultiWaitNoResume-2-ex-generic.cpp=>generic/RTSemEventMultiWaitNoResume-2-ex-generic.c \
++    ${PATH_ROOT}/src/VBox/Runtime/generic/RTTimerCreate-generic.cpp=>generic/RTTimerCreate-generic.c \
++    ${PATH_ROOT}/src/VBox/Runtime/generic/RTMpGetArraySize-generic.cpp=>generic/RTMpGetArraySize-generic.c \
++    ${PATH_ROOT}/src/VBox/Runtime/generic/RTMpOnPair-generic.cpp=>generic/RTMpOnPair-generic.c \
++    ${PATH_ROOT}/src/VBox/Runtime/generic/errvars-generic.cpp=>generic/errvars-generic.c \
++    ${PATH_ROOT}/src/VBox/Runtime/generic/mppresent-generic.cpp=>generic/mppresent-generic.c \
++    ${PATH_ROOT}/src/VBox/Runtime/generic/timer-generic.cpp=>generic/timer-generic.c \
++    ${PATH_ROOT}/src/VBox/Runtime/generic/uuid-generic.cpp=>generic/uuid-generic.c \
++    ${PATH_ROOT}/src/VBox/Runtime/r0drv/alloc-r0drv.cpp=>r0drv/alloc-r0drv.c \
++    ${PATH_ROOT}/src/VBox/Runtime/r0drv/alloc-r0drv.h=>r0drv/alloc-r0drv.h \
++    ${PATH_ROOT}/src/VBox/Runtime/r0drv/initterm-r0drv.cpp=>r0drv/initterm-r0drv.c \
++    ${PATH_ROOT}/src/VBox/Runtime/r0drv/mp-r0drv.h=>r0drv/mp-r0drv.h \
++    ${PATH_ROOT}/src/VBox/Runtime/r0drv/power-r0drv.h=>r0drv/power-r0drv.h \
++    ${PATH_ROOT}/src/VBox/Runtime/r0drv/powernotification-r0drv.c=>r0drv/powernotification-r0drv.c \
++    ${PATH_ROOT}/src/VBox/Runtime/r0drv/netbsd/assert-r0drv-netbsd.c=>r0drv/netbsd/assert-r0drv-netbsd.c \
++    ${PATH_ROOT}/src/VBox/Runtime/r0drv/netbsd/alloc-r0drv-netbsd.c=>r0drv/netbsd/alloc-r0drv-netbsd.c \
++    ${PATH_ROOT}/src/VBox/Runtime/r0drv/netbsd/initterm-r0drv-netbsd.c=>r0drv/netbsd/initterm-r0drv-netbsd.c \
++    ${PATH_ROOT}/src/VBox/Runtime/r0drv/netbsd/memobj-r0drv-netbsd.c=>r0drv/netbsd/memobj-r0drv-netbsd.c \
++    ${PATH_ROOT}/src/VBox/Runtime/r0drv/netbsd/memuserkernel-r0drv-netbsd.c=>r0drv/netbsd/memuserkernel-r0drv-netbsd.c \
++    ${PATH_ROOT}/src/VBox/Runtime/r0drv/netbsd/mp-r0drv-netbsd.c=>r0drv/netbsd/mp-r0drv-netbsd.c \
++    ${PATH_ROOT}/src/VBox/Runtime/r0drv/netbsd/process-r0drv-netbsd.c=>r0drv/netbsd/process-r0drv-netbsd.c \
++    ${PATH_ROOT}/src/VBox/Runtime/r0drv/netbsd/semevent-r0drv-netbsd.c=>r0drv/netbsd/semevent-r0drv-netbsd.c \
++    ${PATH_ROOT}/src/VBox/Runtime/r0drv/netbsd/semeventmulti-r0drv-netbsd.c=>r0drv/netbsd/semeventmulti-r0drv-netbsd.c \
++    ${PATH_ROOT}/src/VBox/Runtime/r0drv/netbsd/semfastmutex-r0drv-netbsd.c=>r0drv/netbsd/semfastmutex-r0drv-netbsd.c \
++    ${PATH_ROOT}/src/VBox/Runtime/r0drv/netbsd/semmutex-r0drv-netbsd.c=>r0drv/netbsd/semmutex-r0drv-netbsd.c \
++    ${PATH_ROOT}/src/VBox/Runtime/r0drv/netbsd/spinlock-r0drv-netbsd.c=>r0drv/netbsd/spinlock-r0drv-netbsd.c \
++    ${PATH_ROOT}/src/VBox/Runtime/r0drv/netbsd/the-netbsd-kernel.h=>r0drv/netbsd/the-netbsd-kernel.h \
++    ${PATH_ROOT}/src/VBox/Runtime/r0drv/netbsd/thread-r0drv-netbsd.c=>r0drv/netbsd/thread-r0drv-netbsd.c \
++    ${PATH_ROOT}/src/VBox/Runtime/r0drv/netbsd/thread2-r0drv-netbsd.c=>r0drv/netbsd/thread2-r0drv-netbsd.c \
++    ${PATH_ROOT}/src/VBox/Runtime/r0drv/netbsd/time-r0drv-netbsd.c=>r0drv/netbsd/time-r0drv-netbsd.c \
++    ${PATH_ROOT}/src/VBox/Runtime/r0drv/netbsd/sleepqueue-r0drv-netbsd.h=>r0drv/netbsd/sleepqueue-r0drv-netbsd.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 \
++    ${PATH_OUT}/version-generated.h=>version-generated.h \
++    ${PATH_OUT}/product-generated.h=>product-generated.h \
++"
++
++FILES_VBOXDRV_BIN=" \
++"
diff --git a/virtualbox-svn/patches/patch-src_VBox_HostDrivers_VBoxNetAdp_Makefile.kmk b/virtualbox-svn/patches/patch-src_VBox_HostDrivers_VBoxNetAdp_Makefile.kmk
new file mode 100644
index 0000000..2c8eb72
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_HostDrivers_VBoxNetAdp_Makefile.kmk
@@ -0,0 +1,64 @@
+$NetBSD$
+
+--- src/VBox/HostDrivers/VBoxNetAdp/Makefile.kmk.orig	2016-03-04 19:29:26.000000000 +0000
++++ src/VBox/HostDrivers/VBoxNetAdp/Makefile.kmk
+@@ -18,7 +18,7 @@
+ SUB_DEPTH = ../../../..
+ include $(KBUILD_PATH)/subheader.kmk
+ 
+-if1of ($(KBUILD_TARGET), solaris darwin linux freebsd)
++if1of ($(KBUILD_TARGET), solaris darwin linux freebsd netbsd)
+  #
+  # VBoxNetAdp - Virtual Network Adapter
+  # Note! On Solaris the name has to be <= 8 chars long.
+@@ -31,6 +31,7 @@ if1of ($(KBUILD_TARGET), solaris darwin 
+   VBoxNetAdp_NAME.solaris     = vboxnet
+   VBoxNetAdp_NAME.linux       = vboxnetadp
+   VBoxNetAdp_NAME.freebsd     = vboxnetadp
++  VBoxNetAdp_NAME.netbsd      = vboxnetadp
+   VBoxNetAdp_DEPS.solaris    += $(VBOX_SVN_REV_KMK)
+   VBoxNetAdp_DEFS             = IN_RT_R0 VBOX_SVN_REV=$(VBOX_SVN_REV) IN_SUP_STATIC
+   VBoxNetAdp_DEFS.linux       = KBUILD_MODNAME=KBUILD_STR\(vboxnetadp\) KBUILD_BASENAME=KBUILD_STR\(vboxnetadp\) MODULE
+@@ -51,6 +52,9 @@ if1of ($(KBUILD_TARGET), solaris darwin 
+   VBoxNetAdp_SOURCES.freebsd   = \
+   	freebsd/VBoxNetAdp-freebsd.c \
+   	VBoxNetAdp.c
++  VBoxNetAdp_SOURCES.netbsd   = \
++  	freebsd/VBoxNetAdp-netbsd.c \
++  	VBoxNetAdp.c
+   VBoxNetAdp_SOURCES          =
+   #VBoxNetAdp_SOURCES          = \
+   #	VBoxNetAdp.c
+@@ -211,5 +215,31 @@ $$(VBoxNetAdp-src_0_OUTDIR)/Makefile: \
+ 
+ endif # freebsd
+ 
+-include $(FILE_KBUILD_SUB_FOOTER)
++ifeq ($(KBUILD_TARGET),netbsd)
++ #
++ # Install source files for compilation on NetBSD.
++ # files_vboxnetadp defines VBOX_VBOXNETADP_SOURCES.
++ #
++ INSTALLS += VBoxNetAdp-src
++ include $(PATH_SUB_CURRENT)/netbsd/files_vboxnetadp
++ VBoxNetAdp-src_INST = bin/src/vboxnetadp/
++ VBoxNetAdp-src_SOURCES = \
++	$(subst $(DQUOTE),,$(VBOX_VBOXNETADP_SOURCES)) \
++	$(VBoxNetAdp-src_0_OUTDIR)/Makefile
++ VBoxNetAdp-src_CLEAN = \
++	$(VBoxNetAdp-src_0_OUTDIR)/Makefile	\
+ 
++$$(VBoxNetAdp-src_0_OUTDIR)/Makefile: \
++		$(PATH_SUB_CURRENT)/netbsd/Makefile \
++		$$(if $$(eq $$(VBoxNetAdp/netbsd/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 $< $@
++ endif
++
++endif # netbsd
++
++include $(FILE_KBUILD_SUB_FOOTER)
diff --git a/virtualbox-svn/patches/patch-src_VBox_HostDrivers_VBoxNetAdp_VBoxNetAdpInternal.h b/virtualbox-svn/patches/patch-src_VBox_HostDrivers_VBoxNetAdp_VBoxNetAdpInternal.h
new file mode 100644
index 0000000..78ddcfc
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_HostDrivers_VBoxNetAdp_VBoxNetAdpInternal.h
@@ -0,0 +1,21 @@
+$NetBSD$
+
+--- src/VBox/HostDrivers/VBoxNetAdp/VBoxNetAdpInternal.h.orig	2016-03-04 19:29:26.000000000 +0000
++++ src/VBox/HostDrivers/VBoxNetAdp/VBoxNetAdpInternal.h
+@@ -113,6 +113,11 @@ struct VBoxNetAdapter
+              * @{ */
+             struct ifnet *ifp;
+             /** @} */
++# elif defined(RT_OS_NETBSD)
++            /** @name NetBSD instance data.
++             * @{ */
++            struct ifnet *ifp;
++            /** @} */
+ # else
+ # error PORTME
+ # endif
+@@ -178,4 +183,3 @@ DECLHIDDEN(int) vboxNetAdpOsCreate(PVBOX
+ RT_C_DECLS_END
+ 
+ #endif
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_HostDrivers_VBoxNetAdp_netbsd_Makefile b/virtualbox-svn/patches/patch-src_VBox_HostDrivers_VBoxNetAdp_netbsd_Makefile
new file mode 100644
index 0000000..0f9b087
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_HostDrivers_VBoxNetAdp_netbsd_Makefile
@@ -0,0 +1,40 @@
+$NetBSD$
+
+--- src/VBox/HostDrivers/VBoxNetAdp/netbsd/Makefile.orig	2016-07-07 07:08:46.534055230 +0000
++++ src/VBox/HostDrivers/VBoxNetAdp/netbsd/Makefile
+@@ -0,0 +1,35 @@
++#  Makefile $
++## @file
++# Makefile for the VirtualBox NetBSD Host Driver.
++#
++
++#
++#
++# Copyright (C) 2006-2015 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.
++#
++
++KMOD = vboxnetadp
++
++CFLAGS += -DRT_OS_NETBSD -DIN_RING0 -DIN_RT_R0 -DIN_SUP_R0 -DVBOX -DRT_WITH_VBOX -Iinclude -I. -Ir0drv -w -DVBOX_WITH_HARDENING -DVIMAGE
++
++.if (${MACHINE_ARCH} == "i386")
++ CFLAGS += -DRT_ARCH_X86
++.elif (${MACHINE_ARCH} == "amd64")
++ CFLAGS += -DRT_ARCH_AMD64
++.endif
++
++SRCS = \
++	VBoxNetAdp-netbsd.c \
++	VBoxNetAdp.c
++
++SRCS += device_if.h bus_if.h
++
++.include <bsd.kmod.mk>
diff --git a/virtualbox-svn/patches/patch-src_VBox_HostDrivers_VBoxNetAdp_netbsd_VBoxNetAdp-netbsd.c b/virtualbox-svn/patches/patch-src_VBox_HostDrivers_VBoxNetAdp_netbsd_VBoxNetAdp-netbsd.c
new file mode 100644
index 0000000..f3ccfe5
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_HostDrivers_VBoxNetAdp_netbsd_VBoxNetAdp-netbsd.c
@@ -0,0 +1,331 @@
+$NetBSD$
+
+--- src/VBox/HostDrivers/VBoxNetAdp/netbsd/VBoxNetAdp-netbsd.c.orig	2016-07-07 07:08:46.543692306 +0000
++++ src/VBox/HostDrivers/VBoxNetAdp/netbsd/VBoxNetAdp-netbsd.c
+@@ -0,0 +1,326 @@
++/*  VBoxNetAdp-netbsd.c $ */
++/** @file
++ * VBoxNetAdp - Virtual Network Adapter Driver (Host), NetBSD Specific Code.
++ */
++
++/*-
++ * Copyright (c) 2009 Fredrik Lindberg <fli%shapeshifter.se@localhost>
++ *
++ * Permission is hereby granted, free of charge, to any person
++ * obtaining a copy of this software and associated documentation
++ * files (the "Software"), to deal in the Software without
++ * restriction, including without limitation the rights to use,
++ * copy, modify, merge, publish, distribute, sublicense, and/or sell
++ * copies of the Software, and to permit persons to whom the
++ * Software is furnished to do so, subject to the following
++ * conditions:
++ *
++ * The above copyright notice and this permission notice shall be
++ * included in all copies or substantial portions of the Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
++ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
++ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
++ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
++ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
++ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
++ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
++ * OTHER DEALINGS IN THE SOFTWARE.
++ */
++
++
++/*********************************************************************************************************************************
++*   Header Files                                                                                                                 *
++*********************************************************************************************************************************/
++#include <sys/param.h>
++#undef PVM
++#include <sys/types.h>
++#include <sys/module.h>
++#include <sys/systm.h>
++#include <sys/errno.h>
++#include <sys/kernel.h>
++#include <sys/fcntl.h>
++#include <sys/conf.h>
++#include <sys/uio.h>
++#include <sys/socket.h>
++#include <sys/sockio.h>
++
++#include <net/if.h>
++#include <net/if_var.h>
++#include <net/route.h>
++#include <net/if_dl.h>
++#include <net/if_media.h>
++#include <net/if_types.h>
++#include <net/ethernet.h>
++#include <net/bpf.h>
++
++#define LOG_GROUP LOG_GROUP_NET_ADP_DRV
++#include <VBox/version.h>
++#include <VBox/err.h>
++#include <VBox/log.h>
++#include <iprt/initterm.h>
++#include <iprt/string.h>
++#include <iprt/spinlock.h>
++#include <iprt/process.h>
++#include <iprt/assert.h>
++#include <iprt/uuid.h>
++#include <iprt/alloc.h>
++#include <iprt/err.h>
++
++#define VBOXNETADP_OS_SPECFIC 1
++#include "../VBoxNetAdpInternal.h"
++
++# include <sys/jail.h>
++# include <net/vnet.h>
++
++# define VBOXCURVNET_SET(arg)           CURVNET_SET_QUIET(arg)
++# define VBOXCURVNET_SET_FROM_UCRED()   VBOXCURVNET_SET(CRED_TO_VNET(curthread->td_ucred))
++# define VBOXCURVNET_RESTORE()          CURVNET_RESTORE()
++
++static int VBoxNetAdpNetBSDCtrlioctl(struct cdev *, u_long, caddr_t, int flags,
++    struct thread *);
++static struct cdevsw vboxnetadp_cdevsw =
++{
++    .d_version = D_VERSION,
++    .d_ioctl = VBoxNetAdpNetBSDCtrlioctl,
++    .d_read = (d_read_t *)nullop,
++    .d_write = (d_write_t *)nullop,
++    .d_name = VBOXNETADP_CTL_DEV_NAME,
++};
++
++static struct cdev *VBoxNetAdpNetBSDcdev;
++
++static int VBoxNetAdpNetBSDModuleEvent(struct module *, int, void *);
++static moduledata_t g_VBoxNetAdpNetBSDModule = {
++    "vboxnetadp",
++    VBoxNetAdpNetBSDModuleEvent,
++    NULL
++};
++
++/** Declare the module as a pseudo device. */
++DECLARE_MODULE(vboxnetadp, g_VBoxNetAdpNetBSDModule, SI_SUB_PSEUDO, SI_ORDER_ANY);
++MODULE_VERSION(vboxnetadp, 1);
++MODULE_DEPEND(vboxnetadp, vboxdrv, 1, 1, 1);
++MODULE_DEPEND(vboxnetadp, vboxnetflt, 1, 1, 1);
++
++/**
++ * Module event handler
++ */
++static int
++VBoxNetAdpNetBSDModuleEvent(struct module *pMod, int enmEventType, void *pvArg)
++{
++    int rc = 0;
++
++    Log(("VBoxNetAdpNetBSDModuleEvent\n"));
++
++    switch (enmEventType)
++    {
++        case MOD_LOAD:
++            rc = RTR0Init(0);
++            if (RT_FAILURE(rc))
++            {
++                Log(("RTR0Init failed %d\n", rc));
++                return RTErrConvertToErrno(rc);
++            }
++            rc = vboxNetAdpInit();
++            if (RT_FAILURE(rc))
++            {
++                RTR0Term();
++                Log(("vboxNetAdpInit failed %d\n", rc));
++                return RTErrConvertToErrno(rc);
++            }
++            /* Create dev node */
++            VBoxNetAdpNetBSDcdev = make_dev(&vboxnetadp_cdevsw, 0,
++                UID_ROOT, GID_WHEEL, 0600, VBOXNETADP_CTL_DEV_NAME);
++
++            break;
++
++        case MOD_UNLOAD:
++            vboxNetAdpShutdown();
++            destroy_dev(VBoxNetAdpNetBSDcdev);
++            RTR0Term();
++            break;
++        case MOD_SHUTDOWN:
++        case MOD_QUIESCE:
++        default:
++            return EOPNOTSUPP;
++    }
++
++    if (RT_SUCCESS(rc))
++        return 0;
++    return RTErrConvertToErrno(rc);
++}
++
++/**
++ * Device I/O Control entry point.
++ */
++static int
++VBoxNetAdpNetBSDCtrlioctl(struct cdev *dev, u_long iCmd, caddr_t data, int flags, struct thread *td)
++{
++    PVBOXNETADP pAdp;
++    PVBOXNETADPREQ pReq = (PVBOXNETADPREQ)data;
++    struct ifnet *ifp;
++    int rc;
++
++    switch (iCmd)
++    {
++        case VBOXNETADP_CTL_ADD:
++            if (   !(iCmd & IOC_INOUT)   /* paranoia*/
++                || IOCPARM_LEN(iCmd) < sizeof(*pReq))
++                return EINVAL;
++
++            rc = vboxNetAdpCreate(&pAdp,
++                                  pReq->szName[0] && RTStrEnd(pReq->szName, RT_MIN(IOCPARM_LEN(iCmd), sizeof(pReq->szName))) ?
++                                  pReq->szName : NULL);
++            if (RT_FAILURE(rc))
++                return EINVAL;
++
++            strncpy(pReq->szName, pAdp->szName, sizeof(pReq->szName) - 1);
++            pReq->szName[sizeof(pReq->szName) - 1] = '\0';
++            break;
++
++        case VBOXNETADP_CTL_REMOVE:
++            if (!RTStrEnd(pReq->szName, RT_MIN(sizeof(pReq->szName), IOCPARM_LEN(iCmd))))
++                return EINVAL;
++
++            pAdp = vboxNetAdpFindByName(pReq->szName);
++            if (!pAdp)
++                return EINVAL;
++
++            rc = vboxNetAdpDestroy(pAdp);
++            if (RT_FAILURE(rc))
++                return EINVAL;
++
++            break;
++
++        default:
++            return EINVAL;
++    }
++    return 0;
++}
++
++/**
++ * Initialize device, just set the running flag.
++ */
++static void VBoxNetAdpNetBSDNetinit(void *priv)
++{
++    PVBOXNETADP pThis = priv;
++    struct ifnet *ifp = pThis->u.s.ifp;
++
++    ifp->if_drv_flags |= IFF_DRV_RUNNING;
++}
++
++/**
++ * Transmit packets.
++ * netflt has already done everything for us so we just hand the
++ * packets to BPF and increment the packet stats.
++ */
++static void VBoxNetAdpNetBSDNetstart(struct ifnet *ifp)
++{
++    PVBOXNETADP pThis = ifp->if_softc;
++    struct mbuf *m;
++
++    if ((ifp->if_drv_flags & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) != IFF_DRV_RUNNING)
++        return;
++
++    ifp->if_drv_flags |= IFF_DRV_OACTIVE;
++    while (!IFQ_DRV_IS_EMPTY(&ifp->if_snd))
++    {
++        ifp->if_opackets++;
++        IFQ_DRV_DEQUEUE(&ifp->if_snd, m);
++        BPF_MTAP(ifp, m);
++        m_freem(m);
++    }
++    ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
++}
++
++/**
++ * Interface ioctl handling
++ */
++static int VBoxNetAdpNetBSDNetioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
++{
++    int error = 0;
++
++    switch (cmd)
++    {
++        case SIOCSIFFLAGS:
++            if (ifp->if_flags & IFF_UP)
++            {
++                if (!(ifp->if_drv_flags & IFF_DRV_RUNNING))
++                    ifp->if_init(ifp->if_softc);
++            }
++            else
++            {
++                if (ifp->if_drv_flags & IFF_DRV_RUNNING)
++                    ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
++            }
++            break;
++        case SIOCGIFMEDIA:
++        {
++            struct ifmediareq *ifmr;
++            int count;
++
++            ifmr = (struct ifmediareq *)data;
++            count = ifmr->ifm_count;
++            ifmr->ifm_count = 1;
++            ifmr->ifm_status = IFM_AVALID;
++            ifmr->ifm_active = IFM_ETHER;
++            ifmr->ifm_status |= IFM_ACTIVE;
++            ifmr->ifm_current = ifmr->ifm_active;
++            if (count >= 1)
++            {
++                int media = IFM_ETHER;
++                error = copyout(&media, ifmr->ifm_ulist, sizeof(int));
++            }
++            break;
++        }
++        default:
++            return ether_ioctl(ifp, cmd, data);
++    }
++    return error;
++}
++
++int vboxNetAdpOsInit(PVBOXNETADP pThis)
++{
++    pThis->u.s.ifp = NULL;
++    return VINF_SUCCESS;;
++}
++
++int vboxNetAdpOsCreate(PVBOXNETADP pThis, PCRTMAC pMac)
++{
++    struct ifnet *ifp;
++
++    VBOXCURVNET_SET_FROM_UCRED();
++    ifp = if_alloc(IFT_ETHER);
++    if (ifp == NULL)
++        return VERR_NO_MEMORY;
++
++    if_initname(ifp, VBOXNETADP_NAME, pThis->iUnit);
++    ifp->if_softc = pThis;
++    ifp->if_mtu = ETHERMTU;
++    ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
++    ifp->if_ioctl = VBoxNetAdpNetBSDNetioctl;
++    ifp->if_start = VBoxNetAdpNetBSDNetstart;
++    ifp->if_init = VBoxNetAdpNetBSDNetinit;
++    IFQ_SET_MAXLEN(&ifp->if_snd, IFQ_MAXLEN);
++    ifp->if_snd.ifq_drv_maxlen = IFQ_MAXLEN;
++    IFQ_SET_READY(&ifp->if_snd);
++    ether_ifattach(ifp, (void *)pMac);
++    ifp->if_baudrate = 0;
++
++    strncpy(pThis->szName, ifp->if_xname, VBOXNETADP_MAX_NAME_LEN);
++    pThis->u.s.ifp = ifp;
++    VBOXCURVNET_RESTORE();
++    return 0;
++}
++
++void vboxNetAdpOsDestroy(PVBOXNETADP pThis)
++{
++    struct ifnet *ifp;
++
++    ifp = pThis->u.s.ifp;
++    VBOXCURVNET_SET(ifp->if_vnet);
++    ether_ifdetach(ifp);
++    if_free(ifp);
++    VBOXCURVNET_RESTORE();
++}
diff --git a/virtualbox-svn/patches/patch-src_VBox_HostDrivers_VBoxNetAdp_netbsd_files__vboxnetadp b/virtualbox-svn/patches/patch-src_VBox_HostDrivers_VBoxNetAdp_netbsd_files__vboxnetadp
new file mode 100644
index 0000000..48ef684
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_HostDrivers_VBoxNetAdp_netbsd_files__vboxnetadp
@@ -0,0 +1,85 @@
+$NetBSD$
+
+--- src/VBox/HostDrivers/VBoxNetAdp/netbsd/files_vboxnetadp.orig	2016-07-07 07:08:46.553240648 +0000
++++ src/VBox/HostDrivers/VBoxNetAdp/netbsd/files_vboxnetadp
+@@ -0,0 +1,80 @@
++#!/bin/sh
++#  files_vboxnetadp $
++## @file
++# Shared file between Makefile.kmk and export_modules
++#
++
++#
++# Copyright (C) 2007-2015 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.
++#
++
++
++VBOX_VBOXNETADP_SOURCES=" \
++    ${PATH_ROOT}/include/iprt/alloc.h=>include/iprt/alloc.h \
++    ${PATH_ROOT}/include/iprt/alloca.h=>include/iprt/alloca.h \
++    ${PATH_ROOT}/include/iprt/asm.h=>include/iprt/asm.h \
++    ${PATH_ROOT}/include/iprt/asm-amd64-x86.h=>include/iprt/asm-amd64-x86.h \
++    ${PATH_ROOT}/include/iprt/asm-math.h=>include/iprt/asm-math.h \
++    ${PATH_ROOT}/include/iprt/assert.h=>include/iprt/assert.h \
++    ${PATH_ROOT}/include/iprt/avl.h=>include/iprt/avl.h \
++    ${PATH_ROOT}/include/iprt/cdefs.h=>include/iprt/cdefs.h \
++    ${PATH_ROOT}/include/iprt/cpuset.h=>include/iprt/cpuset.h \
++    ${PATH_ROOT}/include/iprt/ctype.h=>include/iprt/ctype.h \
++    ${PATH_ROOT}/include/iprt/err.h=>include/iprt/err.h \
++    ${PATH_ROOT}/include/iprt/heap.h=>include/iprt/heap.h \
++    ${PATH_ROOT}/include/iprt/initterm.h=>include/iprt/initterm.h \
++    ${PATH_ROOT}/include/iprt/latin1.h=>include/iprt/latin1.h \
++    ${PATH_ROOT}/include/iprt/log.h=>include/iprt/log.h \
++    ${PATH_ROOT}/include/iprt/mangling.h=>include/iprt/mangling.h \
++    ${PATH_ROOT}/include/iprt/mem.h=>include/iprt/mem.h \
++    ${PATH_ROOT}/include/iprt/memobj.h=>include/iprt/memobj.h \
++    ${PATH_ROOT}/include/iprt/mp.h=>include/iprt/mp.h \
++    ${PATH_ROOT}/include/iprt/param.h=>include/iprt/param.h \
++    ${PATH_ROOT}/include/iprt/power.h=>include/iprt/power.h \
++    ${PATH_ROOT}/include/iprt/process.h=>include/iprt/process.h \
++    ${PATH_ROOT}/include/iprt/semaphore.h=>include/iprt/semaphore.h \
++    ${PATH_ROOT}/include/iprt/spinlock.h=>include/iprt/spinlock.h \
++    ${PATH_ROOT}/include/iprt/stdarg.h=>include/iprt/stdarg.h \
++    ${PATH_ROOT}/include/iprt/stdint.h=>include/iprt/stdint.h \
++    ${PATH_ROOT}/include/iprt/string.h=>include/iprt/string.h \
++    ${PATH_ROOT}/include/iprt/thread.h=>include/iprt/thread.h \
++    ${PATH_ROOT}/include/iprt/time.h=>include/iprt/time.h \
++    ${PATH_ROOT}/include/iprt/timer.h=>include/iprt/timer.h \
++    ${PATH_ROOT}/include/iprt/types.h=>include/iprt/types.h \
++    ${PATH_ROOT}/include/iprt/uni.h=>include/iprt/uni.h \
++    ${PATH_ROOT}/include/iprt/utf16.h=>include/iprt/utf16.h \
++    ${PATH_ROOT}/include/iprt/uuid.h=>include/iprt/uuid.h \
++    ${PATH_ROOT}/include/iprt/nocrt/limits.h=>include/iprt/nocrt/limits.h \
++    ${PATH_ROOT}/include/VBox/cdefs.h=>include/VBox/cdefs.h \
++    ${PATH_ROOT}/include/VBox/err.h=>include/VBox/err.h \
++    ${PATH_ROOT}/include/VBox/log.h=>include/VBox/log.h \
++    ${PATH_ROOT}/include/VBox/intnet.h=>include/VBox/intnet.h \
++    ${PATH_ROOT}/include/VBox/vmm/stam.h=>include/VBox/vmm/stam.h \
++    ${PATH_ROOT}/include/VBox/sup.h=>include/VBox/sup.h \
++    ${PATH_ROOT}/include/VBox/types.h=>include/VBox/types.h \
++    ${PATH_ROOT}/include/VBox/version.h=>include/VBox/version.h \
++    ${PATH_ROOT}/include/VBox/SUPDrvMangling.h=>include/VBox/SUPDrvMangling.h \
++    ${PATH_ROOT}/src/VBox/HostDrivers/VBoxNetAdp/netbsd/VBoxNetAdp-netbsd.c=>VBoxNetAdp-netbsd.c \
++    ${PATH_ROOT}/src/VBox/HostDrivers/VBoxNetAdp/VBoxNetAdp.c=>VBoxNetAdp.c \
++    ${PATH_ROOT}/src/VBox/HostDrivers/VBoxNetAdp/VBoxNetAdpInternal.h=>VBoxNetAdpInternal.h \
++    ${PATH_ROOT}/src/VBox/Runtime/r0drv/netbsd/the-netbsd-kernel.h=>r0drv/netbsd/the-netbsd-kernel.h \
++    ${PATH_OUT}/version-generated.h=>version-generated.h \
++    ${PATH_OUT}/product-generated.h=>product-generated.h \
++"
diff --git a/virtualbox-svn/patches/patch-src_VBox_HostDrivers_VBoxNetFlt_Makefile.kmk b/virtualbox-svn/patches/patch-src_VBox_HostDrivers_VBoxNetFlt_Makefile.kmk
new file mode 100644
index 0000000..50e2436
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_HostDrivers_VBoxNetFlt_Makefile.kmk
@@ -0,0 +1,54 @@
+$NetBSD$
+
+--- src/VBox/HostDrivers/VBoxNetFlt/Makefile.kmk.orig	2016-07-10 20:59:37.000000000 +0000
++++ src/VBox/HostDrivers/VBoxNetFlt/Makefile.kmk
+@@ -450,7 +450,7 @@ $(PATH_TARGET)/VBoxNetAdpCat.dir/VBoxNet
+ 
+ endif #ifeq ($(KBUILD_TARGET), win)
+ 
+-else if1of ($(KBUILD_TARGET), linux solaris freebsd) ## @todo merge this with the mixed case stuff.
++else if1of ($(KBUILD_TARGET), linux solaris freebsd netbsd) ## @todo merge this with the mixed case stuff.
+ #
+ # vboxnetflt(.ko/.o/) - The lower case driver.
+ # Note! On Solaris the name has to be <= 8 chars long.
+@@ -569,5 +569,39 @@ $(PATH_OUT)/opt_netgraph.h:
+  endif
+ endif # freebsd
+ 
+-include $(FILE_KBUILD_SUB_FOOTER)
++## @todo Properly generate opt_netgraph.h
++ifeq ($(KBUILD_TARGET),netbsd)
++ vboxnetflt_DEPS.netbsd += $(PATH_OUT)/opt_netgraph.h
++$(PATH_OUT)/opt_netgraph.h:
++	echo > $(PATH_OUT)/opt_netgraph.h
++
++ #
++ # Install source files for compilation on NetBSD.
++ # files_vboxnetflt defines VBOX_VBOXNETFLT_SOURCES.
++ #
++ include $(PATH_SUB_CURRENT)/netbsd/files_vboxnetflt
++ INSTALLS += VBoxNetFlt-src
++ VBoxNetFlt-src_INST    = bin/src/vboxnetflt/
++ VBoxNetFlt-src_SOURCES = \
++	$(subst $(DQUOTE),,$(VBOX_VBOXNETFLT_SOURCES)) \
++ 	$(VBoxNetFlt-src_0_OUTDIR)/Makefile
++ VBoxNetFlt-src_CLEAN   = \
++ 	$(VBoxNetFlt-src_0_OUTDIR)/Makefile	\
+ 
++ $$(VBoxNetFlt-src_0_OUTDIR)/Makefile: \
++		$(PATH_SUB_CURRENT)/netbsd/Makefile \
++		$$(if $$(eq $$(VBoxNetFlt/netbsd/Makefile_VBOX_HARDENED),$$(VBOX_WITH_HARDENING)),,FORCE) \
++		| $$(dir $$@)
++	$(QUIET)$(RM) -f -- $@
++	$(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 # netbsd
++
++include $(FILE_KBUILD_SUB_FOOTER)
diff --git a/virtualbox-svn/patches/patch-src_VBox_HostDrivers_VBoxNetFlt_VBoxNetFltInternal.h b/virtualbox-svn/patches/patch-src_VBox_HostDrivers_VBoxNetFlt_VBoxNetFltInternal.h
new file mode 100644
index 0000000..2e55e6f
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_HostDrivers_VBoxNetFlt_VBoxNetFltInternal.h
@@ -0,0 +1,40 @@
+$NetBSD$
+
+--- src/VBox/HostDrivers/VBoxNetFlt/VBoxNetFltInternal.h.orig	2016-03-04 19:29:26.000000000 +0000
++++ src/VBox/HostDrivers/VBoxNetFlt/VBoxNetFltInternal.h
+@@ -244,6 +244,30 @@ typedef struct VBOXNETFLTINS
+             /** The MAC address of the interface. */
+             RTMAC MacAddr;
+             /** @} */
++# elif defined(RT_OS_NETBSD)
++            /** @name NetBSD instance data.
++             * @{ */
++            /** Interface handle */
++            struct ifnet *ifp;
++            /** Netgraph node handle */
++            node_p node;
++            /** Input hook */
++            hook_p input;
++            /** Output hook */
++            hook_p output;
++            /** Original interface flags */
++            unsigned int flags;
++            /** Input queue */
++            struct ifqueue inq;
++            /** Output queue */
++            struct ifqueue outq;
++            /** Input task */
++            struct task tskin;
++            /** Output task */
++            struct task tskout;
++            /** The MAC address of the interface. */
++            RTMAC MacAddr;
++            /** @} */
+ # elif defined(RT_OS_WINDOWS)
+             /** @name Windows instance data.
+              * @{ */
+@@ -475,4 +499,3 @@ DECLHIDDEN(int) vboxNetFltOsPreInitInsta
+ RT_C_DECLS_END
+ 
+ #endif
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_HostDrivers_VBoxNetFlt_netbsd_Makefile b/virtualbox-svn/patches/patch-src_VBox_HostDrivers_VBoxNetFlt_netbsd_Makefile
new file mode 100644
index 0000000..ee187e5
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_HostDrivers_VBoxNetFlt_netbsd_Makefile
@@ -0,0 +1,43 @@
+$NetBSD$
+
+--- src/VBox/HostDrivers/VBoxNetFlt/netbsd/Makefile.orig	2016-07-07 07:08:46.562307341 +0000
++++ src/VBox/HostDrivers/VBoxNetFlt/netbsd/Makefile
+@@ -0,0 +1,38 @@
++#  Makefile $
++## @file
++# Makefile for the VirtualBox NetBSD Host Driver.
++#
++
++#
++#
++# Copyright (C) 2006-2015 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.
++#
++
++KMOD = vboxnetflt
++
++CFLAGS += -DRT_OS_NETBSD -DIN_RING0 -DIN_RT_R0 -DIN_SUP_R0 -DVBOX -DRT_WITH_VBOX -Iinclude -I. -Ir0drv -w -DVBOX_WITH_HARDENING -DVIMAGE
++
++.if (${MACHINE_ARCH} == "i386")
++ CFLAGS += -DRT_ARCH_X86
++.elif (${MACHINE_ARCH} == "amd64")
++ CFLAGS += -DRT_ARCH_AMD64
++.endif
++
++SRCS = \
++	VBoxNetFlt-netbsd.c \
++	VBoxNetFlt.c \
++	SUPR0IdcClient-netbsd.c \
++	SUPR0IdcClient.c \
++	SUPR0IdcClientComponent.c
++
++SRCS += device_if.h bus_if.h opt_netgraph.h
++
++.include <bsd.kmod.mk>
diff --git a/virtualbox-svn/patches/patch-src_VBox_HostDrivers_VBoxNetFlt_netbsd_VBoxNetFlt-netbsd.c b/virtualbox-svn/patches/patch-src_VBox_HostDrivers_VBoxNetFlt_netbsd_VBoxNetFlt-netbsd.c
new file mode 100644
index 0000000..390e545
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_HostDrivers_VBoxNetFlt_netbsd_VBoxNetFlt-netbsd.c
@@ -0,0 +1,802 @@
+$NetBSD$
+
+--- src/VBox/HostDrivers/VBoxNetFlt/netbsd/VBoxNetFlt-netbsd.c.orig	2016-07-07 07:08:46.572066003 +0000
++++ src/VBox/HostDrivers/VBoxNetFlt/netbsd/VBoxNetFlt-netbsd.c
+@@ -0,0 +1,797 @@
++/*  VBoxNetFlt-netbsd.c $ */
++/** @file
++ * VBoxNetFlt - Network Filter Driver (Host), NetBSD Specific Code.
++ */
++
++/*
++ * Copyright (c) 2009 Fredrik Lindberg <fli%shapeshifter.se@localhost>
++ *
++ * Permission is hereby granted, free of charge, to any person
++ * obtaining a copy of this software and associated documentation
++ * files (the "Software"), to deal in the Software without
++ * restriction, including without limitation the rights to use,
++ * copy, modify, merge, publish, distribute, sublicense, and/or sell
++ * copies of the Software, and to permit persons to whom the
++ * Software is furnished to do so, subject to the following
++ * conditions:
++ *
++ * The above copyright notice and this permission notice shall be
++ * included in all copies or substantial portions of the Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
++ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
++ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
++ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
++ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
++ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
++ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
++ * OTHER DEALINGS IN THE SOFTWARE.
++ */
++
++
++/*********************************************************************************************************************************
++*   Header Files                                                                                                                 *
++*********************************************************************************************************************************/
++#include <sys/param.h>
++#undef PVM
++#include <sys/types.h>
++#include <sys/module.h>
++#include <sys/systm.h>
++#include <sys/errno.h>
++#include <sys/kernel.h>
++#include <sys/fcntl.h>
++#include <sys/conf.h>
++#include <sys/socket.h>
++#include <sys/sockio.h>
++#include <sys/syscallsubr.h>
++#include <sys/queue.h>
++#include <sys/taskqueue.h>
++
++#include <net/if.h>
++#include <net/if_var.h>
++#include <net/if_dl.h>
++#include <net/if_types.h>
++#include <net/ethernet.h>
++
++#include <netgraph/ng_message.h>
++#include <netgraph/netgraph.h>
++#include <netgraph/ng_parse.h>
++
++#define LOG_GROUP LOG_GROUP_NET_FLT_DRV
++#include <VBox/version.h>
++#include <VBox/err.h>
++#include <VBox/log.h>
++#include <VBox/intnetinline.h>
++#include <iprt/initterm.h>
++#include <iprt/string.h>
++#include <iprt/spinlock.h>
++#include <iprt/process.h>
++#include <iprt/assert.h>
++#include <iprt/uuid.h>
++#include <iprt/alloc.h>
++#include <iprt/err.h>
++
++#define VBOXNETFLT_OS_SPECFIC 1
++#include "../VBoxNetFltInternal.h"
++
++static int vboxnetflt_modevent(struct module *, int, void *);
++static ng_constructor_t    ng_vboxnetflt_constructor;
++static ng_rcvmsg_t    ng_vboxnetflt_rcvmsg;
++static ng_shutdown_t    ng_vboxnetflt_shutdown;
++static ng_newhook_t    ng_vboxnetflt_newhook;
++static ng_rcvdata_t    ng_vboxnetflt_rcvdata;
++static ng_disconnect_t    ng_vboxnetflt_disconnect;
++static int        ng_vboxnetflt_mod_event(module_t mod, int event, void *data);
++
++/** Netgraph node type */
++#define NG_VBOXNETFLT_NODE_TYPE     "vboxnetflt"
++/** Netgraph message cookie */
++#define NGM_VBOXNETFLT_COOKIE       0x56424f58
++
++/** Input netgraph hook name */
++#define NG_VBOXNETFLT_HOOK_IN       "input"
++/** Output netgraph hook name */
++#define NG_VBOXNETFLT_HOOK_OUT      "output"
++
++/** mbuf tag identifier */
++#define MTAG_VBOX                   0x56424f58
++/** mbuf packet tag */
++#define PACKET_TAG_VBOX             128
++
++# include <sys/jail.h>
++# include <net/vnet.h>
++
++# define VBOXCURVNET_SET(arg)           CURVNET_SET_QUIET(arg)
++# define VBOXCURVNET_SET_FROM_UCRED()   VBOXCURVNET_SET(CRED_TO_VNET(curthread->td_ucred))
++# define VBOXCURVNET_RESTORE()          CURVNET_RESTORE()
++
++/*
++ * Netgraph command list, we don't support any
++ * additional commands.
++ */
++static const struct ng_cmdlist ng_vboxnetflt_cmdlist[] =
++{
++    { 0 }
++};
++
++/*
++ * Netgraph type definition
++ */
++static struct ng_type ng_vboxnetflt_typestruct =
++{
++    .version    = NG_ABI_VERSION,
++    .name       = NG_VBOXNETFLT_NODE_TYPE,
++    .mod_event  = vboxnetflt_modevent,
++    .constructor= ng_vboxnetflt_constructor,
++    .rcvmsg     = ng_vboxnetflt_rcvmsg,
++    .shutdown   = ng_vboxnetflt_shutdown,
++    .newhook    = ng_vboxnetflt_newhook,
++    .rcvdata    = ng_vboxnetflt_rcvdata,
++    .disconnect = ng_vboxnetflt_disconnect,
++    .cmdlist    = ng_vboxnetflt_cmdlist,
++};
++NETGRAPH_INIT(vboxnetflt, &ng_vboxnetflt_typestruct);
++
++/*
++ * Use vboxnetflt because the kernel module is named vboxnetflt and vboxnetadp
++ * depends on this when loading dependencies.
++ * NETGRAP_INIT will prefix the given name with ng_ so MODULE_DEPEND needs the
++ * prefixed name.
++ */
++MODULE_VERSION(vboxnetflt, 1);
++MODULE_DEPEND(ng_vboxnetflt, vboxdrv, 1, 1, 1);
++
++/**
++ * The (common) global data.
++ */
++static VBOXNETFLTGLOBALS g_VBoxNetFltGlobals;
++
++/**
++ * Module event handler, called from netgraph subsystem.
++ */
++static int vboxnetflt_modevent(struct module *pMod, int enmEventType, void *pvArg)
++{
++    int rc;
++
++    Log(("VBoxNetFltNetBSDModuleEvent\n"));
++
++    switch (enmEventType)
++    {
++        case MOD_LOAD:
++            rc = RTR0Init(0);
++            if (RT_FAILURE(rc))
++            {
++                printf("RTR0Init failed %d\n", rc);
++                return RTErrConvertToErrno(rc);
++            }
++
++            memset(&g_VBoxNetFltGlobals, 0, sizeof(VBOXNETFLTGLOBALS));
++            rc = vboxNetFltInitGlobalsAndIdc(&g_VBoxNetFltGlobals);
++            if (RT_FAILURE(rc))
++            {
++                printf("vboxNetFltInitGlobalsAndIdc failed %d\n", rc);
++                return RTErrConvertToErrno(rc);
++            }
++            /* No MODULE_VERSION in ng_ether so we can't MODULE_DEPEND it */
++            kern_kldload(curthread, "ng_ether", NULL);
++            break;
++
++        case MOD_UNLOAD:
++            rc = vboxNetFltTryDeleteIdcAndGlobals(&g_VBoxNetFltGlobals);
++            memset(&g_VBoxNetFltGlobals, 0, sizeof(VBOXNETFLTGLOBALS));
++            RTR0Term();
++            break;
++
++        case MOD_SHUTDOWN:
++        case MOD_QUIESCE:
++        default:
++            return EOPNOTSUPP;
++    }
++
++    if (RT_SUCCESS(rc))
++        return 0;
++    return RTErrConvertToErrno(rc);
++}
++
++/*
++ * Convert from mbufs to vbox scatter-gather data structure
++ */
++static void vboxNetFltNetBSDMBufToSG(PVBOXNETFLTINS pThis, struct mbuf *m, PINTNETSG pSG,
++    unsigned int cSegs, unsigned int segOffset)
++{
++    static uint8_t const s_abZero[128] = {0};
++    unsigned int i;
++    struct mbuf *m0;
++
++    IntNetSgInitTempSegs(pSG, m_length(m, NULL), cSegs, 0 /*cSegsUsed*/);
++
++    for (m0 = m, i = segOffset; m0; m0 = m0->m_next)
++    {
++        if (m0->m_len == 0)
++            continue;
++
++        pSG->aSegs[i].cb = m0->m_len;
++        pSG->aSegs[i].pv = mtod(m0, uint8_t *);
++        pSG->aSegs[i].Phys = NIL_RTHCPHYS;
++        i++;
++    }
++
++#ifdef PADD_RUNT_FRAMES_FROM_HOST
++    if (pSG->cbTotal < 60)
++    {
++        pSG->aSegs[i].Phys = NIL_RTHCPHYS;
++        pSG->aSegs[i].pv = (void *)&s_abZero[0];
++        pSG->aSegs[i].cb = 60 - pSG->cbTotal;
++        pSG->cbTotal = 60;
++        i++;
++    }
++#endif
++
++    pSG->cSegsUsed = i;
++}
++
++/*
++ * Convert to mbufs from vbox scatter-gather data structure
++ */
++static struct mbuf * vboxNetFltNetBSDSGMBufFromSG(PVBOXNETFLTINS pThis, PINTNETSG pSG)
++{
++    struct mbuf *m;
++    int error;
++    unsigned int i;
++
++    if (pSG->cbTotal == 0)
++        return (NULL);
++
++    m = m_getcl(M_WAITOK, MT_DATA, M_PKTHDR);
++    if (m == NULL)
++        return (NULL);
++
++    m->m_pkthdr.len = m->m_len = 0;
++    m->m_pkthdr.rcvif = NULL;
++
++    for (i = 0; i < pSG->cSegsUsed; i++)
++    {
++        error = m_append(m, pSG->aSegs[i].cb, pSG->aSegs[i].pv);
++        if (error == 0)
++        {
++            m_freem(m);
++            return (NULL);
++        }
++    }
++    return (m);
++}
++
++
++static int ng_vboxnetflt_constructor(node_p node)
++{
++    /* Nothing to do */
++    return (EINVAL);
++}
++
++/*
++ * Setup netgraph hooks
++ */
++static int ng_vboxnetflt_newhook(node_p node, hook_p hook, const char *name)
++{
++    PVBOXNETFLTINS pThis = NG_NODE_PRIVATE(node);
++
++    if (strcmp(name, NG_VBOXNETFLT_HOOK_IN) == 0)
++    {
++        NG_HOOK_SET_TO_INBOUND(hook);
++        pThis->u.s.input = hook;
++    }
++    else if (strcmp(name, NG_VBOXNETFLT_HOOK_OUT) == 0)
++    {
++        pThis->u.s.output = hook;
++    }
++    else
++        return (EINVAL);
++
++    NG_HOOK_HI_STACK(hook);
++    return (0);
++}
++
++/**
++ * Netgraph message processing for node specific messages.
++ * We don't accept any special messages so this is not used.
++ */
++static int ng_vboxnetflt_rcvmsg(node_p node, item_p item, hook_p lasthook)
++{
++    PVBOXNETFLTINS pThis = NG_NODE_PRIVATE(node);
++    struct ng_mesg *msg;
++    int error = 0;
++
++    NGI_GET_MSG(item, msg);
++    if (msg->header.typecookie != NGM_VBOXNETFLT_COOKIE)
++        return (EINVAL);
++
++    switch (msg->header.cmd)
++    {
++        default:
++            error = EINVAL;
++    }
++    return (error);
++}
++
++/**
++ * Handle data on netgraph hooks.
++ * Frames processing is deferred to a taskqueue because this might
++ * be called with non-sleepable locks held and code paths inside
++ * the virtual switch might sleep.
++ */
++static int ng_vboxnetflt_rcvdata(hook_p hook, item_p item)
++{
++    const node_p node = NG_HOOK_NODE(hook);
++    PVBOXNETFLTINS pThis = NG_NODE_PRIVATE(node);
++    struct ifnet *ifp = pThis->u.s.ifp;
++    struct mbuf *m;
++    struct m_tag *mtag;
++    bool fActive;
++
++    VBOXCURVNET_SET(ifp->if_vnet);
++    fActive = vboxNetFltTryRetainBusyActive(pThis);
++
++    NGI_GET_M(item, m);
++    NG_FREE_ITEM(item);
++
++    /* Locate tag to see if processing should be skipped for this frame */
++    mtag = m_tag_locate(m, MTAG_VBOX, PACKET_TAG_VBOX, NULL);
++    if (mtag != NULL)
++    {
++        m_tag_unlink(m, mtag);
++        m_tag_free(mtag);
++    }
++
++    /*
++     * Handle incoming hook. This is connected to the
++     * input path of the interface, thus handling incoming frames.
++     */
++    if (pThis->u.s.input == hook)
++    {
++        if (mtag != NULL || !fActive)
++        {
++            ether_demux(ifp, m);
++            if (fActive)
++                vboxNetFltRelease(pThis, true /*fBusy*/);
++            VBOXCURVNET_RESTORE();
++            return (0);
++        }
++        mtx_lock_spin(&pThis->u.s.inq.ifq_mtx);
++        _IF_ENQUEUE(&pThis->u.s.inq, m);
++        mtx_unlock_spin(&pThis->u.s.inq.ifq_mtx);
++        taskqueue_enqueue_fast(taskqueue_fast, &pThis->u.s.tskin);
++    }
++    /*
++     * Handle mbufs on the outgoing hook, frames going to the interface
++     */
++    else if (pThis->u.s.output == hook)
++    {
++        if (mtag != NULL || !fActive)
++        {
++            int rc = ether_output_frame(ifp, m);
++            if (fActive)
++                vboxNetFltRelease(pThis, true /*fBusy*/);
++            VBOXCURVNET_RESTORE();
++            return rc;
++        }
++        mtx_lock_spin(&pThis->u.s.outq.ifq_mtx);
++        _IF_ENQUEUE(&pThis->u.s.outq, m);
++        mtx_unlock_spin(&pThis->u.s.outq.ifq_mtx);
++        taskqueue_enqueue_fast(taskqueue_fast, &pThis->u.s.tskout);
++    }
++    else
++    {
++        m_freem(m);
++    }
++
++    if (fActive)
++        vboxNetFltRelease(pThis, true /*fBusy*/);
++    VBOXCURVNET_RESTORE();
++    return (0);
++}
++
++static int ng_vboxnetflt_shutdown(node_p node)
++{
++    PVBOXNETFLTINS pThis = NG_NODE_PRIVATE(node);
++    bool fActive;
++
++    /* Prevent node shutdown if we're active */
++    if (pThis->enmTrunkState == INTNETTRUNKIFSTATE_ACTIVE)
++        return (EBUSY);
++    NG_NODE_UNREF(node);
++    return (0);
++}
++
++static int ng_vboxnetflt_disconnect(hook_p hook)
++{
++    return (0);
++}
++
++/**
++ * Input processing task, handles incoming frames
++ */
++static void vboxNetFltNetBSDinput(void *arg, int pending)
++{
++    PVBOXNETFLTINS pThis = (PVBOXNETFLTINS)arg;
++    struct mbuf *m, *m0;
++    struct ifnet *ifp = pThis->u.s.ifp;
++    unsigned int cSegs = 0;
++    bool fDropIt = false, fActive;
++    PINTNETSG pSG;
++
++    VBOXCURVNET_SET(ifp->if_vnet);
++    vboxNetFltRetain(pThis, true /* fBusy */);
++    for (;;)
++    {
++        mtx_lock_spin(&pThis->u.s.inq.ifq_mtx);
++        _IF_DEQUEUE(&pThis->u.s.inq, m);
++        mtx_unlock_spin(&pThis->u.s.inq.ifq_mtx);
++        if (m == NULL)
++            break;
++
++        for (m0 = m; m0 != NULL; m0 = m0->m_next)
++            if (m0->m_len > 0)
++                cSegs++;
++
++#ifdef PADD_RUNT_FRAMES_FROM_HOST
++        if (m_length(m, NULL) < 60)
++            cSegs++;
++#endif
++
++        /* Create a copy and deliver to the virtual switch */
++        pSG = RTMemTmpAlloc(RT_OFFSETOF(INTNETSG, aSegs[cSegs]));
++        vboxNetFltNetBSDMBufToSG(pThis, m, pSG, cSegs, 0);
++        fDropIt = pThis->pSwitchPort->pfnRecv(pThis->pSwitchPort, NULL /* pvIf */, pSG, INTNETTRUNKDIR_WIRE);
++        RTMemTmpFree(pSG);
++        if (fDropIt)
++            m_freem(m);
++        else
++            ether_demux(ifp, m);
++    }
++    vboxNetFltRelease(pThis, true /* fBusy */);
++    VBOXCURVNET_RESTORE();
++}
++
++/**
++ * Output processing task, handles outgoing frames
++ */
++static void vboxNetFltNetBSDoutput(void *arg, int pending)
++{
++    PVBOXNETFLTINS pThis = (PVBOXNETFLTINS)arg;
++    struct mbuf *m, *m0;
++    struct ifnet *ifp = pThis->u.s.ifp;
++    unsigned int cSegs = 0;
++    bool fDropIt = false, fActive;
++    PINTNETSG pSG;
++
++    VBOXCURVNET_SET(ifp->if_vnet);
++    vboxNetFltRetain(pThis, true /* fBusy */);
++    for (;;)
++    {
++        mtx_lock_spin(&pThis->u.s.outq.ifq_mtx);
++        _IF_DEQUEUE(&pThis->u.s.outq, m);
++        mtx_unlock_spin(&pThis->u.s.outq.ifq_mtx);
++        if (m == NULL)
++            break;
++
++        for (m0 = m; m0 != NULL; m0 = m0->m_next)
++            if (m0->m_len > 0)
++                cSegs++;
++
++#ifdef PADD_RUNT_FRAMES_FROM_HOST
++        if (m_length(m, NULL) < 60)
++            cSegs++;
++#endif
++        /* Create a copy and deliver to the virtual switch */
++        pSG = RTMemTmpAlloc(RT_OFFSETOF(INTNETSG, aSegs[cSegs]));
++        vboxNetFltNetBSDMBufToSG(pThis, m, pSG, cSegs, 0);
++        fDropIt = pThis->pSwitchPort->pfnRecv(pThis->pSwitchPort, NULL /* pvIf */, pSG, INTNETTRUNKDIR_HOST);
++        RTMemTmpFree(pSG);
++
++        if (fDropIt)
++            m_freem(m);
++        else
++            ether_output_frame(ifp, m);
++    }
++    vboxNetFltRelease(pThis, true /* fBusy */);
++    VBOXCURVNET_RESTORE();
++}
++
++/**
++ * Called to deliver a frame to either the host, the wire or both.
++ */
++int vboxNetFltPortOsXmit(PVBOXNETFLTINS pThis, void *pvIfData, PINTNETSG pSG, uint32_t fDst)
++{
++    NOREF(pvIfData);
++
++    void (*input_f)(struct ifnet *, struct mbuf *);
++    struct ifnet *ifp;
++    struct mbuf *m;
++    struct m_tag *mtag;
++    bool fActive;
++    int error;
++
++    ifp = ASMAtomicUoReadPtrT(&pThis->u.s.ifp, struct ifnet *);
++    VBOXCURVNET_SET(ifp->if_vnet);
++
++    if (fDst & INTNETTRUNKDIR_WIRE)
++    {
++        m = vboxNetFltNetBSDSGMBufFromSG(pThis, pSG);
++        if (m == NULL)
++            return VERR_NO_MEMORY;
++        m = m_pullup(m, ETHER_HDR_LEN);
++        if (m == NULL)
++            return VERR_NO_MEMORY;
++
++        m->m_flags |= M_PKTHDR;
++        ether_output_frame(ifp, m);
++    }
++
++    if (fDst & INTNETTRUNKDIR_HOST)
++    {
++        m = vboxNetFltNetBSDSGMBufFromSG(pThis, pSG);
++        if (m == NULL)
++            return VERR_NO_MEMORY;
++        m = m_pullup(m, ETHER_HDR_LEN);
++        if (m == NULL)
++            return VERR_NO_MEMORY;
++        /*
++         * Delivering packets to the host will be captured by the
++         * input hook. Tag the packet with a mbuf tag so that we
++         * can skip re-delivery of the packet to the guest during
++         * input hook processing.
++         */
++        mtag = m_tag_alloc(MTAG_VBOX, PACKET_TAG_VBOX, 0, M_NOWAIT);
++        if (mtag == NULL)
++        {
++            m_freem(m);
++            return VERR_NO_MEMORY;
++        }
++
++        m_tag_init(m);
++        m_tag_prepend(m, mtag);
++        m->m_flags |= M_PKTHDR;
++        m->m_pkthdr.rcvif = ifp;
++        ifp->if_input(ifp, m);
++    }
++    VBOXCURVNET_RESTORE();
++    return VINF_SUCCESS;
++}
++
++static bool vboxNetFltNetBsdIsPromiscuous(PVBOXNETFLTINS pThis)
++{
++    /** @todo This isn't taking into account that we put the interface in
++     *        promiscuous mode.  */
++    return (pThis->u.s.flags & IFF_PROMISC) ? true : false;
++}
++
++int vboxNetFltOsInitInstance(PVBOXNETFLTINS pThis, void *pvContext)
++{
++    char nam[NG_NODESIZ];
++    struct ifnet *ifp;
++    node_p node;
++
++    VBOXCURVNET_SET_FROM_UCRED();
++    NOREF(pvContext);
++    ifp = ifunit(pThis->szName);
++    if (ifp == NULL)
++        return VERR_INTNET_FLT_IF_NOT_FOUND;
++
++    /* Create a new netgraph node for this instance */
++    if (ng_make_node_common(&ng_vboxnetflt_typestruct, &node) != 0)
++        return VERR_INTERNAL_ERROR;
++
++    RTSpinlockAcquire(pThis->hSpinlock);
++
++    ASMAtomicUoWritePtr(&pThis->u.s.ifp, ifp);
++    pThis->u.s.node = node;
++    bcopy(IF_LLADDR(ifp), &pThis->u.s.MacAddr, ETHER_ADDR_LEN);
++    ASMAtomicUoWriteBool(&pThis->fDisconnectedFromHost, false);
++
++    /* Initialize deferred input queue */
++    bzero(&pThis->u.s.inq, sizeof(struct ifqueue));
++    mtx_init(&pThis->u.s.inq.ifq_mtx, "vboxnetflt inq", NULL, MTX_SPIN);
++    TASK_INIT(&pThis->u.s.tskin, 0, vboxNetFltNetBSDinput, pThis);
++
++    /* Initialize deferred output queue */
++    bzero(&pThis->u.s.outq, sizeof(struct ifqueue));
++    mtx_init(&pThis->u.s.outq.ifq_mtx, "vboxnetflt outq", NULL, MTX_SPIN);
++    TASK_INIT(&pThis->u.s.tskout, 0, vboxNetFltNetBSDoutput, pThis);
++
++    RTSpinlockRelease(pThis->hSpinlock);
++
++    NG_NODE_SET_PRIVATE(node, pThis);
++
++    /* Attempt to name it vboxnetflt_<ifname> */
++    snprintf(nam, NG_NODESIZ, "vboxnetflt_%s", pThis->szName);
++    ng_name_node(node, nam);
++
++    /* Report MAC address, promiscuous mode and GSO capabilities. */
++    /** @todo keep these reports up to date, either by polling for changes or
++     *        intercept some control flow if possible. */
++    if (vboxNetFltTryRetainBusyNotDisconnected(pThis))
++    {
++        Assert(pThis->pSwitchPort);
++        pThis->pSwitchPort->pfnReportMacAddress(pThis->pSwitchPort, &pThis->u.s.MacAddr);
++        pThis->pSwitchPort->pfnReportPromiscuousMode(pThis->pSwitchPort, vboxNetFltNetBsdIsPromiscuous(pThis));
++        pThis->pSwitchPort->pfnReportGsoCapabilities(pThis->pSwitchPort, 0, INTNETTRUNKDIR_WIRE | INTNETTRUNKDIR_HOST);
++        pThis->pSwitchPort->pfnReportNoPreemptDsts(pThis->pSwitchPort, 0 /* none */);
++        vboxNetFltRelease(pThis, true /*fBusy*/);
++    }
++    VBOXCURVNET_RESTORE();
++
++    return VINF_SUCCESS;
++}
++
++bool vboxNetFltOsMaybeRediscovered(PVBOXNETFLTINS pThis)
++{
++    struct ifnet *ifp, *ifp0;
++
++    ifp = ASMAtomicUoReadPtrT(&pThis->u.s.ifp, struct ifnet *);
++    VBOXCURVNET_SET(ifp->if_vnet);
++    /*
++     * Attempt to check if the interface is still there and re-initialize if
++     * something has changed.
++     */
++    ifp0 = ifunit(pThis->szName);
++    if (ifp != ifp0)
++    {
++        ASMAtomicUoWriteBool(&pThis->fDisconnectedFromHost, true);
++        ng_rmnode_self(pThis->u.s.node);
++        pThis->u.s.node = NULL;
++    }
++    VBOXCURVNET_RESTORE();
++
++    if (ifp0 != NULL)
++    {
++        vboxNetFltOsDeleteInstance(pThis);
++        vboxNetFltOsInitInstance(pThis, NULL);
++    }
++
++    return !ASMAtomicUoReadBool(&pThis->fDisconnectedFromHost);
++}
++
++void vboxNetFltOsDeleteInstance(PVBOXNETFLTINS pThis)
++{
++
++    taskqueue_drain(taskqueue_fast, &pThis->u.s.tskin);
++    taskqueue_drain(taskqueue_fast, &pThis->u.s.tskout);
++
++    mtx_destroy(&pThis->u.s.inq.ifq_mtx);
++    mtx_destroy(&pThis->u.s.outq.ifq_mtx);
++
++    VBOXCURVNET_SET_FROM_UCRED();
++    if (pThis->u.s.node != NULL)
++        ng_rmnode_self(pThis->u.s.node);
++    VBOXCURVNET_RESTORE();
++    pThis->u.s.node = NULL;
++}
++
++int vboxNetFltOsPreInitInstance(PVBOXNETFLTINS pThis)
++{
++
++    pThis->u.s.ifp = NULL;
++    pThis->u.s.flags = 0;
++    pThis->u.s.node = NULL;
++    return VINF_SUCCESS;
++}
++
++void vboxNetFltPortOsSetActive(PVBOXNETFLTINS pThis, bool fActive)
++{
++    struct ifnet *ifp;
++    struct ifreq ifreq;
++    int error;
++    node_p node;
++    struct ng_mesg *msg;
++    struct ngm_connect *con;
++    struct ngm_rmhook *rm;
++    char path[NG_PATHSIZ];
++
++    Log(("%s: fActive:%d\n", __func__, fActive));
++
++    ifp = ASMAtomicUoReadPtrT(&pThis->u.s.ifp, struct ifnet *);
++    VBOXCURVNET_SET(ifp->if_vnet);
++    node = ASMAtomicUoReadPtrT(&pThis->u.s.node, node_p);
++
++    memset(&ifreq, 0, sizeof(struct ifreq));
++    /* Activate interface */
++    if (fActive)
++    {
++        pThis->u.s.flags = ifp->if_flags;
++        ifpromisc(ifp, 1);
++
++        /* ng_ether nodes are named after the interface name */
++        snprintf(path, sizeof(path), "%s:", ifp->if_xname);
++
++        /*
++         * Send a netgraph connect message to the ng_ether node
++         * assigned to the bridged interface. Connecting
++         * the hooks 'lower' (ng_ether) to out 'input'.
++         */
++        NG_MKMESSAGE(msg, NGM_GENERIC_COOKIE, NGM_CONNECT,
++            sizeof(struct ngm_connect), M_NOWAIT);
++        if (msg == NULL)
++            return;
++        con = (struct ngm_connect *)msg->data;
++        snprintf(con->path, NG_PATHSIZ, "vboxnetflt_%s:", ifp->if_xname);
++        strlcpy(con->ourhook, "lower", NG_HOOKSIZ);
++        strlcpy(con->peerhook, "input", NG_HOOKSIZ);
++        NG_SEND_MSG_PATH(error, node, msg, path, 0);
++
++        /*
++         * Do the same for the hooks 'upper' (ng_ether) and our
++         * 'output' hook.
++         */
++        NG_MKMESSAGE(msg, NGM_GENERIC_COOKIE, NGM_CONNECT,
++            sizeof(struct ngm_connect), M_NOWAIT);
++        if (msg == NULL)
++            return;
++        con = (struct ngm_connect *)msg->data;
++        snprintf(con->path, NG_PATHSIZ, "vboxnetflt_%s:",
++            ifp->if_xname);
++        strlcpy(con->ourhook, "upper", sizeof(con->ourhook));
++        strlcpy(con->peerhook, "output", sizeof(con->peerhook));
++        NG_SEND_MSG_PATH(error, node, msg, path, 0);
++    }
++    else
++    {
++        /* De-activate interface */
++        pThis->u.s.flags = 0;
++        ifpromisc(ifp, 0);
++
++        /* Disconnect msgs are addressed to ourself */
++        snprintf(path, sizeof(path), "vboxnetflt_%s:", ifp->if_xname);
++
++        /*
++         * Send a netgraph message to disconnect our 'input' hook
++         */
++        NG_MKMESSAGE(msg, NGM_GENERIC_COOKIE, NGM_RMHOOK,
++            sizeof(struct ngm_rmhook), M_NOWAIT);
++        if (msg == NULL)
++            return;
++        rm = (struct ngm_rmhook *)msg->data;
++        strlcpy(rm->ourhook, "input", NG_HOOKSIZ);
++        NG_SEND_MSG_PATH(error, node, msg, path, 0);
++
++        /*
++         * Send a netgraph message to disconnect our 'output' hook
++         */
++        NG_MKMESSAGE(msg, NGM_GENERIC_COOKIE, NGM_RMHOOK,
++            sizeof(struct ngm_rmhook), M_NOWAIT);
++        if (msg == NULL)
++            return;
++        rm = (struct ngm_rmhook *)msg->data;
++        strlcpy(rm->ourhook, "output", NG_HOOKSIZ);
++        NG_SEND_MSG_PATH(error, node, msg, path, 0);
++    }
++    VBOXCURVNET_RESTORE();
++}
++
++int vboxNetFltOsDisconnectIt(PVBOXNETFLTINS pThis)
++{
++    return VINF_SUCCESS;
++}
++
++int vboxNetFltOsConnectIt(PVBOXNETFLTINS pThis)
++{
++    return VINF_SUCCESS;
++}
++
++void vboxNetFltPortOsNotifyMacAddress(PVBOXNETFLTINS pThis, void *pvIfData, PCRTMAC pMac)
++{
++    NOREF(pThis); NOREF(pvIfData); NOREF(pMac);
++}
++
++int vboxNetFltPortOsConnectInterface(PVBOXNETFLTINS pThis, void *pvIf, void **ppvIfData)
++{
++    /* Nothing to do */
++    NOREF(pThis); NOREF(pvIf); NOREF(ppvIfData);
++    return VINF_SUCCESS;
++}
++
++int vboxNetFltPortOsDisconnectInterface(PVBOXNETFLTINS pThis, void *pvIfData)
++{
++    /* Nothing to do */
++    NOREF(pThis); NOREF(pvIfData);
++    return VINF_SUCCESS;
++}
diff --git a/virtualbox-svn/patches/patch-src_VBox_HostDrivers_VBoxNetFlt_netbsd_files__vboxnetflt b/virtualbox-svn/patches/patch-src_VBox_HostDrivers_VBoxNetFlt_netbsd_files__vboxnetflt
new file mode 100644
index 0000000..1e03d1f
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_HostDrivers_VBoxNetFlt_netbsd_files__vboxnetflt
@@ -0,0 +1,90 @@
+$NetBSD$
+
+--- src/VBox/HostDrivers/VBoxNetFlt/netbsd/files_vboxnetflt.orig	2016-07-07 07:08:46.581760114 +0000
++++ src/VBox/HostDrivers/VBoxNetFlt/netbsd/files_vboxnetflt
+@@ -0,0 +1,85 @@
++#!/bin/sh
++#  files_vboxnetflt $
++## @file
++# Shared file between Makefile.kmk and export_modules
++#
++
++#
++# Copyright (C) 2007-2015 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.
++#
++
++VBOX_VBOXNETFLT_SOURCES=" \
++    ${PATH_ROOT}/include/iprt/alloc.h=>include/iprt/alloc.h \
++    ${PATH_ROOT}/include/iprt/alloca.h=>include/iprt/alloca.h \
++    ${PATH_ROOT}/include/iprt/asm.h=>include/iprt/asm.h \
++    ${PATH_ROOT}/include/iprt/asm-amd64-x86.h=>include/iprt/asm-amd64-x86.h \
++    ${PATH_ROOT}/include/iprt/asm-math.h=>include/iprt/asm-math.h \
++    ${PATH_ROOT}/include/iprt/assert.h=>include/iprt/assert.h \
++    ${PATH_ROOT}/include/iprt/avl.h=>include/iprt/avl.h \
++    ${PATH_ROOT}/include/iprt/cdefs.h=>include/iprt/cdefs.h \
++    ${PATH_ROOT}/include/iprt/cpuset.h=>include/iprt/cpuset.h \
++    ${PATH_ROOT}/include/iprt/ctype.h=>include/iprt/ctype.h \
++    ${PATH_ROOT}/include/iprt/err.h=>include/iprt/err.h \
++    ${PATH_ROOT}/include/iprt/heap.h=>include/iprt/heap.h \
++    ${PATH_ROOT}/include/iprt/initterm.h=>include/iprt/initterm.h \
++    ${PATH_ROOT}/include/iprt/latin1.h=>include/iprt/latin1.h \
++    ${PATH_ROOT}/include/iprt/log.h=>include/iprt/log.h \
++    ${PATH_ROOT}/include/iprt/mangling.h=>include/iprt/mangling.h \
++    ${PATH_ROOT}/include/iprt/mem.h=>include/iprt/mem.h \
++    ${PATH_ROOT}/include/iprt/memobj.h=>include/iprt/memobj.h \
++    ${PATH_ROOT}/include/iprt/mp.h=>include/iprt/mp.h \
++    ${PATH_ROOT}/include/iprt/param.h=>include/iprt/param.h \
++    ${PATH_ROOT}/include/iprt/power.h=>include/iprt/power.h \
++    ${PATH_ROOT}/include/iprt/process.h=>include/iprt/process.h \
++    ${PATH_ROOT}/include/iprt/semaphore.h=>include/iprt/semaphore.h \
++    ${PATH_ROOT}/include/iprt/spinlock.h=>include/iprt/spinlock.h \
++    ${PATH_ROOT}/include/iprt/stdarg.h=>include/iprt/stdarg.h \
++    ${PATH_ROOT}/include/iprt/stdint.h=>include/iprt/stdint.h \
++    ${PATH_ROOT}/include/iprt/string.h=>include/iprt/string.h \
++    ${PATH_ROOT}/include/iprt/thread.h=>include/iprt/thread.h \
++    ${PATH_ROOT}/include/iprt/time.h=>include/iprt/time.h \
++    ${PATH_ROOT}/include/iprt/timer.h=>include/iprt/timer.h \
++    ${PATH_ROOT}/include/iprt/types.h=>include/iprt/types.h \
++    ${PATH_ROOT}/include/iprt/uni.h=>include/iprt/uni.h \
++    ${PATH_ROOT}/include/iprt/utf16.h=>include/iprt/utf16.h \
++    ${PATH_ROOT}/include/iprt/uuid.h=>include/iprt/uuid.h \
++    ${PATH_ROOT}/include/iprt/nocrt/limits.h=>include/iprt/nocrt/limits.h \
++    ${PATH_ROOT}/include/VBox/cdefs.h=>include/VBox/cdefs.h \
++    ${PATH_ROOT}/include/VBox/err.h=>include/VBox/err.h \
++    ${PATH_ROOT}/include/VBox/log.h=>include/VBox/log.h \
++    ${PATH_ROOT}/include/VBox/intnet.h=>include/VBox/intnet.h \
++    ${PATH_ROOT}/include/VBox/intnetinline.h=>include/VBox/intnetinline.h \
++    ${PATH_ROOT}/include/VBox/vmm/stam.h=>include/VBox/vmm/stam.h \
++    ${PATH_ROOT}/include/VBox/sup.h=>include/VBox/sup.h \
++    ${PATH_ROOT}/include/VBox/types.h=>include/VBox/types.h \
++    ${PATH_ROOT}/include/VBox/version.h=>include/VBox/version.h \
++    ${PATH_ROOT}/include/VBox/SUPDrvMangling.h=>include/VBox/SUPDrvMangling.h \
++    ${PATH_ROOT}/src/VBox/HostDrivers/VBoxNetFlt/netbsd/VBoxNetFlt-netbsd.c=>VBoxNetFlt-netbsd.c \
++    ${PATH_ROOT}/src/VBox/HostDrivers/VBoxNetFlt/VBoxNetFlt.c=>VBoxNetFlt.c \
++    ${PATH_ROOT}/src/VBox/HostDrivers/VBoxNetFlt/VBoxNetFltInternal.h=>VBoxNetFltInternal.h \
++    ${PATH_ROOT}/src/VBox/HostDrivers/Support/SUPDrvIDC.h=>SUPDrvIDC.h \
++    ${PATH_ROOT}/src/VBox/HostDrivers/Support/SUPR0IdcClient.c=>SUPR0IdcClient.c \
++    ${PATH_ROOT}/src/VBox/HostDrivers/Support/SUPR0IdcClientComponent.c=>SUPR0IdcClientComponent.c \
++    ${PATH_ROOT}/src/VBox/HostDrivers/Support/SUPR0IdcClientInternal.h=>SUPR0IdcClientInternal.h \
++    ${PATH_ROOT}/src/VBox/HostDrivers/Support/netbsd/SUPR0IdcClient-netbsd.c=>SUPR0IdcClient-netbsd.c \
++    ${PATH_ROOT}/src/VBox/Runtime/r0drv/netbsd/the-netbsd-kernel.h=>r0drv/netbsd/the-netbsd-kernel.h \
++    ${PATH_OUT}/version-generated.h=>version-generated.h \
++    ${PATH_OUT}/product-generated.h=>product-generated.h \
++"
diff --git a/virtualbox-svn/patches/patch-src_VBox_HostDrivers_netbsd_Makefile b/virtualbox-svn/patches/patch-src_VBox_HostDrivers_netbsd_Makefile
new file mode 100644
index 0000000..113544e
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_HostDrivers_netbsd_Makefile
@@ -0,0 +1,81 @@
+$NetBSD$
+
+--- src/VBox/HostDrivers/netbsd/Makefile.orig	2016-07-07 07:08:46.590334369 +0000
++++ src/VBox/HostDrivers/netbsd/Makefile
+@@ -0,0 +1,76 @@
++#
++# Makefile for the VirtualBox NetBSD Host Drivers.
++#
++
++#
++#
++# Copyright (C) 2008-2015 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.
++#
++
++KBUILD_VERBOSE =
++
++all:
++	@echo "*** Building 'vboxdrv' module ***"
++	@$(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) -C vboxdrv
++	@cp vboxdrv/vboxdrv.kmod .
++	@echo
++	@if [ -d vboxnetflt ]; then \
++	    if [ -f vboxdrv/Module.symvers ]; then \
++	        cp vboxdrv/Module.symvers vboxnetflt; \
++	    fi; \
++	    echo "*** Building 'vboxnetflt' module ***"; \
++	    $(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) -C vboxnetflt; \
++	    cp vboxnetflt/vboxnetflt.kmod .; \
++	    echo; \
++	fi
++	@if [ -d vboxnetadp ]; then \
++	    if [ -f vboxdrv/Module.symvers ]; then \
++	        cp vboxdrv/Module.symvers vboxnetadp; \
++	    fi; \
++	    echo "*** Building 'vboxnetadp' module ***"; \
++	    $(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) -C vboxnetadp; \
++	    cp vboxnetadp/vboxnetadp.kmod .; \
++	    echo; \
++	fi
++
++
++install:
++	@$(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) -C vboxdrv install
++	@if [ -d vboxnetflt ]; then \
++	    $(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) -C vboxnetflt install; \
++	fi
++	@if [ -d vboxnetadp ]; then \
++	    $(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) -C vboxnetadp install; \
++	fi
++
++clean:
++	@$(MAKE) -C vboxdrv clean
++	@if [ -d vboxnetflt ]; then \
++	    $(MAKE) -C vboxnetflt clean; \
++	fi
++	@if [ -d vboxnetadp ]; then \
++	    $(MAKE) -C vboxnetadp clean; \
++	fi
++	rm -f vboxdrv.kmod vboxnetflt.kmod vboxnetadp.kmod
++
++load:
++	@for module in vboxnetadp vboxnetflt vboxdrv; do \
++		if modstat -n "$$module" >/dev/null; then \
++			echo "Removing previously installed $$module module"; \
++			/sbin/modunload $$module; \
++		fi; \
++	done
++	@for module in vboxdrv vboxnetflt vboxnetadp; do \
++		if test -f $$module.kmod; then \
++			echo "Installing $$module module"; \
++			/sbin/modload ./$$module.kmod; \
++		fi; \
++	done
diff --git a/virtualbox-svn/patches/patch-src_VBox_HostDrivers_netbsd_Makefile.kmk b/virtualbox-svn/patches/patch-src_VBox_HostDrivers_netbsd_Makefile.kmk
new file mode 100644
index 0000000..272b7e3
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_HostDrivers_netbsd_Makefile.kmk
@@ -0,0 +1,30 @@
+$NetBSD$
+
+--- src/VBox/HostDrivers/netbsd/Makefile.kmk.orig	2016-07-07 07:08:46.599051025 +0000
++++ src/VBox/HostDrivers/netbsd/Makefile.kmk
+@@ -0,0 +1,25 @@
++#  Makefile.kmk $
++## @file
++# Sub-makefile for the NetBSD host driver helper scripts.
++#
++
++#
++# Copyright (C) 2006-2015 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.
++#
++
++SUB_DEPTH = ../../../..
++include $(KBUILD_PATH)/subheader.kmk
++
++INSTALLS += HostDrivers-scripts
++HostDrivers-scripts_INST    = bin/src/
++HostDrivers-scripts_SOURCES = Makefile
++
++include $(FILE_KBUILD_SUB_FOOTER)
diff --git a/virtualbox-svn/patches/patch-src_VBox_HostServices_Makefile.kmk b/virtualbox-svn/patches/patch-src_VBox_HostServices_Makefile.kmk
new file mode 100644
index 0000000..dea16fb
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_HostServices_Makefile.kmk
@@ -0,0 +1,24 @@
+$NetBSD$
+
+--- src/VBox/HostServices/Makefile.kmk.orig	2016-03-04 19:29:29.000000000 +0000
++++ src/VBox/HostServices/Makefile.kmk
+@@ -23,12 +23,12 @@ include $(PATH_SUB_CURRENT)/auth/Makefil
+ ifdef VBOX_WITH_SHARED_FOLDERS
+  include $(PATH_SUB_CURRENT)/SharedFolders/Makefile.kmk
+ endif
+-if1of ($(KBUILD_TARGET), win linux solaris darwin freebsd)
++if1of ($(KBUILD_TARGET), win linux solaris darwin freebsd netbsd)
+  ifdef VBOX_WITH_CROGL
+   include $(PATH_SUB_CURRENT)/SharedOpenGL/Makefile.kmk
+  endif
+ endif
+-if1of ($(KBUILD_TARGET), win linux solaris darwin freebsd)
++if1of ($(KBUILD_TARGET), win linux solaris darwin freebsd netbsd)
+  ifdef VBOX_WITH_SHARED_CLIPBOARD
+   include $(PATH_SUB_CURRENT)/SharedClipboard/Makefile.kmk
+  endif
+@@ -48,4 +48,3 @@ endif
+ include $(PATH_SUB_CURRENT)/testcase/Makefile.kmk
+ 
+ include $(FILE_KBUILD_SUB_FOOTER)
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_HostServices_SharedClipboard_Makefile.kmk b/virtualbox-svn/patches/patch-src_VBox_HostServices_SharedClipboard_Makefile.kmk
new file mode 100644
index 0000000..b1aa7c5
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_HostServices_SharedClipboard_Makefile.kmk
@@ -0,0 +1,22 @@
+$NetBSD$
+
+--- src/VBox/HostServices/SharedClipboard/Makefile.kmk.orig	2016-03-04 19:29:29.000000000 +0000
++++ src/VBox/HostServices/SharedClipboard/Makefile.kmk
+@@ -39,7 +39,7 @@ VBoxSharedClipboard_SOURCES.darwin = \
+ 	darwin.cpp \
+ 	$(PATH_ROOT)/src/VBox/GuestHost/SharedClipboard/clipboard-helper.cpp \
+ 	darwin-pasteboard.cpp
+-if1of ($(KBUILD_TARGET), linux solaris freebsd) ## @todo X11
++if1of ($(KBUILD_TARGET), linux solaris freebsd netbsd) ## @todo X11
+  ifndef VBOX_HEADLESS
+   VBoxSharedClipboard_SOURCES += \
+   	$(PATH_ROOT)/src/VBox/GuestHost/SharedClipboard/clipboard-helper.cpp \
+@@ -55,7 +55,7 @@ VBoxSharedClipboard_LIBS = \
+ 	$(LIB_VMM) \
+ 	$(LIB_RUNTIME) \
+ 	$(LIB_REM)
+-if1of ($(KBUILD_TARGET), linux solaris freebsd)
++if1of ($(KBUILD_TARGET), linux solaris freebsd netbsd)
+  ifndef VBOX_HEADLESS
+   VBoxSharedClipboard_LIBPATH = \
+ 	$(VBOX_LIBPATH_X11)
diff --git a/virtualbox-svn/patches/patch-src_VBox_HostServices_SharedOpenGL_Makefile.kmk b/virtualbox-svn/patches/patch-src_VBox_HostServices_SharedOpenGL_Makefile.kmk
new file mode 100644
index 0000000..4404e7c
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_HostServices_SharedOpenGL_Makefile.kmk
@@ -0,0 +1,17 @@
+$NetBSD$
+
+--- src/VBox/HostServices/SharedOpenGL/Makefile.kmk.orig	2016-07-10 19:57:04.000000000 +0000
++++ src/VBox/HostServices/SharedOpenGL/Makefile.kmk
+@@ -374,6 +374,7 @@ VBoxOGLrenderspu_SOURCES.win     = \
+ VBoxOGLrenderspu_SOURCES.linux   = render/renderspu_glx.c
+ VBoxOGLrenderspu_SOURCES.solaris = render/renderspu_glx.c
+ VBoxOGLrenderspu_SOURCES.freebsd = render/renderspu_glx.c
++VBoxOGLrenderspu_SOURCES.netbsd = render/renderspu_glx.c
+ VBoxOGLrenderspu_OBJCFLAGS.darwin = -Wno-shadow
+ VBoxOGLrenderspu_SOURCES.darwin  = \
+ 	OpenGLTest/OpenGLTestDarwin.cpp \
+@@ -457,4 +458,3 @@ if (   defined(VBOX_WITH_QTGUI) \
+ endif
+ 
+ include $(FILE_KBUILD_SUB_FOOTER)
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_HostServices_auth_Makefile.kmk b/virtualbox-svn/patches/patch-src_VBox_HostServices_auth_Makefile.kmk
new file mode 100644
index 0000000..926b9f9
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_HostServices_auth_Makefile.kmk
@@ -0,0 +1,9 @@
+$NetBSD$
+
+--- src/VBox/HostServices/auth/Makefile.kmk.orig	2016-07-10 19:56:34.000000000 +0000
++++ src/VBox/HostServices/auth/Makefile.kmk
+@@ -63,4 +63,3 @@ VBoxAuth-sdkhdr_SOURCES = $(PATH_ROOT)/i
+ 
+ 
+ include $(FILE_KBUILD_SUB_FOOTER)
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_HostServices_auth_pam_VBoxAuthPAM.c b/virtualbox-svn/patches/patch-src_VBox_HostServices_auth_pam_VBoxAuthPAM.c
new file mode 100644
index 0000000..1deb567
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_HostServices_auth_pam_VBoxAuthPAM.c
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- src/VBox/HostServices/auth/pam/VBoxAuthPAM.c.orig	2016-03-04 19:29:32.000000000 +0000
++++ src/VBox/HostServices/auth/pam/VBoxAuthPAM.c
+@@ -74,7 +74,7 @@
+ #include <stdlib.h>
+ #include <stdarg.h>
+ #include <string.h>
+-#ifndef RT_OS_FREEBSD
++#if !defined(RT_OS_FREEBSD) && !defied(RT_OS_NETBSD)
+ # include <malloc.h>
+ #endif
+ 
diff --git a/virtualbox-svn/patches/patch-src_VBox_ImageMounter_VBoxFUSE_Makefile.kmk b/virtualbox-svn/patches/patch-src_VBox_ImageMounter_VBoxFUSE_Makefile.kmk
new file mode 100644
index 0000000..eee00aa
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_ImageMounter_VBoxFUSE_Makefile.kmk
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- src/VBox/ImageMounter/VBoxFUSE/Makefile.kmk.orig	2016-03-04 19:29:32.000000000 +0000
++++ src/VBox/ImageMounter/VBoxFUSE/Makefile.kmk
+@@ -51,7 +51,7 @@ VBoxFUSE_LIBS = \
+ VBoxFUSE_LIBS.darwin = fuse
+ VBoxFUSE_LIBS.linux = fuse
+ VBoxFUSE_LIBS.freebsd = fuse
++VBoxFUSE_LIBS.netbsd = fuse
+ VBoxFUSE_LIBPATHS.darwin = /usr/local/lib
+ 
+ include $(FILE_KBUILD_SUB_FOOTER)
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_ImageMounter_VBoxFUSE_VBoxFUSE.cpp b/virtualbox-svn/patches/patch-src_VBox_ImageMounter_VBoxFUSE_VBoxFUSE.cpp
new file mode 100644
index 0000000..bcdf98a
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_ImageMounter_VBoxFUSE_VBoxFUSE.cpp
@@ -0,0 +1,27 @@
+$NetBSD$
+
+--- src/VBox/ImageMounter/VBoxFUSE/VBoxFUSE.cpp.orig	2016-03-04 19:29:32.000000000 +0000
++++ src/VBox/ImageMounter/VBoxFUSE/VBoxFUSE.cpp
+@@ -22,7 +22,7 @@
+ #define LOG_GROUP LOG_GROUP_DEFAULT /** @todo log group */
+ #include <iprt/types.h>
+ 
+-#if defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD) || defined(RT_OS_LINUX)
++#if defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD) || defined(RT_OS_LINUX) || defined(RT_OS_NETBSD)
+ # include <sys/param.h>
+ # undef PVM     /* Blasted old BSD mess still hanging around darwin. */
+ #endif
+@@ -1013,7 +1013,7 @@ static int vboxfuseOp_open(const char *p
+         return -EINVAL;
+     if ((pInfo->flags & O_ACCMODE) == O_ACCMODE)
+         return -EINVAL;
+-#elif defined(RT_OS_FREEBSD)
++#elif defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+     if (pInfo->flags & (  O_APPEND | O_ASYNC | O_DIRECT /* | O_LARGEFILE ? */
+                         | O_NOCTTY | O_NOFOLLOW | O_NONBLOCK
+                         /* | O_SYNC ? */))
+@@ -1473,4 +1473,3 @@ int main(int argc, char **argv)
+     RTPrintf("VBoxFUSE: fuse_main -> %d\n", rc);
+     return rc;
+ }
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_Installer_Makefile.kmk b/virtualbox-svn/patches/patch-src_VBox_Installer_Makefile.kmk
new file mode 100644
index 0000000..67938ab
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Installer_Makefile.kmk
@@ -0,0 +1,19 @@
+$NetBSD$
+
+--- src/VBox/Installer/Makefile.kmk.orig	2016-03-04 19:29:32.000000000 +0000
++++ src/VBox/Installer/Makefile.kmk
+@@ -44,6 +44,9 @@ ifndef VBOX_ONLY_SDK
+  if "$(KBUILD_TARGET)" == "freebsd" && "$(KBUILD_HOST)" == "freebsd"
+   include $(PATH_SUB_CURRENT)/freebsd/Makefile.kmk
+  endif
++ if "$(KBUILD_TARGET)" == "netbsd" && "$(KBUILD_HOST)" == "netbsd"
++  include $(PATH_SUB_CURRENT)/netbsd/Makefile.kmk
++ endif
+ endif
+ 
+ include $(PATH_SUB_CURRENT)/common/Makefile.kmk
+@@ -68,4 +71,3 @@ endif
+ 
+ 
+ include $(FILE_KBUILD_SUB_FOOTER)
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_Installer_darwin_VirtualBox_postflight b/virtualbox-svn/patches/patch-src_VBox_Installer_darwin_VirtualBox_postflight
new file mode 100644
index 0000000..f7359f6
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Installer_darwin_VirtualBox_postflight
@@ -0,0 +1,18 @@
+$NetBSD$
+
+--- src/VBox/Installer/darwin/VirtualBox/postflight.orig	2016-03-04 19:29:32.000000000 +0000
++++ src/VBox/Installer/darwin/VirtualBox/postflight
+@@ -69,7 +69,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
+@@ -96,4 +96,3 @@ for bin in ${SET_UID_BINARIES}; do
+ done
+ 
+ exit 0;
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_Installer_darwin_VirtualBox_preflight b/virtualbox-svn/patches/patch-src_VBox_Installer_darwin_VirtualBox_preflight
new file mode 100644
index 0000000..97daad1
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Installer_darwin_VirtualBox_preflight
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- src/VBox/Installer/darwin/VirtualBox/preflight.orig	2016-03-04 19:29:32.000000000 +0000
++++ src/VBox/Installer/darwin/VirtualBox/preflight
+@@ -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-svn/patches/patch-src_VBox_Installer_linux_VBoxSysInfo.sh b/virtualbox-svn/patches/patch-src_VBox_Installer_linux_VBoxSysInfo.sh
new file mode 100644
index 0000000..e94b19e
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Installer_linux_VBoxSysInfo.sh
@@ -0,0 +1,27 @@
+$NetBSD$
+
+--- src/VBox/Installer/linux/VBoxSysInfo.sh.orig	2016-03-04 19:29:33.000000000 +0000
++++ src/VBox/Installer/linux/VBoxSysInfo.sh
+@@ -109,6 +109,12 @@ get_freebsd_info () {
+     echo "Kernel: $kernel"
+ }
+ 
++# Print information about a NetBSD system.  FIXME.
++get_netbsd_info () {
++    kernel=`uname -v`
++    echo "Kernel: $kernel"
++}
++
+ system=`uname -s`
+ case "$system" in
+ Linux|linux)
+@@ -123,6 +129,9 @@ Darwin)
+ FreeBSD)
+     get_freebsd_info
+     ;;
++NetBSD)
++    get_netbsd_info
++    ;;
+ *)
+     echo "System unknown"
+     exit 1
diff --git a/virtualbox-svn/patches/patch-src_VBox_Installer_linux_debian_control b/virtualbox-svn/patches/patch-src_VBox_Installer_linux_debian_control
new file mode 100644
index 0000000..b0ca6a1
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Installer_linux_debian_control
@@ -0,0 +1,22 @@
+$NetBSD$
+
+--- src/VBox/Installer/linux/debian/control.orig	2016-03-04 19:29:33.000000000 +0000
++++ src/VBox/Installer/linux/debian/control
+@@ -26,7 +26,7 @@ Conflicts: virtualbox, virtualbox-ose, v
+ Description: Oracle VM VirtualBox
+  VirtualBox is a powerful PC virtualization solution allowing you to run a
+  wide range of PC operating systems on your Linux system. This includes
+- Windows, Linux, FreeBSD, DOS, OpenBSD and others. VirtualBox comes with a broad
++ Windows, Linux, FreeBSD, NetBSD, DOS, OpenBSD and others. VirtualBox comes with a broad
+  feature set and excellent performance, making it the premier virtualization
+  software solution on the market.
+ XB-Python-Version: ${python:Versions}
+@@ -40,7 +40,7 @@ Conflicts: virtualbox-dbg, virtualbox-os
+ Description: Oracle VM VirtualBox debugging symbols
+  VirtualBox is a powerful PC virtualization solution allowing you to run a
+  wide range of PC operating systems on your Linux system. This includes
+- Windows, Linux, FreeBSD, DOS, OpenBSD and others. VirtualBox comes with a broad
++ Windows, Linux, FreeBSD, NetBSD, DOS, OpenBSD and others. VirtualBox comes with a broad
+  feature set and excellent performance, making it the premier virtualization
+  software solution on the market.
+  .
diff --git a/virtualbox-svn/patches/patch-src_VBox_Installer_linux_rpm_VirtualBox.tmpl.spec b/virtualbox-svn/patches/patch-src_VBox_Installer_linux_rpm_VirtualBox.tmpl.spec
new file mode 100644
index 0000000..697c1e3
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Installer_linux_rpm_VirtualBox.tmpl.spec
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- src/VBox/Installer/linux/rpm/VirtualBox.tmpl.spec.orig	2016-03-04 19:29:33.000000000 +0000
++++ src/VBox/Installer/linux/rpm/VirtualBox.tmpl.spec
+@@ -40,7 +40,7 @@ Requires:  %INITSCRIPTS% %LIBASOUND% net
+ %description
+ VirtualBox is a powerful PC virtualization solution allowing
+ you to run a wide range of PC operating systems on your Linux
+-system. This includes Windows, Linux, FreeBSD, DOS, OpenBSD
++system. This includes Windows, Linux, FreeBSD, NetBSD, DOS, OpenBSD
+ and others. VirtualBox comes with a broad feature set and
+ excellent performance, making it the premier virtualization
+ software solution on the market.
diff --git a/virtualbox-svn/patches/patch-src_VBox_Installer_netbsd_Makefile.kmk b/virtualbox-svn/patches/patch-src_VBox_Installer_netbsd_Makefile.kmk
new file mode 100644
index 0000000..1f10771
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Installer_netbsd_Makefile.kmk
@@ -0,0 +1,343 @@
+$NetBSD$
+
+--- src/VBox/Installer/netbsd/Makefile.kmk.orig	2016-07-08 22:38:40.777304438 +0000
++++ src/VBox/Installer/netbsd/Makefile.kmk
+@@ -0,0 +1,338 @@
++#  Makefile.kmk $
++## @file
++# Makefile for the NetBSD installer.
++#
++
++#
++# Copyright (C) 2006-2015 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.
++#
++
++SUB_DEPTH = ../../../..
++include $(KBUILD_PATH)/subheader.kmk
++
++ifneq ($(KBUILD_HOST),netbsd)
++ $(error "The NetBSD installer can only be built on NetBSD!")
++endif
++
++#
++# Globals and targets.
++#
++VBOX_PATH_NBSD_INST_SRC      := $(PATH_SUB_CURRENT)
++VBOX_NBSD_INST_OUT_DIR       := $(PATH_TARGET)/Installer/netbsd
++VBOX_NBSD_INST_STAGE_DIR     := $(PATH_TARGET)/Installer/netbsd/install
++VBOX_NBSD_DBG_PATH           := usr/lib/debug/opt/VirtualBox
++VBOX_NBSD_PACKAGE_NAME        = VirtualBox-$(VBOX_VERSION_STRING)-r$(VBOX_SVN_REV).tbz
++VBOX_NBSD_INST_LIB_DIR       := $(VBOX_NBSD_INST_STAGE_DIR)/lib
++VBOX_NBSD_INST_BIN_DIR       := $(VBOX_NBSD_INST_STAGE_DIR)/bin
++VBOX_NBSD_INST_LIBVBOX_DIR   := $(VBOX_NBSD_INST_LIB_DIR)/virtualbox
++VBOX_NBSD_INST_SHARE_DIR     := $(VBOX_NBSD_INST_STAGE_DIR)/share
++VBOX_NBSD_INST_SHAREAPP_DIR  := $(VBOX_NBSD_INST_SHARE_DIR)/applications
++VBOX_NBSD_INST_SHAREICON_DIR := $(VBOX_NBSD_INST_SHARE_DIR)/pixmaps
++VBOX_NBSD_INST_SHAREVBOX_DIR := $(VBOX_NBSD_INST_SHARE_DIR)/virtualbox
++
++# Unset this to speed up things during makefile hacking.
++VBOX_NBSD_INST_DEP_ON_MAKEFILE := $(MAKEFILE_CURRENT)
++
++BLDDIRS  += $(VBOX_NBSD_INST_OUT_DIR) $(VBOX_NBSD_INST_STAGE_DIR)
++PACKING  += $(PATH_STAGE_BIN)/$(VBOX_NBSD_PACKAGE_NAME)
++
++OTHER_CLEAN   += \
++	$(addprefix $(VBOX_NBSD_INST_STAGE_DIR)/,\
++		pkg_plist \
++		LICENSE) \
++	$(wildcard $(VBOX_NBSD_INST_OUT_DIR)/VirtualBox-*)
++
++#
++# NetBSD installs.
++#
++INSTALLS += netbsd-misc
++netbsd-misc_INST = bin/
++netbsd-misc_MODE = a+r,u+w
++netbsd-misc_SOURCES = \
++	$(PATH_ROOT)/src/VBox/Frontends/VirtualBox/images/$(if $(VBOX_OSE),OSE,NonOSE)/VirtualBox_32px.png=>VBox.png \
++	$(if $(VBOX_OSE),,$(VBOX_BRAND_LICENSE_TXT)=>LICENSE) \
++	$(if $(VBOX_WITH_QTGUI),$(netbsd-misc_0_OUTDIR)/virtualbox.desktop,)
++netbsd-misc_CLEAN = $(netbsd-misc_0_OUTDIR)/virtualbox.desktop
++
++$$(PATH_netbsd-misc)/virtualbox.desktop: $(PATH_SUB_CURRENT)/virtualbox.desktop $(VBOX_VERSION_STAMP) | $$(dir $$@)
++	$(call MSG_GENERATE,,$@,$<)
++ifdef VBOX_PATH_PACKAGE_DOCS
++	$(QUIET)$(SED) -e "s+\$$VBOX_DOC_PATH+$(VBOX_PATH_PACKAGE_DOCS)+" --output $@ $<
++else
++	$(QUIET)$(SED) -e "s+\$$VBOX_DOC_PATH+/opt/VirtualBox+" --output $@ $<
++endif
++
++
++
++#
++# The files residing in bin/ that we'll ship.
++#
++
++# Strip these binaries
++VBOX_NBSD_STRIP_BIN = \
++	VBoxDD.so \
++	VBoxDD2.so \
++	VBoxREM.so \
++	VBoxDDU.so \
++	VBoxVMM.so \
++	$(if $(eq $(KBUILD_TARGET_ARCH),x86),VBoxREM32.so,) \
++	$(if $(eq $(KBUILD_TARGET_ARCH),x86),VBoxREM64.so,) \
++	VBoxRT.so \
++	$(if $(VBOX_WITH_VBOXSDL),VBoxSDL $(if $(VBOX_WITH_HARDENING),VBoxSDL.so),) \
++	$(if $(VBOX_WITH_SHARED_CLIPBOARD), VBoxSharedClipboard.so,) \
++	$(if $(VBOX_WITH_SHARED_FOLDERS), VBoxSharedFolders.so,) \
++	$(if $(VBOX_WITH_GUEST_PROPS),VBoxGuestPropSvc.so,) \
++	$(if $(VBOX_WITH_GUEST_CONTROL),VBoxGuestControlSvc.so,) \
++	VBoxHostChannel.so \
++	$(if $(VBOX_WITH_MAIN), \
++		VBoxManage \
++		VBoxNetDHCP $(if $(VBOX_WITH_HARDENING),VBoxNetDHCP.so,) \
++		VBoxNetAdpCtl \
++		VBoxSVC \
++		VBoxXPCOM.so \
++		VBoxXPCOMC.so \
++		VBoxXPCOMIPCD \
++		components/VBoxXPCOMIPCC.so \
++		components/VBoxSVCM.so \
++		components/VBoxC.so,) \
++	$(if $(VBOX_WITH_CROGL),\
++		VBoxOGLhostcrutil.so \
++		VBoxOGLhosterrorspu.so \
++		VBoxOGLrenderspu.so \
++		VBoxTestOGL \
++		VBoxSharedCrOpenGL.so,) \
++	$(if $(VBOX_WITH_PYTHON),VBoxPython.so,) \
++	$(if $(VBOX_WITH_DTRACE),VBoxDTrace,)
++
++# Do not remove relocation information of these binaries
++VBOX_NBSD_STRIP_OBJ = \
++	VBoxDD2RC.rc \
++	VBoxDD2R0.r0 \
++	VBoxDDRC.rc \
++	VBoxDDR0.r0 \
++	VMMRC.rc \
++	VMMR0.r0
++
++# Do not strip anything of these files
++VBOX_NBSD_NO_STRIP = \
++	$(if $(VBOX_OSE),,LICENSE) \
++	$(if $(VBOX_WITH_MAIN), \
++	  components/VBoxXPCOMBase.xpt \
++	  components/VirtualBox_XPCOM.xpt) \
++	vboxdrv.tar.gz
++
++# EFI firmware
++ifdef VBOX_WITH_EFIFW_PACKING
++ VBOX_NBSD_NO_STRIP += \
++ 	VBoxEFI32.fd \
++ 	VBoxEFI64.fd
++endif
++
++# Symlinks residing in bin/
++VBOX_NBSD_SYMLINKS = \
++	$(if $(VBOX_WITH_MAIN), \
++		VBoxManage \
++		VBoxSVC) \
++	$(if $(VBOX_WITH_VBOXSDL),VBoxSDL,) \
++	$(if $(VBOX_WITH_DTRACE),VBoxDTrace,)
++
++# Qt4 GUI
++ifdef VBOX_WITH_QTGUI
++ include $(PATH_ROOT)/src/VBox/Frontends/VirtualBox/nls/ApprovedLanguages.kmk
++ VBOX_NBSD_STRIP_BIN += \
++ 	VBoxKeyboard.so \
++ 	VirtualBox \
++ 	$(if $(VBOX_WITH_HARDENING),VirtualBox.so) \
++	$(if $(VBOX_WITH_DEBUGGER_GUI),VBoxDbg.so DbgPlugInDiggers.so,)
++ VBOX_NBSD_SYMLINKS += \
++ 	VirtualBox
++ VBOX_NBSD_NO_STRIP += \
++	$(VBOX_LICENSE_FILES) \
++ 	$(if $(VBOX_WITH_QT4_SUN),$(notdir $(wildcard $(PATH_STAGE_BIN)/lib*VBox*)),) \
++	$(if $(VBOX_WITH_QT4_SUN),accessible/libqtaccessiblewidgets.so,) \
++ 	$(foreach f,$(VBOX_APPROVED_GUI_LANGUAGES),nls/VirtualBox_$(f).qm nls/qt_$(f).qm)
++ VBOX_NBSD_DESKTOP_FILE = \
++	virtualbox.desktop
++ VBOX_NBSD_ICON_FILE = \
++	VBox.png
++endif
++
++# Guest Additions
++ifdef VBOX_WITH_ADDITIONS_PACKING
++ VBOX_NBSD_NO_STRIP += \
++ 	additions/VBoxGuestAdditions.iso
++endif
++
++# Documentation
++ifdef VBOX_WITH_DOCS_PACKING
++ VBOX_NBSD_NO_STRIP += \
++	VirtualBox.chm UserManual.pdf \
++	$(foreach f,$(VBOX_MANUAL_ADD_LANGUAGES),VirtualBox_$(f).chm UserManual_$(f).pdf)
++ VBOX_NBSD_STRIP_BIN += \
++	$(if $(VBOX_WITH_KCHMVIEWER),kchmviewer,)
++endif
++
++# VRDP
++ifdef VBOX_WITH_VRDP
++ VBOX_NBSD_STRIP_BIN += \
++	VBoxVRDP.so \
++	VBoxAuth.so
++ VBOX_NBSD_NO_STRIP += \
++	rdesktop-vrdp.tar.gz
++ ifdef VBOX_WITH_VRDP_RDESKTOP
++#  VBOX_NBSD_NO_STRIP += \
++#	rdesktop-vrdp-keymaps
++  VBOX_NBSD_STRIP_BIN += \
++	rdesktop-vrdp
++ endif
++endif
++
++# Headless
++ifdef VBOX_WITH_HEADLESS
++ VBOX_NBSD_STRIP_BIN += \
++	VBoxHeadless \
++	$(if $(VBOX_WITH_HARDENING),VBoxHeadless.so)
++ VBOX_NBSD_SYMLINKS += \
++	VBoxHeadless
++endif
++
++# Webservices
++ifdef VBOX_WITH_WEBSERVICES
++ VBOX_NBSD_STRIP_BIN += \
++	vboxwebsrv \
++	webtest
++ VBOX_NBSD_SYMLINKS += \
++	vboxwebsrv
++endif
++
++# DTrace library, testcase and scripts (as the rest of this file, this makes bold
++# ASSUMPTIONS about VBPX_INST_XXX variable values).
++ifdef VBOX_WITH_DTRACE
++ VBOX_NBSD_NO_STRIP += \
++       $(addprefix dtrace/lib/$(KBUILD_TARGET_ARCH)/,$(VBOXINST_DTRACE_LIB_ARCH_FILES)) \
++       $(addprefix dtrace/testcase/$(KBUILD_TARGET_ARCH)/,$(VBOXINST_DTRACE_TESTCASE_ARCH_FILES)) \
++       $(addprefix dtrace/scripts/,$(VBOXINST_DTRACE_SCRIPTS_FILES))
++endif
++
++#
++# All the bin files that goes into the archives.
++#
++VBOX_NBSD_ARCH_FILES := $(VBOX_NBSD_STRIP_BIN) $(VBOX_NBSD_STRIP_OBJ) $(VBOX_NBSD_NO_STRIP)
++
++# Cleanup of the files we copy/symlink from bin.
++OTHER_CLEAN += $(addprefix $(VBOX_NBSD_INST_LIBVBOX_DIR)/,$(VBOX_NBSD_ARCH_FILES))
++
++#
++# The module source archive
++#
++$(PATH_STAGE_BIN)/vboxdrv.tar.gz: \
++		src
++	$(call MSG_TOOL, export_modules,,$@)
++	$(QUIET)$(PATH_STAGE_BIN)/export_modules $@
++
++#
++# The generic installer.
++## @todo r=aeichner: Create pkg_plist dynamically based on the available features
++#
++$(PATH_STAGE_BIN)/$(VBOX_NBSD_PACKAGE_NAME): \
++		$(VBOX_VERSION_STAMP) \
++		$(VBOX_NBSD_INST_OUT_DIR)/pkg_plist \
++		$(addprefix $(VBOX_NBSD_INST_LIBVBOX_DIR)/,$(VBOX_NBSD_ARCH_FILES)) \
++		$(addprefix $(VBOX_NBSD_INST_BIN_DIR)/,$(VBOX_NBSD_SYMLINKS)) \
++		$(if $(VBOX_OSE),,$(VBOX_BRAND_LICENSE_TXT)) \
++		$(if $(VBOX_WITH_QTGUI),$(addprefix $(VBOX_NBSD_INST_SHAREAPP_DIR)/,$(VBOX_NBSD_DESKTOP_FILE)),) \
++		$(if $(VBOX_WITH_QTGUI),$(addprefix $(VBOX_NBSD_INST_SHAREICON_DIR)/,$(VBOX_NBSD_ICON_FILE)),) \
++		$(VBOX_PATH_NBSD_INST_SRC)/postinstall.sh \
++		$(VBOX_PATH_NBSD_INST_SRC)/postdeinstall.sh
++	$(call MSG_TOOL,pkg_create,,$@)
++	$(QUIET)$(RM) -f $@
++	$(QUIET)pkg_create \
++		-I $(VBOX_PATH_NBSD_INST_SRC)/postinstall.sh \
++		-K $(VBOX_PATH_NBSD_INST_SRC)/postdeinstall.sh \
++		-c $(VBOX_PATH_NBSD_INST_SRC)/pkg-comment \
++		-d $(VBOX_PATH_NBSD_INST_SRC)/pkg-descr \
++		-f $(VBOX_NBSD_INST_OUT_DIR)/pkg_plist \
++		-p /usr/local \
++		-s $(VBOX_NBSD_INST_STAGE_DIR) \
++		$@
++	$(QUIET)$(RM) -Rf $(VBOX_NBSD_INST_STAGE_DIR)
++
++$(addprefix $(VBOX_NBSD_INST_LIBVBOX_DIR)/,$(VBOX_NBSD_STRIP_BIN)): \
++		$(VBOX_NBSD_INST_LIBVBOX_DIR)/% : $(PATH_STAGE_BIN)/%
++	$(call MSG_INST_FILE,$<,$@)
++	$(QUIET)$(INSTALL) -d $(dir $@)
++	$(QUIET)$(INSTALL) -m 0755 $(if $(VBOX_DO_STRIP),-s,) $< $@
++
++# pattern rule for striping and copying the VBOX_NBSD_STRIP_OBJ files to install/lib/virtualbox
++$(addprefix $(VBOX_NBSD_INST_LIBVBOX_DIR)/,$(VBOX_NBSD_STRIP_OBJ)): \
++		$(VBOX_NBSD_INST_LIBVBOX_DIR)/% : $(PATH_STAGE_BIN)/%
++	$(call MSG_INST_FILE,$<,$@)
++	$(QUIET)$(INSTALL) -d $(dir $@)
++ifeq ($(VBOX_DO_STRIP),)
++	$(QUIET)$(INSTALL) -m 0644 $< $@
++else # strip to temp file because of umask.
++	$(QUIET)objcopy --strip-unneeded -R .comment $< $@.tmp
++	$(QUIET)$(INSTALL) -m 0644 $@.tmp $@
++	$(QUIET)$(RM) -f -- $@.tmp
++endif
++
++# pattern rule for linking the VBOX_NBSD_NO_STRIP into lib/virtualbox/
++$(addprefix $(VBOX_NBSD_INST_LIBVBOX_DIR)/,$(VBOX_NBSD_NO_STRIP)): \
++		$(VBOX_NBSD_INST_LIBVBOX_DIR)/% : $(PATH_STAGE_BIN)/%
++	$(call MSG_INST_FILE,$<,$@)
++	$(QUIET)$(INSTALL) -d $(dir $@)
++	$(QUIET)$(RM) -f $@
++	$(QUIET)$(INSTALL) -m 0644 $< $@
++
++# pattern rule for symlinking the VBOX_NBSD_SYMLINKS into bin/
++$(addprefix $(VBOX_NBSD_INST_BIN_DIR)/,$(VBOX_NBSD_SYMLINKS)): \
++		$(VBOX_NBSD_INST_BIN_DIR)/% : $(PATH_STAGE_BIN)/%
++	$(call MSG_INST_SYM,$<,$@)
++	$(QUIET)$(INSTALL) -d $(dir $@)
++	$(QUIET)$(RM) -f $@
++	$(QUIET)$(LN_SYMLINK) ../lib/virtualbox/$(notdir $@) $@
++
++# pattern rule for copying the VBOX_NBSD_DESKTOP_FILE into share/applications/
++$(addprefix $(VBOX_NBSD_INST_SHAREAPP_DIR)/,$(VBOX_NBSD_DESKTOP_FILE)): \
++		$(VBOX_NBSD_INST_SHAREAPP_DIR)/% : $(PATH_STAGE_BIN)/%
++	$(call MSG_INST_FILE,$<,$@)
++	$(QUIET)$(INSTALL) -d $(dir $@)
++	$(QUIET)$(RM) -f $@
++	$(QUIET)$(INSTALL) -m 0644 $< $@
++
++# pattern rule for copying the VBOX_NBSD_ICON_FILE into share/pixmaps/
++$(addprefix $(VBOX_NBSD_INST_SHAREICON_DIR)/,$(VBOX_NBSD_ICON_FILE)): \
++		$(VBOX_NBSD_INST_SHAREICON_DIR)/% : $(PATH_STAGE_BIN)/%
++	$(call MSG_INST_FILE,$<,$@)
++	$(QUIET)$(INSTALL) -d $(dir $@)
++	$(QUIET)$(RM) -f $@
++	$(QUIET)$(INSTALL) -m 0644 $< $@
++
++# Create pkg_plist
++$(VBOX_NBSD_INST_OUT_DIR)/pkg_plist: \
++		$(VBOX_PATH_NBSD_INST_SRC)/pkg_plist
++	$(call MSG_INST_FILE,$<,$@)
++	$(QUIET)$(INSTALL) -d $(dir $@)
++	$(QUIET)$(SED) \
++		-e "s;_VBOX_REM_32BIT_MODULE_;$(if $(eq $(KBUILD_TARGET_ARCH),x86),VBoxREM32.so,);g" \
++		-e "s;_VBOX_REM_64BIT_MODULE_;$(if $(eq $(KBUILD_TARGET_ARCH),x86),VBoxREM64.so,);g" \
++		--output $@ \
++		$<
++ifdef VBOX_WITH_DTRACE
++	$(QUIET)$(APPEND) -n "$@" "@mode 644" \
++		$(addprefix lib/virtualbox/dtrace/lib/$(KBUILD_TARGET_ARCH)/,$(VBOXINST_DTRACE_LIB_ARCH_FILES)) \
++		$(addprefix lib/virtualbox/dtrace/testcase/$(KBUILD_TARGET_ARCH)/,$(VBOXINST_DTRACE_TESTCASE_ARCH_FILES)) \
++		$(addprefix lib/virtualbox/dtrace/scripts/,$(VBOXINST_DTRACE_SCRIPTS_FILES)) \
++		"@mode 755" \
++		"bin/VBoxDTrace"
++endif
++
++include $(FILE_KBUILD_SUB_FOOTER)
diff --git a/virtualbox-svn/patches/patch-src_VBox_Installer_netbsd_pkg-comment b/virtualbox-svn/patches/patch-src_VBox_Installer_netbsd_pkg-comment
new file mode 100644
index 0000000..f994e82
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Installer_netbsd_pkg-comment
@@ -0,0 +1,6 @@
+$NetBSD$
+
+--- src/VBox/Installer/netbsd/pkg-comment.orig	2016-07-06 20:01:35.493671141 +0000
++++ src/VBox/Installer/netbsd/pkg-comment
+@@ -0,0 +1 @@
++VirtualBox x86 virtualization package
diff --git a/virtualbox-svn/patches/patch-src_VBox_Installer_netbsd_pkg-descr b/virtualbox-svn/patches/patch-src_VBox_Installer_netbsd_pkg-descr
new file mode 100644
index 0000000..cd5a879
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Installer_netbsd_pkg-descr
@@ -0,0 +1,8 @@
+$NetBSD$
+
+--- src/VBox/Installer/netbsd/pkg-descr.orig	2016-07-07 07:08:46.642993647 +0000
++++ src/VBox/Installer/netbsd/pkg-descr
+@@ -0,0 +1,3 @@
++VirtualBox for the NetBSD operating system
++
++WWW: http://www.virtualbox.org
diff --git a/virtualbox-svn/patches/patch-src_VBox_Installer_netbsd_pkg__plist b/virtualbox-svn/patches/patch-src_VBox_Installer_netbsd_pkg__plist
new file mode 100644
index 0000000..23cbbc4
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Installer_netbsd_pkg__plist
@@ -0,0 +1,103 @@
+$NetBSD$
+
+--- src/VBox/Installer/netbsd/pkg_plist.orig	2016-07-06 20:01:35.495294415 +0000
++++ src/VBox/Installer/netbsd/pkg_plist
+@@ -0,0 +1,98 @@
++@owner root
++@group wheel
++@mode 755
++lib/virtualbox/VBoxDbg.so
++lib/virtualbox/DbgPlugInDiggers.so
++lib/virtualbox/VBoxDD.so
++lib/virtualbox/VBoxDD2.so
++lib/virtualbox/VBoxDDU.so
++lib/virtualbox/VBoxGuestPropSvc.so
++lib/virtualbox/VBoxGuestControlSvc.so
++lib/virtualbox/VBoxHostChannel.so
++lib/virtualbox/VBoxHeadless.so
++lib/virtualbox/VBoxKeyboard.so
++lib/virtualbox/VBoxManage
++lib/virtualbox/VBoxNetDHCP.so
++lib/virtualbox/VBoxPython.so
++lib/virtualbox/VBoxREM.so
++lib/virtualbox/VBoxRT.so
++lib/virtualbox/VBoxSDL.so
++lib/virtualbox/VBoxSharedFolders.so
++lib/virtualbox/VBoxSVC
++lib/virtualbox/VBoxVMM.so
++lib/virtualbox/VBoxVRDP.so
++lib/virtualbox/VBoxXPCOM.so
++lib/virtualbox/VBoxXPCOMC.so
++lib/virtualbox/VBoxXPCOMIPCD
++lib/virtualbox/VirtualBox.so
++lib/virtualbox/VBoxOGLhostcrutil.so
++lib/virtualbox/VBoxOGLhosterrorspu.so
++lib/virtualbox/VBoxOGLrenderspu.so
++lib/virtualbox/vboxwebsrv
++lib/virtualbox/webtest
++lib/virtualbox/rdesktop-vrdp
++lib/virtualbox/VBoxTestOGL
++_VBOX_REM_32BIT_MODULE_
++_VBOX_REM_64BIT_MODULE_
++@mode 4755
++lib/virtualbox/VBoxSDL
++lib/virtualbox/VirtualBox
++lib/virtualbox/VBoxNetDHCP
++lib/virtualbox/VBoxNetAdpCtl
++lib/virtualbox/VBoxHeadless
++@mode 755
++lib/virtualbox/components/VBoxC.so
++lib/virtualbox/components/VBoxSVCM.so
++lib/virtualbox/components/VBoxXPCOMIPCC.so
++@mode 644
++lib/virtualbox/components/VBoxXPCOMBase.xpt
++lib/virtualbox/components/VirtualBox_XPCOM.xpt
++@mode 755
++bin/VirtualBox
++bin/VBoxManage
++bin/VBoxSVC
++bin/VBoxHeadless
++bin/VBoxSDL
++bin/vboxwebsrv
++@mode 644
++lib/virtualbox/VBoxDDRC.rc
++lib/virtualbox/VBoxDD2RC.rc
++lib/virtualbox/VBoxDDR0.r0
++lib/virtualbox/VBoxDD2R0.r0
++lib/virtualbox/VMMRC.rc
++lib/virtualbox/VMMR0.r0
++lib/virtualbox/License-7.html
++lib/virtualbox/vboxdrv.tar.gz
++lib/virtualbox/nls/qt_de.qm
++lib/virtualbox/nls/VirtualBox_de.qm
++lib/virtualbox/nls/qt_fr.qm
++lib/virtualbox/nls/VirtualBox_fr.qm
++lib/virtualbox/nls/qt_it.qm
++lib/virtualbox/nls/VirtualBox_it.qm
++lib/virtualbox/nls/qt_ro.qm
++lib/virtualbox/nls/VirtualBox_ro.qm
++lib/virtualbox/nls/qt_zh_CN.qm
++lib/virtualbox/nls/VirtualBox_zh_CN.qm
++lib/virtualbox/nls/qt_ja.qm
++lib/virtualbox/nls/VirtualBox_ja.qm
++lib/virtualbox/nls/qt_es.qm
++lib/virtualbox/nls/VirtualBox_es.qm
++lib/virtualbox/nls/qt_ru.qm
++lib/virtualbox/nls/VirtualBox_ru.qm
++lib/virtualbox/nls/qt_pl.qm
++lib/virtualbox/nls/VirtualBox_pl.qm
++lib/virtualbox/nls/qt_pt_BR.qm
++lib/virtualbox/nls/VirtualBox_pt_BR.qm
++lib/virtualbox/nls/qt_ko.qm
++lib/virtualbox/nls/VirtualBox_ko.qm
++lib/virtualbox/nls/qt_sv.qm
++lib/virtualbox/nls/VirtualBox_sv.qm
++lib/virtualbox/nls/qt_fi.qm
++lib/virtualbox/nls/VirtualBox_fi.qm
++lib/virtualbox/nls/qt_hu.qm
++lib/virtualbox/nls/VirtualBox_hu.qm
++lib/virtualbox/nls/qt_cs.qm
++lib/virtualbox/nls/VirtualBox_cs.qm
++share/applications/virtualbox.desktop
++share/pixmaps/VBox.png
++
diff --git a/virtualbox-svn/patches/patch-src_VBox_Installer_netbsd_postdeinstall.sh b/virtualbox-svn/patches/patch-src_VBox_Installer_netbsd_postdeinstall.sh
new file mode 100644
index 0000000..73a1a9d
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Installer_netbsd_postdeinstall.sh
@@ -0,0 +1,36 @@
+$NetBSD$
+
+--- src/VBox/Installer/netbsd/postdeinstall.sh.orig	2016-07-07 07:08:46.660385240 +0000
++++ src/VBox/Installer/netbsd/postdeinstall.sh
+@@ -0,0 +1,31 @@
++#!/bin/sh
++## @file
++#
++# VirtualBox postdeinstall script for NetBSD.
++#
++
++#
++# Copyright (C) 2007-2015 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.
++#
++
++echo "Removing kernel modules, please wait..."
++
++kldunload vboxnetadp
++kldunload vboxnetflt
++kldunload vboxdrv
++rm /boot/kernel/vboxnetflt.ko
++rm /boot/kernel/vboxnetadp.ko
++rm /boot/kernel/vboxdrv.ko
++kldxref -R /boot
++
++echo "Kernel modules successfully removed."
++
++exit 0
diff --git a/virtualbox-svn/patches/patch-src_VBox_Installer_netbsd_postinstall.sh b/virtualbox-svn/patches/patch-src_VBox_Installer_netbsd_postinstall.sh
new file mode 100644
index 0000000..33874f0
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Installer_netbsd_postinstall.sh
@@ -0,0 +1,80 @@
+$NetBSD$
+
+--- src/VBox/Installer/netbsd/postinstall.sh.orig	2016-07-07 07:08:46.669159987 +0000
++++ src/VBox/Installer/netbsd/postinstall.sh
+@@ -0,0 +1,75 @@
++#!/bin/sh
++## @file
++#
++# VirtualBox postinstall script for NetBSD.
++#
++
++#
++# Copyright (C) 2007-2015 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_TMP="/tmp"
++PATH_TMP_MODS="$PATH_TMP/vbox_mods"
++PATH_INST="/usr/local/lib/virtualbox"
++PATH_KERN_SRC="/usr/src/sys"
++FILE_VBOXDRV="$PATH_INST/vboxdrv.tar.gz"
++
++
++if [ ! -f $PATH_KERN_SRC/Makefile ]; then
++    echo "Kernel sources are not installed. Please install them and reinstall VirtualBox"
++    exit 1
++fi
++
++echo "Compiling kernel modules, please wait..."
++
++# Create temporary directory
++mkdir -p $PATH_TMP_MODS
++
++# Unpack archive
++tar -C $PATH_TMP_MODS -xf  $FILE_VBOXDRV
++
++# Compile
++cd $PATH_TMP_MODS
++make
++
++# Check if we succeeded
++if [ $? != 0 ]; then
++    echo "Compiling kernel modules failed."
++    cd ..
++    rm -rf $PATH_TMP_MODS
++    exit 1
++fi
++
++# Copy the modules to /boot/kernel
++echo "Installing kernel modules to /boot/kernel, please wait..."
++cp $PATH_TMP_MODS/vboxdrv.ko /boot/kernel
++cp $PATH_TMP_MODS/vboxnetflt.ko /boot/kernel
++cp $PATH_TMP_MODS/vboxnetadp.ko /boot/kernel
++kldxref -R /boot
++
++# Load them now, unloading old modules
++make load
++
++if [ $? != 0 ]; then
++    echo "Loading kernel modules failed"
++    cd ..
++    rm -rf $PATH_TMP_MODS
++    exit 1
++fi
++
++echo "Kernel modules successfully installed."
++echo "To load them on every boot put them into /boot/loader.conf"
++
++# Cleanup
++cd ..
++rm -rf $PATH_TMP_MODS
++
++exit 0
diff --git a/virtualbox-svn/patches/patch-src_VBox_Installer_netbsd_virtualbox.desktop b/virtualbox-svn/patches/patch-src_VBox_Installer_netbsd_virtualbox.desktop
new file mode 100644
index 0000000..d8f2b5b
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Installer_netbsd_virtualbox.desktop
@@ -0,0 +1,23 @@
+$NetBSD$
+
+--- src/VBox/Installer/netbsd/virtualbox.desktop.orig	2016-07-07 07:08:46.678057739 +0000
++++ src/VBox/Installer/netbsd/virtualbox.desktop
+@@ -0,0 +1,18 @@
++
++[Desktop Entry]
++Encoding=UTF-8
++Version=1.0
++Name=Oracle VM VirtualBox
++GenericName=Virtual Machine
++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
++Comment[de]=Windows und andere Betriebssysteme unter NetBSD ausführen
++Comment[it]=Esegui più macchine virtuali su un singolo computer
++Comment[pl]=Uruchamianie wielu systemów wirtualnych na jednym komputerze gospodarza
++Comment[sv]=Kör flera virtuella system på en enda värddator
++Comment[ko]=가상 머신
diff --git a/virtualbox-svn/patches/patch-src_VBox_Main_Makefile.kmk b/virtualbox-svn/patches/patch-src_VBox_Main_Makefile.kmk
new file mode 100644
index 0000000..ed4abc9
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Main_Makefile.kmk
@@ -0,0 +1,39 @@
+$NetBSD$
+
+--- src/VBox/Main/Makefile.kmk.orig	2016-07-10 20:39:13.000000000 +0000
++++ src/VBox/Main/Makefile.kmk
+@@ -445,6 +445,10 @@ VBoxSVC_SOURCES.freebsd = \
+ 	src-server/freebsd/HostHardwareFreeBSD.cpp \
+ 	src-server/HostDnsServiceResolvConf.cpp
+ 
++VBoxSVC_SOURCES.netbsd = \
++	src-server/netbsd/HostHardwareNetBSD.cpp \
++	src-server/HostDnsServiceResolvConf.cpp
++
+ 
+ ifdef VBOX_WITH_USB
+  ifdef VBOX_WITH_SYSFS_BY_DEFAULT
+@@ -490,6 +494,7 @@ ifdef VBOX_WITH_RESOURCE_USAGE_API
+ 	src-server/Performance.cpp
+  VBoxSVC_SOURCES.darwin  +=  src-server/darwin/PerformanceDarwin.cpp
+  VBoxSVC_SOURCES.freebsd += src-server/freebsd/PerformanceFreeBSD.cpp
++ VBoxSVC_SOURCES.netbsd += src-server/netbsd/PerformanceNetBSD.cpp
+  VBoxSVC_SOURCES.linux   +=   src-server/linux/PerformanceLinux.cpp
+  VBoxSVC_SOURCES.os2     +=     src-server/os2/PerformanceOs2.cpp
+  VBoxSVC_SOURCES.solaris += src-server/solaris/PerformanceSolaris.cpp
+@@ -506,8 +511,9 @@ ifdef VBOX_WITH_HOSTNETIF_API
+  VBoxSVC_SOURCES.darwin  +=  src-server/darwin/NetIf-darwin.cpp
+  VBoxSVC_SOURCES.solaris += src-server/solaris/NetIf-solaris.cpp
+  VBoxSVC_SOURCES.freebsd += src-server/freebsd/NetIf-freebsd.cpp
++ VBoxSVC_SOURCES.netbsd  += src-server/netbsd/NetIf-netbsd.cpp
+  VBoxSVC_DEFS            += VBOX_WITH_HOSTNETIF_API
+- if1of ($(KBUILD_TARGET), linux darwin solaris freebsd)
++ if1of ($(KBUILD_TARGET), linux darwin solaris freebsd netbsd)
+   VBoxSVC_SOURCES        += src-server/generic/NetIf-generic.cpp
+  endif
+ endif
+@@ -1376,4 +1382,3 @@ testapiwrappers:: \
+ updatenls::
+ 	$(VBOX_LUPDATE) $(VBoxSVC_SOURCES) $(VBoxSVC_VBOX_HEADERS) -ts $(VBoxSVC_VBOX_TRANSLATIONS)
+ 	$(VBOX_LUPDATE) $(VBoxC_SOURCES) $(VBoxC_VBOX_HEADERS) -ts $(VBoxC_VBOX_TRANSLATIONS)
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_Main_cbinding_VBoxCAPIGlue.c b/virtualbox-svn/patches/patch-src_VBox_Main_cbinding_VBoxCAPIGlue.c
new file mode 100644
index 0000000..95fbf04
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Main_cbinding_VBoxCAPIGlue.c
@@ -0,0 +1,28 @@
+$NetBSD$
+
+--- src/VBox/Main/cbinding/VBoxCAPIGlue.c.orig	2016-03-04 19:29:35.000000000 +0000
++++ src/VBox/Main/cbinding/VBoxCAPIGlue.c
+@@ -50,7 +50,7 @@
+ /*********************************************************************************************************************************
+ *   Defined Constants And Macros                                                                                                 *
+ *********************************************************************************************************************************/
+-#if defined(__linux__) || defined(__linux_gnu__) || defined(__sun__) || defined(__FreeBSD__)
++#if defined(__linux__) || defined(__linux_gnu__) || defined(__sun__) || defined(__FreeBSD__) || defined(__NetBSD__)
+ # define DYNLIB_NAME        "VBoxXPCOMC.so"
+ #elif defined(__APPLE__)
+ # define DYNLIB_NAME        "VBoxXPCOMC.dylib"
+@@ -280,6 +280,9 @@ int VBoxCGlueInit(void)
+ #elif defined(__FreeBSD__)
+     if (tryLoadLibrary("/usr/local/lib/virtualbox", 1) == 0)
+         return 0;
++#elif defined(__NetBSD__)
++    if (tryLoadLibrary("/usr/local/lib/virtualbox", 1) == 0)
++        return 0;
+ #elif defined(__OS2__)
+     if (tryLoadLibrary("C:/Apps/VirtualBox", 1) == 0)
+         return 0;
+@@ -336,4 +339,3 @@ void VBoxCGlueTerm(void)
+     g_pfnGetFunctions = NULL;
+     memset(g_szVBoxErrMsg, 0, sizeof(g_szVBoxErrMsg));
+ }
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_Main_cbinding_VBoxCAPI__v2__2.h b/virtualbox-svn/patches/patch-src_VBox_Main_cbinding_VBoxCAPI__v2__2.h
new file mode 100644
index 0000000..41c1e37
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Main_cbinding_VBoxCAPI__v2__2.h
@@ -0,0 +1,14 @@
+$NetBSD$
+
+--- src/VBox/Main/cbinding/VBoxCAPI_v2_2.h.orig	2016-03-04 19:29:35.000000000 +0000
++++ src/VBox/Main/cbinding/VBoxCAPI_v2_2.h
+@@ -921,7 +921,8 @@ enum CIMOSType
+     CIMOSType_CIMOS_Linux_2_6_x = 99,
+     CIMOSType_CIMOS_Linux_2_6_x_64 = 100,
+     CIMOSType_CIMOS_Linux_64 = 101,
+-    CIMOSType_CIMOS_Other_64 = 102
++    CIMOSType_CIMOS_Other_64 = 102,
++    CIMOSType_CIMOS_NetBSD_64 = 103,
+ };
+ /* End of enum CIMOSType Declaration */
+ 
diff --git a/virtualbox-svn/patches/patch-src_VBox_Main_cbinding_VBoxCAPI__v3__0.h b/virtualbox-svn/patches/patch-src_VBox_Main_cbinding_VBoxCAPI__v3__0.h
new file mode 100644
index 0000000..9c4ee6e
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Main_cbinding_VBoxCAPI__v3__0.h
@@ -0,0 +1,14 @@
+$NetBSD$
+
+--- src/VBox/Main/cbinding/VBoxCAPI_v3_0.h.orig	2016-03-04 19:29:35.000000000 +0000
++++ src/VBox/Main/cbinding/VBoxCAPI_v3_0.h
+@@ -1371,7 +1371,8 @@ enum CIMOSType
+     CIMOSType_CIMOS_Linux_2_6_x = 99,
+     CIMOSType_CIMOS_Linux_2_6_x_64 = 100,
+     CIMOSType_CIMOS_Linux_64 = 101,
+-    CIMOSType_CIMOS_Other_64 = 102
++    CIMOSType_CIMOS_Other_64 = 102,
++    CIMOSType_CIMOS_NetBSD_64 = 78,
+ };
+ /* End of enum CIMOSType Declaration */
+ 
diff --git a/virtualbox-svn/patches/patch-src_VBox_Main_glue_NativeEventQueue.cpp b/virtualbox-svn/patches/patch-src_VBox_Main_glue_NativeEventQueue.cpp
new file mode 100644
index 0000000..360cc8f
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Main_glue_NativeEventQueue.cpp
@@ -0,0 +1,16 @@
+$NetBSD$
+
+--- src/VBox/Main/glue/NativeEventQueue.cpp.orig	2016-03-04 19:29:36.000000000 +0000
++++ src/VBox/Main/glue/NativeEventQueue.cpp
+@@ -20,6 +20,11 @@
+ 
+ #include <new> /* For bad_alloc. */
+ 
++#ifdef RT_OS_NETBSD
++#include <sys/select.h>
++#include <sys/time.h>
++#endif
++
+ #ifdef RT_OS_DARWIN
+ # include <CoreFoundation/CFRunLoop.h>
+ #endif
diff --git a/virtualbox-svn/patches/patch-src_VBox_Main_glue_tests_Makefile b/virtualbox-svn/patches/patch-src_VBox_Main_glue_tests_Makefile
new file mode 100644
index 0000000..54b7003
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Main_glue_tests_Makefile
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- src/VBox/Main/glue/tests/Makefile.orig	2016-03-04 19:29:36.000000000 +0000
++++ src/VBox/Main/glue/tests/Makefile
+@@ -17,7 +17,7 @@
+ # User serviceable parts: adjust the following lines appropriately
+ #
+ 
+-# The host OS: linux, solaris, win, darwin, freebsd
++# The host OS: linux, solaris, win, darwin, freebsd, netbsd
+ HOSTOS=linux
+ # Absolute (!) path to the VirtualBox install directory
+ VBOX_BIN = /opt/VirtualBox
diff --git a/virtualbox-svn/patches/patch-src_VBox_Main_include_ConsoleImpl.h b/virtualbox-svn/patches/patch-src_VBox_Main_include_ConsoleImpl.h
new file mode 100644
index 0000000..1239e91
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Main_include_ConsoleImpl.h
@@ -0,0 +1,22 @@
+$NetBSD$
+
+--- src/VBox/Main/include/ConsoleImpl.h.orig	2016-03-04 19:29:36.000000000 +0000
++++ src/VBox/Main/include/ConsoleImpl.h
+@@ -579,7 +579,7 @@ private:
+     HRESULT i_powerDown(IProgress *aProgress = NULL);
+ 
+ /* Note: FreeBSD needs this whether netflt is used or not. */
+-#if ((defined(RT_OS_LINUX) && !defined(VBOX_WITH_NETFLT)) || defined(RT_OS_FREEBSD))
++#if ((defined(RT_OS_LINUX) && !defined(VBOX_WITH_NETFLT)) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD))
+     HRESULT i_attachToTapInterface(INetworkAdapter *networkAdapter);
+     HRESULT i_detachFromTapInterface(INetworkAdapter *networkAdapter);
+ #endif
+@@ -946,7 +946,7 @@ private:
+     } *mpIfSecKeyHlp;
+ 
+ /* Note: FreeBSD needs this whether netflt is used or not. */
+-#if ((defined(RT_OS_LINUX) && !defined(VBOX_WITH_NETFLT)) || defined(RT_OS_FREEBSD))
++#if ((defined(RT_OS_LINUX) && !defined(VBOX_WITH_NETFLT)) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD))
+     Utf8Str      maTAPDeviceName[8];
+     RTFILE       maTapFD[8];
+ #endif
diff --git a/virtualbox-svn/patches/patch-src_VBox_Main_include_HostUSBDeviceImpl.h b/virtualbox-svn/patches/patch-src_VBox_Main_include_HostUSBDeviceImpl.h
new file mode 100644
index 0000000..afc7651
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Main_include_HostUSBDeviceImpl.h
@@ -0,0 +1,2 @@
+$NetBSD$
+
diff --git a/virtualbox-svn/patches/patch-src_VBox_Main_include_USBProxyService.h b/virtualbox-svn/patches/patch-src_VBox_Main_include_USBProxyService.h
new file mode 100644
index 0000000..afc7651
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Main_include_USBProxyService.h
@@ -0,0 +1,2 @@
+$NetBSD$
+
diff --git a/virtualbox-svn/patches/patch-src_VBox_Main_include_ovfreader.h b/virtualbox-svn/patches/patch-src_VBox_Main_include_ovfreader.h
new file mode 100644
index 0000000..3d39375
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Main_include_ovfreader.h
@@ -0,0 +1,19 @@
+$NetBSD$
+
+--- src/VBox/Main/include/ovfreader.h.orig	2016-03-04 19:29:37.000000000 +0000
++++ src/VBox/Main/include/ovfreader.h
+@@ -174,7 +174,8 @@ enum CIMOSType_T
+     CIMOSType_CIMOS_CentOS_64 = 107,
+     CIMOSType_CIMOS_OracleEnterpriseLinux = 108,
+     CIMOSType_CIMOS_OracleEnterpriseLinux_64 = 109,
+-    CIMOSType_CIMOS_eComStation = 110
++    CIMOSType_CIMOS_eComStation = 110,
++    CIMOSType_CIMOS_NetBSD_64  = 78,
+     // no new types added with CIM 2.26.0
+ };
+ 
+@@ -655,4 +656,3 @@ private:
+ } // end namespace ovf
+ 
+ #endif // !____H_OVFREADER
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_Main_src-client_ConsoleImpl.cpp b/virtualbox-svn/patches/patch-src_VBox_Main_src-client_ConsoleImpl.cpp
new file mode 100644
index 0000000..2879188
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Main_src-client_ConsoleImpl.cpp
@@ -0,0 +1,54 @@
+$NetBSD$
+
+--- src/VBox/Main/src-client/ConsoleImpl.cpp.orig	2016-03-04 19:29:38.000000000 +0000
++++ src/VBox/Main/src-client/ConsoleImpl.cpp
+@@ -29,7 +29,7 @@
+ # include <stdio.h>
+ # include <stdlib.h>
+ # include <string.h>
+-#elif defined(RT_OS_FREEBSD)
++#elif defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+ # include <errno.h>
+ # include <sys/ioctl.h>
+ # include <sys/poll.h>
+@@ -8771,7 +8771,7 @@ Console::i_usbDetachCallback(Console *th
+ #endif /* VBOX_WITH_USB */
+ 
+ /* Note: FreeBSD needs this whether netflt is used or not. */
+-#if ((defined(RT_OS_LINUX) && !defined(VBOX_WITH_NETFLT)) || defined(RT_OS_FREEBSD))
++#if ((defined(RT_OS_LINUX) && !defined(VBOX_WITH_NETFLT)) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD))
+ /**
+  * Helper function to handle host interface device creation and attachment.
+  *
+@@ -8885,7 +8885,7 @@ HRESULT Console::i_attachToTapInterface(
+         }
+     }
+ 
+-# elif defined(RT_OS_FREEBSD)
++# elif defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+     /*
+      * Set/obtain the tap interface.
+      */
+@@ -9003,7 +9003,7 @@ HRESULT Console::i_detachFromTapInterfac
+     LogFlowThisFunc(("returning %d\n", rc));
+     return rc;
+ }
+-#endif /* (RT_OS_LINUX || RT_OS_FREEBSD) && !VBOX_WITH_NETFLT */
++#endif /* (RT_OS_LINUX || RT_OS_FREEBSD || RT_OS_NETBSD) && !VBOX_WITH_NETFLT */
+ 
+ /**
+  * Called at power down to terminate host interface networking.
+@@ -9047,11 +9047,11 @@ HRESULT Console::i_powerDownHostInterfac
+         pNetworkAdapter->COMGETTER(AttachmentType)(&attachment);
+         if (attachment == NetworkAttachmentType_Bridged)
+         {
+-#if ((defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD)) && !defined(VBOX_WITH_NETFLT))
++#if ((defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)) && !defined(VBOX_WITH_NETFLT))
+             HRESULT rc2 = i_detachFromTapInterface(pNetworkAdapter);
+             if (FAILED(rc2) && SUCCEEDED(rc))
+                 rc = rc2;
+-#endif /* (RT_OS_LINUX || RT_OS_FREEBSD) && !VBOX_WITH_NETFLT */
++#endif /* (RT_OS_LINUX || RT_OS_FREEBSD || RT_OS_NETBSD) && !VBOX_WITH_NETFLT */
+         }
+     }
+ 
diff --git a/virtualbox-svn/patches/patch-src_VBox_Main_src-client_ConsoleImpl2.cpp b/virtualbox-svn/patches/patch-src_VBox_Main_src-client_ConsoleImpl2.cpp
new file mode 100644
index 0000000..c33a0bd
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Main_src-client_ConsoleImpl2.cpp
@@ -0,0 +1,51 @@
+$NetBSD$
+
+--- src/VBox/Main/src-client/ConsoleImpl2.cpp.orig	2016-07-10 20:39:31.000000000 +0000
++++ src/VBox/Main/src-client/ConsoleImpl2.cpp
+@@ -103,7 +103,7 @@
+ #  include <linux/types.h>
+ #  include <linux/if.h>
+ #  include <linux/wireless.h>
+-# elif defined(RT_OS_FREEBSD)
++# elif defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+ #  include <unistd.h>
+ #  include <sys/types.h>
+ #  include <sys/ioctl.h>
+@@ -4862,7 +4862,7 @@ int Console::i_configNetwork(const char 
+ 
+             case NetworkAttachmentType_Bridged:
+             {
+-#if (defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD)) && !defined(VBOX_WITH_NETFLT)
++#if (defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)) && !defined(VBOX_WITH_NETFLT)
+                 hrc = i_attachToTapInterface(aNetworkAdapter);
+                 if (FAILED(hrc))
+                 {
+@@ -5057,8 +5057,8 @@ int Console::i_configNetwork(const char 
+                 const char *pszTrunk = szTrunkName;
+                 /* we're not releasing the INetCfg stuff here since we use it later to figure out whether it is wireless */
+ 
+-# elif defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD)
+-#  if defined(RT_OS_FREEBSD)
++# elif defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
++#  if defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+                 /*
+                  * If we bridge to a tap interface open it the `old' direct way.
+                  * This works and performs better than bridging a physical
+@@ -5168,7 +5168,7 @@ int Console::i_configNetwork(const char 
+                 }
+                 else
+                     Log(("Failed to open wireless socket\n"));
+-# elif defined(RT_OS_FREEBSD)
++# elif defined(RT_OS_FREEBSD)  || defined(RT_OS_NETBSD)
+                 int iSock = socket(AF_INET, SOCK_DGRAM, 0);
+                 if (iSock >= 0)
+                 {
+@@ -5286,7 +5286,7 @@ int Console::i_configNetwork(const char 
+             /* NOTHING TO DO HERE */
+ #elif defined(RT_OS_LINUX)
+ /// @todo aleksey: is there anything to be done here?
+-#elif defined(RT_OS_FREEBSD)
++#elif defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+ /** @todo FreeBSD: Check out this later (HIF networking). */
+ #else
+ # error "Port me"
diff --git a/virtualbox-svn/patches/patch-src_VBox_Main_src-server_ApplianceImpl.cpp b/virtualbox-svn/patches/patch-src_VBox_Main_src-server_ApplianceImpl.cpp
new file mode 100644
index 0000000..4f0a92c
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Main_src-server_ApplianceImpl.cpp
@@ -0,0 +1,25 @@
+$NetBSD$
+
+--- src/VBox/Main/src-server/ApplianceImpl.cpp.orig	2016-03-04 19:29:39.000000000 +0000
++++ src/VBox/Main/src-server/ApplianceImpl.cpp
+@@ -138,6 +138,7 @@ g_osTypes[] =
+     { ovf::CIMOSType_CIMOS_MicrosoftWindowsServer2008,           VBOXOSTYPE_Win2k8 },
+     { ovf::CIMOSType_CIMOS_MicrosoftWindowsServer2008_64,        VBOXOSTYPE_Win2k8_x64 },
+     { ovf::CIMOSType_CIMOS_FreeBSD_64,                           VBOXOSTYPE_FreeBSD_x64 },
++    { ovf::CIMOSType_CIMOS_NetBSD_64,                            VBOXOSTYPE_NetBSD_x64 },
+     { ovf::CIMOSType_CIMOS_MACOS,                                VBOXOSTYPE_MacOS },
+     { ovf::CIMOSType_CIMOS_MACOS,                                VBOXOSTYPE_MacOS_x64 }, // there is no CIM 64-bit type for this
+     { ovf::CIMOSType_CIMOS_MACOS,                                VBOXOSTYPE_MacOS106 },
+@@ -263,6 +264,7 @@ static const osTypePattern g_osTypesPatt
+     {"OpenSolaris",   VBOXOSTYPE_OpenSolaris_x64},
+     {"Solaris",       VBOXOSTYPE_OpenSolaris_x64},
+     {"FreeBSD",       VBOXOSTYPE_FreeBSD_x64},
++    {"NetBSD",        VBOXOSTYPE_NetBSD_x64},
+ };
+ 
+ /**
+@@ -1695,4 +1697,3 @@ const settings::MachineConfigFile* Virtu
+ {
+     return m->pConfig;
+ }
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_Main_src-server_HostDnsService.cpp b/virtualbox-svn/patches/patch-src_VBox_Main_src-server_HostDnsService.cpp
new file mode 100644
index 0000000..f266977
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Main_src-server_HostDnsService.cpp
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- src/VBox/Main/src-server/HostDnsService.cpp.orig	2016-03-04 19:29:40.000000000 +0000
++++ src/VBox/Main/src-server/HostDnsService.cpp
+@@ -152,6 +152,8 @@ const HostDnsMonitor *HostDnsMonitor::ge
+         g_monitor =  new HostDnsServiceSolaris();
+ # elif defined(RT_OS_FREEBSD)
+         g_monitor = new HostDnsServiceFreebsd();
++# elif defined(RT_OS_NETBSD)
++        g_monitor = new HostDnsServiceNetbsd();
+ # elif defined(RT_OS_OS2)
+         g_monitor = new HostDnsServiceOs2();
+ # else
diff --git a/virtualbox-svn/patches/patch-src_VBox_Main_src-server_HostDnsService.h b/virtualbox-svn/patches/patch-src_VBox_Main_src-server_HostDnsService.h
new file mode 100644
index 0000000..82b9a2a
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Main_src-server_HostDnsService.h
@@ -0,0 +1,31 @@
+$NetBSD$
+
+--- src/VBox/Main/src-server/HostDnsService.h.orig	2016-03-04 19:29:40.000000000 +0000
++++ src/VBox/Main/src-server/HostDnsService.h
+@@ -154,7 +154,7 @@ class HostDnsServiceWin : public HostDns
+     Data *m;
+ };
+ # endif
+-# if defined(RT_OS_SOLARIS) || defined(RT_OS_LINUX) || defined(RT_OS_OS2) || defined(RT_OS_FREEBSD)
++# if defined(RT_OS_SOLARIS) || defined(RT_OS_LINUX) || defined(RT_OS_OS2) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+ class HostDnsServiceResolvConf: public HostDnsMonitor
+ {
+   public:
+@@ -215,6 +215,17 @@ class HostDnsServiceFreebsd: public Host
+     }
+ };
+ 
++#  elif defined(RT_OS_NETBSD)
++class HostDnsServiceNetbsd: public HostDnsServiceResolvConf
++{
++    public:
++    HostDnsServiceNetbsd(){}
++    ~HostDnsServiceNetbsd(){}
++    virtual HRESULT init(VirtualBox *virtualbox) {
++        return HostDnsServiceResolvConf::init(virtualbox, "/etc/resolv.conf");
++    }
++};
++
+ #  elif defined(RT_OS_OS2)
+ class HostDnsServiceOs2 : public HostDnsServiceResolvConf
+ {
diff --git a/virtualbox-svn/patches/patch-src_VBox_Main_src-server_HostImpl.cpp b/virtualbox-svn/patches/patch-src_VBox_Main_src-server_HostImpl.cpp
new file mode 100644
index 0000000..6d74b41
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Main_src-server_HostImpl.cpp
@@ -0,0 +1,54 @@
+$NetBSD$
+
+--- src/VBox/Main/src-server/HostImpl.cpp.orig	2016-07-10 20:33:47.000000000 +0000
++++ src/VBox/Main/src-server/HostImpl.cpp
+@@ -47,11 +47,11 @@
+ #include "MediumImpl.h"
+ #include "HostPower.h"
+ 
+-#if defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD)
++#if defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+ # include <HostHardwareLinux.h>
+ #endif
+ 
+-#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD)
++#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+ # include <set>
+ #endif
+ 
+@@ -214,7 +214,7 @@ struct Host::Data
+     bool                    fDVDDrivesListBuilt,
+                             fFloppyDrivesListBuilt;
+ 
+-#if defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD)
++#if defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+     /** Object with information about host drives */
+     VBoxMainDriveInfo       hostDrives;
+ #endif
+@@ -407,7 +407,7 @@ HRESULT Host::init(VirtualBox *aParent)
+     m->f3DAccelerationSupported = false;
+ #endif
+ 
+-#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD)
++#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+     /* Extract the list of configured host-only interfaces */
+     std::set<Utf8Str> aConfiguredNames;
+     SafeArray<BSTR> aGlobalExtraDataKeys;
+@@ -441,7 +441,7 @@ HRESULT Host::init(VirtualBox *aParent)
+             LogRel(("failed to create %s, error (0x%x)\n", it->c_str(), r));
+     }
+ 
+-#endif /* defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD) */
++#endif /* defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD) */
+ 
+     /* Confirm a successful initialization */
+     autoInitSpan.setSucceeded();
+@@ -2087,7 +2087,7 @@ HRESULT Host::i_buildDVDDrivesList(Media
+             i_getDVDInfoFromDevTree(list);
+         }
+ 
+-#elif defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD)
++#elif defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+         if (RT_SUCCESS(m->hostDrives.updateDVDs()))
+             for (DriveInfoList::const_iterator it = m->hostDrives.DVDBegin();
+                 SUCCEEDED(rc) && it != m->hostDrives.DVDEnd(); ++it)
diff --git a/virtualbox-svn/patches/patch-src_VBox_Main_src-server_HostNetworkInterfaceImpl.cpp b/virtualbox-svn/patches/patch-src_VBox_Main_src-server_HostNetworkInterfaceImpl.cpp
new file mode 100644
index 0000000..0ad8657
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Main_src-server_HostNetworkInterfaceImpl.cpp
@@ -0,0 +1,16 @@
+$NetBSD$
+
+--- src/VBox/Main/src-server/HostNetworkInterfaceImpl.cpp.orig	2016-03-04 19:29:40.000000000 +0000
++++ src/VBox/Main/src-server/HostNetworkInterfaceImpl.cpp
+@@ -27,9 +27,9 @@
+ 
+ #include <iprt/cpp/utils.h>
+ 
+-#ifdef RT_OS_FREEBSD
++#if defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+ # include <netinet/in.h> /* INADDR_NONE */
+-#endif /* RT_OS_FREEBSD */
++#endif /* RT_OS_FREEBSD || RT_OS_NETBSD */
+ 
+ #include "VirtualBoxImpl.h"
+ 
diff --git a/virtualbox-svn/patches/patch-src_VBox_Main_src-server_MachineImpl.cpp b/virtualbox-svn/patches/patch-src_VBox_Main_src-server_MachineImpl.cpp
new file mode 100644
index 0000000..a344b9d
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Main_src-server_MachineImpl.cpp
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- src/VBox/Main/src-server/MachineImpl.cpp.orig	2016-03-04 19:29:40.000000000 +0000
++++ src/VBox/Main/src-server/MachineImpl.cpp
+@@ -2021,7 +2021,7 @@ HRESULT Machine::getMemoryBalloonSize(UL
+ HRESULT Machine::setMemoryBalloonSize(ULONG aMemoryBalloonSize)
+ {
+     /* This must match GMMR0Init; currently we only support memory ballooning on all 64-bit hosts except Mac OS X */
+-#if HC_ARCH_BITS == 64 && (defined(RT_OS_WINDOWS) || defined(RT_OS_SOLARIS) || defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD))
++#if HC_ARCH_BITS == 64 && (defined(RT_OS_WINDOWS) || defined(RT_OS_SOLARIS) || defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD))
+     /* check limits */
+     if (aMemoryBalloonSize >= VMMDEV_MAX_MEMORY_BALLOON(mHWData->mMemorySize))
+         return setError(E_INVALIDARG,
diff --git a/virtualbox-svn/patches/patch-src_VBox_Main_src-server_generic_NetIf-generic.cpp b/virtualbox-svn/patches/patch-src_VBox_Main_src-server_generic_NetIf-generic.cpp
new file mode 100644
index 0000000..0cf276d
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Main_src-server_generic_NetIf-generic.cpp
@@ -0,0 +1,22 @@
+$NetBSD$
+
+--- src/VBox/Main/src-server/generic/NetIf-generic.cpp.orig	2016-03-04 19:29:41.000000000 +0000
++++ src/VBox/Main/src-server/generic/NetIf-generic.cpp
+@@ -184,7 +184,7 @@ int NetIfCreateHostOnlyNetworkInterface(
+                                         IProgress **aProgress,
+                                         const char *pcszName)
+ {
+-#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD)
++#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+     /* create a progress object */
+     ComObjPtr<Progress> progress;
+     progress.createObject();
+@@ -311,7 +311,7 @@ int NetIfCreateHostOnlyNetworkInterface(
+ int NetIfRemoveHostOnlyNetworkInterface(VirtualBox *pVirtualBox, IN_GUID aId,
+                                         IProgress **aProgress)
+ {
+-#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD)
++#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+     /* create a progress object */
+     ComObjPtr<Progress> progress;
+     progress.createObject();
diff --git a/virtualbox-svn/patches/patch-src_VBox_Main_src-server_netbsd_HostHardwareNetBSD.cpp b/virtualbox-svn/patches/patch-src_VBox_Main_src-server_netbsd_HostHardwareNetBSD.cpp
new file mode 100644
index 0000000..081d414
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Main_src-server_netbsd_HostHardwareNetBSD.cpp
@@ -0,0 +1,389 @@
+$NetBSD$
+
+--- src/VBox/Main/src-server/netbsd/HostHardwareNetBSD.cpp.orig	2016-07-06 20:08:39.045579684 +0000
++++ src/VBox/Main/src-server/netbsd/HostHardwareNetBSD.cpp
+@@ -0,0 +1,384 @@
++/*  HostHardwareNetBSD.cpp $ */
++/** @file
++ * Classes for handling hardware detection under NetBSD.
++ */
++
++/*
++ * Copyright (C) 2008-2013 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.
++ */
++
++#define LOG_GROUP LOG_GROUP_MAIN
++
++
++/*********************************************************************************************************************************
++*   Header Files                                                                                                                 *
++*********************************************************************************************************************************/
++
++#include <HostHardwareLinux.h>
++
++#include <VBox/log.h>
++
++#include <iprt/dir.h>
++#include <iprt/env.h>
++#include <iprt/file.h>
++#include <iprt/mem.h>
++#include <iprt/param.h>
++#include <iprt/path.h>
++#include <iprt/string.h>
++
++#ifdef RT_OS_NETBSD
++# include <sys/param.h>
++# include <sys/types.h>
++# include <sys/stat.h>
++# include <unistd.h>
++# include <stdio.h>
++# include <sys/ioctl.h>
++# include <fcntl.h>
++# include <cam/cam.h>
++# include <cam/cam_ccb.h>
++# include <cam/scsi/scsi_pass.h>
++#endif /* RT_OS_NETBSD */
++#include <vector>
++
++
++/*********************************************************************************************************************************
++*   Typedefs and Defines                                                                                                         *
++*********************************************************************************************************************************/
++
++static int getDriveInfoFromEnv(const char *pcszVar, DriveInfoList *pList,
++                               bool isDVD, bool *pfSuccess);
++static int getDVDInfoFromCAM(DriveInfoList *pList, bool *pfSuccess);
++
++/** Find the length of a string, ignoring trailing non-ascii or control
++ * characters */
++static size_t strLenStripped(const char *pcsz)
++{
++    size_t cch = 0;
++    for (size_t i = 0; pcsz[i] != '\0'; ++i)
++        if (pcsz[i] > 32 && pcsz[i] < 127)
++            cch = i;
++    return cch + 1;
++}
++
++static void strLenRemoveTrailingWhiteSpace(char *psz, size_t cchStr)
++{
++    while (   (cchStr > 0)
++           && (psz[cchStr -1] == ' '))
++        psz[--cchStr] = '\0';
++}
++
++/**
++ * Initialise the device description for a DVD drive based on
++ * vendor and model name strings.
++ * @param pcszVendor  the vendor ID string
++ * @param pcszModel   the product ID string
++ * @param pszDesc    where to store the description string (optional)
++ * @param cchDesc    the size of the buffer in @pszDesc
++ */
++/* static */
++void dvdCreateDeviceString(const char *pcszVendor, const char *pcszModel,
++                            char *pszDesc, size_t cchDesc)
++{
++    AssertPtrReturnVoid(pcszVendor);
++    AssertPtrReturnVoid(pcszModel);
++    AssertPtrNullReturnVoid(pszDesc);
++    AssertReturnVoid(!pszDesc || cchDesc > 0);
++    size_t cchVendor = strLenStripped(pcszVendor);
++    size_t cchModel = strLenStripped(pcszModel);
++
++    /* Construct the description string as "Vendor Product" */
++    if (pszDesc)
++    {
++        if (cchVendor > 0)
++            RTStrPrintf(pszDesc, cchDesc, "%.*s %s", cchVendor, pcszVendor,
++                        cchModel > 0 ? pcszModel : "(unknown drive model)");
++        else
++            RTStrPrintf(pszDesc, cchDesc, "%s", pcszModel);
++    }
++}
++
++
++int VBoxMainDriveInfo::updateDVDs ()
++{
++    LogFlowThisFunc(("entered\n"));
++    int rc = VINF_SUCCESS;
++    bool fSuccess = false;  /* Have we succeeded in finding anything yet? */
++
++    try
++    {
++        mDVDList.clear ();
++        /* Always allow the user to override our auto-detection using an
++         * environment variable. */
++        if (RT_SUCCESS(rc) && !fSuccess)
++            rc = getDriveInfoFromEnv("VBOX_CDROM", &mDVDList, true /* isDVD */,
++                                     &fSuccess);
++        if (RT_SUCCESS(rc) && !fSuccess)
++            rc = getDVDInfoFromCAM(&mDVDList, &fSuccess);
++    }
++    catch(std::bad_alloc &e)
++    {
++        rc = VERR_NO_MEMORY;
++    }
++    LogFlowThisFunc(("rc=%Rrc\n", rc));
++    return rc;
++}
++
++int VBoxMainDriveInfo::updateFloppies ()
++{
++    LogFlowThisFunc(("entered\n"));
++    int rc = VINF_SUCCESS;
++    bool fSuccess = false;  /* Have we succeeded in finding anything yet? */
++
++    try
++    {
++        mFloppyList.clear ();
++        /* Always allow the user to override our auto-detection using an
++         * environment variable. */
++        if (RT_SUCCESS(rc) && !fSuccess)
++            rc = getDriveInfoFromEnv("VBOX_FLOPPY", &mFloppyList, false /* isDVD */,
++                                     &fSuccess);
++    }
++    catch(std::bad_alloc &e)
++    {
++        rc = VERR_NO_MEMORY;
++    }
++    LogFlowThisFunc(("rc=%Rrc\n", rc));
++    return rc;
++}
++
++/**
++ * Search for available CD/DVD drives using the CAM layer.
++ *
++ * @returns iprt status code
++ * @param   pList      the list to append the drives found to
++ * @param   pfSuccess  this will be set to true if we found at least one drive
++ *                     and to false otherwise.  Optional.
++ */
++static int getDVDInfoFromCAM(DriveInfoList *pList, bool *pfSuccess)
++{
++    int rc = VINF_SUCCESS;
++    RTFILE FileXpt;
++
++    rc = RTFileOpen(&FileXpt, "/dev/xpt0", RTFILE_O_READWRITE | RTFILE_O_OPEN | RTFILE_O_DENY_NONE);
++    if (RT_SUCCESS(rc))
++    {
++        union ccb DeviceCCB;
++        struct dev_match_pattern DeviceMatchPattern;
++        struct dev_match_result *paMatches = NULL;
++
++        RT_ZERO(DeviceCCB);
++        RT_ZERO(DeviceMatchPattern);
++
++        /* We want to get all devices. */
++        DeviceCCB.ccb_h.func_code  = XPT_DEV_MATCH;
++        DeviceCCB.ccb_h.path_id    = CAM_XPT_PATH_ID;
++        DeviceCCB.ccb_h.target_id  = CAM_TARGET_WILDCARD;
++        DeviceCCB.ccb_h.target_lun = CAM_LUN_WILDCARD;
++
++        /* Setup the pattern */
++        DeviceMatchPattern.type = DEV_MATCH_DEVICE;
++        DeviceMatchPattern.pattern.device_pattern.path_id    = CAM_XPT_PATH_ID;
++        DeviceMatchPattern.pattern.device_pattern.target_id  = CAM_TARGET_WILDCARD;
++        DeviceMatchPattern.pattern.device_pattern.target_lun = CAM_LUN_WILDCARD;
++        DeviceMatchPattern.pattern.device_pattern.flags      = DEV_MATCH_INQUIRY;
++
++#if __NetBSD_version >= 900000
++# define INQ_PAT data.inq_pat
++#else
++ #define INQ_PAT inq_pat
++#endif
++        DeviceMatchPattern.pattern.device_pattern.INQ_PAT.type = T_CDROM;
++        DeviceMatchPattern.pattern.device_pattern.INQ_PAT.media_type  = SIP_MEDIA_REMOVABLE | SIP_MEDIA_FIXED;
++        DeviceMatchPattern.pattern.device_pattern.INQ_PAT.vendor[0]   = '*'; /* Matches anything */
++        DeviceMatchPattern.pattern.device_pattern.INQ_PAT.product[0]  = '*'; /* Matches anything */
++        DeviceMatchPattern.pattern.device_pattern.INQ_PAT.revision[0] = '*'; /* Matches anything */
++#undef INQ_PAT
++        DeviceCCB.cdm.num_patterns    = 1;
++        DeviceCCB.cdm.pattern_buf_len = sizeof(struct dev_match_result);
++        DeviceCCB.cdm.patterns        = &DeviceMatchPattern;
++
++        /*
++         * Allocate the buffer holding the matches.
++         * We will allocate for 10 results and call
++         * CAM multiple times if we have more results.
++         */
++        paMatches = (struct dev_match_result *)RTMemAllocZ(10 * sizeof(struct dev_match_result));
++        if (paMatches)
++        {
++            DeviceCCB.cdm.num_matches   = 0;
++            DeviceCCB.cdm.match_buf_len = 10 * sizeof(struct dev_match_result);
++            DeviceCCB.cdm.matches       = paMatches;
++
++            do
++            {
++                rc = RTFileIoCtl(FileXpt, CAMIOCOMMAND, &DeviceCCB, sizeof(union ccb), NULL);
++                if (RT_FAILURE(rc))
++                {
++                    Log(("Error while querying available CD/DVD devices rc=%Rrc\n", rc));
++                    break;
++                }
++
++                for (unsigned i = 0; i < DeviceCCB.cdm.num_matches; i++)
++                {
++                    if (paMatches[i].type == DEV_MATCH_DEVICE)
++                    {
++                        /* We have the drive now but need the appropriate device node */
++                        struct device_match_result *pDevResult = &paMatches[i].result.device_result;
++                        union ccb PeriphCCB;
++                        struct dev_match_pattern PeriphMatchPattern;
++                        struct dev_match_result aPeriphMatches[2];
++                        struct periph_match_result *pPeriphResult = NULL;
++                        unsigned iPeriphMatch = 0;
++
++                        RT_ZERO(PeriphCCB);
++                        RT_ZERO(PeriphMatchPattern);
++                        RT_ZERO(aPeriphMatches);
++
++                        /* This time we only want the specific nodes for the device. */
++                        PeriphCCB.ccb_h.func_code  = XPT_DEV_MATCH;
++                        PeriphCCB.ccb_h.path_id    = paMatches[i].result.device_result.path_id;
++                        PeriphCCB.ccb_h.target_id  = paMatches[i].result.device_result.target_id;
++                        PeriphCCB.ccb_h.target_lun = paMatches[i].result.device_result.target_lun;
++
++                        /* Setup the pattern */
++                        PeriphMatchPattern.type = DEV_MATCH_PERIPH;
++                        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;
++                        PeriphCCB.cdm.num_patterns    = 1;
++                        PeriphCCB.cdm.pattern_buf_len = sizeof(struct dev_match_result);
++                        PeriphCCB.cdm.patterns        = &PeriphMatchPattern;
++                        PeriphCCB.cdm.num_matches   = 0;
++                        PeriphCCB.cdm.match_buf_len = sizeof(aPeriphMatches);
++                        PeriphCCB.cdm.matches       = aPeriphMatches;
++
++                        do
++                        {
++                            rc = RTFileIoCtl(FileXpt, CAMIOCOMMAND, &PeriphCCB, sizeof(union ccb), NULL);
++                            if (RT_FAILURE(rc))
++                            {
++                                Log(("Error while querying available periph devices rc=%Rrc\n", rc));
++                                break;
++                            }
++
++                            for (iPeriphMatch = 0; iPeriphMatch < PeriphCCB.cdm.num_matches; iPeriphMatch++)
++                            {
++                                if (   (aPeriphMatches[iPeriphMatch].type == DEV_MATCH_PERIPH)
++                                    && (!strcmp(aPeriphMatches[iPeriphMatch].result.periph_result.periph_name, "cd")))
++                                {
++                                    pPeriphResult = &aPeriphMatches[iPeriphMatch].result.periph_result;
++                                    break; /* We found the periph device */
++                                }
++                            }
++
++                            if (iPeriphMatch < PeriphCCB.cdm.num_matches)
++                                break;
++
++                        } while (   (DeviceCCB.ccb_h.status == CAM_REQ_CMP)
++                                 && (DeviceCCB.cdm.status == CAM_DEV_MATCH_MORE));
++
++                        if (pPeriphResult)
++                        {
++                            char szPath[RTPATH_MAX];
++                            char szDesc[256];
++
++                            RTStrPrintf(szPath, sizeof(szPath), "/dev/%s%d",
++                                        pPeriphResult->periph_name, pPeriphResult->unit_number);
++
++                            /* Remove trailing white space. */
++                            strLenRemoveTrailingWhiteSpace(pDevResult->inq_data.vendor,
++                                                            sizeof(pDevResult->inq_data.vendor));
++                            strLenRemoveTrailingWhiteSpace(pDevResult->inq_data.product,
++                                                            sizeof(pDevResult->inq_data.product));
++
++                            dvdCreateDeviceString(pDevResult->inq_data.vendor,
++                                                    pDevResult->inq_data.product,
++                                                    szDesc, sizeof(szDesc));
++
++                            pList->push_back(DriveInfo(szPath, "", szDesc));
++                            if (pfSuccess)
++                                *pfSuccess = true;
++                        }
++                    }
++                }
++            } while (   (DeviceCCB.ccb_h.status == CAM_REQ_CMP)
++                     && (DeviceCCB.cdm.status == CAM_DEV_MATCH_MORE));
++
++            RTMemFree(paMatches);
++        }
++        else
++            rc = VERR_NO_MEMORY;
++
++        RTFileClose(FileXpt);
++    }
++
++    return rc;
++}
++
++/**
++ * Extract the names of drives from an environment variable and add them to a
++ * list if they are valid.
++ * @returns iprt status code
++ * @param   pcszVar     the name of the environment variable.  The variable
++ *                     value should be a list of device node names, separated
++ *                     by ':' characters.
++ * @param   pList      the list to append the drives found to
++ * @param   isDVD      are we looking for DVD drives or for floppies?
++ * @param   pfSuccess  this will be set to true if we found at least one drive
++ *                     and to false otherwise.  Optional.
++ */
++static int getDriveInfoFromEnv(const char *pcszVar, DriveInfoList *pList,
++                               bool isDVD, bool *pfSuccess)
++{
++    AssertPtrReturn(pcszVar, VERR_INVALID_POINTER);
++    AssertPtrReturn(pList, VERR_INVALID_POINTER);
++    AssertPtrNullReturn(pfSuccess, VERR_INVALID_POINTER);
++    LogFlowFunc(("pcszVar=%s, pList=%p, isDVD=%d, pfSuccess=%p\n", pcszVar,
++                 pList, isDVD, pfSuccess));
++    int rc = VINF_SUCCESS;
++    bool success = false;
++    char *pszFreeMe = RTEnvDupEx(RTENV_DEFAULT, pcszVar);
++
++    try
++    {
++        const char *pcszCurrent = pszFreeMe;
++        while (pcszCurrent && *pcszCurrent != '\0')
++        {
++            const char *pcszNext = strchr(pcszCurrent, ':');
++            char szPath[RTPATH_MAX], szReal[RTPATH_MAX];
++            char szDesc[256], szUdi[256];
++            if (pcszNext)
++                RTStrPrintf(szPath, sizeof(szPath), "%.*s",
++                            pcszNext - pcszCurrent - 1, pcszCurrent);
++            else
++                RTStrPrintf(szPath, sizeof(szPath), "%s", pcszCurrent);
++            if (RT_SUCCESS(RTPathReal(szPath, szReal, sizeof(szReal))))
++            {
++                szUdi[0] = '\0'; /** @todo r=bird: missing a call to devValidateDevice() here and szUdi wasn't
++                                  *        initialized because of that.  Need proper fixing. */
++                pList->push_back(DriveInfo(szReal, szUdi, szDesc));
++                success = true;
++            }
++            pcszCurrent = pcszNext ? pcszNext + 1 : NULL;
++        }
++        if (pfSuccess != NULL)
++            *pfSuccess = success;
++    }
++    catch(std::bad_alloc &e)
++    {
++        rc = VERR_NO_MEMORY;
++    }
++    RTStrFree(pszFreeMe);
++    LogFlowFunc(("rc=%Rrc, success=%d\n", rc, success));
++    return rc;
++}
diff --git a/virtualbox-svn/patches/patch-src_VBox_Main_src-server_netbsd_Makefile.kup b/virtualbox-svn/patches/patch-src_VBox_Main_src-server_netbsd_Makefile.kup
new file mode 100644
index 0000000..34cfa7a
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Main_src-server_netbsd_Makefile.kup
@@ -0,0 +1,6 @@
+$NetBSD$
+
+--- src/VBox/Main/src-server/netbsd/Makefile.kup.orig	2016-07-06 19:26:53.627141891 +0000
++++ src/VBox/Main/src-server/netbsd/Makefile.kup
+@@ -0,0 +1 @@
++#
diff --git a/virtualbox-svn/patches/patch-src_VBox_Main_src-server_netbsd_NetIf-netbsd.cpp b/virtualbox-svn/patches/patch-src_VBox_Main_src-server_netbsd_NetIf-netbsd.cpp
new file mode 100644
index 0000000..b7ce315
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Main_src-server_netbsd_NetIf-netbsd.cpp
@@ -0,0 +1,429 @@
+$NetBSD$
+
+--- src/VBox/Main/src-server/netbsd/NetIf-netbsd.cpp.orig	2016-07-06 20:08:39.061471350 +0000
++++ src/VBox/Main/src-server/netbsd/NetIf-netbsd.cpp
+@@ -0,0 +1,424 @@
++/*  NetIf-netbsd.cpp $ */
++/** @file
++ * Main - NetIfList, NetBSD implementation.
++ */
++
++/*
++ * Copyright (C) 2008-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.
++ */
++
++/*
++ * Original (C) 2009 Fredrik Lindberg <fli%shapeshifter.se@localhost>. Contributed
++ * to VirtualBox under the MIT license by the author.
++ */
++
++
++/*********************************************************************************************************************************
++*   Header Files                                                                                                                 *
++*********************************************************************************************************************************/
++#define LOG_GROUP LOG_GROUP_MAIN
++#include <sys/types.h>
++
++#include <sys/sysctl.h>
++#include <sys/socket.h>
++#include <sys/sockio.h>
++#include <net/if.h>
++#include <net/if_types.h>
++
++#include <net/route.h>
++/*
++ * route.h includes net/radix.h which for some reason defines Free as a wrapper
++ * around free. This collides with Free defined in xpcom/include/nsIMemory.h
++ * Undefine it and hope for the best
++ */
++#undef Free
++
++#include <net/if_dl.h>
++#include <netinet/in.h>
++
++#include <stdlib.h>
++#include <stdio.h>
++#include <unistd.h>
++#include <errno.h>
++
++#include <list>
++
++#include "HostNetworkInterfaceImpl.h"
++#include "netif.h"
++#include "Logging.h"
++
++#define ROUNDUP(a) \
++    ((a) > 0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) : sizeof(long))
++#define ADVANCE(x, n) (x += ROUNDUP((n)->sa_len))
++
++void extractAddresses(int iAddrMask, caddr_t cp, caddr_t cplim, struct sockaddr **pAddresses)
++{
++    struct sockaddr *sa;
++
++    for (int i = 0; i < RTAX_MAX && cp < cplim; i++) {
++        if (!(iAddrMask & (1 << i)))
++            continue;
++
++        sa = (struct sockaddr *)cp;
++
++        pAddresses[i] = sa;
++
++        ADVANCE(cp, sa);
++    }
++}
++
++static int getDefaultIfaceIndex(unsigned short *pu16Index, int family)
++{
++    size_t cbNeeded;
++    char *pBuf, *pNext;
++    int aiMib[6];
++    struct sockaddr *addresses[RTAX_MAX];
++    aiMib[0] = CTL_NET;
++    aiMib[1] = PF_ROUTE;
++    aiMib[2] = 0;
++    aiMib[3] = family;    /* address family */
++    aiMib[4] = NET_RT_DUMP;
++    aiMib[5] = 0;
++
++    if (sysctl(aiMib, 6, NULL, &cbNeeded, NULL, 0) < 0)
++    {
++        Log(("getDefaultIfaceIndex: Failed to get estimate for list size (errno=%d).\n", errno));
++        return RTErrConvertFromErrno(errno);
++    }
++    if ((pBuf = (char*)malloc(cbNeeded)) == NULL)
++        return VERR_NO_MEMORY;
++    if (sysctl(aiMib, 6, pBuf, &cbNeeded, NULL, 0) < 0)
++    {
++        free(pBuf);
++        Log(("getDefaultIfaceIndex: Failed to retrieve interface table (errno=%d).\n", errno));
++        return RTErrConvertFromErrno(errno);
++    }
++
++    char *pEnd = pBuf + cbNeeded;
++    struct rt_msghdr *pRtMsg;
++    for (pNext = pBuf; pNext < pEnd; pNext += pRtMsg->rtm_msglen)
++    {
++        pRtMsg = (struct rt_msghdr *)pNext;
++
++        if (pRtMsg->rtm_type != RTM_GET)
++        {
++            Log(("getDefaultIfaceIndex: Got message %u while expecting %u.\n",
++                 pRtMsg->rtm_type, RTM_GET));
++            //rc = VERR_INTERNAL_ERROR;
++            continue;
++        }
++        if ((char*)(pRtMsg + 1) < pEnd)
++        {
++            /* Extract addresses from the message. */
++            extractAddresses(pRtMsg->rtm_addrs, (char *)(pRtMsg + 1),
++                             pRtMsg->rtm_msglen + (char *)pRtMsg, addresses);
++            if ((pRtMsg->rtm_addrs & RTA_DST))
++            {
++                if (addresses[RTAX_DST]->sa_family != AF_INET)
++                    continue;
++                struct sockaddr_in *addr = (struct sockaddr_in *)addresses[RTAX_DST];
++                struct sockaddr_in *mask = (struct sockaddr_in *)addresses[RTAX_NETMASK];
++                if ((addr->sin_addr.s_addr == INADDR_ANY) &&
++                    mask &&
++                    (ntohl(mask->sin_addr.s_addr) == 0L ||
++                     mask->sin_len == 0))
++                {
++                    *pu16Index = pRtMsg->rtm_index;
++                    free(pBuf);
++                    return VINF_SUCCESS;
++                }
++            }
++        }
++    }
++    free(pBuf);
++    return VERR_INTERNAL_ERROR;
++
++}
++
++void extractAddressesToNetInfo(int iAddrMask, caddr_t cp, caddr_t cplim, PNETIFINFO pInfo)
++{
++    struct sockaddr *addresses[RTAX_MAX];
++
++    extractAddresses(iAddrMask, cp, cplim, addresses);
++    switch (addresses[RTAX_IFA]->sa_family)
++    {
++        case AF_INET:
++            if (!pInfo->IPAddress.u)
++            {
++                pInfo->IPAddress.u = ((struct sockaddr_in *)addresses[RTAX_IFA])->sin_addr.s_addr;
++                pInfo->IPNetMask.u = ((struct sockaddr_in *)addresses[RTAX_NETMASK])->sin_addr.s_addr;
++            }
++            break;
++        case AF_INET6:
++            if (!pInfo->IPv6Address.s.Lo && !pInfo->IPv6Address.s.Hi)
++            {
++                memcpy(pInfo->IPv6Address.au8,
++                       ((struct sockaddr_in6 *)addresses[RTAX_IFA])->sin6_addr.__u6_addr.__u6_addr8,
++                       sizeof(pInfo->IPv6Address));
++                memcpy(pInfo->IPv6NetMask.au8,
++                       ((struct sockaddr_in6 *)addresses[RTAX_NETMASK])->sin6_addr.__u6_addr.__u6_addr8,
++                       sizeof(pInfo->IPv6NetMask));
++            }
++            break;
++        default:
++            Log(("NetIfList: Unsupported address family: %u\n", addresses[RTAX_IFA]->sa_family));
++            break;
++    }
++}
++
++
++int NetIfList(std::list <ComObjPtr<HostNetworkInterface> > &list)
++{
++    int rc = VINF_SUCCESS;
++    size_t cbNeeded;
++    char *pBuf, *pNext;
++    int aiMib[6];
++    unsigned short u16DefaultIface = 0; /* shut up gcc. */
++    bool fDefaultIfaceExistent = true;
++
++    /* Get the index of the interface associated with default route. */
++    rc = getDefaultIfaceIndex(&u16DefaultIface, PF_INET);
++    if (RT_FAILURE(rc))
++    {
++        fDefaultIfaceExistent = false;
++        rc = VINF_SUCCESS;
++    }
++
++    aiMib[0] = CTL_NET;
++    aiMib[1] = PF_ROUTE;
++    aiMib[2] = 0;
++    aiMib[3] = 0;    /* address family */
++    aiMib[4] = NET_RT_IFLIST;
++    aiMib[5] = 0;
++
++    if (sysctl(aiMib, 6, NULL, &cbNeeded, NULL, 0) < 0)
++    {
++        Log(("NetIfList: Failed to get estimate for list size (errno=%d).\n", errno));
++        return RTErrConvertFromErrno(errno);
++    }
++    if ((pBuf = (char*)malloc(cbNeeded)) == NULL)
++        return VERR_NO_MEMORY;
++    if (sysctl(aiMib, 6, pBuf, &cbNeeded, NULL, 0) < 0)
++    {
++        free(pBuf);
++        Log(("NetIfList: Failed to retrieve interface table (errno=%d).\n", errno));
++        return RTErrConvertFromErrno(errno);
++    }
++
++    int sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP);
++    if (sock < 0)
++    {
++        free(pBuf);
++        Log(("NetIfList: socket() -> %d\n", errno));
++        return RTErrConvertFromErrno(errno);
++    }
++
++    char *pEnd = pBuf + cbNeeded;
++    for (pNext = pBuf; pNext < pEnd;)
++    {
++        struct if_msghdr *pIfMsg = (struct if_msghdr *)pNext;
++
++        if (pIfMsg->ifm_type != RTM_IFINFO)
++        {
++            Log(("NetIfList: Got message %u while expecting %u.\n",
++                 pIfMsg->ifm_type, RTM_IFINFO));
++            rc = VERR_INTERNAL_ERROR;
++            break;
++        }
++        struct sockaddr_dl *pSdl = (struct sockaddr_dl *)(pIfMsg + 1);
++
++        size_t cbNameLen = pSdl->sdl_nlen + 1;
++        PNETIFINFO pNew = (PNETIFINFO)RTMemAllocZ(RT_OFFSETOF(NETIFINFO, szName[cbNameLen]));
++        if (!pNew)
++        {
++            rc = VERR_NO_MEMORY;
++            break;
++        }
++        memcpy(pNew->MACAddress.au8, LLADDR(pSdl), sizeof(pNew->MACAddress.au8));
++        pNew->enmMediumType = NETIF_T_ETHERNET;
++        Assert(sizeof(pNew->szShortName) >= cbNameLen);
++        strlcpy(pNew->szShortName, pSdl->sdl_data, cbNameLen);
++        strlcpy(pNew->szName, pSdl->sdl_data, cbNameLen);
++        /* Generate UUID from name and MAC address. */
++        RTUUID uuid;
++        RTUuidClear(&uuid);
++        memcpy(&uuid, pNew->szShortName, RT_MIN(cbNameLen, sizeof(uuid)));
++        uuid.Gen.u8ClockSeqHiAndReserved = (uuid.Gen.u8ClockSeqHiAndReserved & 0x3f) | 0x80;
++        uuid.Gen.u16TimeHiAndVersion = (uuid.Gen.u16TimeHiAndVersion & 0x0fff) | 0x4000;
++        memcpy(uuid.Gen.au8Node, pNew->MACAddress.au8, sizeof(uuid.Gen.au8Node));
++        pNew->Uuid = uuid;
++
++        pNext += pIfMsg->ifm_msglen;
++        while (pNext < pEnd)
++        {
++            struct ifa_msghdr *pIfAddrMsg = (struct ifa_msghdr *)pNext;
++
++            if (pIfAddrMsg->ifam_type != RTM_NEWADDR)
++                break;
++            extractAddressesToNetInfo(pIfAddrMsg->ifam_addrs,
++                                      (char *)(pIfAddrMsg + 1),
++                                      pIfAddrMsg->ifam_msglen + (char *)pIfAddrMsg,
++                                      pNew);
++            pNext += pIfAddrMsg->ifam_msglen;
++        }
++
++        if (pSdl->sdl_type == IFT_ETHER || pSdl->sdl_type == IFT_L2VLAN)
++        {
++            struct ifreq IfReq;
++            RTStrCopy(IfReq.ifr_name, sizeof(IfReq.ifr_name), pNew->szShortName);
++            if (ioctl(sock, SIOCGIFFLAGS, &IfReq) < 0)
++            {
++                Log(("NetIfList: ioctl(SIOCGIFFLAGS) -> %d\n", errno));
++                pNew->enmStatus = NETIF_S_UNKNOWN;
++            }
++            else
++                pNew->enmStatus = (IfReq.ifr_flags & IFF_UP) ? NETIF_S_UP : NETIF_S_DOWN;
++
++            HostNetworkInterfaceType_T enmType;
++            if (strncmp(pNew->szName, RT_STR_TUPLE("vboxnet")))
++                enmType = HostNetworkInterfaceType_Bridged;
++            else
++                enmType = HostNetworkInterfaceType_HostOnly;
++
++            ComObjPtr<HostNetworkInterface> IfObj;
++            IfObj.createObject();
++            if (SUCCEEDED(IfObj->init(Bstr(pNew->szName), enmType, pNew)))
++            {
++                /* Make sure the default interface gets to the beginning. */
++                if (   fDefaultIfaceExistent
++                    && pIfMsg->ifm_index == u16DefaultIface)
++                    list.push_front(IfObj);
++                else
++                    list.push_back(IfObj);
++            }
++        }
++        RTMemFree(pNew);
++    }
++
++    close(sock);
++    free(pBuf);
++    return rc;
++
++
++}
++
++int NetIfGetConfigByName(PNETIFINFO pInfo)
++{
++    int rc = VINF_SUCCESS;
++    size_t cbNeeded;
++    char *pBuf, *pNext;
++    int aiMib[6];
++
++    aiMib[0] = CTL_NET;
++    aiMib[1] = PF_ROUTE;
++    aiMib[2] = 0;
++    aiMib[3] = 0;    /* address family */
++    aiMib[4] = NET_RT_IFLIST;
++    aiMib[5] = 0;
++
++    if (sysctl(aiMib, 6, NULL, &cbNeeded, NULL, 0) < 0)
++    {
++        Log(("NetIfList: Failed to get estimate for list size (errno=%d).\n", errno));
++        return RTErrConvertFromErrno(errno);
++    }
++    if ((pBuf = (char*)malloc(cbNeeded)) == NULL)
++        return VERR_NO_MEMORY;
++    if (sysctl(aiMib, 6, pBuf, &cbNeeded, NULL, 0) < 0)
++    {
++        free(pBuf);
++        Log(("NetIfList: Failed to retrieve interface table (errno=%d).\n", errno));
++        return RTErrConvertFromErrno(errno);
++    }
++
++    int sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP);
++    if (sock < 0)
++    {
++        free(pBuf);
++        Log(("NetIfList: socket() -> %d\n", errno));
++        return RTErrConvertFromErrno(errno);
++    }
++
++    char *pEnd = pBuf + cbNeeded;
++    for (pNext = pBuf; pNext < pEnd;)
++    {
++        struct if_msghdr *pIfMsg = (struct if_msghdr *)pNext;
++
++        if (pIfMsg->ifm_type != RTM_IFINFO)
++        {
++            Log(("NetIfList: Got message %u while expecting %u.\n",
++                 pIfMsg->ifm_type, RTM_IFINFO));
++            rc = VERR_INTERNAL_ERROR;
++            break;
++        }
++        struct sockaddr_dl *pSdl = (struct sockaddr_dl *)(pIfMsg + 1);
++
++        bool fSkip = !!strcmp(pInfo->szShortName, pSdl->sdl_data);
++
++        pNext += pIfMsg->ifm_msglen;
++        while (pNext < pEnd)
++        {
++            struct ifa_msghdr *pIfAddrMsg = (struct ifa_msghdr *)pNext;
++
++            if (pIfAddrMsg->ifam_type != RTM_NEWADDR)
++                break;
++            if (!fSkip)
++                extractAddressesToNetInfo(pIfAddrMsg->ifam_addrs,
++                                          (char *)(pIfAddrMsg + 1),
++                                          pIfAddrMsg->ifam_msglen + (char *)pIfAddrMsg,
++                                          pInfo);
++            pNext += pIfAddrMsg->ifam_msglen;
++        }
++
++        if (!fSkip && (pSdl->sdl_type == IFT_ETHER || pSdl->sdl_type == IFT_L2VLAN))
++        {
++            size_t cbNameLen = pSdl->sdl_nlen + 1;
++            memcpy(pInfo->MACAddress.au8, LLADDR(pSdl), sizeof(pInfo->MACAddress.au8));
++            pInfo->enmMediumType = NETIF_T_ETHERNET;
++            /* Generate UUID from name and MAC address. */
++            RTUUID uuid;
++            RTUuidClear(&uuid);
++            memcpy(&uuid, pInfo->szShortName, RT_MIN(cbNameLen, sizeof(uuid)));
++            uuid.Gen.u8ClockSeqHiAndReserved = (uuid.Gen.u8ClockSeqHiAndReserved & 0x3f) | 0x80;
++            uuid.Gen.u16TimeHiAndVersion = (uuid.Gen.u16TimeHiAndVersion & 0x0fff) | 0x4000;
++            memcpy(uuid.Gen.au8Node, pInfo->MACAddress.au8, sizeof(uuid.Gen.au8Node));
++            pInfo->Uuid = uuid;
++
++            struct ifreq IfReq;
++            RTStrCopy(IfReq.ifr_name, sizeof(IfReq.ifr_name), pInfo->szShortName);
++            if (ioctl(sock, SIOCGIFFLAGS, &IfReq) < 0)
++            {
++                Log(("NetIfList: ioctl(SIOCGIFFLAGS) -> %d\n", errno));
++                pInfo->enmStatus = NETIF_S_UNKNOWN;
++            }
++            else
++                pInfo->enmStatus = (IfReq.ifr_flags & IFF_UP) ? NETIF_S_UP : NETIF_S_DOWN;
++
++            return VINF_SUCCESS;
++        }
++    }
++    close(sock);
++    free(pBuf);
++    return rc;
++}
++
++/**
++ * Retrieve the physical link speed in megabits per second. If the interface is
++ * not up or otherwise unavailable the zero speed is returned.
++ *
++ * @returns VBox status code.
++ *
++ * @param   pcszIfName  Interface name.
++ * @param   puMbits     Where to store the link speed.
++ */
++int NetIfGetLinkSpeed(const char * /*pcszIfName*/, uint32_t * /*puMbits*/)
++{
++    return VERR_NOT_IMPLEMENTED;
++}
diff --git a/virtualbox-svn/patches/patch-src_VBox_Main_src-server_netbsd_PerformanceNetBSD.cpp b/virtualbox-svn/patches/patch-src_VBox_Main_src-server_netbsd_PerformanceNetBSD.cpp
new file mode 100644
index 0000000..1b5993a
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Main_src-server_netbsd_PerformanceNetBSD.cpp
@@ -0,0 +1,122 @@
+$NetBSD$
+
+--- src/VBox/Main/src-server/netbsd/PerformanceNetBSD.cpp.orig	2016-07-06 20:08:39.069695369 +0000
++++ src/VBox/Main/src-server/netbsd/PerformanceNetBSD.cpp
+@@ -0,0 +1,117 @@
++/*  PerformanceNetBSD.cpp $ */
++/** @file
++ * VirtualBox Performance Collector, NetBSD Specialization.
++ */
++
++/*
++ * Copyright (C) 2008-2013 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.
++ */
++
++#include <sys/types.h>
++#include <sys/sysctl.h>
++#include "Performance.h"
++
++namespace pm {
++
++class CollectorNetBSD : public CollectorHAL
++{
++public:
++    virtual int getHostCpuLoad(ULONG *user, ULONG *kernel, ULONG *idle);
++    virtual int getHostCpuMHz(ULONG *mhz);
++    virtual int getHostMemoryUsage(ULONG *total, ULONG *used, ULONG *available);
++    virtual int getProcessCpuLoad(RTPROCESS process, ULONG *user, ULONG *kernel);
++    virtual int getProcessMemoryUsage(RTPROCESS process, ULONG *used);
++};
++
++
++CollectorHAL *createHAL()
++{
++    return new CollectorNetBSD();
++}
++
++int CollectorNetBSD::getHostCpuLoad(ULONG *user, ULONG *kernel, ULONG *idle)
++{
++    return VERR_NOT_IMPLEMENTED;
++}
++
++int CollectorNetBSD::getHostCpuMHz(ULONG *mhz)
++{
++    int CpuMHz = 0;
++    size_t cbParameter = sizeof(CpuMHz);
++
++    /** @todo: Howto support more than one CPU? */
++    if (sysctlbyname("dev.cpu.0.freq", &CpuMHz, &cbParameter, NULL, 0))
++        return VERR_NOT_SUPPORTED;
++
++    *mhz = CpuMHz;
++
++    return VINF_SUCCESS;
++}
++
++int CollectorNetBSD::getHostMemoryUsage(ULONG *total, ULONG *used, ULONG *available)
++{
++    int rc = VINF_SUCCESS;
++    u_long cbMemPhys = 0;
++    u_int cPagesMemFree = 0;
++    u_int cPagesMemInactive = 0;
++    u_int cPagesMemCached = 0;
++    u_int cPagesMemUsed = 0;
++    int cbPage = 0;
++    size_t cbParameter = sizeof(cbMemPhys);
++    int cProcessed = 0;
++
++    if (!sysctlbyname("hw.physmem", &cbMemPhys, &cbParameter, NULL, 0))
++        cProcessed++;
++
++    cbParameter = sizeof(cPagesMemFree);
++    if (!sysctlbyname("vm.stats.vm.v_free_count", &cPagesMemFree, &cbParameter, NULL, 0))
++        cProcessed++;
++    cbParameter = sizeof(cPagesMemUsed);
++    if (!sysctlbyname("vm.stats.vm.v_active_count", &cPagesMemUsed, &cbParameter, NULL, 0))
++        cProcessed++;
++    cbParameter = sizeof(cPagesMemInactive);
++    if (!sysctlbyname("vm.stats.vm.v_inactive_count", &cPagesMemInactive, &cbParameter, NULL, 0))
++        cProcessed++;
++    cbParameter = sizeof(cPagesMemCached);
++    if (!sysctlbyname("vm.stats.vm.v_cache_count", &cPagesMemCached, &cbParameter, NULL, 0))
++        cProcessed++;
++    cbParameter = sizeof(cbPage);
++    if (!sysctlbyname("hw.pagesize", &cbPage, &cbParameter, NULL, 0))
++        cProcessed++;
++
++    if (cProcessed == 6)
++    {
++        *total     = cbMemPhys / _1K;
++        *used      = cPagesMemUsed * (cbPage / _1K);
++        *available = (cPagesMemFree + cPagesMemInactive + cPagesMemCached ) * (cbPage / _1K);
++    }
++    else
++        rc = VERR_NOT_SUPPORTED;
++
++    return rc;
++}
++
++int CollectorNetBSD::getProcessCpuLoad(RTPROCESS process, ULONG *user, ULONG *kernel)
++{
++    return VERR_NOT_IMPLEMENTED;
++}
++
++int CollectorNetBSD::getProcessMemoryUsage(RTPROCESS process, ULONG *used)
++{
++    return VERR_NOT_IMPLEMENTED;
++}
++
++int getDiskListByFs(const char *name, DiskList& list)
++{
++    return VERR_NOT_IMPLEMENTED;
++}
++
++} /* namespace pm */
diff --git a/virtualbox-svn/patches/patch-src_VBox_Main_src-server_netbsd_USBProxyServiceNetBSD.cpp b/virtualbox-svn/patches/patch-src_VBox_Main_src-server_netbsd_USBProxyServiceNetBSD.cpp
new file mode 100644
index 0000000..e4ed058
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Main_src-server_netbsd_USBProxyServiceNetBSD.cpp
@@ -0,0 +1,359 @@
+$NetBSD$
+
+--- src/VBox/Main/src-server/netbsd/USBProxyServiceNetBSD.cpp.orig	2016-07-06 20:08:39.078040350 +0000
++++ src/VBox/Main/src-server/netbsd/USBProxyServiceNetBSD.cpp
+@@ -0,0 +1,354 @@
++/*  USBProxyServiceNetBSD.cpp $ */
++/** @file
++ * VirtualBox USB Proxy Service, NetBSD Specialization.
++ */
++
++/*
++ * Copyright (C) 2005-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.
++ */
++
++
++/*********************************************************************************************************************************
++*   Header Files                                                                                                                 *
++*********************************************************************************************************************************/
++#include "USBProxyService.h"
++#include "Logging.h"
++
++#include <VBox/usb.h>
++#include <VBox/usblib.h>
++#include <VBox/err.h>
++
++#include <iprt/string.h>
++#include <iprt/alloc.h>
++#include <iprt/assert.h>
++#include <iprt/file.h>
++#include <iprt/err.h>
++#include <iprt/mem.h>
++#include <iprt/param.h>
++#include <iprt/path.h>
++#include <iprt/semaphore.h>
++
++#include <stdlib.h>
++#include <string.h>
++#include <stdio.h>
++#include <errno.h>
++#include <unistd.h>
++#include <fcntl.h>
++#include <sys/poll.h>
++#include <dev/usb/usb.h>
++#include <dev/usb/usb_ioctl.h>
++
++
++/*********************************************************************************************************************************
++*   Structures and Typedefs                                                                                                      *
++*********************************************************************************************************************************/
++
++
++/*********************************************************************************************************************************
++*   Global Variables                                                                                                             *
++*********************************************************************************************************************************/
++
++/**
++ * Initialize data members.
++ */
++USBProxyServiceNetBSD::USBProxyServiceNetBSD(Host *aHost)
++    : USBProxyService(aHost)
++{
++    LogFlowThisFunc(("aHost=%p\n", aHost));
++}
++
++
++/**
++ * Initializes the object (called right after construction).
++ *
++ * @returns S_OK on success and non-fatal failures, some COM error otherwise.
++ */
++HRESULT USBProxyServiceNetBSD::init(void)
++{
++    /*
++     * Create semaphore.
++     */
++    int rc = RTSemEventCreate(&mNotifyEventSem);
++    if (RT_FAILURE(rc))
++    {
++        mLastError = rc;
++        return E_FAIL;
++    }
++
++    /*
++     * Start the poller thread.
++     */
++    start();
++    return S_OK;
++}
++
++
++/**
++ * Stop all service threads and free the device chain.
++ */
++USBProxyServiceNetBSD::~USBProxyServiceNetBSD()
++{
++    LogFlowThisFunc(("\n"));
++
++    /*
++     * Stop the service.
++     */
++    if (isActive())
++        stop();
++
++    RTSemEventDestroy(mNotifyEventSem);
++    mNotifyEventSem = NULL;
++}
++
++
++int USBProxyServiceNetBSD::captureDevice(HostUSBDevice *aDevice)
++{
++    AssertReturn(aDevice, VERR_GENERAL_FAILURE);
++    AssertReturn(!aDevice->isWriteLockOnCurrentThread(), VERR_GENERAL_FAILURE);
++
++    AutoReadLock devLock(aDevice COMMA_LOCKVAL_SRC_POS);
++    LogFlowThisFunc(("aDevice=%s\n", aDevice->i_getName().c_str()));
++
++    /*
++     * Don't think we need to do anything when the device is held... fake it.
++     */
++    Assert(aDevice->i_getUnistate() == kHostUSBDeviceState_Capturing);
++    devLock.release();
++    interruptWait();
++
++    return VINF_SUCCESS;
++}
++
++
++int USBProxyServiceNetBSD::releaseDevice(HostUSBDevice *aDevice)
++{
++    AssertReturn(aDevice, VERR_GENERAL_FAILURE);
++    AssertReturn(!aDevice->isWriteLockOnCurrentThread(), VERR_GENERAL_FAILURE);
++
++    AutoReadLock devLock(aDevice COMMA_LOCKVAL_SRC_POS);
++    LogFlowThisFunc(("aDevice=%s\n", aDevice->i_getName().c_str()));
++
++    /*
++     * We're not really holding it atm., just fake it.
++     */
++    Assert(aDevice->i_getUnistate() == kHostUSBDeviceState_ReleasingToHost);
++    devLock.release();
++    interruptWait();
++
++    return VINF_SUCCESS;
++}
++
++
++bool USBProxyServiceNetBSD::updateDeviceState(HostUSBDevice *aDevice, PUSBDEVICE aUSBDevice, bool *aRunFilters,
++                                               SessionMachine **aIgnoreMachine)
++{
++    AssertReturn(aDevice, false);
++    AssertReturn(!aDevice->isWriteLockOnCurrentThread(), false);
++
++    return updateDeviceStateFake(aDevice, aUSBDevice, aRunFilters, aIgnoreMachine);
++}
++
++
++/**
++ * A device was added
++ *
++ * See USBProxyService::deviceAdded for details.
++ */
++void USBProxyServiceNetBSD::deviceAdded(ComObjPtr<HostUSBDevice> &aDevice, SessionMachinesList &llOpenedMachines,
++                                         PUSBDEVICE aUSBDevice)
++{
++    USBProxyService::deviceAdded(aDevice, llOpenedMachines, aUSBDevice);
++}
++
++int USBProxyServiceNetBSD::wait(RTMSINTERVAL aMillies)
++{
++    return RTSemEventWait(mNotifyEventSem, aMillies < 1000 ? 1000 : 5000);
++}
++
++
++int USBProxyServiceNetBSD::interruptWait(void)
++{
++    return RTSemEventSignal(mNotifyEventSem);
++}
++
++
++/**
++ * Dumps a USBDEVICE structure to the log using LogLevel 3.
++ * @param   pDev        The structure to log.
++ * @todo    This is really common code.
++ */
++DECLINLINE(void) usbLogDevice(PUSBDEVICE pDev)
++{
++    NOREF(pDev);
++
++    Log3(("USB device:\n"));
++    Log3(("Product: %s (%x)\n", pDev->pszProduct, pDev->idProduct));
++    Log3(("Manufacturer: %s (Vendor ID %x)\n", pDev->pszManufacturer, pDev->idVendor));
++    Log3(("Serial number: %s (%llx)\n", pDev->pszSerialNumber, pDev->u64SerialHash));
++    Log3(("Device revision: %d\n", pDev->bcdDevice));
++    Log3(("Device class: %x\n", pDev->bDeviceClass));
++    Log3(("Device subclass: %x\n", pDev->bDeviceSubClass));
++    Log3(("Device protocol: %x\n", pDev->bDeviceProtocol));
++    Log3(("USB version number: %d\n", pDev->bcdUSB));
++    Log3(("Device speed: %s\n",
++            pDev->enmSpeed == USBDEVICESPEED_UNKNOWN  ? "unknown"
++          : pDev->enmSpeed == USBDEVICESPEED_LOW      ? "1.5 MBit/s"
++          : pDev->enmSpeed == USBDEVICESPEED_FULL     ? "12 MBit/s"
++          : pDev->enmSpeed == USBDEVICESPEED_HIGH     ? "480 MBit/s"
++          : pDev->enmSpeed == USBDEVICESPEED_VARIABLE ? "variable"
++          :                                             "invalid"));
++    Log3(("Number of configurations: %d\n", pDev->bNumConfigurations));
++    Log3(("Bus number: %d\n", pDev->bBus));
++    Log3(("Port number: %d\n", pDev->bPort));
++    Log3(("Device number: %d\n", pDev->bDevNum));
++    Log3(("Device state: %s\n",
++            pDev->enmState == USBDEVICESTATE_UNSUPPORTED   ? "unsupported"
++          : pDev->enmState == USBDEVICESTATE_USED_BY_HOST  ? "in use by host"
++          : pDev->enmState == USBDEVICESTATE_USED_BY_HOST_CAPTURABLE ? "in use by host, possibly capturable"
++          : pDev->enmState == USBDEVICESTATE_UNUSED        ? "not in use"
++          : pDev->enmState == USBDEVICESTATE_HELD_BY_PROXY ? "held by proxy"
++          : pDev->enmState == USBDEVICESTATE_USED_BY_GUEST ? "used by guest"
++          :                                                  "invalid"));
++    Log3(("OS device address: %s\n", pDev->pszAddress));
++}
++
++PUSBDEVICE USBProxyServiceNetBSD::getDevices(void)
++{
++    PUSBDEVICE pDevices = NULL;
++    int FileUsb = 0;
++    int iBus  = 0;
++    int iAddr = 1;
++    int rc = VINF_SUCCESS;
++    char *pszDevicePath = NULL;
++    uint32_t PlugTime = 0;
++
++    for (;;)
++    {
++        rc = RTStrAPrintf(&pszDevicePath, "/dev/%s%d.%d", USB_GENERIC_NAME, iBus, iAddr);
++        if (RT_FAILURE(rc))
++        {
++            mLastError = rc;
++            break;
++        }
++
++        LogFlowFunc((": Opening %s\n", pszDevicePath));
++
++        FileUsb = open(pszDevicePath, O_RDONLY);
++        if (FileUsb < 0)
++        {
++            if (   (errno != ENOENT)
++                && (errno != EACCES))
++                mLastError = RTErrConvertFromErrno(errno);
++
++            RTStrFree(pszDevicePath);
++
++            if ((errno == ENOENT) && (iAddr > 1))
++            {
++                iAddr = 1;
++                iBus++;
++                continue;
++            }
++            else if (errno == EACCES)
++            {
++                /* Skip devices without the right permission. */
++                iAddr++;
++                continue;
++            }
++            else
++                break;
++        }
++
++        LogFlowFunc((": %s opened successfully\n", pszDevicePath));
++
++        struct usb_device_info UsbDevInfo;
++        RT_ZERO(UsbDevInfo);
++
++        rc = ioctl(FileUsb, USB_GET_DEVICEINFO, &UsbDevInfo);
++        if (rc < 0)
++        {
++            LogFlowFunc((": Error querying device info rc=%Rrc\n", RTErrConvertFromErrno(errno)));
++            mLastError = RTErrConvertFromErrno(errno);
++            close(FileUsb);
++            RTStrFree(pszDevicePath);
++            break;
++        }
++
++        /* Filter out hubs */
++        if (UsbDevInfo.udi_class != 0x09)
++        {
++            PUSBDEVICE pDevice = (PUSBDEVICE)RTMemAllocZ(sizeof(USBDEVICE));
++            if (!pDevice)
++            {
++                mLastError = VERR_NO_MEMORY;
++                close(FileUsb);
++                RTStrFree(pszDevicePath);
++                break;
++            }
++
++            pDevice->enmState           = USBDEVICESTATE_UNUSED;
++            pDevice->bBus               = UsbDevInfo.udi_bus;
++            pDevice->bDeviceClass       = UsbDevInfo.udi_class;
++            pDevice->bDeviceSubClass    = UsbDevInfo.udi_subclass;
++            pDevice->bDeviceProtocol    = UsbDevInfo.udi_protocol;
++            pDevice->bNumConfigurations = UsbDevInfo.udi_config_no;
++            pDevice->idVendor           = UsbDevInfo.udi_vendorNo;
++            pDevice->idProduct          = UsbDevInfo.udi_productNo;
++            pDevice->bDevNum            = UsbDevInfo.udi_index;
++
++            switch (UsbDevInfo.udi_speed)
++            {
++                case USB_SPEED_LOW:
++                    pDevice->enmSpeed = USBDEVICESPEED_LOW;
++                    break;
++                case USB_SPEED_FULL:
++                    pDevice->enmSpeed = USBDEVICESPEED_FULL;
++                    break;
++                case USB_SPEED_HIGH:
++                    pDevice->enmSpeed = USBDEVICESPEED_HIGH;
++                    break;
++                case USB_SPEED_SUPER:
++                case USB_SPEED_VARIABLE:
++                default:
++                    pDevice->enmSpeed = USBDEVICESPEED_UNKNOWN;
++            }
++
++            if (UsbDevInfo.udi_vendor[0] != '\0')
++                pDevice->pszManufacturer = RTStrDupN(UsbDevInfo.udi_vendor, sizeof(UsbDevInfo.udi_vendor));
++
++            if (UsbDevInfo.udi_product[0] != '\0')
++                pDevice->pszProduct = RTStrDupN(UsbDevInfo.udi_product, sizeof(UsbDevInfo.udi_product));
++
++            if (UsbDevInfo.udi_serial[0] != '\0')
++            {
++                pDevice->pszSerialNumber = RTStrDupN(UsbDevInfo.udi_serial, sizeof(UsbDevInfo.udi_serial));
++                pDevice->u64SerialHash   = USBLibHashSerial(pDevice->pszSerialNumber);
++            }
++            rc = ioctl(FileUsb, USB_GET_PLUGTIME, &PlugTime);
++            if (rc == 0)
++                pDevice->u64SerialHash  += PlugTime;
++
++            pDevice->pszAddress = RTStrDup(pszDevicePath);
++            pDevice->enmState   = USBDEVICESTATE_USED_BY_HOST_CAPTURABLE;
++
++            usbLogDevice(pDevice);
++
++            pDevice->pNext = pDevices;
++            if (pDevices)
++                pDevices->pPrev = pDevice;
++            pDevices = pDevice;
++        }
++        close(FileUsb);
++        RTStrFree(pszDevicePath);
++        iAddr++;
++    }
++
++    return pDevices;
++}
diff --git a/virtualbox-svn/patches/patch-src_VBox_Main_testcase_tstCollector.cpp b/virtualbox-svn/patches/patch-src_VBox_Main_testcase_tstCollector.cpp
new file mode 100644
index 0000000..fa822d0
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Main_testcase_tstCollector.cpp
@@ -0,0 +1,19 @@
+$NetBSD$
+
+--- src/VBox/Main/testcase/tstCollector.cpp.orig	2016-03-04 19:29:42.000000000 +0000
++++ src/VBox/Main/testcase/tstCollector.cpp
+@@ -23,6 +23,9 @@
+ #ifdef RT_OS_FREEBSD
+ # include "../src-server/freebsd/PerformanceFreeBSD.cpp"
+ #endif
++#ifdef RT_OS_NETBSD
++# include "../src-server/netbsd/PerformanceNetBSD.cpp"
++#endif
+ #ifdef RT_OS_LINUX
+ # include "../src-server/linux/PerformanceLinux.cpp"
+ #endif
+@@ -577,4 +580,3 @@ int main(int argc, char *argv[])
+ 
+     return rc;
+ }
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_Main_webservice_vboxweb.cpp b/virtualbox-svn/patches/patch-src_VBox_Main_webservice_vboxweb.cpp
new file mode 100644
index 0000000..e6f51c2
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Main_webservice_vboxweb.cpp
@@ -0,0 +1,40 @@
+$NetBSD$
+
+--- src/VBox/Main/webservice/vboxweb.cpp.orig	2016-03-04 19:29:42.000000000 +0000
++++ src/VBox/Main/webservice/vboxweb.cpp
+@@ -189,7 +189,7 @@ static ThreadsMap               g_mapThr
+ static const RTGETOPTDEF g_aOptions[]
+     = {
+         { "--help",             'h', RTGETOPT_REQ_NOTHING }, /* for DisplayHelp() */
+-#if defined(RT_OS_DARWIN) || defined(RT_OS_LINUX) || defined (RT_OS_SOLARIS) || defined(RT_OS_FREEBSD)
++#if defined(RT_OS_DARWIN) || defined(RT_OS_LINUX) || defined (RT_OS_SOLARIS) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+         { "--background",       'b', RTGETOPT_REQ_NOTHING },
+ #endif
+         { "--host",             'H', RTGETOPT_REQ_STRING },
+@@ -236,7 +236,7 @@ static void DisplayHelp()
+                 pcszDescr = "Print this help message and exit.";
+                 break;
+ 
+-#if defined(RT_OS_DARWIN) || defined(RT_OS_LINUX) || defined (RT_OS_SOLARIS) || defined(RT_OS_FREEBSD)
++#if defined(RT_OS_DARWIN) || defined(RT_OS_LINUX) || defined (RT_OS_SOLARIS) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+             case 'b':
+                 pcszDescr = "Run in background (daemon mode).";
+                 break;
+@@ -1161,7 +1161,7 @@ int main(int argc, char *argv[])
+                 g_fVerbose = true;
+                 break;
+ 
+-#if defined(RT_OS_DARWIN) || defined(RT_OS_LINUX) || defined (RT_OS_SOLARIS) || defined(RT_OS_FREEBSD)
++#if defined(RT_OS_DARWIN) || defined(RT_OS_LINUX) || defined (RT_OS_SOLARIS) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+             case 'b':
+                 g_fDaemonize = true;
+                 break;
+@@ -1187,7 +1187,7 @@ int main(int argc, char *argv[])
+     if (RT_FAILURE(rc))
+         return RTMsgErrorExit(RTEXITCODE_FAILURE, "failed to open release log (%s, %Rrc)", szError, rc);
+ 
+-#if defined(RT_OS_DARWIN) || defined(RT_OS_LINUX) || defined (RT_OS_SOLARIS) || defined(RT_OS_FREEBSD)
++#if defined(RT_OS_DARWIN) || defined(RT_OS_LINUX) || defined (RT_OS_SOLARIS) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+     if (g_fDaemonize)
+     {
+         /* prepare release logging */
diff --git a/virtualbox-svn/patches/patch-src_VBox_Main_xml_Settings.cpp b/virtualbox-svn/patches/patch-src_VBox_Main_xml_Settings.cpp
new file mode 100644
index 0000000..afc7651
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Main_xml_Settings.cpp
@@ -0,0 +1,2 @@
+$NetBSD$
+
diff --git a/virtualbox-svn/patches/patch-src_VBox_Main_xml_VirtualBox-settings.xsd b/virtualbox-svn/patches/patch-src_VBox_Main_xml_VirtualBox-settings.xsd
new file mode 100644
index 0000000..dca729a
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Main_xml_VirtualBox-settings.xsd
@@ -0,0 +1,17 @@
+$NetBSD$
+
+--- src/VBox/Main/xml/VirtualBox-settings.xsd.orig	2016-03-04 19:29:43.000000000 +0000
++++ src/VBox/Main/xml/VirtualBox-settings.xsd
+@@ -743,9 +743,9 @@
+       <xsd:restriction base="xsd:token">
+         <xsd:enumeration value="null"/> <!-- deprecated -->
+         <xsd:enumeration value="Null"/> <!-- all platforms -->
+-        <xsd:enumeration value="OSS"/> <!-- Linux, Solaris, FreeBSD -->
+-        <xsd:enumeration value="ALSA"/> <!-- Linux, FreeBSD -->
+-        <xsd:enumeration value="Pulse"/> <!-- Linux -->
++        <xsd:enumeration value="OSS"/> <!-- Linux, Solaris, FreeBSD, NetBSD -->
++        <xsd:enumeration value="ALSA"/> <!-- Linux, FreeBSD, NetBSD -->
++        <xsd:enumeration value="Pulse"/> <!-- Linux, NetBSD -->
+         <xsd:enumeration value="CoreAudio"/> <!-- Mac OS X -->
+         <xsd:enumeration value="MMPM"/> <!-- OS/2 -->
+         <xsd:enumeration value="SolAudio"/> <!-- Solaris -->
diff --git a/virtualbox-svn/patches/patch-src_VBox_Makefile.kmk b/virtualbox-svn/patches/patch-src_VBox_Makefile.kmk
new file mode 100644
index 0000000..fa9080f
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Makefile.kmk
@@ -0,0 +1,62 @@
+$NetBSD$
+
+--- src/VBox/Makefile.kmk.orig	2016-03-04 19:29:43.000000000 +0000
++++ src/VBox/Makefile.kmk
+@@ -22,21 +22,21 @@ include $(KBUILD_PATH)/subheader.kmk
+ ifdef VBOX_ONLY_ADDITIONS
+  include $(PATH_SUB_CURRENT)/Runtime/Makefile.kmk
+  if defined(VBOX_WITH_CROGL) || defined(VBOX_WITH_HGSMI)
+-  if1of ($(KBUILD_TARGET),win linux solaris freebsd haiku)
+-   include $(PATH_SUB_CURRENT)/GuestHost/Makefile.kmk
++  if1of ($(KBUILD_TARGET),win linux solaris freebsd haiku netbsd)
++#   include $(PATH_SUB_CURRENT)/GuestHost/Makefile.kmk
+   endif
+  endif
+  include $(PATH_SUB_CURRENT)/Additions/Makefile.kmk
+ 
+ else ifdef VBOX_ONLY_DOCS
+  include $(PATH_SUB_CURRENT)/Runtime/Makefile.kmk
+- include $(PATH_SUB_CURRENT)/HostDrivers/Makefile.kmk
++# include $(PATH_SUB_CURRENT)/HostDrivers/Makefile.kmk
+  include $(PATH_SUB_CURRENT)/Frontends/Makefile.kmk
+ 
+ else ifdef VBOX_ONLY_EXTPACKS
+  include $(PATH_SUB_CURRENT)/Runtime/Makefile.kmk
+  include $(PATH_SUB_CURRENT)/Devices/Makefile.kmk
+- include $(PATH_SUB_CURRENT)/HostDrivers/Makefile.kmk
++# include $(PATH_SUB_CURRENT)/HostDrivers/Makefile.kmk
+  include $(PATH_SUB_CURRENT)/Storage/Makefile.kmk
+  include $(PATH_SUB_CURRENT)/ExtPacks/Makefile.kmk
+  ifdef VBOX_WITH_VRDP
+@@ -57,7 +57,7 @@ else ifdef VBOX_ONLY_SDK
+ 
+ else ifdef VBOX_ONLY_VALIDATIONKIT
+  include $(PATH_SUB_CURRENT)/Runtime/Makefile.kmk
+- include $(PATH_SUB_CURRENT)/HostDrivers/Makefile.kmk
++# include $(PATH_SUB_CURRENT)/HostDrivers/Makefile.kmk
+  include $(PATH_SUB_CURRENT)/Additions/Makefile.kmk
+  include $(PATH_SUB_CURRENT)/Disassembler/Makefile.kmk
+  include $(PATH_SUB_CURRENT)/ValidationKit/Makefile.kmk
+@@ -72,7 +72,7 @@ else
+  if1of ($(KBUILD_TARGET_ARCH), amd64 x86)
+   include $(PATH_SUB_CURRENT)/VMM/Makefile.kmk
+   include $(PATH_SUB_CURRENT)/Devices/Makefile.kmk
+-  include $(PATH_SUB_CURRENT)/HostDrivers/Makefile.kmk
++#  include $(PATH_SUB_CURRENT)/HostDrivers/Makefile.kmk
+   include $(PATH_SUB_CURRENT)/HostServices/Makefile.kmk
+  endif
+  ifdef VBOX_WITH_DEBUGGER
+@@ -85,7 +85,7 @@ else
+   include $(PATH_SUB_CURRENT)/RDP/client-1.8.3/Makefile.kmk
+  endif
+  if defined(VBOX_WITH_CROGL) || defined(VBOX_WITH_HGSMI) || defined(VBOX_WITH_HGCM)
+-  include $(PATH_SUB_CURRENT)/GuestHost/Makefile.kmk
++#  include $(PATH_SUB_CURRENT)/GuestHost/Makefile.kmk
+  endif
+  ifdef VBOX_WITH_ADDITIONS
+   include $(PATH_SUB_CURRENT)/Additions/Makefile.kmk
+@@ -106,4 +106,3 @@ endif # !VBOX_ONLY_ADDITIONS && !VBOX_ON
+ 
+ 
+ include $(FILE_KBUILD_SUB_FOOTER)
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_NetworkServices_NAT_Makefile.kmk b/virtualbox-svn/patches/patch-src_VBox_NetworkServices_NAT_Makefile.kmk
new file mode 100644
index 0000000..4851c0e
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_NetworkServices_NAT_Makefile.kmk
@@ -0,0 +1,12 @@
+$NetBSD$
+
+--- src/VBox/NetworkServices/NAT/Makefile.kmk.orig	2016-03-04 19:29:43.000000000 +0000
++++ src/VBox/NetworkServices/NAT/Makefile.kmk
+@@ -119,6 +119,7 @@ endif
+ 
+ VBoxNetLwipNAT_SOURCES.darwin  += rtmon_bsd.c
+ VBoxNetLwipNAT_SOURCES.freebsd += rtmon_bsd.c
++VBoxNetLwipNAT_SOURCES.netbsd  += rtmon_bsd.c
+ VBoxNetLwipNAT_SOURCES.linux   += rtmon_linux.c
+ VBoxNetLwipNAT_SOURCES.solaris += rtmon_bsd.c
+ VBoxNetLwipNAT_SOURCES.win     += rtmon_win.c
diff --git a/virtualbox-svn/patches/patch-src_VBox_NetworkServices_NAT_pxping.c b/virtualbox-svn/patches/patch-src_VBox_NetworkServices_NAT_pxping.c
new file mode 100644
index 0000000..0d09494
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_NetworkServices_NAT_pxping.c
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- src/VBox/NetworkServices/NAT/pxping.c.orig	2016-03-04 19:29:43.000000000 +0000
++++ src/VBox/NetworkServices/NAT/pxping.c
+@@ -560,7 +560,7 @@ pxping_recv4(void *arg, struct pbuf *p)
+ #if   defined(RT_OS_LINUX)
+         USE_DF_OPTION(IP_MTU_DISCOVER);
+         df = df ? IP_PMTUDISC_DO : IP_PMTUDISC_DONT;
+-#elif defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD)
++#elif defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+         USE_DF_OPTION(IP_DONTFRAG);
+ #elif defined(RT_OS_WINDOWS)
+         USE_DF_OPTION(IP_DONTFRAGMENT);
diff --git a/virtualbox-svn/patches/patch-src_VBox_NetworkServices_NAT_pxudp.c b/virtualbox-svn/patches/patch-src_VBox_NetworkServices_NAT_pxudp.c
new file mode 100644
index 0000000..9496a3a
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_NetworkServices_NAT_pxudp.c
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- src/VBox/NetworkServices/NAT/pxudp.c.orig	2016-03-04 19:29:43.000000000 +0000
++++ src/VBox/NetworkServices/NAT/pxudp.c
+@@ -603,7 +603,7 @@ pxudp_pcb_forward_outbound(struct pxudp 
+         const char * const dfoptname = #_Optname;
+ #if   defined(IP_MTU_DISCOVER)  /* Linux */
+         USE_DF_OPTION(IP_MTU_DISCOVER);
+-#elif defined(IP_DONTFRAG)      /* Solaris 11+, FreeBSD */
++#elif defined(IP_DONTFRAG)      /* Solaris 11+, FreeBSD, NetBSD */
+         USE_DF_OPTION(IP_DONTFRAG);
+ #elif defined(IP_DONTFRAGMENT)  /* Windows */
+         USE_DF_OPTION(IP_DONTFRAGMENT);
diff --git a/virtualbox-svn/patches/patch-src_VBox_Runtime_Makefile.kmk b/virtualbox-svn/patches/patch-src_VBox_Runtime_Makefile.kmk
new file mode 100644
index 0000000..e23a117
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Runtime_Makefile.kmk
@@ -0,0 +1,270 @@
+$NetBSD$
+
+--- src/VBox/Runtime/Makefile.kmk.orig	2016-03-04 19:29:47.000000000 +0000
++++ src/VBox/Runtime/Makefile.kmk
+@@ -34,7 +34,7 @@ ifdef VBOX_ONLY_ADDITIONS
+  LIBRARIES += RuntimeGuestR3 RuntimeGuestR3Shared
+  LIBRARIES.win.amd64 += RuntimeGuestR3-x86 RuntimeGuestR3Shared-x86
+  ifdef VBOX_WITH_ADDITION_DRIVERS
+-  LIBRARIES += RuntimeGuestR0
++#  LIBRARIES += RuntimeGuestR0
+   #LIBRARIES.os2 += RuntimeGuestR0OS2Warp3
+   LIBRARIES.win.x86 += RuntimeGuestR0NT4
+  endif
+@@ -84,13 +84,13 @@ else # !VBOX_ONLY_ADDITIONS && !VBOX_ONL
+   LIBRARIES.win += RuntimeRCStub
+  endif
+  ifdef VBOX_WITH_VBOXDRV
+-  LIBRARIES += RuntimeR0Drv
++#  LIBRARIES += RuntimeR0Drv
+  endif
+  ifdef VBOX_WITH_ADDITIONS
+   LIBRARIES += RuntimeGuestR3 RuntimeGuestR3Shared
+   LIBRARIES.win.amd64 += RuntimeGuestR3-x86 RuntimeGuestR3Shared-x86
+   ifdef VBOX_WITH_ADDITION_DRIVERS
+-   LIBRARIES += RuntimeGuestR0
++#   LIBRARIES += RuntimeGuestR0
+   endif
+   #LIBRARIES.os2 += RuntimeGuestR0OS2Warp3
+   LIBRARIES.win.x86 += RuntimeGuestR0NT4
+@@ -1094,6 +1094,81 @@ RuntimeR3_SOURCES.freebsd = \
+ RuntimeR3_SOURCES.freebsd.x86   += common/string/memrchr.asm
+ RuntimeR3_SOURCES.freebsd.amd64 += common/string/memrchr.asm
+ 
++## @todo Make BSD sched, implement RTMP*.
++RuntimeR3_SOURCES.netbsd = \
++	generic/cdrom-generic.cpp \
++	generic/RTCrStoreCreateSnapshotById-generic.cpp \
++	generic/RTDirQueryInfo-generic.cpp \
++	generic/RTDirSetTimes-generic.cpp \
++	generic/RTFileMove-generic.cpp \
++	generic/RTLogWriteDebugger-generic.cpp \
++	generic/RTPathAbs-generic.cpp \
++	generic/RTPathGetCurrentOnDrive-generic.cpp \
++ 	generic/RTSemEventMultiWait-2-ex-generic.cpp \
++ 	generic/RTSemEventMultiWaitNoResume-2-ex-generic.cpp \
++	generic/RTSystemQueryDmiString-generic.cpp \
++	generic/RTSystemShutdown-generic.cpp \
++	generic/RTThreadGetAffinity-stub-generic.cpp \
++	generic/RTThreadSetAffinity-stub-generic.cpp \
++	generic/RTThreadSetAffinityToCpu-generic.cpp \
++	generic/RTTimeLocalNow-generic.cpp \
++	generic/RTTimerCreate-generic.cpp \
++	generic/RTUuidCreate-generic.cpp \
++	generic/mppresent-generic.cpp \
++	generic/sched-generic.cpp \
++	generic/utf16locale-generic.cpp \
++	generic/uuid-generic.cpp \
++	generic/RTMpCpuId-generic.cpp \
++	generic/RTMpGetCoreCount-generic.cpp \
++	generic/RTMpGetOnlineCoreCount-generic.cpp \
++	generic/RTProcDaemonize-generic.cpp \
++	generic/RTProcIsRunningByName-generic.cpp \
++	generic/RTThreadGetNativeState-generic.cpp \
++	r3/netbsd/mp-netbsd.cpp \
++	r3/netbsd/systemmem-netbsd.cpp \
++	r3/netbsd/rtProcInitExePath-netbsd.cpp \
++	r3/generic/allocex-r3-generic.cpp \
++	r3/posix/RTFileQueryFsSizes-posix.cpp \
++	r3/posix/RTHandleGetStandard-posix.cpp \
++	r3/posix/RTMemProtect-posix.cpp \
++	r3/posix/RTPathUserHome-posix.cpp \
++	r3/posix/RTSystemQueryOSInfo-posix.cpp \
++	r3/posix/RTTimeNow-posix.cpp \
++	r3/posix/RTTimeSet-posix.cpp \
++	r3/posix/dir-posix.cpp \
++	r3/posix/env-posix.cpp \
++	r3/posix/errvars-posix.cpp \
++	r3/posix/fileio-posix.cpp \
++	r3/posix/fileio2-posix.cpp \
++	r3/posix/filelock-posix.cpp \
++	r3/posix/fs-posix.cpp \
++	r3/posix/fs2-posix.cpp \
++	r3/posix/fs3-posix.cpp \
++	r3/posix/ldrNative-posix.cpp \
++	r3/posix/rtmempage-exec-mmap-heap-posix.cpp \
++	r3/posix/path-posix.cpp \
++	r3/posix/path2-posix.cpp \
++	r3/posix/pathhost-posix.cpp \
++	r3/posix/RTPathUserDocuments-posix.cpp \
++	r3/posix/pipe-posix.cpp \
++	r3/posix/process-posix.cpp \
++	r3/posix/process-creation-posix.cpp \
++	r3/posix/rand-posix.cpp \
++	r3/posix/semevent-posix.cpp \
++	r3/posix/semeventmulti-posix.cpp \
++	r3/posix/semmutex-posix.cpp \
++	r3/posix/semrw-posix.cpp \
++	r3/posix/symlink-posix.cpp \
++	r3/posix/thread-posix.cpp \
++	r3/posix/thread2-posix.cpp \
++	r3/posix/time-posix.cpp \
++	r3/posix/timelocal-posix.cpp \
++	r3/posix/timer-posix.cpp \
++	r3/posix/tls-posix.cpp \
++	r3/posix/utf8-posix.cpp
++RuntimeR3_SOURCES.netbsd.x86   += common/string/memrchr.asm
++RuntimeR3_SOURCES.netbsd.amd64 += common/string/memrchr.asm
++
+ RuntimeR3_SOURCES.solaris = \
+ 	generic/cdrom-generic.cpp \
+ 	generic/RTCrStoreCreateSnapshotById-generic.cpp \
+@@ -1386,6 +1461,8 @@ VBoxRT_SOURCES.darwin         += \
+ 	r3/posix/fileaio-posix.cpp
+ VBoxRT_SOURCES.freebsd        += \
+ 	r3/freebsd/fileaio-freebsd.cpp
++VBoxRT_SOURCES.netbsd        += \
++	r3/netbsd/fileaio-netbsd.cpp
+ VBoxRT_INCS                   := $(RuntimeR3_INCS)
+ VBoxRT_INCS.$(KBUILD_TARGET)  := $(RuntimeR3_INCS.$(KBUILD_TARGET))
+ VBoxRT_INCS.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH) := $(RuntimeR3_INCS.$(KBUILD_TARGET).$(KBUILD_TARGET_ARCH))
+@@ -1424,6 +1501,8 @@ VBoxRT_LIBS.darwin             = \
+ VBoxRT_LIBS.freebsd            = \
+ 	iconv \
+ 	rt
++VBoxRT_LIBS.netbsd             = \
++	rt
+ VBoxRT_LIBS.haiku              = \
+ 	iconv
+ VBoxRT_LIBS.solaris            = \
+@@ -1569,6 +1648,8 @@ VBoxRT-x86_LIBS.darwin             = \
+ VBoxRT-x86_LIBS.freebsd            = \
+ 	iconv \
+ 	rt
++VBoxRT-x86_LIBS.netbsd             = \
++	rt
+ VBoxRT-x86_LIBS.haiku              = \
+ 	iconv
+ VBoxRT-x86_LIBS.solaris            = \
+@@ -1749,7 +1830,7 @@ RuntimeR0_SOURCES      := \
+ 	\
+ 	$(RuntimeNoCrt_SOURCES)
+ 
+-if1of ($(KBUILD_TARGET), darwin solaris freebsd)
++if1of ($(KBUILD_TARGET), darwin solaris freebsd netbsd)
+ RuntimeR0_SOURCES += \
+ 	common/math/gcc/adddi3.c \
+ 	common/math/gcc/anddi3.c \
+@@ -1838,6 +1919,8 @@ RuntimeR0Drv_DEFS.linux = MODULE KBUILD_
+ RuntimeR0Drv_INCS      := $(PATH_SUB_CURRENT) include
+ RuntimeR0Drv_INCS.freebsd = \
+ 	$(PATH_STAGE)/gen-sys-hdrs
++#RuntimeR0Drv_INCS.netbsd = \
++#	$(PATH_STAGE)/gen-sys-hdrs
+ RuntimeR0Drv_INCS.linux = \
+ 	r0drv/linux
+ RuntimeR0Drv_INCS.solaris = \
+@@ -2257,6 +2340,41 @@ RuntimeR0Drv_SOURCES.freebsd = \
+ 	r0drv/memobj-r0drv.cpp \
+ 	r0drv/powernotification-r0drv.c
+ 
++RuntimeR0Drv_SOURCES.netbsd = \
++	common/misc/thread.cpp \
++	common/string/memchr.asm \
++	common/string/memmove.asm \
++	common/string/strpbrk.cpp \
++	common/string/memcmp.asm \
++	common/string/strchr.asm \
++	generic/RTAssertShouldPanic-generic.cpp \
++	generic/RTLogWriteDebugger-generic.cpp \
++	generic/RTLogWriteStdOut-stub-generic.cpp \
++	generic/RTMpOnPair-generic.cpp \
++	generic/RTTimerCreate-generic.cpp \
++	generic/mppresent-generic.cpp \
++	r0drv/generic/RTMpIsCpuWorkPending-r0drv-generic.cpp \
++	r0drv/generic/mpnotification-r0drv-generic.cpp \
++	r0drv/generic/threadctxhooks-r0drv-generic.cpp \
++	r0drv/netbsd/alloc-r0drv-netbsd.c \
++	r0drv/netbsd/assert-r0drv-netbsd.c \
++	r0drv/netbsd/initterm-r0drv-netbsd.c \
++	r0drv/netbsd/memobj-r0drv-netbsd.c \
++	r0drv/netbsd/memuserkernel-r0drv-netbsd.c \
++	r0drv/netbsd/process-r0drv-netbsd.c \
++	r0drv/netbsd/semevent-r0drv-netbsd.c \
++	r0drv/netbsd/semeventmulti-r0drv-netbsd.c \
++	r0drv/netbsd/semfastmutex-r0drv-netbsd.c \
++	r0drv/netbsd/semmutex-r0drv-netbsd.c \
++	r0drv/netbsd/spinlock-r0drv-netbsd.c \
++	r0drv/netbsd/thread-r0drv-netbsd.c \
++	r0drv/netbsd/thread2-r0drv-netbsd.c \
++	r0drv/netbsd/time-r0drv-netbsd.c \
++	r0drv/netbsd/mp-r0drv-netbsd.c \
++	generic/timer-generic.cpp \
++	r0drv/memobj-r0drv.cpp \
++	r0drv/powernotification-r0drv.c
++
+ RuntimeR0Drv_SOURCES.solaris = \
+ 	common/misc/thread.cpp \
+ 	common/string/memchr.asm \
+@@ -2330,6 +2448,10 @@ RuntimeR0Drv_ORDERDEPS.freebsd = \
+ 	$(PATH_STAGE)/gen-sys-hdrs/bus_if.h \
+ 	$(PATH_STAGE)/gen-sys-hdrs/device_if.h
+ 
++#RuntimeR0Drv_ORDERDEPS.netbsd = \
++#	$(PATH_STAGE)/gen-sys-hdrs/bus_if.h \
++#	$(PATH_STAGE)/gen-sys-hdrs/device_if.h
++
+ 
+ #
+ # RuntimeGuestR0 - Guest driver runtime.
+@@ -2429,7 +2551,7 @@ ifdef VBOX_WITH_RAW_MODE
+   RuntimeRC_SOURCES += os2/sys0.asm
+  endif
+ 
+- if1of ($(KBUILD_TARGET), darwin solaris freebsd)
++ if1of ($(KBUILD_TARGET), darwin solaris freebsd netbsd)
+   RuntimeRC_SOURCES += \
+  	common/math/gcc/adddi3.c \
+  	common/math/gcc/anddi3.c \
+@@ -2644,6 +2766,46 @@ $$(FreeBSDGeneratedKernelHeaders_0_OUTDI
+ 	$(QUIET)$(RM) $(@D)/pci_if.m
+ endif # FreeBSD
+ 
++#if "$(KBUILD_TARGET)" == "netbsd"
++#
++# NetBSDGeneratedKernelHeaders - Generate some kernel interface headers.
++#
++# These are used by:
++#      - The RTMp* API in IPRT.
++#      - VBoxGuest
++#
++# Note! We cannot give a output path to the awk program, it will always
++# generate the header next to the source. So, we'll have to temporarily copy
++# the source file to the destination directory to work.
++#
++#VBOX_AWK := /usr/bin/awk
++#INSTALLS += NetBSDGeneratedKernelHeaders
++#NetBSDGeneratedKernelHeaders_INST = gen-sys-hdrs/
++#NetBSDGeneratedKernelHeaders_SOURCES = \
++#	$(NetBSDGeneratedKernelHeaders_0_OUTDIR)/bus_if.h \
++#	$(NetBSDGeneratedKernelHeaders_0_OUTDIR)/device_if.h \
++#	$(NetBSDGeneratedKernelHeaders_0_OUTDIR)/pci_if.h
++#NetBSDGeneratedKernelHeaders_CLEAN = $(NetBSDGeneratedKernelHeaders_SOURCES)
++#
++#$$(NetBSDGeneratedKernelHeaders_0_OUTDIR)/bus_if.h: $(VBOX_NETBSD_SRC)/kern/bus_if.m | $$(dir $$@)
++#	$(call MSG_TOOL,awk,NetBSDGeneratedKernelHeaders,$<,$@)
++#	$(QUIET)$(CP) -f $< $(@D)/bus_if.m
++#	$(QUIET)$(VBOX_AWK) -f $(VBOX_NETBSD_SRC)/tools/makeobjops.awk $(@D)/bus_if.m -h -p
++#	$(QUIET)$(RM) $(@D)/bus_if.m
++#
++#$$(NetBSDGeneratedKernelHeaders_0_OUTDIR)/device_if.h: $(VBOX_NETBSD_SRC)/kern/device_if.m | $$(dir $$@)
++#	$(call MSG_TOOL,awk,NetBSDGeneratedKernelHeaders,$<,$@)
++#	$(QUIET)$(CP) -f $< $(@D)/device_if.m
++#	$(QUIET)$(VBOX_AWK) -f $(VBOX_NETBSD_SRC)/tools/makeobjops.awk $(@D)/device_if.m -h -p
++#	$(QUIET)$(RM) $(@D)/device_if.m
++#
++#$$(NetBSDGeneratedKernelHeaders_0_OUTDIR)/pci_if.h: $(VBOX_NETBSD_SRC)/dev/pci/pci_if.m | $$(dir $$@)
++#	$(call MSG_TOOL,awk,NetBSDGeneratedKernelHeaders,$<,$@)
++#	$(QUIET)$(CP) -f $< $(@D)/pci_if.m
++#	$(QUIET)$(VBOX_AWK) -f $(VBOX_NETBSD_SRC)/tools/makeobjops.awk $(@D)/pci_if.m -h -p
++#	$(QUIET)$(RM) $(@D)/pci_if.m
++#endif # NetBSD
++
+ 
+ #
+ # Aliases for .cpp.h files so we can more easily do syntax checking from the editor.
+@@ -2924,4 +3086,3 @@ taf-template.o taf-template.obj: taf-cor
+ tsp-template.o tsp-template.obj: tsp-core.o tsp-asn1-decoder.o tsp-sanity.o tsp-init.o
+ x509-template.o x509-template.obj: x509-core.o x509-asn1-decoder.o x509-sanity.o x509-init.o
+ pkcs7-template.o pkcs7-template.obj: pkcs7-core.o pkcs7-asn1-decoder.o pkcs7-sanity.o pkcs7-init.o
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_Runtime_VBox_log-vbox.cpp b/virtualbox-svn/patches/patch-src_VBox_Runtime_VBox_log-vbox.cpp
new file mode 100644
index 0000000..6264893
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Runtime_VBox_log-vbox.cpp
@@ -0,0 +1,57 @@
+$NetBSD$
+
+--- src/VBox/Runtime/VBox/log-vbox.cpp.orig	2016-03-04 19:29:47.000000000 +0000
++++ src/VBox/Runtime/VBox/log-vbox.cpp
+@@ -137,6 +137,11 @@
+ #  include <sys/user.h>
+ #  include <stdlib.h>
+ #  include <unistd.h>
++# elif defined(RT_OS_NETBSD)
++#  include <sys/param.h>
++#  include <sys/sysctl.h>
++#  include <stdlib.h>
++#  include <unistd.h>
+ # elif defined(RT_OS_HAIKU)
+ #  include <OS.h>
+ # elif defined(RT_OS_SOLARIS)
+@@ -422,6 +427,40 @@ RTDECL(PRTLOGGER) RTLogDefaultInit(void)
+             }
+         }
+ 
++#  elif defined(RT_OS_NETBSD)
++        /* Retrieve the required length first */
++        int aiName[4];
++        aiName[0] = CTL_KERN;
++        aiName[1] = KERN_PROC_ARGS;
++        aiName[2] = getpid();
++        aiName[3] = KERN_PROC_ARGV;
++        size_t cchArgs = 0;
++        int rcBSD = sysctl(aiName, RT_ELEMENTS(aiName), NULL, &cchArgs, NULL, 0);
++        if (cchArgs > 0)
++        {
++            char *pszArgFileBuf = (char *)RTMemAllocZ(cchArgs + 1 /* Safety */);
++            if (pszArgFileBuf)
++            {
++                /* Retrieve the argument list */
++                rcBSD = sysctl(aiName, RT_ELEMENTS(aiName), pszArgFileBuf, &cchArgs, NULL, 0);
++                if (!rcBSD)
++                {
++                    unsigned    iArg = 0;
++                    size_t      off = 0;
++                    while (off < cchArgs)
++                    {
++                        size_t cchArg = strlen(&pszArgFileBuf[off]);
++                        RTLogLoggerEx(pLogger, 0, ~0U, "Arg[%u]: %s\n", iArg, &pszArgFileBuf[off]);
++
++                        /* advance */
++                        off += cchArg + 1;
++                        iArg++;
++                    }
++                }
++                RTMemFree(pszArgFileBuf);
++            }
++        }
++
+ #  elif defined(RT_OS_OS2) || defined(RT_OS_DARWIN)
+         /* commandline? */
+ #  else
diff --git a/virtualbox-svn/patches/patch-src_VBox_Runtime_r0drv_netbsd_alloc-r0drv-netbsd.c b/virtualbox-svn/patches/patch-src_VBox_Runtime_r0drv_netbsd_alloc-r0drv-netbsd.c
new file mode 100644
index 0000000..a7725fa
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Runtime_r0drv_netbsd_alloc-r0drv-netbsd.c
@@ -0,0 +1,184 @@
+$NetBSD$
+
+--- src/VBox/Runtime/r0drv/netbsd/alloc-r0drv-netbsd.c.orig	2016-07-07 07:08:46.872622650 +0000
++++ src/VBox/Runtime/r0drv/netbsd/alloc-r0drv-netbsd.c
+@@ -0,0 +1,179 @@
++/*  alloc-r0drv-netbsd.c $ */
++/** @file
++ * IPRT - Memory Allocation, Ring-0 Driver, NetBSD.
++ */
++
++/*
++ * Copyright (c) 2007 knut st. osmundsen <bird-src-spam%anduin.net@localhost>
++ *
++ * Permission is hereby granted, free of charge, to any person
++ * obtaining a copy of this software and associated documentation
++ * files (the "Software"), to deal in the Software without
++ * restriction, including without limitation the rights to use,
++ * copy, modify, merge, publish, distribute, sublicense, and/or sell
++ * copies of the Software, and to permit persons to whom the
++ * Software is furnished to do so, subject to the following
++ * conditions:
++ *
++ * The above copyright notice and this permission notice shall be
++ * included in all copies or substantial portions of the Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
++ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
++ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
++ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
++ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
++ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
++ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
++ * OTHER DEALINGS IN THE SOFTWARE.
++ */
++
++
++/*********************************************************************************************************************************
++*   Header Files                                                                                                                 *
++*********************************************************************************************************************************/
++#include "the-netbsd-kernel.h"
++#include "internal/iprt.h"
++#include <iprt/mem.h>
++
++#include <iprt/assert.h>
++#include <iprt/err.h>
++#include <iprt/param.h>
++
++#include "r0drv/alloc-r0drv.h"
++
++
++/*********************************************************************************************************************************
++*   Global Variables                                                                                                             *
++*********************************************************************************************************************************/
++/* These two statements will define two globals and add initializers
++   and destructors that will be called at load/unload time (I think). */
++MALLOC_DEFINE(M_IPRTHEAP, "iprtheap", "IPRT - heap");
++MALLOC_DEFINE(M_IPRTCONT, "iprtcont", "IPRT - contiguous");
++
++
++DECLHIDDEN(int) rtR0MemAllocEx(size_t cb, uint32_t fFlags, PRTMEMHDR *ppHdr)
++{
++    size_t      cbAllocated = cb;
++    PRTMEMHDR   pHdr        = NULL;
++
++#ifdef RT_ARCH_AMD64
++    /*
++     * Things are a bit more complicated on AMD64 for executable memory
++     * because we need to be in the ~2GB..~0 range for code.
++     */
++    if (fFlags & RTMEMHDR_FLAG_EXEC)
++    {
++        if (fFlags & RTMEMHDR_FLAG_ANY_CTX)
++            return VERR_NOT_SUPPORTED;
++
++# ifdef USE_KMEM_ALLOC_PROT
++        pHdr = (PRTMEMHDR)kmem_alloc_prot(kernel_map, cb + sizeof(*pHdr),
++                                          VM_PROT_ALL, VM_PROT_ALL, KERNBASE);
++# else
++        vm_object_t pVmObject = NULL;
++        vm_offset_t Addr = KERNBASE;
++        cbAllocated = RT_ALIGN_Z(cb + sizeof(*pHdr), PAGE_SIZE);
++
++        pVmObject = vm_object_allocate(OBJT_DEFAULT, cbAllocated >> PAGE_SHIFT);
++        if (!pVmObject)
++            return VERR_NO_EXEC_MEMORY;
++
++        /* Addr contains a start address vm_map_find will start searching for suitable space at. */
++        int rc = vm_map_find(kernel_map, pVmObject, 0, &Addr,
++                             cbAllocated, 0, VMFS_ANY_SPACE, VM_PROT_ALL, VM_PROT_ALL, 0);
++        if (rc == KERN_SUCCESS)
++        {
++            rc = vm_map_wire(kernel_map, Addr, Addr + cbAllocated,
++                             VM_MAP_WIRE_SYSTEM | VM_MAP_WIRE_NOHOLES);
++            if (rc == KERN_SUCCESS)
++            {
++                pHdr = (PRTMEMHDR)Addr;
++
++                if (fFlags & RTMEMHDR_FLAG_ZEROED)
++                    bzero(pHdr, cbAllocated);
++            }
++            else
++                vm_map_remove(kernel_map,
++                              Addr,
++                              Addr + cbAllocated);
++        }
++        else
++            vm_object_deallocate(pVmObject);
++# endif
++    }
++    else
++#endif
++    {
++        pHdr = (PRTMEMHDR)malloc(cb + sizeof(RTMEMHDR), M_IPRTHEAP,
++                                 fFlags & RTMEMHDR_FLAG_ZEROED ? M_NOWAIT | M_ZERO : M_NOWAIT);
++    }
++
++    if (RT_UNLIKELY(!pHdr))
++        return VERR_NO_MEMORY;
++
++    pHdr->u32Magic   = RTMEMHDR_MAGIC;
++    pHdr->fFlags     = fFlags;
++    pHdr->cb         = cbAllocated;
++    pHdr->cbReq      = cb;
++
++    *ppHdr = pHdr;
++    return VINF_SUCCESS;
++}
++
++
++DECLHIDDEN(void) rtR0MemFree(PRTMEMHDR pHdr)
++{
++    pHdr->u32Magic += 1;
++
++#ifdef RT_ARCH_AMD64
++    if (pHdr->fFlags & RTMEMHDR_FLAG_EXEC)
++# ifdef USE_KMEM_ALLOC_PROT
++        kmem_free(kernel_map, (vm_offset_t)pHdr, pHdr->cb);
++# else
++        vm_map_remove(kernel_map, (vm_offset_t)pHdr, ((vm_offset_t)pHdr) + pHdr->cb);
++# endif
++    else
++#endif
++        free(pHdr, M_IPRTHEAP);
++}
++
++
++RTR0DECL(void *) RTMemContAlloc(PRTCCPHYS pPhys, size_t cb)
++{
++    void *pv;
++
++    /*
++     * Validate input.
++     */
++    AssertPtr(pPhys);
++    Assert(cb > 0);
++
++    /*
++     * This API works in pages, so no need to do any size aligning.
++     */
++    pv = contigmalloc(cb,                   /* size */
++                      M_IPRTCONT,           /* type */
++                      M_NOWAIT | M_ZERO,    /* flags */
++                      0,                    /* lowest physical address*/
++                      _4G-1,                /* highest physical address */
++                      PAGE_SIZE,            /* alignment. */
++                      0);                   /* boundary */
++    if (pv)
++    {
++        Assert(!((uintptr_t)pv & PAGE_OFFSET_MASK));
++        *pPhys = vtophys(pv);
++        Assert(!(*pPhys & PAGE_OFFSET_MASK));
++    }
++    return pv;
++}
++
++
++RTR0DECL(void) RTMemContFree(void *pv, size_t cb)
++{
++    if (pv)
++    {
++        AssertMsg(!((uintptr_t)pv & PAGE_OFFSET_MASK), ("pv=%p\n", pv));
++        contigfree(pv, cb, M_IPRTCONT);
++    }
++}
diff --git a/virtualbox-svn/patches/patch-src_VBox_Runtime_r0drv_netbsd_assert-r0drv-netbsd.c b/virtualbox-svn/patches/patch-src_VBox_Runtime_r0drv_netbsd_assert-r0drv-netbsd.c
new file mode 100644
index 0000000..7ad2a12
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Runtime_r0drv_netbsd_assert-r0drv-netbsd.c
@@ -0,0 +1,74 @@
+$NetBSD$
+
+--- src/VBox/Runtime/r0drv/netbsd/assert-r0drv-netbsd.c.orig	2016-07-07 07:08:46.881887133 +0000
++++ src/VBox/Runtime/r0drv/netbsd/assert-r0drv-netbsd.c
+@@ -0,0 +1,69 @@
++/*  assert-r0drv-netbsd.c $ */
++/** @file
++ * IPRT - Assertion Workers, Ring-0 Drivers, NetBSD.
++ */
++
++/*
++ * Copyright (c) 2007 knut st. osmundsen <bird-src-spam%anduin.net@localhost>
++ *
++ * Permission is hereby granted, free of charge, to any person
++ * obtaining a copy of this software and associated documentation
++ * files (the "Software"), to deal in the Software without
++ * restriction, including without limitation the rights to use,
++ * copy, modify, merge, publish, distribute, sublicense, and/or sell
++ * copies of the Software, and to permit persons to whom the
++ * Software is furnished to do so, subject to the following
++ * conditions:
++ *
++ * The above copyright notice and this permission notice shall be
++ * included in all copies or substantial portions of the Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
++ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
++ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
++ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
++ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
++ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
++ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
++ * OTHER DEALINGS IN THE SOFTWARE.
++ */
++
++
++/*********************************************************************************************************************************
++*   Header Files                                                                                                                 *
++*********************************************************************************************************************************/
++#include "the-netbsd-kernel.h"
++
++#include <iprt/assert.h>
++#include <iprt/log.h>
++#include <iprt/string.h>
++#include <iprt/stdarg.h>
++
++#include "internal/assert.h"
++
++
++DECLHIDDEN(void) rtR0AssertNativeMsg1(const char *pszExpr, unsigned uLine, const char *pszFile, const char *pszFunction)
++{
++    printf("\r\n!!Assertion Failed!!\r\n"
++           "Expression: %s\r\n"
++           "Location  : %s(%d) %s\r\n",
++           pszExpr, pszFile, uLine, pszFunction);
++}
++
++
++DECLHIDDEN(void) rtR0AssertNativeMsg2V(bool fInitial, const char *pszFormat, va_list va)
++{
++    char szMsg[256];
++
++    RTStrPrintfV(szMsg, sizeof(szMsg) - 1, pszFormat, va);
++    szMsg[sizeof(szMsg) - 1] = '\0';
++    printf("%s", szMsg);
++
++    NOREF(fInitial);
++}
++
++
++RTR0DECL(void) RTR0AssertPanicSystem(void)
++{
++    /** @todo implement RTR0AssertPanicSystem. */
++}
diff --git a/virtualbox-svn/patches/patch-src_VBox_Runtime_r0drv_netbsd_initterm-r0drv-netbsd.c b/virtualbox-svn/patches/patch-src_VBox_Runtime_r0drv_netbsd_initterm-r0drv-netbsd.c
new file mode 100644
index 0000000..7a2eddb
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Runtime_r0drv_netbsd_initterm-r0drv-netbsd.c
@@ -0,0 +1,57 @@
+$NetBSD$
+
+--- src/VBox/Runtime/r0drv/netbsd/initterm-r0drv-netbsd.c.orig	2016-07-07 07:08:46.891248736 +0000
++++ src/VBox/Runtime/r0drv/netbsd/initterm-r0drv-netbsd.c
+@@ -0,0 +1,52 @@
++/*  initterm-r0drv-netbsd.c $ */
++/** @file
++ * IPRT - Initialization & Termination, Ring-0 Driver, NetBSD.
++ */
++
++/*
++ * Copyright (c) 2007 knut st. osmundsen <bird-src-spam%anduin.net@localhost>
++ *
++ * Permission is hereby granted, free of charge, to any person
++ * obtaining a copy of this software and associated documentation
++ * files (the "Software"), to deal in the Software without
++ * restriction, including without limitation the rights to use,
++ * copy, modify, merge, publish, distribute, sublicense, and/or sell
++ * copies of the Software, and to permit persons to whom the
++ * Software is furnished to do so, subject to the following
++ * conditions:
++ *
++ * The above copyright notice and this permission notice shall be
++ * included in all copies or substantial portions of the Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
++ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
++ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
++ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
++ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
++ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
++ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
++ * OTHER DEALINGS IN THE SOFTWARE.
++ */
++
++
++/*********************************************************************************************************************************
++*   Header Files                                                                                                                 *
++*********************************************************************************************************************************/
++#include "the-netbsd-kernel.h"
++
++#include <iprt/err.h>
++
++#include "internal/initterm.h"
++
++
++DECLHIDDEN(int) rtR0InitNative(void)
++{
++    /* nothing to do */
++    return VINF_SUCCESS;
++}
++
++
++DECLHIDDEN(void) rtR0TermNative(void)
++{
++    /* nothing to undo */
++}
diff --git a/virtualbox-svn/patches/patch-src_VBox_Runtime_r0drv_netbsd_memobj-r0drv-netbsd.c b/virtualbox-svn/patches/patch-src_VBox_Runtime_r0drv_netbsd_memobj-r0drv-netbsd.c
new file mode 100644
index 0000000..e8606f3
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Runtime_r0drv_netbsd_memobj-r0drv-netbsd.c
@@ -0,0 +1,811 @@
+$NetBSD$
+
+--- src/VBox/Runtime/r0drv/netbsd/memobj-r0drv-netbsd.c.orig	2016-07-07 07:08:46.900749311 +0000
++++ src/VBox/Runtime/r0drv/netbsd/memobj-r0drv-netbsd.c
+@@ -0,0 +1,806 @@
++/*  memobj-r0drv-netbsd.c $ */
++/** @file
++ * IPRT - Ring-0 Memory Objects, NetBSD.
++ */
++
++/*
++ * Copyright (c) 2007 knut st. osmundsen <bird-src-spam%anduin.net@localhost>
++ * Copyright (c) 2011 Andriy Gapon <avg%FreeBSD.org@localhost>
++ *
++ * Permission is hereby granted, free of charge, to any person
++ * obtaining a copy of this software and associated documentation
++ * files (the "Software"), to deal in the Software without
++ * restriction, including without limitation the rights to use,
++ * copy, modify, merge, publish, distribute, sublicense, and/or sell
++ * copies of the Software, and to permit persons to whom the
++ * Software is furnished to do so, subject to the following
++ * conditions:
++ *
++ * The above copyright notice and this permission notice shall be
++ * included in all copies or substantial portions of the Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
++ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
++ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
++ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
++ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
++ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
++ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
++ * OTHER DEALINGS IN THE SOFTWARE.
++ */
++
++
++/*********************************************************************************************************************************
++*   Header Files                                                                                                                 *
++*********************************************************************************************************************************/
++#include "the-netbsd-kernel.h"
++
++#include <iprt/memobj.h>
++#include <iprt/mem.h>
++#include <iprt/err.h>
++#include <iprt/assert.h>
++#include <iprt/log.h>
++#include <iprt/param.h>
++#include <iprt/process.h>
++#include "internal/memobj.h"
++
++
++/*********************************************************************************************************************************
++*   Structures and Typedefs                                                                                                      *
++*********************************************************************************************************************************/
++/**
++ * The NetBSD version of the memory object structure.
++ */
++typedef struct RTR0MEMOBJNETBSD
++{
++    /** The core structure. */
++    RTR0MEMOBJINTERNAL  Core;
++    /** The VM object associated with the allocation. */
++    vm_object_t         pObject;
++} RTR0MEMOBJNETBSD, *PRTR0MEMOBJNETBSD;
++
++
++MALLOC_DEFINE(M_IPRTMOBJ, "iprtmobj", "IPRT - R0MemObj");
++
++
++/**
++ * Gets the virtual memory map the specified object is mapped into.
++ *
++ * @returns VM map handle on success, NULL if no map.
++ * @param   pMem                The memory object.
++ */
++static vm_map_t rtR0MemObjNetBSDGetMap(PRTR0MEMOBJINTERNAL pMem)
++{
++    switch (pMem->enmType)
++    {
++        case RTR0MEMOBJTYPE_PAGE:
++        case RTR0MEMOBJTYPE_LOW:
++        case RTR0MEMOBJTYPE_CONT:
++            return kernel_map;
++
++        case RTR0MEMOBJTYPE_PHYS:
++        case RTR0MEMOBJTYPE_PHYS_NC:
++            return NULL; /* pretend these have no mapping atm. */
++
++        case RTR0MEMOBJTYPE_LOCK:
++            return pMem->u.Lock.R0Process == NIL_RTR0PROCESS
++                ? kernel_map
++                : &((struct proc *)pMem->u.Lock.R0Process)->p_vmspace->vm_map;
++
++        case RTR0MEMOBJTYPE_RES_VIRT:
++            return pMem->u.ResVirt.R0Process == NIL_RTR0PROCESS
++                ? kernel_map
++                : &((struct proc *)pMem->u.ResVirt.R0Process)->p_vmspace->vm_map;
++
++        case RTR0MEMOBJTYPE_MAPPING:
++            return pMem->u.Mapping.R0Process == NIL_RTR0PROCESS
++                ? kernel_map
++                : &((struct proc *)pMem->u.Mapping.R0Process)->p_vmspace->vm_map;
++
++        default:
++            return NULL;
++    }
++}
++
++
++DECLHIDDEN(int) rtR0MemObjNativeFree(RTR0MEMOBJ pMem)
++{
++    PRTR0MEMOBJNETBSD pMemNetBSD = (PRTR0MEMOBJNETBSD)pMem;
++    int rc;
++
++    switch (pMemNetBSD->Core.enmType)
++    {
++        case RTR0MEMOBJTYPE_PAGE:
++        case RTR0MEMOBJTYPE_LOW:
++        case RTR0MEMOBJTYPE_CONT:
++            rc = vm_map_remove(kernel_map,
++                                (vm_offset_t)pMemNetBSD->Core.pv,
++                                (vm_offset_t)pMemNetBSD->Core.pv + pMemNetBSD->Core.cb);
++            AssertMsg(rc == KERN_SUCCESS, ("%#x", rc));
++            break;
++
++        case RTR0MEMOBJTYPE_LOCK:
++        {
++            vm_map_t pMap = kernel_map;
++
++            if (pMemNetBSD->Core.u.Lock.R0Process != NIL_RTR0PROCESS)
++                pMap = &((struct proc *)pMemNetBSD->Core.u.Lock.R0Process)->p_vmspace->vm_map;
++
++            rc = vm_map_unwire(pMap,
++                               (vm_offset_t)pMemNetBSD->Core.pv,
++                               (vm_offset_t)pMemNetBSD->Core.pv + pMemNetBSD->Core.cb,
++                               VM_MAP_WIRE_SYSTEM | VM_MAP_WIRE_NOHOLES);
++            AssertMsg(rc == KERN_SUCCESS, ("%#x", rc));
++            break;
++        }
++
++        case RTR0MEMOBJTYPE_RES_VIRT:
++        {
++            vm_map_t pMap = kernel_map;
++            if (pMemNetBSD->Core.u.ResVirt.R0Process != NIL_RTR0PROCESS)
++                pMap = &((struct proc *)pMemNetBSD->Core.u.ResVirt.R0Process)->p_vmspace->vm_map;
++            rc = vm_map_remove(pMap,
++                               (vm_offset_t)pMemNetBSD->Core.pv,
++                               (vm_offset_t)pMemNetBSD->Core.pv + pMemNetBSD->Core.cb);
++            AssertMsg(rc == KERN_SUCCESS, ("%#x", rc));
++            break;
++        }
++
++        case RTR0MEMOBJTYPE_MAPPING:
++        {
++            vm_map_t pMap = kernel_map;
++
++            if (pMemNetBSD->Core.u.Mapping.R0Process != NIL_RTR0PROCESS)
++                pMap = &((struct proc *)pMemNetBSD->Core.u.Mapping.R0Process)->p_vmspace->vm_map;
++            rc = vm_map_remove(pMap,
++                               (vm_offset_t)pMemNetBSD->Core.pv,
++                               (vm_offset_t)pMemNetBSD->Core.pv + pMemNetBSD->Core.cb);
++            AssertMsg(rc == KERN_SUCCESS, ("%#x", rc));
++            break;
++        }
++
++        case RTR0MEMOBJTYPE_PHYS:
++        case RTR0MEMOBJTYPE_PHYS_NC:
++        {
++            VM_OBJECT_WLOCK(pMemNetBSD->pObject);
++            vm_page_t pPage = vm_page_find_least(pMemNetBSD->pObject, 0);
++            vm_page_lock_queues();
++
++            for (vm_page_t pPage = vm_page_find_least(pMemNetBSD->pObject, 0);
++                 pPage != NULL;
++                 pPage = vm_page_next(pPage))
++            {
++                vm_page_unwire(pPage, 0);
++            }
++            VM_OBJECT_WUNLOCK(pMemNetBSD->pObject);
++            vm_object_deallocate(pMemNetBSD->pObject);
++            break;
++        }
++
++        default:
++            AssertMsgFailed(("enmType=%d\n", pMemNetBSD->Core.enmType));
++            return VERR_INTERNAL_ERROR;
++    }
++
++    return VINF_SUCCESS;
++}
++
++
++static vm_page_t rtR0MemObjNetBSDContigPhysAllocHelper(vm_object_t pObject, vm_pindex_t iPIndex,
++                                                        u_long cPages, vm_paddr_t VmPhysAddrHigh,
++                                                        u_long uAlignment, bool fWire)
++{
++    vm_page_t pPages;
++    int cTries = 0;
++
++    int fFlags = VM_ALLOC_INTERRUPT | VM_ALLOC_NOBUSY;
++    if (fWire)
++        fFlags |= VM_ALLOC_WIRED;
++
++    while (cTries <= 1)
++    {
++        VM_OBJECT_WLOCK(pObject);
++        pPages = vm_page_alloc_contig(pObject, iPIndex, fFlags, cPages, 0,
++                                      VmPhysAddrHigh, uAlignment, 0, VM_MEMATTR_DEFAULT);
++        VM_OBJECT_WUNLOCK(pObject);
++        if (pPages)
++            break;
++        vm_pageout_grow_cache(cTries, 0, VmPhysAddrHigh);
++        cTries++;
++    }
++
++    return pPages;
++}
++
++static int rtR0MemObjNetBSDPhysAllocHelper(vm_object_t pObject, u_long cPages,
++                                            vm_paddr_t VmPhysAddrHigh, u_long uAlignment,
++                                            bool fContiguous, bool fWire, int rcNoMem)
++{
++    if (fContiguous)
++    {
++        if (rtR0MemObjNetBSDContigPhysAllocHelper(pObject, 0, cPages, VmPhysAddrHigh,
++                                                   uAlignment, fWire) != NULL)
++            return VINF_SUCCESS;
++        return rcNoMem;
++    }
++
++    for (vm_pindex_t iPage = 0; iPage < cPages; iPage++)
++    {
++        vm_page_t pPage = rtR0MemObjNetBSDContigPhysAllocHelper(pObject, iPage, 1, VmPhysAddrHigh,
++                                                                 uAlignment, fWire);
++        if (!pPage)
++        {
++            /* Free all allocated pages */
++            VM_OBJECT_WLOCK(pObject);
++            while (iPage-- > 0)
++            {
++                pPage = vm_page_lookup(pObject, iPage);
++                if (fWire)
++                    vm_page_unwire(pPage, 0);
++                vm_page_free(pPage);
++            }
++            VM_OBJECT_WUNLOCK(pObject);
++            return rcNoMem;
++        }
++    }
++    return VINF_SUCCESS;
++}
++
++static int rtR0MemObjNetBSDAllocHelper(PRTR0MEMOBJNETBSD pMemNetBSD, bool fExecutable,
++                                        vm_paddr_t VmPhysAddrHigh, bool fContiguous, int rcNoMem)
++{
++    vm_offset_t MapAddress = vm_map_min(kernel_map);
++    size_t      cPages = atop(pMemNetBSD->Core.cb);
++    int         rc;
++
++    pMemNetBSD->pObject = vm_object_allocate(OBJT_PHYS, cPages);
++
++    /* No additional object reference for auto-deallocation upon unmapping. */
++    rc = vm_map_find(kernel_map, pMemNetBSD->pObject, 0,
++                     &MapAddress, pMemNetBSD->Core.cb, 0, VMFS_ANY_SPACE,
++                     fExecutable ? VM_PROT_ALL : VM_PROT_RW, VM_PROT_ALL, 0);
++
++    if (rc == KERN_SUCCESS)
++    {
++        rc = rtR0MemObjNetBSDPhysAllocHelper(pMemNetBSD->pObject, cPages,
++                                              VmPhysAddrHigh, PAGE_SIZE, fContiguous,
++                                              false, rcNoMem);
++        if (RT_SUCCESS(rc))
++        {
++            vm_map_wire(kernel_map, MapAddress, MapAddress + pMemNetBSD->Core.cb,
++                        VM_MAP_WIRE_SYSTEM | VM_MAP_WIRE_NOHOLES);
++
++            /* Store start address */
++            pMemNetBSD->Core.pv = (void *)MapAddress;
++            return VINF_SUCCESS;
++        }
++
++        vm_map_remove(kernel_map, MapAddress, MapAddress + pMemNetBSD->Core.cb);
++    }
++    else
++    {
++        rc = rcNoMem; /** @todo fix translation (borrow from darwin) */
++        vm_object_deallocate(pMemNetBSD->pObject);
++    }
++
++    rtR0MemObjDelete(&pMemNetBSD->Core);
++    return rc;
++}
++DECLHIDDEN(int) rtR0MemObjNativeAllocPage(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, bool fExecutable)
++{
++    PRTR0MEMOBJNETBSD pMemNetBSD = (PRTR0MEMOBJNETBSD)rtR0MemObjNew(sizeof(*pMemNetBSD),
++                                                                       RTR0MEMOBJTYPE_PAGE, NULL, cb);
++    if (!pMemNetBSD)
++        return VERR_NO_MEMORY;
++
++    int rc = rtR0MemObjNetBSDAllocHelper(pMemNetBSD, fExecutable, ~(vm_paddr_t)0, false, VERR_NO_MEMORY);
++    if (RT_FAILURE(rc))
++    {
++        rtR0MemObjDelete(&pMemNetBSD->Core);
++        return rc;
++    }
++
++    *ppMem = &pMemNetBSD->Core;
++    return rc;
++}
++
++
++DECLHIDDEN(int) rtR0MemObjNativeAllocLow(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, bool fExecutable)
++{
++    PRTR0MEMOBJNETBSD pMemNetBSD = (PRTR0MEMOBJNETBSD)rtR0MemObjNew(sizeof(*pMemNetBSD),
++                                                                       RTR0MEMOBJTYPE_LOW, NULL, cb);
++    if (!pMemNetBSD)
++        return VERR_NO_MEMORY;
++
++    int rc = rtR0MemObjNetBSDAllocHelper(pMemNetBSD, fExecutable, _4G - 1, false, VERR_NO_LOW_MEMORY);
++    if (RT_FAILURE(rc))
++    {
++        rtR0MemObjDelete(&pMemNetBSD->Core);
++        return rc;
++    }
++
++    *ppMem = &pMemNetBSD->Core;
++    return rc;
++}
++
++
++DECLHIDDEN(int) rtR0MemObjNativeAllocCont(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, bool fExecutable)
++{
++    PRTR0MEMOBJNETBSD pMemNetBSD = (PRTR0MEMOBJNETBSD)rtR0MemObjNew(sizeof(*pMemNetBSD),
++                                                                       RTR0MEMOBJTYPE_CONT, NULL, cb);
++    if (!pMemNetBSD)
++        return VERR_NO_MEMORY;
++
++    int rc = rtR0MemObjNetBSDAllocHelper(pMemNetBSD, fExecutable, _4G - 1, true, VERR_NO_CONT_MEMORY);
++    if (RT_FAILURE(rc))
++    {
++        rtR0MemObjDelete(&pMemNetBSD->Core);
++        return rc;
++    }
++
++    pMemNetBSD->Core.u.Cont.Phys = vtophys(pMemNetBSD->Core.pv);
++    *ppMem = &pMemNetBSD->Core;
++    return rc;
++}
++
++
++static int rtR0MemObjNetBSDAllocPhysPages(PPRTR0MEMOBJINTERNAL ppMem, RTR0MEMOBJTYPE enmType,
++                                           size_t cb,
++                                           RTHCPHYS PhysHighest, size_t uAlignment,
++                                           bool fContiguous, int rcNoMem)
++{
++    uint32_t   cPages = atop(cb);
++    vm_paddr_t VmPhysAddrHigh;
++
++    /* create the object. */
++    PRTR0MEMOBJNETBSD pMemNetBSD = (PRTR0MEMOBJNETBSD)rtR0MemObjNew(sizeof(*pMemNetBSD),
++                                                                       enmType, NULL, cb);
++    if (!pMemNetBSD)
++        return VERR_NO_MEMORY;
++
++    pMemNetBSD->pObject = vm_object_allocate(OBJT_PHYS, atop(cb));
++
++    if (PhysHighest != NIL_RTHCPHYS)
++        VmPhysAddrHigh = PhysHighest;
++    else
++        VmPhysAddrHigh = ~(vm_paddr_t)0;
++
++    int rc = rtR0MemObjNetBSDPhysAllocHelper(pMemNetBSD->pObject, cPages, VmPhysAddrHigh,
++                                              uAlignment, fContiguous, true, rcNoMem);
++    if (RT_SUCCESS(rc))
++    {
++        if (fContiguous)
++        {
++            Assert(enmType == RTR0MEMOBJTYPE_PHYS);
++            VM_OBJECT_WLOCK(pMemNetBSD->pObject);
++            pMemNetBSD->Core.u.Phys.PhysBase = VM_PAGE_TO_PHYS(vm_page_find_least(pMemNetBSD->pObject, 0));
++            VM_OBJECT_WUNLOCK(pMemNetBSD->pObject);
++            pMemNetBSD->Core.u.Phys.fAllocated = true;
++        }
++
++        *ppMem = &pMemNetBSD->Core;
++    }
++    else
++    {
++        vm_object_deallocate(pMemNetBSD->pObject);
++        rtR0MemObjDelete(&pMemNetBSD->Core);
++    }
++
++    return rc;
++}
++
++
++DECLHIDDEN(int) rtR0MemObjNativeAllocPhys(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, RTHCPHYS PhysHighest, size_t uAlignment)
++{
++    return rtR0MemObjNetBSDAllocPhysPages(ppMem, RTR0MEMOBJTYPE_PHYS, cb, PhysHighest, uAlignment, true, VERR_NO_MEMORY);
++}
++
++
++DECLHIDDEN(int) rtR0MemObjNativeAllocPhysNC(PPRTR0MEMOBJINTERNAL ppMem, size_t cb, RTHCPHYS PhysHighest)
++{
++    return rtR0MemObjNetBSDAllocPhysPages(ppMem, RTR0MEMOBJTYPE_PHYS_NC, cb, PhysHighest, PAGE_SIZE, false, VERR_NO_PHYS_MEMORY);
++}
++
++
++DECLHIDDEN(int) rtR0MemObjNativeEnterPhys(PPRTR0MEMOBJINTERNAL ppMem, RTHCPHYS Phys, size_t cb, uint32_t uCachePolicy)
++{
++    AssertReturn(uCachePolicy == RTMEM_CACHE_POLICY_DONT_CARE, VERR_NOT_SUPPORTED);
++
++    /* create the object. */
++    PRTR0MEMOBJNETBSD pMemNetBSD = (PRTR0MEMOBJNETBSD)rtR0MemObjNew(sizeof(*pMemNetBSD), RTR0MEMOBJTYPE_PHYS, NULL, cb);
++    if (!pMemNetBSD)
++        return VERR_NO_MEMORY;
++
++    /* there is no allocation here, it needs to be mapped somewhere first. */
++    pMemNetBSD->Core.u.Phys.fAllocated = false;
++    pMemNetBSD->Core.u.Phys.PhysBase = Phys;
++    pMemNetBSD->Core.u.Phys.uCachePolicy = uCachePolicy;
++    *ppMem = &pMemNetBSD->Core;
++    return VINF_SUCCESS;
++}
++
++
++/**
++ * Worker locking the memory in either kernel or user maps.
++ */
++static int rtR0MemObjNativeLockInMap(PPRTR0MEMOBJINTERNAL ppMem, vm_map_t pVmMap,
++                                     vm_offset_t AddrStart, size_t cb, uint32_t fAccess,
++                                     RTR0PROCESS R0Process, int fFlags)
++{
++    int rc;
++    NOREF(fAccess);
++
++    /* create the object. */
++    PRTR0MEMOBJNETBSD pMemNetBSD = (PRTR0MEMOBJNETBSD)rtR0MemObjNew(sizeof(*pMemNetBSD), RTR0MEMOBJTYPE_LOCK, (void *)AddrStart, cb);
++    if (!pMemNetBSD)
++        return VERR_NO_MEMORY;
++
++    /*
++     * We could've used vslock here, but we don't wish to be subject to
++     * resource usage restrictions, so we'll call vm_map_wire directly.
++     */
++    rc = vm_map_wire(pVmMap,                                         /* the map */
++                     AddrStart,                                      /* start */
++                     AddrStart + cb,                                 /* end */
++                     fFlags);                                        /* flags */
++    if (rc == KERN_SUCCESS)
++    {
++        pMemNetBSD->Core.u.Lock.R0Process = R0Process;
++        *ppMem = &pMemNetBSD->Core;
++        return VINF_SUCCESS;
++    }
++    rtR0MemObjDelete(&pMemNetBSD->Core);
++    return VERR_NO_MEMORY;/** @todo fix mach -> vbox error conversion for freebsd. */
++}
++
++
++DECLHIDDEN(int) rtR0MemObjNativeLockUser(PPRTR0MEMOBJINTERNAL ppMem, RTR3PTR R3Ptr, size_t cb, uint32_t fAccess, RTR0PROCESS R0Process)
++{
++    return rtR0MemObjNativeLockInMap(ppMem,
++                                     &((struct proc *)R0Process)->p_vmspace->vm_map,
++                                     (vm_offset_t)R3Ptr,
++                                     cb,
++                                     fAccess,
++                                     R0Process,
++                                     VM_MAP_WIRE_USER | VM_MAP_WIRE_NOHOLES);
++}
++
++
++DECLHIDDEN(int) rtR0MemObjNativeLockKernel(PPRTR0MEMOBJINTERNAL ppMem, void *pv, size_t cb, uint32_t fAccess)
++{
++    return rtR0MemObjNativeLockInMap(ppMem,
++                                     kernel_map,
++                                     (vm_offset_t)pv,
++                                     cb,
++                                     fAccess,
++                                     NIL_RTR0PROCESS,
++                                     VM_MAP_WIRE_SYSTEM | VM_MAP_WIRE_NOHOLES);
++}
++
++
++/**
++ * Worker for the two virtual address space reservers.
++ *
++ * We're leaning on the examples provided by mmap and vm_mmap in vm_mmap.c here.
++ */
++static int rtR0MemObjNativeReserveInMap(PPRTR0MEMOBJINTERNAL ppMem, void *pvFixed, size_t cb, size_t uAlignment, RTR0PROCESS R0Process, vm_map_t pMap)
++{
++    int rc;
++
++    /*
++     * The pvFixed address range must be within the VM space when specified.
++     */
++    if (   pvFixed != (void *)-1
++        && (    (vm_offset_t)pvFixed      < vm_map_min(pMap)
++            ||  (vm_offset_t)pvFixed + cb > vm_map_max(pMap)))
++        return VERR_INVALID_PARAMETER;
++
++    /*
++     * Check that the specified alignment is supported.
++     */
++    if (uAlignment > PAGE_SIZE)
++        return VERR_NOT_SUPPORTED;
++
++    /*
++     * Create the object.
++     */
++    PRTR0MEMOBJNETBSD pMemNetBSD = (PRTR0MEMOBJNETBSD)rtR0MemObjNew(sizeof(*pMemNetBSD), RTR0MEMOBJTYPE_RES_VIRT, NULL, cb);
++    if (!pMemNetBSD)
++        return VERR_NO_MEMORY;
++
++    vm_offset_t MapAddress = pvFixed != (void *)-1
++                           ? (vm_offset_t)pvFixed
++                           : vm_map_min(pMap);
++    if (pvFixed != (void *)-1)
++        vm_map_remove(pMap,
++                      MapAddress,
++                      MapAddress + cb);
++
++    rc = vm_map_find(pMap,                          /* map */
++                     NULL,                          /* object */
++                     0,                             /* offset */
++                     &MapAddress,                   /* addr (IN/OUT) */
++                     cb,                            /* length */
++                     0,                             /* max addr */
++                     pvFixed == (void *)-1 ? VMFS_ANY_SPACE : VMFS_NO_SPACE,
++                                                    /* find_space */
++                     VM_PROT_NONE,                  /* protection */
++                     VM_PROT_ALL,                   /* max(_prot) ?? */
++                     0);                            /* cow (copy-on-write) */
++    if (rc == KERN_SUCCESS)
++    {
++        if (R0Process != NIL_RTR0PROCESS)
++        {
++            rc = vm_map_inherit(pMap,
++                                MapAddress,
++                                MapAddress + cb,
++                                VM_INHERIT_SHARE);
++            AssertMsg(rc == KERN_SUCCESS, ("%#x\n", rc));
++        }
++        pMemNetBSD->Core.pv = (void *)MapAddress;
++        pMemNetBSD->Core.u.ResVirt.R0Process = R0Process;
++        *ppMem = &pMemNetBSD->Core;
++        return VINF_SUCCESS;
++    }
++
++    rc = VERR_NO_MEMORY; /** @todo fix translation (borrow from darwin) */
++    rtR0MemObjDelete(&pMemNetBSD->Core);
++    return rc;
++
++}
++
++
++DECLHIDDEN(int) rtR0MemObjNativeReserveKernel(PPRTR0MEMOBJINTERNAL ppMem, void *pvFixed, size_t cb, size_t uAlignment)
++{
++    return rtR0MemObjNativeReserveInMap(ppMem, pvFixed, cb, uAlignment, NIL_RTR0PROCESS, kernel_map);
++}
++
++
++DECLHIDDEN(int) rtR0MemObjNativeReserveUser(PPRTR0MEMOBJINTERNAL ppMem, RTR3PTR R3PtrFixed, size_t cb, size_t uAlignment, RTR0PROCESS R0Process)
++{
++    return rtR0MemObjNativeReserveInMap(ppMem, (void *)R3PtrFixed, cb, uAlignment, R0Process,
++                                        &((struct proc *)R0Process)->p_vmspace->vm_map);
++}
++
++
++DECLHIDDEN(int) rtR0MemObjNativeMapKernel(PPRTR0MEMOBJINTERNAL ppMem, RTR0MEMOBJ pMemToMap, void *pvFixed, size_t uAlignment,
++                                          unsigned fProt, size_t offSub, size_t cbSub)
++{
++//  AssertMsgReturn(!offSub && !cbSub, ("%#x %#x\n", offSub, cbSub), VERR_NOT_SUPPORTED);
++    AssertMsgReturn(pvFixed == (void *)-1, ("%p\n", pvFixed), VERR_NOT_SUPPORTED);
++
++    /*
++     * Check that the specified alignment is supported.
++     */
++    if (uAlignment > PAGE_SIZE)
++        return VERR_NOT_SUPPORTED;
++
++    int                rc;
++    PRTR0MEMOBJNETBSD pMemToMapNetBSD = (PRTR0MEMOBJNETBSD)pMemToMap;
++
++    /* calc protection */
++    vm_prot_t       ProtectionFlags = 0;
++    if ((fProt & RTMEM_PROT_NONE) == RTMEM_PROT_NONE)
++        ProtectionFlags = VM_PROT_NONE;
++    if ((fProt & RTMEM_PROT_READ) == RTMEM_PROT_READ)
++        ProtectionFlags |= VM_PROT_READ;
++    if ((fProt & RTMEM_PROT_WRITE) == RTMEM_PROT_WRITE)
++        ProtectionFlags |= VM_PROT_WRITE;
++    if ((fProt & RTMEM_PROT_EXEC) == RTMEM_PROT_EXEC)
++        ProtectionFlags |= VM_PROT_EXECUTE;
++
++    vm_offset_t  Addr = vm_map_min(kernel_map);
++    if (cbSub == 0)
++        cbSub = pMemToMap->cb - offSub;
++
++    vm_object_reference(pMemToMapNetBSD->pObject);
++    rc = vm_map_find(kernel_map,            /* Map to insert the object in */
++                     pMemToMapNetBSD->pObject, /* Object to map */
++                     offSub,                /* Start offset in the object */
++                     &Addr,                 /* Start address IN/OUT */
++                     cbSub,                 /* Size of the mapping */
++                     0,                     /* Upper bound of mapping */
++                     VMFS_ANY_SPACE,        /* Whether a suitable address should be searched for first */
++                     ProtectionFlags,       /* protection flags */
++                     VM_PROT_ALL,           /* Maximum protection flags */
++                     0);                    /* copy-on-write and similar flags */
++
++    if (rc == KERN_SUCCESS)
++    {
++        rc = vm_map_wire(kernel_map, Addr, Addr + cbSub, VM_MAP_WIRE_SYSTEM|VM_MAP_WIRE_NOHOLES);
++        AssertMsg(rc == KERN_SUCCESS, ("%#x\n", rc));
++
++        PRTR0MEMOBJNETBSD pMemNetBSD = (PRTR0MEMOBJNETBSD)rtR0MemObjNew(sizeof(RTR0MEMOBJNETBSD),
++                                                                           RTR0MEMOBJTYPE_MAPPING,
++                                                                           (void *)Addr,
++                                                                           cbSub);
++        if (pMemNetBSD)
++        {
++            Assert((vm_offset_t)pMemNetBSD->Core.pv == Addr);
++            pMemNetBSD->Core.u.Mapping.R0Process = NIL_RTR0PROCESS;
++            *ppMem = &pMemNetBSD->Core;
++            return VINF_SUCCESS;
++        }
++        rc = vm_map_remove(kernel_map, Addr, Addr + cbSub);
++        AssertMsg(rc == KERN_SUCCESS, ("Deleting mapping failed\n"));
++    }
++    else
++        vm_object_deallocate(pMemToMapNetBSD->pObject);
++
++    return VERR_NO_MEMORY;
++}
++
++
++DECLHIDDEN(int) rtR0MemObjNativeMapUser(PPRTR0MEMOBJINTERNAL ppMem, RTR0MEMOBJ pMemToMap, RTR3PTR R3PtrFixed, size_t uAlignment,
++                                        unsigned fProt, RTR0PROCESS R0Process)
++{
++    /*
++     * Check for unsupported stuff.
++     */
++    AssertMsgReturn(R0Process == RTR0ProcHandleSelf(), ("%p != %p\n", R0Process, RTR0ProcHandleSelf()), VERR_NOT_SUPPORTED);
++    if (uAlignment > PAGE_SIZE)
++        return VERR_NOT_SUPPORTED;
++
++    int                rc;
++    PRTR0MEMOBJNETBSD pMemToMapNetBSD = (PRTR0MEMOBJNETBSD)pMemToMap;
++    struct proc       *pProc            = (struct proc *)R0Process;
++    struct vm_map     *pProcMap         = &pProc->p_vmspace->vm_map;
++
++    /* calc protection */
++    vm_prot_t       ProtectionFlags = 0;
++    if ((fProt & RTMEM_PROT_NONE) == RTMEM_PROT_NONE)
++        ProtectionFlags = VM_PROT_NONE;
++    if ((fProt & RTMEM_PROT_READ) == RTMEM_PROT_READ)
++        ProtectionFlags |= VM_PROT_READ;
++    if ((fProt & RTMEM_PROT_WRITE) == RTMEM_PROT_WRITE)
++        ProtectionFlags |= VM_PROT_WRITE;
++    if ((fProt & RTMEM_PROT_EXEC) == RTMEM_PROT_EXEC)
++        ProtectionFlags |= VM_PROT_EXECUTE;
++
++    /* calc mapping address */
++    vm_offset_t AddrR3;
++    if (R3PtrFixed == (RTR3PTR)-1)
++    {
++        /** @todo: is this needed?. */
++        PROC_LOCK(pProc);
++        AddrR3 = round_page((vm_offset_t)pProc->p_vmspace->vm_daddr + lim_max(pProc, RLIMIT_DATA));
++        PROC_UNLOCK(pProc);
++    }
++    else
++        AddrR3 = (vm_offset_t)R3PtrFixed;
++
++    /* Insert the pObject in the map. */
++    vm_object_reference(pMemToMapNetBSD->pObject);
++    rc = vm_map_find(pProcMap,              /* Map to insert the object in */
++                     pMemToMapNetBSD->pObject, /* Object to map */
++                     0,                     /* Start offset in the object */
++                     &AddrR3,               /* Start address IN/OUT */
++                     pMemToMap->cb,         /* Size of the mapping */
++                     0,                     /* Upper bound of the mapping */
++                     R3PtrFixed == (RTR3PTR)-1 ? VMFS_ANY_SPACE : VMFS_NO_SPACE,
++                                            /* Whether a suitable address should be searched for first */
++                     ProtectionFlags,       /* protection flags */
++                     VM_PROT_ALL,           /* Maximum protection flags */
++                     0);                    /* copy-on-write and similar flags */
++
++    if (rc == KERN_SUCCESS)
++    {
++        rc = vm_map_wire(pProcMap, AddrR3, AddrR3 + pMemToMap->cb, VM_MAP_WIRE_USER|VM_MAP_WIRE_NOHOLES);
++        AssertMsg(rc == KERN_SUCCESS, ("%#x\n", rc));
++
++        rc = vm_map_inherit(pProcMap, AddrR3, AddrR3 + pMemToMap->cb, VM_INHERIT_SHARE);
++        AssertMsg(rc == KERN_SUCCESS, ("%#x\n", rc));
++
++        /*
++         * Create a mapping object for it.
++         */
++        PRTR0MEMOBJNETBSD pMemNetBSD = (PRTR0MEMOBJNETBSD)rtR0MemObjNew(sizeof(RTR0MEMOBJNETBSD),
++                                                                           RTR0MEMOBJTYPE_MAPPING,
++                                                                           (void *)AddrR3,
++                                                                           pMemToMap->cb);
++        if (pMemNetBSD)
++        {
++            Assert((vm_offset_t)pMemNetBSD->Core.pv == AddrR3);
++            pMemNetBSD->Core.u.Mapping.R0Process = R0Process;
++            *ppMem = &pMemNetBSD->Core;
++            return VINF_SUCCESS;
++        }
++
++        rc = vm_map_remove(pProcMap, AddrR3, AddrR3 + pMemToMap->cb);
++        AssertMsg(rc == KERN_SUCCESS, ("Deleting mapping failed\n"));
++    }
++    else
++        vm_object_deallocate(pMemToMapNetBSD->pObject);
++
++    return VERR_NO_MEMORY;
++}
++
++
++DECLHIDDEN(int) rtR0MemObjNativeProtect(PRTR0MEMOBJINTERNAL pMem, size_t offSub, size_t cbSub, uint32_t fProt)
++{
++    vm_prot_t          ProtectionFlags = 0;
++    vm_offset_t        AddrStart       = (uintptr_t)pMem->pv + offSub;
++    vm_offset_t        AddrEnd         = AddrStart + cbSub;
++    vm_map_t           pVmMap          = rtR0MemObjNetBSDGetMap(pMem);
++
++    if (!pVmMap)
++        return VERR_NOT_SUPPORTED;
++
++    if ((fProt & RTMEM_PROT_NONE) == RTMEM_PROT_NONE)
++        ProtectionFlags = VM_PROT_NONE;
++    if ((fProt & RTMEM_PROT_READ) == RTMEM_PROT_READ)
++        ProtectionFlags |= VM_PROT_READ;
++    if ((fProt & RTMEM_PROT_WRITE) == RTMEM_PROT_WRITE)
++        ProtectionFlags |= VM_PROT_WRITE;
++    if ((fProt & RTMEM_PROT_EXEC) == RTMEM_PROT_EXEC)
++        ProtectionFlags |= VM_PROT_EXECUTE;
++
++    int krc = vm_map_protect(pVmMap, AddrStart, AddrEnd, ProtectionFlags, FALSE);
++    if (krc == KERN_SUCCESS)
++        return VINF_SUCCESS;
++
++    return VERR_NOT_SUPPORTED;
++}
++
++
++DECLHIDDEN(RTHCPHYS) rtR0MemObjNativeGetPagePhysAddr(PRTR0MEMOBJINTERNAL pMem, size_t iPage)
++{
++    PRTR0MEMOBJNETBSD pMemNetBSD = (PRTR0MEMOBJNETBSD)pMem;
++
++    switch (pMemNetBSD->Core.enmType)
++    {
++        case RTR0MEMOBJTYPE_LOCK:
++        {
++            if (    pMemNetBSD->Core.u.Lock.R0Process != NIL_RTR0PROCESS
++                &&  pMemNetBSD->Core.u.Lock.R0Process != (RTR0PROCESS)curproc)
++            {
++                /* later */
++                return NIL_RTHCPHYS;
++            }
++
++            vm_offset_t pb = (vm_offset_t)pMemNetBSD->Core.pv + ptoa(iPage);
++
++            struct proc    *pProc     = (struct proc *)pMemNetBSD->Core.u.Lock.R0Process;
++            struct vm_map  *pProcMap  = &pProc->p_vmspace->vm_map;
++            pmap_t pPhysicalMap       = vm_map_pmap(pProcMap);
++
++            return pmap_extract(pPhysicalMap, pb);
++        }
++
++        case RTR0MEMOBJTYPE_MAPPING:
++        {
++            vm_offset_t pb = (vm_offset_t)pMemNetBSD->Core.pv + ptoa(iPage);
++
++            if (pMemNetBSD->Core.u.Mapping.R0Process != NIL_RTR0PROCESS)
++            {
++                struct proc    *pProc     = (struct proc *)pMemNetBSD->Core.u.Mapping.R0Process;
++                struct vm_map  *pProcMap  = &pProc->p_vmspace->vm_map;
++                pmap_t pPhysicalMap       = vm_map_pmap(pProcMap);
++
++                return pmap_extract(pPhysicalMap, pb);
++            }
++            return vtophys(pb);
++        }
++
++        case RTR0MEMOBJTYPE_PAGE:
++        case RTR0MEMOBJTYPE_LOW:
++        case RTR0MEMOBJTYPE_PHYS_NC:
++        {
++            RTHCPHYS addr;
++            VM_OBJECT_WLOCK(pMemNetBSD->pObject);
++            addr = VM_PAGE_TO_PHYS(vm_page_lookup(pMemNetBSD->pObject, iPage));
++            VM_OBJECT_WUNLOCK(pMemNetBSD->pObject);
++            return addr;
++        }
++
++        case RTR0MEMOBJTYPE_PHYS:
++            return pMemNetBSD->Core.u.Cont.Phys + ptoa(iPage);
++
++        case RTR0MEMOBJTYPE_CONT:
++            return pMemNetBSD->Core.u.Phys.PhysBase + ptoa(iPage);
++
++        case RTR0MEMOBJTYPE_RES_VIRT:
++        default:
++            return NIL_RTHCPHYS;
++    }
++}
diff --git a/virtualbox-svn/patches/patch-src_VBox_Runtime_r0drv_netbsd_memuserkernel-r0drv-netbsd.c b/virtualbox-svn/patches/patch-src_VBox_Runtime_r0drv_netbsd_memuserkernel-r0drv-netbsd.c
new file mode 100644
index 0000000..eed294e
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Runtime_r0drv_netbsd_memuserkernel-r0drv-netbsd.c
@@ -0,0 +1,87 @@
+$NetBSD$
+
+--- src/VBox/Runtime/r0drv/netbsd/memuserkernel-r0drv-netbsd.c.orig	2016-07-07 07:08:46.910526349 +0000
++++ src/VBox/Runtime/r0drv/netbsd/memuserkernel-r0drv-netbsd.c
+@@ -0,0 +1,82 @@
++/*  memuserkernel-r0drv-netbsd.c $ */
++/** @file
++ * IPRT - User & Kernel Memory, Ring-0 Driver, NetBSD.
++ */
++
++/*
++ * Copyright (C) 2009-2015 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 "the-netbsd-kernel.h"
++
++#include <iprt/mem.h>
++#include <iprt/err.h>
++
++
++RTR0DECL(int) RTR0MemUserCopyFrom(void *pvDst, RTR3PTR R3PtrSrc, size_t cb)
++{
++    int rc = copyin((const void *)R3PtrSrc, pvDst, cb);
++    if (RT_LIKELY(rc == 0))
++        return VINF_SUCCESS;
++    return VERR_ACCESS_DENIED;
++}
++
++
++RTR0DECL(int) RTR0MemUserCopyTo(RTR3PTR R3PtrDst, void const *pvSrc, size_t cb)
++{
++    int rc = copyout(pvSrc, (void *)R3PtrDst, cb);
++    if (RT_LIKELY(rc == 0))
++        return VINF_SUCCESS;
++    return VERR_ACCESS_DENIED;
++}
++
++
++RTR0DECL(bool) RTR0MemUserIsValidAddr(RTR3PTR R3Ptr)
++{
++    return R3Ptr < VM_MAXUSER_ADDRESS;
++}
++
++
++RTR0DECL(bool) RTR0MemKernelIsValidAddr(void *pv)
++{
++    return (uintptr_t)pv >= VM_MAXUSER_ADDRESS;
++}
++
++
++RTR0DECL(bool) RTR0MemAreKrnlAndUsrDifferent(void)
++{
++    return true;
++}
++
++
++RTR0DECL(int) RTR0MemKernelCopyFrom(void *pvDst, void const *pvSrc, size_t cb)
++{
++    return VERR_NOT_SUPPORTED;
++}
++
++
++RTR0DECL(int) RTR0MemKernelCopyTo(void *pvDst, void const *pvSrc, size_t cb)
++{
++    return VERR_NOT_SUPPORTED;
++}
diff --git a/virtualbox-svn/patches/patch-src_VBox_Runtime_r0drv_netbsd_mp-r0drv-netbsd.c b/virtualbox-svn/patches/patch-src_VBox_Runtime_r0drv_netbsd_mp-r0drv-netbsd.c
new file mode 100644
index 0000000..0bd732f
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Runtime_r0drv_netbsd_mp-r0drv-netbsd.c
@@ -0,0 +1,273 @@
+$NetBSD$
+
+--- src/VBox/Runtime/r0drv/netbsd/mp-r0drv-netbsd.c.orig	2016-07-07 07:08:46.919669571 +0000
++++ src/VBox/Runtime/r0drv/netbsd/mp-r0drv-netbsd.c
+@@ -0,0 +1,268 @@
++/*  mp-r0drv-netbsd.c $ */
++/** @file
++ * IPRT - Multiprocessor, Ring-0 Driver, NetBSD.
++ */
++
++/*
++ * Copyright (C) 2008-2015 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 "the-netbsd-kernel.h"
++
++#include <iprt/mp.h>
++#include <iprt/err.h>
++#include <iprt/asm.h>
++#include <iprt/cpuset.h>
++#include "r0drv/mp-r0drv.h"
++
++
++RTDECL(RTCPUID) RTMpCpuId(void)
++{
++    return curcpu;
++}
++
++
++RTDECL(int) RTMpCurSetIndex(void)
++{
++    return curcpu;
++}
++
++
++RTDECL(int) RTMpCurSetIndexAndId(PRTCPUID pidCpu)
++{
++    return *pidCpu = curcpu;
++}
++
++
++RTDECL(int) RTMpCpuIdToSetIndex(RTCPUID idCpu)
++{
++    return idCpu < RTCPUSET_MAX_CPUS && idCpu <= mp_maxid ? (int)idCpu : -1;
++}
++
++
++RTDECL(RTCPUID) RTMpCpuIdFromSetIndex(int iCpu)
++{
++    return (unsigned)iCpu <= mp_maxid ? (RTCPUID)iCpu : NIL_RTCPUID;
++}
++
++
++RTDECL(RTCPUID) RTMpGetMaxCpuId(void)
++{
++    return mp_maxid;
++}
++
++
++RTDECL(bool) RTMpIsCpuPossible(RTCPUID idCpu)
++{
++    return idCpu <= mp_maxid;
++}
++
++
++RTDECL(PRTCPUSET) RTMpGetSet(PRTCPUSET pSet)
++{
++    RTCPUID idCpu;
++
++    RTCpuSetEmpty(pSet);
++    idCpu = RTMpGetMaxCpuId();
++    do
++    {
++        if (RTMpIsCpuPossible(idCpu))
++            RTCpuSetAdd(pSet, idCpu);
++    } while (idCpu-- > 0);
++    return pSet;
++}
++
++
++RTDECL(RTCPUID) RTMpGetCount(void)
++{
++    return mp_maxid + 1;
++}
++
++
++RTDECL(RTCPUID) RTMpGetCoreCount(void)
++{
++    return mp_maxid + 1;
++}
++
++RTDECL(bool) RTMpIsCpuOnline(RTCPUID idCpu)
++{
++    return idCpu <= mp_maxid
++        && !CPU_ABSENT(idCpu);
++}
++
++
++RTDECL(PRTCPUSET) RTMpGetOnlineSet(PRTCPUSET pSet)
++{
++    RTCPUID idCpu;
++
++    RTCpuSetEmpty(pSet);
++    idCpu = RTMpGetMaxCpuId();
++    do
++    {
++        if (RTMpIsCpuOnline(idCpu))
++            RTCpuSetAdd(pSet, idCpu);
++    } while (idCpu-- > 0);
++
++    return pSet;
++}
++
++
++RTDECL(RTCPUID) RTMpGetOnlineCount(void)
++{
++    return mp_ncpus;
++}
++
++
++/**
++ * Wrapper between the native NetBSD per-cpu callback and PFNRTWORKER
++ * for the RTMpOnAll API.
++ *
++ * @param   pvArg   Pointer to the RTMPARGS package.
++ */
++static void rtmpOnAllNetBSDWrapper(void *pvArg)
++{
++    PRTMPARGS pArgs = (PRTMPARGS)pvArg;
++    pArgs->pfnWorker(curcpu, pArgs->pvUser1, pArgs->pvUser2);
++}
++
++
++RTDECL(int) RTMpOnAll(PFNRTMPWORKER pfnWorker, void *pvUser1, void *pvUser2)
++{
++    RTMPARGS Args;
++    Args.pfnWorker = pfnWorker;
++    Args.pvUser1 = pvUser1;
++    Args.pvUser2 = pvUser2;
++    Args.idCpu = NIL_RTCPUID;
++    Args.cHits = 0;
++    smp_rendezvous(NULL, rtmpOnAllNetBSDWrapper, smp_no_rendevous_barrier, &Args);
++    return VINF_SUCCESS;
++}
++
++
++/**
++ * Wrapper between the native NetBSD per-cpu callback and PFNRTWORKER
++ * for the RTMpOnOthers API.
++ *
++ * @param   pvArg   Pointer to the RTMPARGS package.
++ */
++static void rtmpOnOthersNetBSDWrapper(void *pvArg)
++{
++    PRTMPARGS pArgs = (PRTMPARGS)pvArg;
++    RTCPUID idCpu = curcpu;
++    if (pArgs->idCpu != idCpu)
++        pArgs->pfnWorker(idCpu, pArgs->pvUser1, pArgs->pvUser2);
++}
++
++
++RTDECL(int) RTMpOnOthers(PFNRTMPWORKER pfnWorker, void *pvUser1, void *pvUser2)
++{
++    /* Will panic if no rendezvousing cpus, so check up front. */
++    if (RTMpGetOnlineCount() > 1)
++    {
++        cpuset_t    Mask;
++        RTMPARGS    Args;
++
++        Args.pfnWorker = pfnWorker;
++        Args.pvUser1 = pvUser1;
++        Args.pvUser2 = pvUser2;
++        Args.idCpu = RTMpCpuId();
++        Args.cHits = 0;
++    Mask = all_cpus;
++    CPU_CLR(curcpu, &Mask);
++        smp_rendezvous_cpus(Mask, NULL, rtmpOnOthersNetBSDWrapper, smp_no_rendevous_barrier, &Args);
++    }
++    return VINF_SUCCESS;
++}
++
++
++/**
++ * Wrapper between the native NetBSD per-cpu callback and PFNRTWORKER
++ * for the RTMpOnSpecific API.
++ *
++ * @param   pvArg   Pointer to the RTMPARGS package.
++ */
++static void rtmpOnSpecificNetBSDWrapper(void *pvArg)
++{
++    PRTMPARGS   pArgs = (PRTMPARGS)pvArg;
++    RTCPUID     idCpu = curcpu;
++    if (pArgs->idCpu == idCpu)
++    {
++        pArgs->pfnWorker(idCpu, pArgs->pvUser1, pArgs->pvUser2);
++        ASMAtomicIncU32(&pArgs->cHits);
++    }
++}
++
++
++RTDECL(int) RTMpOnSpecific(RTCPUID idCpu, PFNRTMPWORKER pfnWorker, void *pvUser1, void *pvUser2)
++{
++    cpuset_t    Mask;
++    RTMPARGS    Args;
++
++    /* Will panic if no rendezvousing cpus, so make sure the cpu is online. */
++    if (!RTMpIsCpuOnline(idCpu))
++        return VERR_CPU_NOT_FOUND;
++
++    Args.pfnWorker = pfnWorker;
++    Args.pvUser1 = pvUser1;
++    Args.pvUser2 = pvUser2;
++    Args.idCpu = idCpu;
++    Args.cHits = 0;
++
++    CPU_SETOF(idCpu, &Mask);
++    smp_rendezvous_cpus(Mask, NULL, rtmpOnSpecificNetBSDWrapper, smp_no_rendevous_barrier, &Args);
++
++    return Args.cHits == 1
++         ? VINF_SUCCESS
++         : VERR_CPU_NOT_FOUND;
++}
++
++
++/**
++ * Dummy callback for RTMpPokeCpu.
++ * @param   pvArg   Ignored
++ */
++static void rtmpNetBSDPokeCallback(void *pvArg)
++{
++    NOREF(pvArg);
++}
++
++
++RTDECL(int) RTMpPokeCpu(RTCPUID idCpu)
++{
++    cpuset_t    Mask;
++
++    /* Will panic if no rendezvousing cpus, so make sure the cpu is online. */
++    if (!RTMpIsCpuOnline(idCpu))
++        return VERR_CPU_NOT_FOUND;
++
++    CPU_SETOF(idCpu, &Mask);
++    smp_rendezvous_cpus(Mask, NULL, rtmpNetBSDPokeCallback, smp_no_rendevous_barrier, NULL);
++
++    return VINF_SUCCESS;
++}
++
++RTDECL(bool) RTMpOnAllIsConcurrentSafe(void)
++{
++    return true;
++}
diff --git a/virtualbox-svn/patches/patch-src_VBox_Runtime_r0drv_netbsd_process-r0drv-netbsd.c b/virtualbox-svn/patches/patch-src_VBox_Runtime_r0drv_netbsd_process-r0drv-netbsd.c
new file mode 100644
index 0000000..3101597
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Runtime_r0drv_netbsd_process-r0drv-netbsd.c
@@ -0,0 +1,55 @@
+$NetBSD$
+
+--- src/VBox/Runtime/r0drv/netbsd/process-r0drv-netbsd.c.orig	2016-07-07 07:08:46.928969370 +0000
++++ src/VBox/Runtime/r0drv/netbsd/process-r0drv-netbsd.c
+@@ -0,0 +1,50 @@
++/*  process-r0drv-netbsd.c $ */
++/** @file
++ * IPRT - Process Management, Ring-0 Driver, NetBSD.
++ */
++
++/*
++ * Copyright (c) 2007 knut st. osmundsen <bird-src-spam%anduin.net@localhost>
++ *
++ * Permission is hereby granted, free of charge, to any person
++ * obtaining a copy of this software and associated documentation
++ * files (the "Software"), to deal in the Software without
++ * restriction, including without limitation the rights to use,
++ * copy, modify, merge, publish, distribute, sublicense, and/or sell
++ * copies of the Software, and to permit persons to whom the
++ * Software is furnished to do so, subject to the following
++ * conditions:
++ *
++ * The above copyright notice and this permission notice shall be
++ * included in all copies or substantial portions of the Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
++ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
++ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
++ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
++ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
++ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
++ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
++ * OTHER DEALINGS IN THE SOFTWARE.
++ */
++
++
++/*********************************************************************************************************************************
++*   Header Files                                                                                                                 *
++*********************************************************************************************************************************/
++#include "the-netbsd-kernel.h"
++
++#include <iprt/process.h>
++
++
++RTDECL(RTPROCESS) RTProcSelf(void)
++{
++    struct proc *pSelf = curproc;
++    return pSelf->p_pid;
++}
++
++
++RTR0DECL(RTR0PROCESS) RTR0ProcHandleSelf(void)
++{
++    return (RTR0PROCESS)curproc;
++}
diff --git a/virtualbox-svn/patches/patch-src_VBox_Runtime_r0drv_netbsd_semevent-r0drv-netbsd.c b/virtualbox-svn/patches/patch-src_VBox_Runtime_r0drv_netbsd_semevent-r0drv-netbsd.c
new file mode 100644
index 0000000..bef1feb
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Runtime_r0drv_netbsd_semevent-r0drv-netbsd.c
@@ -0,0 +1,260 @@
+$NetBSD$
+
+--- src/VBox/Runtime/r0drv/netbsd/semevent-r0drv-netbsd.c.orig	2016-07-07 07:08:46.938368327 +0000
++++ src/VBox/Runtime/r0drv/netbsd/semevent-r0drv-netbsd.c
+@@ -0,0 +1,255 @@
++/*  semevent-r0drv-netbsd.c $ */
++/** @file
++ * IPRT - Single Release Event Semaphores, Ring-0 Driver, NetBSD.
++ */
++
++/*
++ * Copyright (c) 2007 knut st. osmundsen <bird-src-spam%anduin.net@localhost>
++ *
++ * Permission is hereby granted, free of charge, to any person
++ * obtaining a copy of this software and associated documentation
++ * files (the "Software"), to deal in the Software without
++ * restriction, including without limitation the rights to use,
++ * copy, modify, merge, publish, distribute, sublicense, and/or sell
++ * copies of the Software, and to permit persons to whom the
++ * Software is furnished to do so, subject to the following
++ * conditions:
++ *
++ * The above copyright notice and this permission notice shall be
++ * included in all copies or substantial portions of the Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
++ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
++ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
++ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
++ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
++ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
++ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
++ * OTHER DEALINGS IN THE SOFTWARE.
++ */
++
++
++/*********************************************************************************************************************************
++*   Header Files                                                                                                                 *
++*********************************************************************************************************************************/
++#define RTSEMEVENT_WITHOUT_REMAPPING
++#include "the-netbsd-kernel.h"
++#include "internal/iprt.h"
++#include <iprt/semaphore.h>
++
++#include <iprt/asm.h>
++#include <iprt/assert.h>
++#include <iprt/err.h>
++#include <iprt/lockvalidator.h>
++#include <iprt/mem.h>
++
++#include "sleepqueue-r0drv-netbsd.h"
++#include "internal/magics.h"
++
++
++/*********************************************************************************************************************************
++*   Structures and Typedefs                                                                                                      *
++*********************************************************************************************************************************/
++/**
++ * NetBSD event semaphore.
++ */
++typedef struct RTSEMEVENTINTERNAL
++{
++    /** Magic value (RTSEMEVENT_MAGIC). */
++    uint32_t volatile   u32Magic;
++    /** The object status - !0 when signaled and 0 when reset. */
++    uint32_t volatile   fState;
++    /** Reference counter. */
++    uint32_t volatile   cRefs;
++} RTSEMEVENTINTERNAL, *PRTSEMEVENTINTERNAL;
++
++
++RTDECL(int)  RTSemEventCreate(PRTSEMEVENT phEventSem)
++{
++    return RTSemEventCreateEx(phEventSem, 0 /*fFlags*/, NIL_RTLOCKVALCLASS, NULL);
++}
++
++
++RTDECL(int)  RTSemEventCreateEx(PRTSEMEVENT phEventSem, uint32_t fFlags, RTLOCKVALCLASS hClass, const char *pszNameFmt, ...)
++{
++    AssertCompile(sizeof(RTSEMEVENTINTERNAL) > sizeof(void *));
++    AssertReturn(!(fFlags & ~(RTSEMEVENT_FLAGS_NO_LOCK_VAL | RTSEMEVENT_FLAGS_BOOTSTRAP_HACK)), VERR_INVALID_PARAMETER);
++    Assert(!(fFlags & RTSEMEVENT_FLAGS_BOOTSTRAP_HACK) || (fFlags & RTSEMEVENT_FLAGS_NO_LOCK_VAL));
++    AssertPtrReturn(phEventSem, VERR_INVALID_POINTER);
++
++    PRTSEMEVENTINTERNAL pThis = (PRTSEMEVENTINTERNAL)RTMemAllocZ(sizeof(*pThis));
++    if (!pThis)
++        return VERR_NO_MEMORY;
++
++    pThis->u32Magic  = RTSEMEVENT_MAGIC;
++    pThis->cRefs     = 1;
++    pThis->fState    = 0;
++
++    *phEventSem = pThis;
++    return VINF_SUCCESS;
++}
++
++
++/**
++ * Retains a reference to the event semaphore.
++ *
++ * @param   pThis       The event semaphore.
++ */
++DECLINLINE(void) rtR0SemEventBsdRetain(PRTSEMEVENTINTERNAL pThis)
++{
++    uint32_t cRefs = ASMAtomicIncU32(&pThis->cRefs);
++    Assert(cRefs < 100000); NOREF(cRefs);
++}
++
++
++/**
++ * Releases a reference to the event semaphore.
++ *
++ * @param   pThis       The event semaphore.
++ */
++DECLINLINE(void) rtR0SemEventBsdRelease(PRTSEMEVENTINTERNAL pThis)
++{
++    if (RT_UNLIKELY(ASMAtomicDecU32(&pThis->cRefs) == 0))
++        RTMemFree(pThis);
++}
++
++
++RTDECL(int)  RTSemEventDestroy(RTSEMEVENT hEventSem)
++{
++    /*
++     * Validate input.
++     */
++    PRTSEMEVENTINTERNAL pThis = hEventSem;
++    if (pThis == NIL_RTSEMEVENT)
++        return VINF_SUCCESS;
++    AssertMsgReturn(pThis->u32Magic == RTSEMEVENT_MAGIC, ("pThis->u32Magic=%RX32 pThis=%p\n", pThis->u32Magic, pThis), VERR_INVALID_HANDLE);
++    Assert(pThis->cRefs > 0);
++
++    /*
++     * Invalidate it and signal the object just in case.
++     */
++    ASMAtomicWriteU32(&pThis->u32Magic, ~RTSEMEVENT_MAGIC);
++    ASMAtomicWriteU32(&pThis->fState, 0);
++    rtR0SemBsdBroadcast(pThis);
++    rtR0SemEventBsdRelease(pThis);
++    return VINF_SUCCESS;
++}
++
++
++RTDECL(int)  RTSemEventSignal(RTSEMEVENT hEventSem)
++{
++    /*
++     * Validate input.
++     */
++    PRTSEMEVENTINTERNAL pThis = (PRTSEMEVENTINTERNAL)hEventSem;
++    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
++    AssertMsgReturn(pThis->u32Magic == RTSEMEVENT_MAGIC, ("pThis->u32Magic=%RX32 pThis=%p\n", pThis->u32Magic, pThis), VERR_INVALID_HANDLE);
++    rtR0SemEventBsdRetain(pThis);
++
++    /*
++     * Signal the event object.
++     */
++    ASMAtomicWriteU32(&pThis->fState, 1);
++    rtR0SemBsdSignal(pThis);
++    rtR0SemEventBsdRelease(pThis);
++    return VINF_SUCCESS;
++}
++
++/**
++ * Worker for RTSemEventWaitEx and RTSemEventWaitExDebug.
++ *
++ * @returns VBox status code.
++ * @param   pThis           The event semaphore.
++ * @param   fFlags          See RTSemEventWaitEx.
++ * @param   uTimeout        See RTSemEventWaitEx.
++ * @param   pSrcPos         The source code position of the wait.
++ */
++static int rtR0SemEventWait(PRTSEMEVENTINTERNAL pThis, uint32_t fFlags, uint64_t uTimeout,
++                            PCRTLOCKVALSRCPOS pSrcPos)
++{
++    int rc;
++
++    /*
++     * Validate the input.
++     */
++    AssertPtrReturn(pThis, VERR_INVALID_PARAMETER);
++    AssertMsgReturn(pThis->u32Magic == RTSEMEVENT_MAGIC, ("%p u32Magic=%RX32\n", pThis, pThis->u32Magic), VERR_INVALID_PARAMETER);
++    AssertReturn(RTSEMWAIT_FLAGS_ARE_VALID(fFlags), VERR_INVALID_PARAMETER);
++    rtR0SemEventBsdRetain(pThis);
++
++    /*
++     * Try grab the event without setting up the wait.
++     */
++    if (ASMAtomicCmpXchgU32(&pThis->fState, 0, 1))
++        rc = VINF_SUCCESS;
++    else
++    {
++        /*
++         * We have to wait.
++         */
++        RTR0SEMBSDSLEEP Wait;
++        rc = rtR0SemBsdWaitInit(&Wait, fFlags, uTimeout, pThis);
++        if (RT_SUCCESS(rc))
++        {
++            for (;;)
++            {
++                /* The destruction test. */
++                if (RT_UNLIKELY(pThis->u32Magic != RTSEMEVENT_MAGIC))
++                    rc = VERR_SEM_DESTROYED;
++                else
++                {
++                    rtR0SemBsdWaitPrepare(&Wait);
++
++                    /* Check the exit conditions. */
++                    if (RT_UNLIKELY(pThis->u32Magic != RTSEMEVENT_MAGIC))
++                        rc = VERR_SEM_DESTROYED;
++                    else if (ASMAtomicCmpXchgU32(&pThis->fState, 0, 1))
++                        rc = VINF_SUCCESS;
++                    else if (rtR0SemBsdWaitHasTimedOut(&Wait))
++                        rc = VERR_TIMEOUT;
++                    else if (rtR0SemBsdWaitWasInterrupted(&Wait))
++                        rc = VERR_INTERRUPTED;
++                    else
++                    {
++                        /* Do the wait and then recheck the conditions. */
++                        rtR0SemBsdWaitDoIt(&Wait);
++                        continue;
++                    }
++                }
++                break;
++            }
++
++            rtR0SemBsdWaitDelete(&Wait);
++        }
++    }
++
++    rtR0SemEventBsdRelease(pThis);
++    return rc;
++}
++
++
++RTDECL(int)  RTSemEventWaitEx(RTSEMEVENT hEventSem, uint32_t fFlags, uint64_t uTimeout)
++{
++#ifndef RTSEMEVENT_STRICT
++    return rtR0SemEventWait(hEventSem, fFlags, uTimeout, NULL);
++#else
++    RTLOCKVALSRCPOS SrcPos = RTLOCKVALSRCPOS_INIT_NORMAL_API();
++    return rtR0SemEventWait(hEventSem, fFlags, uTimeout, &SrcPos);
++#endif
++}
++RT_EXPORT_SYMBOL(RTSemEventWaitEx);
++
++
++RTDECL(int)  RTSemEventWaitExDebug(RTSEMEVENT hEventSem, uint32_t fFlags, uint64_t uTimeout,
++                                   RTHCUINTPTR uId, RT_SRC_POS_DECL)
++{
++    RTLOCKVALSRCPOS SrcPos = RTLOCKVALSRCPOS_INIT_DEBUG_API();
++    return rtR0SemEventWait(hEventSem, fFlags, uTimeout, &SrcPos);
++}
++RT_EXPORT_SYMBOL(RTSemEventWaitExDebug);
++
++
++RTDECL(uint32_t) RTSemEventGetResolution(void)
++{
++    return 1000000000 / hz;
++}
diff --git a/virtualbox-svn/patches/patch-src_VBox_Runtime_r0drv_netbsd_semeventmulti-r0drv-netbsd.c b/virtualbox-svn/patches/patch-src_VBox_Runtime_r0drv_netbsd_semeventmulti-r0drv-netbsd.c
new file mode 100644
index 0000000..3b19381
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Runtime_r0drv_netbsd_semeventmulti-r0drv-netbsd.c
@@ -0,0 +1,324 @@
+$NetBSD$
+
+--- src/VBox/Runtime/r0drv/netbsd/semeventmulti-r0drv-netbsd.c.orig	2016-07-07 07:08:46.948049864 +0000
++++ src/VBox/Runtime/r0drv/netbsd/semeventmulti-r0drv-netbsd.c
+@@ -0,0 +1,319 @@
++/*  semeventmulti-r0drv-netbsd.c $ */
++/** @file
++ * IPRT - Multiple Release Event Semaphores, Ring-0 Driver, NetBSD.
++ */
++
++/*
++ * Copyright (c) 2007 knut st. osmundsen <bird-src-spam%anduin.net@localhost>
++ *
++ * Permission is hereby granted, free of charge, to any person
++ * obtaining a copy of this software and associated documentation
++ * files (the "Software"), to deal in the Software without
++ * restriction, including without limitation the rights to use,
++ * copy, modify, merge, publish, distribute, sublicense, and/or sell
++ * copies of the Software, and to permit persons to whom the
++ * Software is furnished to do so, subject to the following
++ * conditions:
++ *
++ * The above copyright notice and this permission notice shall be
++ * included in all copies or substantial portions of the Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
++ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
++ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
++ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
++ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
++ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
++ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
++ * OTHER DEALINGS IN THE SOFTWARE.
++ */
++
++
++/*********************************************************************************************************************************
++*   Header Files                                                                                                                 *
++*********************************************************************************************************************************/
++#define RTSEMEVENTMULTI_WITHOUT_REMAPPING
++#include "the-netbsd-kernel.h"
++#include "internal/iprt.h"
++#include <iprt/semaphore.h>
++
++#include <iprt/assert.h>
++#include <iprt/asm.h>
++#include <iprt/err.h>
++#include <iprt/mem.h>
++#include <iprt/lockvalidator.h>
++
++#include "sleepqueue-r0drv-netbsd.h"
++#include "internal/magics.h"
++
++
++/*********************************************************************************************************************************
++*   Defined Constants And Macros                                                                                                 *
++*********************************************************************************************************************************/
++/** @name fStateAndGen values
++ * @{ */
++/** The state bit number. */
++#define RTSEMEVENTMULTIBSD_STATE_BIT        0
++/** The state mask. */
++#define RTSEMEVENTMULTIBSD_STATE_MASK       RT_BIT_32(RTSEMEVENTMULTIBSD_STATE_BIT)
++/** The generation mask. */
++#define RTSEMEVENTMULTIBSD_GEN_MASK         ~RTSEMEVENTMULTIBSD_STATE_MASK
++/** The generation shift. */
++#define RTSEMEVENTMULTIBSD_GEN_SHIFT        1
++/** The initial variable value. */
++#define RTSEMEVENTMULTIBSD_STATE_GEN_INIT   UINT32_C(0xfffffffc)
++/** @}  */
++
++
++/*********************************************************************************************************************************
++*   Structures and Typedefs                                                                                                      *
++*********************************************************************************************************************************/
++/**
++ * NetBSD multiple release event semaphore.
++ */
++typedef struct RTSEMEVENTMULTIINTERNAL
++{
++    /** Magic value (RTSEMEVENTMULTI_MAGIC). */
++    uint32_t volatile   u32Magic;
++    /** The object state bit and generation counter.
++     * The generation counter is incremented every time the object is
++     * signalled. */
++    uint32_t volatile   fStateAndGen;
++    /** Reference counter. */
++    uint32_t volatile   cRefs;
++} RTSEMEVENTMULTIINTERNAL, *PRTSEMEVENTMULTIINTERNAL;
++
++
++RTDECL(int)  RTSemEventMultiCreate(PRTSEMEVENTMULTI phEventMultiSem)
++{
++    return RTSemEventMultiCreateEx(phEventMultiSem, 0 /*fFlags*/, NIL_RTLOCKVALCLASS, NULL);
++}
++
++
++RTDECL(int)  RTSemEventMultiCreateEx(PRTSEMEVENTMULTI phEventMultiSem, uint32_t fFlags, RTLOCKVALCLASS hClass,
++                                     const char *pszNameFmt, ...)
++{
++    PRTSEMEVENTMULTIINTERNAL pThis;
++
++    AssertReturn(!(fFlags & ~RTSEMEVENTMULTI_FLAGS_NO_LOCK_VAL), VERR_INVALID_PARAMETER);
++    pThis = (PRTSEMEVENTMULTIINTERNAL)RTMemAlloc(sizeof(*pThis));
++    if (pThis)
++    {
++        pThis->u32Magic     = RTSEMEVENTMULTI_MAGIC;
++        pThis->fStateAndGen = RTSEMEVENTMULTIBSD_STATE_GEN_INIT;
++        pThis->cRefs        = 1;
++
++        *phEventMultiSem = pThis;
++        return VINF_SUCCESS;
++    }
++    return VERR_NO_MEMORY;
++}
++
++
++/**
++ * Retain a reference to the semaphore.
++ *
++ * @param   pThis       The semaphore.
++ */
++DECLINLINE(void) rtR0SemEventMultiBsdRetain(PRTSEMEVENTMULTIINTERNAL pThis)
++{
++    uint32_t cRefs = ASMAtomicIncU32(&pThis->cRefs);
++    Assert(cRefs && cRefs < 100000);
++}
++
++
++/**
++ * Release a reference, destroy the thing if necessary.
++ *
++ * @param   pThis       The semaphore.
++ */
++DECLINLINE(void) rtR0SemEventMultiBsdRelease(PRTSEMEVENTMULTIINTERNAL pThis)
++{
++    if (RT_UNLIKELY(ASMAtomicDecU32(&pThis->cRefs) == 0))
++    {
++        Assert(pThis->u32Magic != RTSEMEVENTMULTI_MAGIC);
++        RTMemFree(pThis);
++    }
++}
++
++
++RTDECL(int)  RTSemEventMultiDestroy(RTSEMEVENTMULTI hEventMultiSem)
++{
++    /*
++     * Validate input.
++     */
++    PRTSEMEVENTMULTIINTERNAL pThis = (PRTSEMEVENTMULTIINTERNAL)hEventMultiSem;
++    if (pThis == NIL_RTSEMEVENTMULTI)
++        return VINF_SUCCESS;
++    AssertPtrReturn(pThis, VERR_INVALID_PARAMETER);
++    AssertMsgReturn(pThis->u32Magic == RTSEMEVENTMULTI_MAGIC, ("%p u32Magic=%RX32\n", pThis, pThis->u32Magic), VERR_INVALID_PARAMETER);
++    Assert(pThis->cRefs > 0);
++
++    /*
++     * Invalidate it and signal the object just in case.
++     */
++    ASMAtomicWriteU32(&pThis->u32Magic, ~RTSEMEVENTMULTI_MAGIC);
++    ASMAtomicAndU32(&pThis->fStateAndGen, RTSEMEVENTMULTIBSD_GEN_MASK);
++    rtR0SemBsdBroadcast(pThis);
++    rtR0SemEventMultiBsdRelease(pThis);
++    return VINF_SUCCESS;
++}
++
++
++RTDECL(int)  RTSemEventMultiSignal(RTSEMEVENTMULTI hEventMultiSem)
++{
++    uint32_t fNew;
++    uint32_t fOld;
++
++    /*
++     * Validate input.
++     */
++    PRTSEMEVENTMULTIINTERNAL pThis = (PRTSEMEVENTMULTIINTERNAL)hEventMultiSem;
++    if (!pThis)
++        return VERR_INVALID_PARAMETER;
++    AssertPtrReturn(pThis, VERR_INVALID_PARAMETER);
++    AssertMsgReturn(pThis->u32Magic == RTSEMEVENTMULTI_MAGIC, ("%p u32Magic=%RX32\n", pThis, pThis->u32Magic), VERR_INVALID_PARAMETER);
++    rtR0SemEventMultiBsdRetain(pThis);
++
++    /*
++     * Signal the event object.  The cause of the parnoia here is racing to try
++     * deal with racing RTSemEventMultiSignal calls (should probably be
++     * forbidden, but it's relatively easy to handle).
++     */
++    do
++    {
++        fNew = fOld = ASMAtomicUoReadU32(&pThis->fStateAndGen);
++        fNew += 1 << RTSEMEVENTMULTIBSD_GEN_SHIFT;
++        fNew |= RTSEMEVENTMULTIBSD_STATE_MASK;
++    }
++    while (!ASMAtomicCmpXchgU32(&pThis->fStateAndGen, fNew, fOld));
++
++    rtR0SemBsdBroadcast(pThis);
++    rtR0SemEventMultiBsdRelease(pThis);
++    return VINF_SUCCESS;
++}
++
++
++RTDECL(int)  RTSemEventMultiReset(RTSEMEVENTMULTI hEventMultiSem)
++{
++    /*
++     * Validate input.
++     */
++    PRTSEMEVENTMULTIINTERNAL pThis = (PRTSEMEVENTMULTIINTERNAL)hEventMultiSem;
++    if (!pThis)
++        return VERR_INVALID_PARAMETER;
++    AssertPtrReturn(pThis, VERR_INVALID_PARAMETER);
++    AssertMsgReturn(pThis->u32Magic == RTSEMEVENTMULTI_MAGIC, ("%p u32Magic=%RX32\n", pThis, pThis->u32Magic), VERR_INVALID_PARAMETER);
++    rtR0SemEventMultiBsdRetain(pThis);
++
++    /*
++     * Reset it.
++     */
++    ASMAtomicAndU32(&pThis->fStateAndGen, ~RTSEMEVENTMULTIBSD_STATE_MASK);
++
++    rtR0SemEventMultiBsdRelease(pThis);
++    return VINF_SUCCESS;
++}
++
++
++/**
++ * Worker for RTSemEventMultiWaitEx and RTSemEventMultiWaitExDebug.
++ *
++ * @returns VBox status code.
++ * @param   pThis           The event semaphore.
++ * @param   fFlags          See RTSemEventMultiWaitEx.
++ * @param   uTimeout        See RTSemEventMultiWaitEx.
++ * @param   pSrcPos         The source code position of the wait.
++ */
++static int rtR0SemEventMultiBsdWait(PRTSEMEVENTMULTIINTERNAL pThis, uint32_t fFlags, uint64_t uTimeout,
++                                    PCRTLOCKVALSRCPOS pSrcPos)
++{
++    uint32_t    fOrgStateAndGen;
++    int         rc;
++
++    /*
++     * Validate the input.
++     */
++    AssertPtrReturn(pThis, VERR_INVALID_PARAMETER);
++    AssertMsgReturn(pThis->u32Magic == RTSEMEVENTMULTI_MAGIC, ("%p u32Magic=%RX32\n", pThis, pThis->u32Magic), VERR_INVALID_PARAMETER);
++    AssertReturn(RTSEMWAIT_FLAGS_ARE_VALID(fFlags), VERR_INVALID_PARAMETER);
++    rtR0SemEventMultiBsdRetain(pThis);
++
++    /*
++     * Is the event already signalled or do we have to wait?
++     */
++    fOrgStateAndGen = ASMAtomicUoReadU32(&pThis->fStateAndGen);
++    if (fOrgStateAndGen & RTSEMEVENTMULTIBSD_STATE_MASK)
++        rc = VINF_SUCCESS;
++    else
++    {
++        /*
++         * We have to wait.
++         */
++        RTR0SEMBSDSLEEP Wait;
++        rc = rtR0SemBsdWaitInit(&Wait, fFlags, uTimeout, pThis);
++        if (RT_SUCCESS(rc))
++        {
++            for (;;)
++            {
++                /* The destruction test. */
++                if (RT_UNLIKELY(pThis->u32Magic != RTSEMEVENTMULTI_MAGIC))
++                    rc = VERR_SEM_DESTROYED;
++                else
++                {
++                    rtR0SemBsdWaitPrepare(&Wait);
++
++                    /* Check the exit conditions. */
++                    if (RT_UNLIKELY(pThis->u32Magic != RTSEMEVENTMULTI_MAGIC))
++                        rc = VERR_SEM_DESTROYED;
++                    else if (ASMAtomicUoReadU32(&pThis->fStateAndGen) != fOrgStateAndGen)
++                        rc = VINF_SUCCESS;
++                    else if (rtR0SemBsdWaitHasTimedOut(&Wait))
++                        rc = VERR_TIMEOUT;
++                    else if (rtR0SemBsdWaitWasInterrupted(&Wait))
++                        rc = VERR_INTERRUPTED;
++                    else
++                    {
++                        /* Do the wait and then recheck the conditions. */
++                        rtR0SemBsdWaitDoIt(&Wait);
++                        continue;
++                    }
++                }
++                break;
++            }
++
++            rtR0SemBsdWaitDelete(&Wait);
++        }
++    }
++
++    rtR0SemEventMultiBsdRelease(pThis);
++    return rc;
++}
++
++
++RTDECL(int)  RTSemEventMultiWaitEx(RTSEMEVENTMULTI hEventMultiSem, uint32_t fFlags, uint64_t uTimeout)
++{
++#ifndef RTSEMEVENT_STRICT
++    return rtR0SemEventMultiBsdWait(hEventMultiSem, fFlags, uTimeout, NULL);
++#else
++    RTLOCKVALSRCPOS SrcPos = RTLOCKVALSRCPOS_INIT_NORMAL_API();
++    return rtR0SemEventMultiBsdWait(hEventMultiSem, fFlags, uTimeout, &SrcPos);
++#endif
++}
++RT_EXPORT_SYMBOL(RTSemEventMultiWaitEx);
++
++
++RTDECL(int)  RTSemEventMultiWaitExDebug(RTSEMEVENTMULTI hEventMultiSem, uint32_t fFlags, uint64_t uTimeout,
++                                        RTHCUINTPTR uId, RT_SRC_POS_DECL)
++{
++    RTLOCKVALSRCPOS SrcPos = RTLOCKVALSRCPOS_INIT_DEBUG_API();
++    return rtR0SemEventMultiBsdWait(hEventMultiSem, fFlags, uTimeout, &SrcPos);
++}
++RT_EXPORT_SYMBOL(RTSemEventMultiWaitExDebug);
++
++
++RTDECL(uint32_t) RTSemEventMultiGetResolution(void)
++{
++    return rtR0SemBsdWaitGetResolution();
++}
++RT_EXPORT_SYMBOL(RTSemEventMultiGetResolution);
diff --git a/virtualbox-svn/patches/patch-src_VBox_Runtime_r0drv_netbsd_semfastmutex-r0drv-netbsd.c b/virtualbox-svn/patches/patch-src_VBox_Runtime_r0drv_netbsd_semfastmutex-r0drv-netbsd.c
new file mode 100644
index 0000000..0d9c676
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Runtime_r0drv_netbsd_semfastmutex-r0drv-netbsd.c
@@ -0,0 +1,119 @@
+$NetBSD$
+
+--- src/VBox/Runtime/r0drv/netbsd/semfastmutex-r0drv-netbsd.c.orig	2016-07-07 07:08:46.957643339 +0000
++++ src/VBox/Runtime/r0drv/netbsd/semfastmutex-r0drv-netbsd.c
+@@ -0,0 +1,114 @@
++/*  semfastmutex-r0drv-netbsd.c $ */
++/** @file
++ * IPRT - Fast Mutex Semaphores, Ring-0 Driver, NetBSD.
++ */
++
++/*
++ * Copyright (c) 2007 knut st. osmundsen <bird-src-spam%anduin.net@localhost>
++ *
++ * Permission is hereby granted, free of charge, to any person
++ * obtaining a copy of this software and associated documentation
++ * files (the "Software"), to deal in the Software without
++ * restriction, including without limitation the rights to use,
++ * copy, modify, merge, publish, distribute, sublicense, and/or sell
++ * copies of the Software, and to permit persons to whom the
++ * Software is furnished to do so, subject to the following
++ * conditions:
++ *
++ * The above copyright notice and this permission notice shall be
++ * included in all copies or substantial portions of the Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
++ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
++ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
++ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
++ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
++ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
++ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
++ * OTHER DEALINGS IN THE SOFTWARE.
++ */
++
++
++/*********************************************************************************************************************************
++*   Header Files                                                                                                                 *
++*********************************************************************************************************************************/
++#include "the-netbsd-kernel.h"
++
++#include <iprt/semaphore.h>
++#include <iprt/err.h>
++#include <iprt/alloc.h>
++#include <iprt/assert.h>
++#include <iprt/asm.h>
++
++#include "internal/magics.h"
++
++
++/*********************************************************************************************************************************
++*   Structures and Typedefs                                                                                                      *
++*********************************************************************************************************************************/
++/**
++ * Wrapper for the NetBSD (sleep) mutex.
++ */
++typedef struct RTSEMFASTMUTEXINTERNAL
++{
++    /** Magic value (RTSEMFASTMUTEX_MAGIC). */
++    uint32_t            u32Magic;
++    /** The NetBSD shared/exclusive lock mutex. */
++    struct sx           SxLock;
++} RTSEMFASTMUTEXINTERNAL, *PRTSEMFASTMUTEXINTERNAL;
++
++
++RTDECL(int)  RTSemFastMutexCreate(PRTSEMFASTMUTEX phFastMtx)
++{
++    AssertCompile(sizeof(RTSEMFASTMUTEXINTERNAL) > sizeof(void *));
++    AssertPtrReturn(phFastMtx, VERR_INVALID_POINTER);
++
++    PRTSEMFASTMUTEXINTERNAL pThis = (PRTSEMFASTMUTEXINTERNAL)RTMemAllocZ(sizeof(*pThis));
++    if (pThis)
++    {
++        pThis->u32Magic = RTSEMFASTMUTEX_MAGIC;
++        sx_init_flags(&pThis->SxLock, "IPRT Fast Mutex Semaphore", SX_DUPOK);
++
++        *phFastMtx = pThis;
++        return VINF_SUCCESS;
++    }
++    return VERR_NO_MEMORY;
++}
++
++
++RTDECL(int)  RTSemFastMutexDestroy(RTSEMFASTMUTEX hFastMtx)
++{
++    PRTSEMFASTMUTEXINTERNAL pThis = hFastMtx;
++    if (pThis == NIL_RTSEMFASTMUTEX)
++        return VINF_SUCCESS;
++    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
++    AssertMsgReturn(pThis->u32Magic == RTSEMFASTMUTEX_MAGIC, ("%p: u32Magic=%RX32\n", pThis, pThis->u32Magic), VERR_INVALID_HANDLE);
++
++    ASMAtomicWriteU32(&pThis->u32Magic, RTSEMFASTMUTEX_MAGIC_DEAD);
++    sx_destroy(&pThis->SxLock);
++    RTMemFree(pThis);
++
++    return VINF_SUCCESS;
++}
++
++
++RTDECL(int)  RTSemFastMutexRequest(RTSEMFASTMUTEX hFastMtx)
++{
++    PRTSEMFASTMUTEXINTERNAL pThis = hFastMtx;
++    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
++    AssertMsgReturn(pThis->u32Magic == RTSEMFASTMUTEX_MAGIC, ("%p: u32Magic=%RX32\n", pThis, pThis->u32Magic), VERR_INVALID_HANDLE);
++
++    sx_xlock(&pThis->SxLock);
++    return VINF_SUCCESS;
++}
++
++
++RTDECL(int)  RTSemFastMutexRelease(RTSEMFASTMUTEX hFastMtx)
++{
++    PRTSEMFASTMUTEXINTERNAL pThis = hFastMtx;
++    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
++    AssertMsgReturn(pThis->u32Magic == RTSEMFASTMUTEX_MAGIC, ("%p: u32Magic=%RX32\n", pThis, pThis->u32Magic), VERR_INVALID_HANDLE);
++
++    sx_xunlock(&pThis->SxLock);
++    return VINF_SUCCESS;
++}
diff --git a/virtualbox-svn/patches/patch-src_VBox_Runtime_r0drv_netbsd_semmutex-r0drv-netbsd.c b/virtualbox-svn/patches/patch-src_VBox_Runtime_r0drv_netbsd_semmutex-r0drv-netbsd.c
new file mode 100644
index 0000000..1bcecab
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Runtime_r0drv_netbsd_semmutex-r0drv-netbsd.c
@@ -0,0 +1,223 @@
+$NetBSD$
+
+--- src/VBox/Runtime/r0drv/netbsd/semmutex-r0drv-netbsd.c.orig	2016-07-07 07:08:46.967030335 +0000
++++ src/VBox/Runtime/r0drv/netbsd/semmutex-r0drv-netbsd.c
+@@ -0,0 +1,218 @@
++/*  semmutex-r0drv-netbsd.c $ */
++/** @file
++ * IPRT - Mutex Semaphores, Ring-0 Driver, NetBSD.
++ */
++
++/*
++ * Copyright (C) 2010-2015 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                                                                                                                 *
++*********************************************************************************************************************************/
++#define RTSEMMUTEX_WITHOUT_REMAPPING
++#include "the-netbsd-kernel.h"
++#include "internal/iprt.h"
++#include <iprt/semaphore.h>
++
++#include <iprt/asm.h>
++#include <iprt/assert.h>
++#include <iprt/err.h>
++#include <iprt/mem.h>
++#include <iprt/thread.h>
++#include <iprt/time.h>
++
++#include "internal/magics.h"
++
++
++/*********************************************************************************************************************************
++*   Structures and Typedefs                                                                                                      *
++*********************************************************************************************************************************/
++/**
++ * Wrapper for the NetBSD (sleep) mutex.
++ */
++typedef struct RTSEMMUTEXINTERNAL
++{
++    /** Magic value (RTSEMMUTEX_MAGIC). */
++    uint32_t            u32Magic;
++    /** The NetBSD shared/exclusive lock mutex. */
++    struct sx           SxLock;
++} RTSEMMUTEXINTERNAL, *PRTSEMMUTEXINTERNAL;
++
++
++RTDECL(int)  RTSemMutexCreate(PRTSEMMUTEX phMutexSem)
++{
++    AssertCompile(sizeof(RTSEMMUTEXINTERNAL) > sizeof(void *));
++    AssertPtrReturn(phMutexSem, VERR_INVALID_POINTER);
++
++    PRTSEMMUTEXINTERNAL pThis = (PRTSEMMUTEXINTERNAL)RTMemAllocZ(sizeof(*pThis));
++    if (pThis)
++    {
++        pThis->u32Magic = RTSEMMUTEX_MAGIC;
++        sx_init_flags(&pThis->SxLock, "IPRT Mutex Semaphore", SX_RECURSE);
++
++        *phMutexSem = pThis;
++        return VINF_SUCCESS;
++    }
++    return VERR_NO_MEMORY;
++}
++
++
++RTDECL(int)  RTSemMutexDestroy(RTSEMMUTEX hMutexSem)
++{
++    PRTSEMMUTEXINTERNAL pThis = hMutexSem;
++    if (pThis == NIL_RTSEMMUTEX)
++        return VINF_SUCCESS;
++    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
++    AssertMsgReturn(pThis->u32Magic == RTSEMMUTEX_MAGIC, ("%p: u32Magic=%RX32\n", pThis, pThis->u32Magic), VERR_INVALID_HANDLE);
++
++    AssertReturn(ASMAtomicCmpXchgU32(&pThis->u32Magic, RTSEMMUTEX_MAGIC_DEAD, RTSEMMUTEX_MAGIC), VERR_INVALID_HANDLE);
++
++    sx_destroy(&pThis->SxLock);
++    RTMemFree(pThis);
++
++    return VINF_SUCCESS;
++}
++
++
++RTDECL(int)  RTSemMutexRequest(RTSEMMUTEX hMutexSem, RTMSINTERVAL cMillies)
++{
++    PRTSEMMUTEXINTERNAL pThis = hMutexSem;
++    int                 rc;
++    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
++    AssertMsgReturn(pThis->u32Magic == RTSEMMUTEX_MAGIC, ("%p: u32Magic=%RX32\n", pThis, pThis->u32Magic), VERR_INVALID_HANDLE);
++
++    if (cMillies == RT_INDEFINITE_WAIT)
++    {
++        sx_xlock(&pThis->SxLock);
++        rc = VINF_SUCCESS;
++    }
++    else if (!cMillies)
++    {
++        if (sx_try_xlock(&pThis->SxLock))
++            rc = VINF_SUCCESS;
++        else
++            rc = VERR_TIMEOUT;
++    }
++    /*
++     * GROSS HACK: poll implementation of timeout.
++     */
++    /** @todo Implement timeouts in RTSemMutexRequest. */
++    else if (sx_try_xlock(&pThis->SxLock))
++        rc = VINF_SUCCESS;
++    else
++    {
++        uint64_t StartTS = RTTimeSystemMilliTS();
++        rc = VERR_TIMEOUT;
++        do
++        {
++            RTThreadSleep(1);
++            if (sx_try_xlock(&pThis->SxLock))
++            {
++                rc = VINF_SUCCESS;
++                break;
++            }
++        } while (RTTimeSystemMilliTS() - StartTS < cMillies);
++    }
++
++    return VINF_SUCCESS;
++}
++
++
++RTDECL(int) RTSemMutexRequestDebug(RTSEMMUTEX hMutexSem, RTMSINTERVAL cMillies, RTHCUINTPTR uId, RT_SRC_POS_DECL)
++{
++    return RTSemMutexRequest(hMutexSem, cMillies);
++}
++
++
++RTDECL(int)  RTSemMutexRequestNoResume(RTSEMMUTEX hMutexSem, RTMSINTERVAL cMillies)
++{
++    PRTSEMMUTEXINTERNAL pThis = hMutexSem;
++    int                 rc;
++    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
++    AssertMsgReturn(pThis->u32Magic == RTSEMMUTEX_MAGIC, ("%p: u32Magic=%RX32\n", pThis, pThis->u32Magic), VERR_INVALID_HANDLE);
++
++    if (cMillies == RT_INDEFINITE_WAIT)
++    {
++        if (!sx_xlock_sig(&pThis->SxLock))
++            rc = VINF_SUCCESS;
++        else
++            rc = VERR_INTERRUPTED;
++    }
++    else if (!cMillies)
++    {
++        if (sx_try_xlock(&pThis->SxLock))
++            rc = VINF_SUCCESS;
++        else
++            rc = VERR_TIMEOUT;
++    }
++    /*
++     * GROSS HACK: poll implementation of timeout.
++     */
++    /** @todo Implement timeouts and interrupt checks in
++     *        RTSemMutexRequestNoResume. */
++    else if (sx_try_xlock(&pThis->SxLock))
++        rc = VINF_SUCCESS;
++    else
++    {
++        uint64_t StartTS = RTTimeSystemMilliTS();
++        rc = VERR_TIMEOUT;
++        do
++        {
++            RTThreadSleep(1);
++            if (sx_try_xlock(&pThis->SxLock))
++            {
++                rc = VINF_SUCCESS;
++                break;
++            }
++        } while (RTTimeSystemMilliTS() - StartTS < cMillies);
++    }
++
++    return VINF_SUCCESS;
++}
++
++
++RTDECL(int) RTSemMutexRequestNoResumeDebug(RTSEMMUTEX hMutexSem, RTMSINTERVAL cMillies, RTHCUINTPTR uId, RT_SRC_POS_DECL)
++{
++    return RTSemMutexRequestNoResume(hMutexSem, cMillies);
++}
++
++
++RTDECL(int)  RTSemMutexRelease(RTSEMMUTEX hMutexSem)
++{
++    PRTSEMMUTEXINTERNAL pThis = hMutexSem;
++    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
++    AssertMsgReturn(pThis->u32Magic == RTSEMMUTEX_MAGIC, ("%p: u32Magic=%RX32\n", pThis, pThis->u32Magic), VERR_INVALID_HANDLE);
++
++    sx_xunlock(&pThis->SxLock);
++    return VINF_SUCCESS;
++}
++
++
++
++RTDECL(bool) RTSemMutexIsOwned(RTSEMMUTEX hMutexSem)
++{
++    PRTSEMMUTEXINTERNAL pThis = hMutexSem;
++    AssertPtrReturn(pThis, false);
++    AssertMsgReturn(pThis->u32Magic == RTSEMMUTEX_MAGIC, ("%p: u32Magic=%RX32\n", pThis, pThis->u32Magic), false);
++
++    return sx_xlocked(&pThis->SxLock);
++}
diff --git a/virtualbox-svn/patches/patch-src_VBox_Runtime_r0drv_netbsd_sleepqueue-r0drv-netbsd.h b/virtualbox-svn/patches/patch-src_VBox_Runtime_r0drv_netbsd_sleepqueue-r0drv-netbsd.h
new file mode 100644
index 0000000..5aeb041
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Runtime_r0drv_netbsd_sleepqueue-r0drv-netbsd.h
@@ -0,0 +1,334 @@
+$NetBSD$
+
+--- src/VBox/Runtime/r0drv/netbsd/sleepqueue-r0drv-netbsd.h.orig	2016-07-07 07:08:46.976604489 +0000
++++ src/VBox/Runtime/r0drv/netbsd/sleepqueue-r0drv-netbsd.h
+@@ -0,0 +1,329 @@
++/*  sleepqueue-r0drv-netbsd.h $ */
++/** @file
++ * IPRT - NetBSD Ring-0 Driver Helpers for Abstracting Sleep Queues,
++ */
++
++/*
++ * Copyright (C) 2006-2015 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.
++ */
++
++
++#ifndef ___r0drv_netbsd_sleepqueue_r0drv_netbsd_h
++#define ___r0drv_netbsd_sleepqueue_r0drv_netbsd_h
++
++#include "the-netbsd-kernel.h"
++
++#include <iprt/asm-math.h>
++#include <iprt/err.h>
++#include <iprt/string.h>
++#include <iprt/time.h>
++
++/**
++ * Kernel mode MetBSD wait state structure.
++ */
++typedef struct RTR0SEMBSDSLEEP
++{
++    /** The absolute timeout given as nano seconds since the start of the
++     *  monotonic clock. */
++    uint64_t        uNsAbsTimeout;
++    /** The timeout in ticks. Updated after waiting. */
++    int             iTimeout;
++    /** Set if it's an indefinite wait. */
++    bool            fIndefinite;
++    /** Set if we've already timed out.
++     * Set by rtR0SemBsdWaitDoIt and read by rtR0SemBsdWaitHasTimedOut. */
++    bool            fTimedOut;
++    /** Flag whether the wait was interrupted. */
++    bool            fInterrupted;
++    /** flag whether the wait is interruptible or not. */
++    bool            fInterruptible;
++    /** Opaque wait channel id. */
++    void            *pvWaitChan;
++} RTR0SEMBSDSLEEP;
++/** Pointer to a MetBSD wait state. */
++typedef RTR0SEMBSDSLEEP *PRTR0SEMBSDSLEEP;
++
++
++/**
++ * Updates the timeout of the MetBSD wait.
++ *
++ * @returns RTSEMWAIT_FLAGS_INDEFINITE if the timeout value is too big.
++ *          0 otherwise
++ * @param   pWait               The wait structure.
++ * @param   uTimeout            The relative timeout in nanoseconds.
++ */
++DECLINLINE(uint32_t) rtR0SemBsdWaitUpdateTimeout(PRTR0SEMBSDSLEEP pWait, uint64_t uTimeout)
++{
++#if 0
++    struct timeval tv;
++
++    tv.tv_sec = uTimeout / UINT64_C(1000000000);
++    tv.tv_usec = (uTimeout % UINT64_C(1000000000)) / UINT64_C(1000);
++
++    pWait->iTimeout = tvtohz(&tv);
++#else
++    uint64_t cTicks = ASMMultU64ByU32DivByU32(uTimeout, hz, UINT32_C(1000000000));
++    if (cTicks >= INT_MAX)
++        return RTSEMWAIT_FLAGS_INDEFINITE;
++    else
++        pWait->iTimeout     = (int)cTicks;
++#endif
++
++    return 0;
++}
++
++/**
++ * Initializes a wait.
++ *
++ * The caller MUST check the wait condition BEFORE calling this function or the
++ * timeout logic will be flawed.
++ *
++ * @returns VINF_SUCCESS or VERR_TIMEOUT.
++ * @param   pWait               The wait structure.
++ * @param   fFlags              The wait flags.
++ * @param   uTimeout            The timeout.
++ * @param   pvWaitChan          The opaque wait channel.
++ */
++DECLINLINE(int) rtR0SemBsdWaitInit(PRTR0SEMBSDSLEEP pWait, uint32_t fFlags, uint64_t uTimeout,
++                                   void *pvWaitChan)
++{
++    pWait->iTimeout = 0;
++    pWait->uNsAbsTimeout = 0; /* shut up gcc */
++
++    /*
++     * Process the flags and timeout.
++     */
++    if (!(fFlags & RTSEMWAIT_FLAGS_INDEFINITE))
++    {
++/** @todo optimize: millisecs -> nanosecs -> millisec -> jiffies */
++        if (fFlags & RTSEMWAIT_FLAGS_MILLISECS)
++            uTimeout = uTimeout < UINT64_MAX / UINT32_C(1000000) * UINT32_C(1000000)
++                     ? uTimeout * UINT32_C(1000000)
++                     : UINT64_MAX;
++        if (uTimeout == UINT64_MAX)
++            fFlags |= RTSEMWAIT_FLAGS_INDEFINITE;
++        else
++        {
++            uint64_t u64Now;
++            if (fFlags & RTSEMWAIT_FLAGS_RELATIVE)
++            {
++                if (uTimeout == 0)
++                    return VERR_TIMEOUT;
++
++                u64Now = RTTimeSystemNanoTS();
++                if (u64Now + uTimeout < u64Now) /* overflow */
++                    fFlags |= RTSEMWAIT_FLAGS_INDEFINITE;
++                else
++                    pWait->uNsAbsTimeout = u64Now + uTimeout;
++            }
++            else
++            {
++                u64Now = RTTimeSystemNanoTS();
++                if (u64Now >= uTimeout)
++                    return VERR_TIMEOUT;
++
++                pWait->uNsAbsTimeout = uTimeout;
++                uTimeout -= u64Now; /* Get a relative value. */
++            }
++        }
++    }
++
++    if (!(fFlags & RTSEMWAIT_FLAGS_INDEFINITE))
++    {
++        pWait->fIndefinite      = false;
++        fFlags |= rtR0SemBsdWaitUpdateTimeout(pWait, uTimeout);
++    }
++
++    if (fFlags & RTSEMWAIT_FLAGS_INDEFINITE)
++    {
++        pWait->fIndefinite      = true;
++        pWait->iTimeout         = INT_MAX;
++        pWait->uNsAbsTimeout    = UINT64_MAX;
++    }
++
++    pWait->fTimedOut   = false;
++
++    /*
++     * Initialize the wait queue related bits.
++     */
++    pWait->fInterruptible = fFlags & RTSEMWAIT_FLAGS_INTERRUPTIBLE
++                            ? true : false;
++    pWait->pvWaitChan     = pvWaitChan;
++    pWait->fInterrupted   = false;
++
++    return VINF_SUCCESS;
++}
++
++/**
++ * Prepares the next wait.
++ *
++ * This must be called before rtR0SemBsdWaitDoIt, and the caller should check
++ * the exit conditions inbetween the two calls.
++ *
++ * @param   pWait               The wait structure.
++ */
++DECLINLINE(void) rtR0SemBsdWaitPrepare(PRTR0SEMBSDSLEEP pWait)
++{
++    /* Lock the queues. */
++    sleepq_lock(pWait->pvWaitChan);
++}
++
++/**
++ * Do the actual wait.
++ *
++ * @param   pWait               The wait structure.
++ */
++DECLINLINE(void) rtR0SemBsdWaitDoIt(PRTR0SEMBSDSLEEP pWait)
++{
++    int rcBsd;
++    int fSleepqFlags = SLEEPQ_CONDVAR;
++
++    if (pWait->fInterruptible)
++        fSleepqFlags |= SLEEPQ_INTERRUPTIBLE;
++
++    sleepq_add(pWait->pvWaitChan, NULL, "VBoxIS", fSleepqFlags, 0);
++
++    if (!pWait->fIndefinite)
++    {
++        sleepq_set_timeout(pWait->pvWaitChan, pWait->iTimeout);
++
++        if (pWait->fInterruptible)
++            rcBsd = SLEEPQ_TIMEDWAIT_SIG(pWait->pvWaitChan);
++        else
++            rcBsd = SLEEPQ_TIMEDWAIT(pWait->pvWaitChan);
++    }
++    else
++    {
++        if (pWait->fInterruptible)
++            rcBsd = SLEEPQ_WAIT_SIG(pWait->pvWaitChan);
++        else
++        {
++            rcBsd = 0;
++            SLEEPQ_WAIT(pWait->pvWaitChan);
++        }
++    }
++
++    switch (rcBsd)
++    {
++        case 0:
++            break;
++        case ERESTART:
++        {
++            if (!pWait->fIndefinite)
++            {
++                /* Recalc timeout. */
++                uint64_t u64Now = RTTimeSystemNanoTS();
++                if (u64Now >= pWait->uNsAbsTimeout)
++                    pWait->fTimedOut = true;
++                else
++                {
++                    u64Now = pWait->uNsAbsTimeout - u64Now;
++                    rtR0SemBsdWaitUpdateTimeout(pWait, u64Now);
++                }
++            }
++            break;
++        }
++        case EWOULDBLOCK:
++            pWait->fTimedOut = true;
++            break;
++        case EINTR:
++            Assert(pWait->fInterruptible);
++            pWait->fInterrupted = true;
++            break;
++        default:
++            AssertMsgFailed(("sleepq_* -> %d\n", rcBsd));
++            break;
++    }
++}
++
++
++/**
++ * Checks if a MetBSD wait was interrupted.
++ *
++ * @returns true / false
++ * @param   pWait               The wait structure.
++ * @remarks This shall be called before the first rtR0SemBsdWaitDoIt().
++ */
++DECLINLINE(bool) rtR0SemBsdWaitWasInterrupted(PRTR0SEMBSDSLEEP pWait)
++{
++    return pWait->fInterrupted;
++}
++
++
++/**
++ * Checks if a MetBSD wait has timed out.
++ *
++ * @returns true / false
++ * @param   pWait               The wait structure.
++ */
++DECLINLINE(bool) rtR0SemBsdWaitHasTimedOut(PRTR0SEMBSDSLEEP pWait)
++{
++    return pWait->fTimedOut;
++}
++
++
++/**
++ * Deletes a MetBSD wait.
++ *
++ * @param   pWait               The wait structure.
++ */
++DECLINLINE(void) rtR0SemBsdWaitDelete(PRTR0SEMBSDSLEEP pWait)
++{
++    sleepq_release(pWait->pvWaitChan);
++}
++
++
++/**
++ * Signals the wait channel.
++ *
++ * @param  pvWaitChan           The opaque wait channel handle.
++ */
++DECLINLINE(void) rtR0SemBsdSignal(void *pvWaitChan)
++{
++    sleepq_lock(pvWaitChan);
++    int fWakeupSwapProc = sleepq_signal(pvWaitChan, SLEEPQ_CONDVAR, 0, 0);
++    sleepq_release(pvWaitChan);
++    if (fWakeupSwapProc)
++        kick_proc0();
++}
++
++/**
++ * Wakes up all waiters on the wait channel.
++ *
++ * @param  pvWaitChan           The opaque wait channel handle.
++ */
++DECLINLINE(void) rtR0SemBsdBroadcast(void *pvWaitChan)
++{
++    sleepq_lock(pvWaitChan);
++    sleepq_broadcast(pvWaitChan, SLEEPQ_CONDVAR, 0, 0);
++    sleepq_release(pvWaitChan);
++}
++
++/**
++ * Gets the max resolution of the timeout machinery.
++ *
++ * @returns Resolution specified in nanoseconds.
++ */
++DECLINLINE(uint32_t) rtR0SemBsdWaitGetResolution(void)
++{
++    return 1000000000 / hz; /* ns */
++}
++
++#endif
diff --git a/virtualbox-svn/patches/patch-src_VBox_Runtime_r0drv_netbsd_spinlock-r0drv-netbsd.c b/virtualbox-svn/patches/patch-src_VBox_Runtime_r0drv_netbsd_spinlock-r0drv-netbsd.c
new file mode 100644
index 0000000..974bbab
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Runtime_r0drv_netbsd_spinlock-r0drv-netbsd.c
@@ -0,0 +1,214 @@
+$NetBSD$
+
+--- src/VBox/Runtime/r0drv/netbsd/spinlock-r0drv-netbsd.c.orig	2016-07-07 07:08:46.986058035 +0000
++++ src/VBox/Runtime/r0drv/netbsd/spinlock-r0drv-netbsd.c
+@@ -0,0 +1,209 @@
++/*  spinlock-r0drv-netbsd.c $ */
++/** @file
++ * IPRT - Spinlocks, Ring-0 Driver, NetBSD.
++ */
++
++/*
++ * Copyright (c) 2007 knut st. osmundsen <bird-src-spam%anduin.net@localhost>
++ *
++ * Permission is hereby granted, free of charge, to any person
++ * obtaining a copy of this software and associated documentation
++ * files (the "Software"), to deal in the Software without
++ * restriction, including without limitation the rights to use,
++ * copy, modify, merge, publish, distribute, sublicense, and/or sell
++ * copies of the Software, and to permit persons to whom the
++ * Software is furnished to do so, subject to the following
++ * conditions:
++ *
++ * The above copyright notice and this permission notice shall be
++ * included in all copies or substantial portions of the Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
++ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
++ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
++ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
++ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
++ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
++ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
++ * OTHER DEALINGS IN THE SOFTWARE.
++ */
++
++
++/*********************************************************************************************************************************
++*   Header Files                                                                                                                 *
++*********************************************************************************************************************************/
++#include "the-netbsd-kernel.h"
++#include "internal/iprt.h"
++
++#include <iprt/spinlock.h>
++#include <iprt/err.h>
++#include <iprt/alloc.h>
++#include <iprt/assert.h>
++#include <iprt/asm.h>
++#include <iprt/asm-amd64-x86.h>
++#include <iprt/thread.h>
++#include <iprt/mp.h>
++
++#include "internal/magics.h"
++
++
++/*********************************************************************************************************************************
++*   Structures and Typedefs                                                                                                      *
++*********************************************************************************************************************************/
++/**
++ * Wrapper for the struct mtx type.
++ */
++typedef struct RTSPINLOCKINTERNAL
++{
++    /** Spinlock magic value (RTSPINLOCK_MAGIC). */
++    uint32_t volatile   u32Magic;
++    /** The spinlock. */
++    uint32_t volatile   fLocked;
++    /** Saved interrupt flag. */
++    uint32_t volatile   fIntSaved;
++    /** The spinlock creation flags. */
++    uint32_t            fFlags;
++#ifdef RT_MORE_STRICT
++    /** The idAssertCpu variable before acquring the lock for asserting after
++     *  releasing the spinlock. */
++    RTCPUID volatile    idAssertCpu;
++    /** The CPU that owns the lock. */
++    RTCPUID volatile    idCpuOwner;
++#endif
++} RTSPINLOCKINTERNAL, *PRTSPINLOCKINTERNAL;
++
++
++RTDECL(int)  RTSpinlockCreate(PRTSPINLOCK pSpinlock, uint32_t fFlags, const char *pszName)
++{
++    RT_ASSERT_PREEMPTIBLE();
++    AssertReturn(fFlags == RTSPINLOCK_FLAGS_INTERRUPT_SAFE || fFlags == RTSPINLOCK_FLAGS_INTERRUPT_UNSAFE, VERR_INVALID_PARAMETER);
++
++    /*
++     * Allocate.
++     */
++    AssertCompile(sizeof(RTSPINLOCKINTERNAL) > sizeof(void *));
++    PRTSPINLOCKINTERNAL pThis = (PRTSPINLOCKINTERNAL)RTMemAllocZ(sizeof(*pThis));
++    if (!pThis)
++        return VERR_NO_MEMORY;
++
++    /*
++     * Initialize & return.
++     */
++    pThis->u32Magic  = RTSPINLOCK_MAGIC;
++    pThis->fLocked   = 0;
++    pThis->fFlags    = fFlags;
++    pThis->fIntSaved = 0;
++
++    *pSpinlock = pThis;
++    return VINF_SUCCESS;
++}
++
++
++RTDECL(int)  RTSpinlockDestroy(RTSPINLOCK Spinlock)
++{
++    /*
++     * Validate input.
++     */
++    RT_ASSERT_INTS_ON();
++    PRTSPINLOCKINTERNAL pThis = (PRTSPINLOCKINTERNAL)Spinlock;
++    if (!pThis)
++        return VERR_INVALID_PARAMETER;
++    AssertMsgReturn(pThis->u32Magic == RTSPINLOCK_MAGIC,
++                    ("Invalid spinlock %p magic=%#x\n", pThis, pThis->u32Magic),
++                    VERR_INVALID_PARAMETER);
++
++    /*
++     * Make the lock invalid and release the memory.
++     */
++    ASMAtomicIncU32(&pThis->u32Magic);
++    RTMemFree(pThis);
++    return VINF_SUCCESS;
++}
++
++
++RTDECL(void) RTSpinlockAcquire(RTSPINLOCK Spinlock)
++{
++    PRTSPINLOCKINTERNAL pThis = (PRTSPINLOCKINTERNAL)Spinlock;
++    RT_ASSERT_PREEMPT_CPUID_VAR();
++    AssertPtr(pThis);
++    Assert(pThis->u32Magic == RTSPINLOCK_MAGIC);
++
++    if (pThis->fFlags & RTSPINLOCK_FLAGS_INTERRUPT_SAFE)
++    {
++        for (;;)
++        {
++            uint32_t fIntSaved = ASMIntDisableFlags();
++            critical_enter();
++
++            int c = 50;
++            for (;;)
++            {
++                if (ASMAtomicCmpXchgU32(&pThis->fLocked, 1, 0))
++                {
++                    RT_ASSERT_PREEMPT_CPUID_SPIN_ACQUIRED(pThis);
++                    pThis->fIntSaved = fIntSaved;
++                    return;
++                }
++                if (--c <= 0)
++                    break;
++                cpu_spinwait();
++            }
++
++            /* Enable interrupts while we sleep. */
++            ASMSetFlags(fIntSaved);
++            critical_exit();
++            DELAY(1);
++        }
++    }
++    else
++    {
++        for (;;)
++        {
++            critical_enter();
++
++            int c = 50;
++            for (;;)
++            {
++                if (ASMAtomicCmpXchgU32(&pThis->fLocked, 1, 0))
++                {
++                    RT_ASSERT_PREEMPT_CPUID_SPIN_ACQUIRED(pThis);
++                    return;
++                }
++                if (--c <= 0)
++                    break;
++                cpu_spinwait();
++            }
++
++            critical_exit();
++            DELAY(1);
++        }
++    }
++}
++
++
++RTDECL(void) RTSpinlockRelease(RTSPINLOCK Spinlock)
++{
++    PRTSPINLOCKINTERNAL pThis = (PRTSPINLOCKINTERNAL)Spinlock;
++    RT_ASSERT_PREEMPT_CPUID_SPIN_RELEASE_VARS();
++
++    AssertPtr(pThis);
++    Assert(pThis->u32Magic == RTSPINLOCK_MAGIC);
++    RT_ASSERT_PREEMPT_CPUID_SPIN_RELEASE(pThis);
++
++    if (pThis->fFlags & RTSPINLOCK_FLAGS_INTERRUPT_SAFE)
++    {
++        uint32_t fIntSaved = pThis->fIntSaved;
++        pThis->fIntSaved = 0;
++        if (ASMAtomicCmpXchgU32(&pThis->fLocked, 0, 1))
++            ASMSetFlags(fIntSaved);
++        else
++            AssertMsgFailed(("Spinlock %p was not locked!\n", pThis));
++    }
++    else
++    {
++        if (!ASMAtomicCmpXchgU32(&pThis->fLocked, 0, 1))
++            AssertMsgFailed(("Spinlock %p was not locked!\n", pThis));
++    }
++
++    critical_exit();
++}
diff --git a/virtualbox-svn/patches/patch-src_VBox_Runtime_r0drv_netbsd_the-netbsd-kernel.h b/virtualbox-svn/patches/patch-src_VBox_Runtime_r0drv_netbsd_the-netbsd-kernel.h
new file mode 100644
index 0000000..0c85e5c
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Runtime_r0drv_netbsd_the-netbsd-kernel.h
@@ -0,0 +1,106 @@
+$NetBSD$
+
+--- src/VBox/Runtime/r0drv/netbsd/the-netbsd-kernel.h.orig	2016-07-07 07:08:46.995240419 +0000
++++ src/VBox/Runtime/r0drv/netbsd/the-netbsd-kernel.h
+@@ -0,0 +1,101 @@
++/*  the-netbsd-kernel.h $ */
++/** @file
++ * IPRT - Ring-0 Driver, The NetBSD Kernel Headers.
++ */
++
++/*
++ * Copyright (c) 2007 knut st. osmundsen <bird-src-spam%anduin.net@localhost>
++ *
++ * Permission is hereby granted, free of charge, to any person
++ * obtaining a copy of this software and associated documentation
++ * files (the "Software"), to deal in the Software without
++ * restriction, including without limitation the rights to use,
++ * copy, modify, merge, publish, distribute, sublicense, and/or sell
++ * copies of the Software, and to permit persons to whom the
++ * Software is furnished to do so, subject to the following
++ * conditions:
++ *
++ * The above copyright notice and this permission notice shall be
++ * included in all copies or substantial portions of the Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
++ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
++ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
++ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
++ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
++ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
++ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
++ * OTHER DEALINGS IN THE SOFTWARE.
++ */
++
++#ifndef ___the_netbsd_kernel_h
++#define ___the_netbsd_kernel_h
++
++#include <iprt/types.h>
++
++/* Deal with conflicts first. */
++#include <sys/param.h>
++#undef PVM
++#include <sys/bus.h>
++#include <sys/types.h>
++#include <sys/errno.h>
++#include <sys/kernel.h>
++#include <sys/uio.h>
++#include <sys/libkern.h>
++#include <sys/systm.h>
++#include <sys/malloc.h>
++#include <sys/pcpu.h>
++#include <sys/proc.h>
++#include <sys/limits.h>
++#include <sys/unistd.h>
++#include <sys/kthread.h>
++#include <sys/lock.h>
++#include <sys/rwlock.h>
++#include <sys/mutex.h>
++#include <sys/sched.h>
++#include <sys/callout.h>
++#include <sys/cpu.h>
++#include <sys/smp.h>
++#include <sys/sleepqueue.h>
++#include <sys/sx.h>
++#include <vm/vm.h>
++#include <vm/pmap.h>            /* for vtophys */
++#include <vm/vm_map.h>
++#include <vm/vm_object.h>
++#include <vm/vm_kern.h>
++#include <vm/vm_param.h>        /* KERN_SUCCESS ++ */
++#include <vm/vm_page.h>
++#include <vm/vm_phys.h>         /* vm_phys_alloc_* */
++#include <vm/vm_extern.h>       /* kmem_alloc_attr */
++#include <vm/vm_pageout.h>      /* vm_contig_grow_cache */
++#include <sys/vmmeter.h>        /* cnt */
++#include <sys/resourcevar.h>
++#include <machine/cpu.h>
++
++/**
++ * Wrappers around the sleepq_ KPI.
++ */
++# define SLEEPQ_TIMEDWAIT(EventInt) sleepq_timedwait(EventInt, 0)
++# define SLEEPQ_TIMEDWAIT_SIG(EventInt) sleepq_timedwait_sig(EventInt, 0)
++# define SLEEPQ_WAIT(EventInt) sleepq_wait(EventInt, 0)
++# define SLEEPQ_WAIT_SIG(EventInt) sleepq_wait_sig(EventInt, 0)
++
++/**
++ * Our pmap_enter version
++ */
++# define MY_PMAP_ENTER(pPhysMap, AddrR3, pPage, fProt, fWired) \
++    pmap_enter(pPhysMap, AddrR3, VM_PROT_NONE, pPage, fProt, fWired)
++
++/**
++ * Check whether we can use kmem_alloc_attr for low allocs.
++ */
++# define USE_KMEM_ALLOC_ATTR
++
++/**
++ * Check whether we can use kmem_alloc_prot.
++ */
++#if 0 /** @todo Not available yet. */
++# define USE_KMEM_ALLOC_PROT
++#endif
++
++#endif
diff --git a/virtualbox-svn/patches/patch-src_VBox_Runtime_r0drv_netbsd_thread-r0drv-netbsd.c b/virtualbox-svn/patches/patch-src_VBox_Runtime_r0drv_netbsd_thread-r0drv-netbsd.c
new file mode 100644
index 0000000..9bbffbc
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Runtime_r0drv_netbsd_thread-r0drv-netbsd.c
@@ -0,0 +1,186 @@
+$NetBSD$
+
+--- src/VBox/Runtime/r0drv/netbsd/thread-r0drv-netbsd.c.orig	2016-07-08 22:38:41.522099941 +0000
++++ src/VBox/Runtime/r0drv/netbsd/thread-r0drv-netbsd.c
+@@ -0,0 +1,181 @@
++/*  thread-r0drv-netbsd.c $ */
++/** @file
++ * IPRT - Threads (Part 1), Ring-0 Driver, NetBSD.
++ */
++
++/*
++ * Copyright (C) 2007-2015 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 "the-netbsd-kernel.h"
++#include "internal/iprt.h"
++#include <iprt/thread.h>
++
++#include <iprt/asm.h>
++#include <iprt/asm-amd64-x86.h>
++#include <iprt/assert.h>
++#include <iprt/err.h>
++#include <iprt/mp.h>
++#include "internal/thread.h"
++
++
++RTDECL(RTNATIVETHREAD) RTThreadNativeSelf(void)
++{
++    return (RTNATIVETHREAD)curthread;
++}
++
++
++static int rtR0ThreadNbsdSleepCommon(RTMSINTERVAL cMillies)
++{
++    int rc;
++    int cTicks;
++
++    /*
++     * 0 ms sleep -> yield.
++     */
++    if (!cMillies)
++    {
++        RTThreadYield();
++        return VINF_SUCCESS;
++    }
++
++    /*
++     * Translate milliseconds into ticks and go to sleep.
++     */
++    if (cMillies != RT_INDEFINITE_WAIT)
++    {
++        if (hz == 1000)
++            cTicks = cMillies;
++        else if (hz == 100)
++            cTicks = cMillies / 10;
++        else
++        {
++            int64_t cTicks64 = ((uint64_t)cMillies * hz) / 1000;
++            cTicks = (int)cTicks64;
++            if (cTicks != cTicks64)
++                cTicks = INT_MAX;
++        }
++    }
++    else
++        cTicks = 0;     /* requires giant lock! */
++
++    rc = tsleep((void *)RTThreadSleep,
++                PZERO | PCATCH,
++                "iprtsl",           /* max 6 chars */
++                cTicks);
++    switch (rc)
++    {
++        case 0:
++            return VINF_SUCCESS;
++        case EWOULDBLOCK:
++            return VERR_TIMEOUT;
++        case EINTR:
++        case ERESTART:
++            return VERR_INTERRUPTED;
++        default:
++            AssertMsgFailed(("%d\n", rc));
++            return VERR_NO_TRANSLATION;
++    }
++}
++
++
++RTDECL(int) RTThreadSleep(RTMSINTERVAL cMillies)
++{
++    return rtR0ThreadNbsdSleepCommon(cMillies);
++}
++
++
++RTDECL(int) RTThreadSleepNoLog(RTMSINTERVAL cMillies)
++{
++    return rtR0ThreadNbsdSleepCommon(cMillies);
++}
++
++
++RTDECL(bool) RTThreadYield(void)
++{
++    kern_yield(curthread->td_user_pri);
++    return false; /** @todo figure this one ... */
++}
++
++
++RTDECL(bool) RTThreadPreemptIsEnabled(RTTHREAD hThread)
++{
++    Assert(hThread == NIL_RTTHREAD);
++
++    return curthread->td_critnest == 0
++        && ASMIntAreEnabled(); /** @todo is there a native netbsd function/macro for this? */
++}
++
++
++RTDECL(bool) RTThreadPreemptIsPending(RTTHREAD hThread)
++{
++    Assert(hThread == NIL_RTTHREAD);
++
++    return curthread->td_owepreempt == 1;
++}
++
++
++RTDECL(bool) RTThreadPreemptIsPendingTrusty(void)
++{
++    /* yes, RTThreadPreemptIsPending is reliable. */
++    return true;
++}
++
++
++RTDECL(bool) RTThreadPreemptIsPossible(void)
++{
++    /* yes, kernel preemption is possible. */
++    return true;
++}
++
++
++RTDECL(void) RTThreadPreemptDisable(PRTTHREADPREEMPTSTATE pState)
++{
++    AssertPtr(pState);
++    Assert(pState->u32Reserved == 0);
++    pState->u32Reserved = 42;
++
++    critical_enter();
++    RT_ASSERT_PREEMPT_CPUID_DISABLE(pState);
++}
++
++
++RTDECL(void) RTThreadPreemptRestore(PRTTHREADPREEMPTSTATE pState)
++{
++    AssertPtr(pState);
++    Assert(pState->u32Reserved == 42);
++    pState->u32Reserved = 0;
++
++    RT_ASSERT_PREEMPT_CPUID_RESTORE(pState);
++    critical_exit();
++}
++
++
++RTDECL(bool) RTThreadIsInInterrupt(RTTHREAD hThread)
++{
++    Assert(hThread == NIL_RTTHREAD); NOREF(hThread);
++    /** @todo NetBSD: Implement RTThreadIsInInterrupt. Required for guest
++     *        additions! */
++    return !ASMIntAreEnabled();
++}
diff --git a/virtualbox-svn/patches/patch-src_VBox_Runtime_r0drv_netbsd_thread2-r0drv-netbsd.c b/virtualbox-svn/patches/patch-src_VBox_Runtime_r0drv_netbsd_thread2-r0drv-netbsd.c
new file mode 100644
index 0000000..d64e6e7
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Runtime_r0drv_netbsd_thread2-r0drv-netbsd.c
@@ -0,0 +1,139 @@
+$NetBSD$
+
+--- src/VBox/Runtime/r0drv/netbsd/thread2-r0drv-netbsd.c.orig	2016-07-07 07:08:47.013842911 +0000
++++ src/VBox/Runtime/r0drv/netbsd/thread2-r0drv-netbsd.c
+@@ -0,0 +1,134 @@
++/*  thread2-r0drv-netbsd.c $ */
++/** @file
++ * IPRT - Threads (Part 2), Ring-0 Driver, NetBSD.
++ */
++
++/*
++ * Copyright (c) 2007 knut st. osmundsen <bird-src-spam%anduin.net@localhost>
++ *
++ * Permission is hereby granted, free of charge, to any person
++ * obtaining a copy of this software and associated documentation
++ * files (the "Software"), to deal in the Software without
++ * restriction, including without limitation the rights to use,
++ * copy, modify, merge, publish, distribute, sublicense, and/or sell
++ * copies of the Software, and to permit persons to whom the
++ * Software is furnished to do so, subject to the following
++ * conditions:
++ *
++ * The above copyright notice and this permission notice shall be
++ * included in all copies or substantial portions of the Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
++ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
++ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
++ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
++ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
++ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
++ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
++ * OTHER DEALINGS IN THE SOFTWARE.
++ */
++
++
++/*********************************************************************************************************************************
++*   Header Files                                                                                                                 *
++*********************************************************************************************************************************/
++#include "the-netbsd-kernel.h"
++
++#include <iprt/thread.h>
++#include <iprt/err.h>
++#include <iprt/assert.h>
++
++#include "internal/thread.h"
++
++
++DECLHIDDEN(int) rtThreadNativeInit(void)
++{
++    return VINF_SUCCESS;
++}
++
++
++RTDECL(RTTHREAD) RTThreadSelf(void)
++{
++    return rtThreadGetByNative(RTThreadNativeSelf());
++}
++
++
++DECLHIDDEN(int) rtThreadNativeSetPriority(PRTTHREADINT pThread, RTTHREADTYPE enmType)
++{
++    int iPriority;
++
++    switch (enmType)
++    {
++        case RTTHREADTYPE_INFREQUENT_POLLER:    iPriority = PZERO + 8;      break;
++        case RTTHREADTYPE_EMULATION:            iPriority = PZERO + 4;      break;
++        case RTTHREADTYPE_DEFAULT:              iPriority = PZERO;          break;
++        case RTTHREADTYPE_MSG_PUMP:             iPriority = PZERO - 4;      break;
++        case RTTHREADTYPE_IO:                   iPriority = PRIBIO;         break;
++        case RTTHREADTYPE_TIMER:                iPriority = PRI_MIN_KERN;   break;
++        default:
++            AssertMsgFailed(("enmType=%d\n", enmType));
++            return VERR_INVALID_PARAMETER;
++    }
++
++    thread_lock(curthread);
++    sched_prio(curthread, iPriority);
++    thread_unlock(curthread);
++
++    return VINF_SUCCESS;
++}
++
++
++DECLHIDDEN(int) rtThreadNativeAdopt(PRTTHREADINT pThread)
++{
++    NOREF(pThread);
++    /* There is nothing special that needs doing here, but the
++       user really better know what he's cooking. */
++    return VINF_SUCCESS;
++}
++
++
++DECLHIDDEN(void) rtThreadNativeWaitKludge(PRTTHREADINT pThread)
++{
++    /** @todo fix RTThreadWait/RTR0Term race on netbsd. */
++    RTThreadSleep(1);
++}
++
++
++DECLHIDDEN(void) rtThreadNativeDestroy(PRTTHREADINT pThread)
++{
++    NOREF(pThread);
++}
++
++
++/**
++ * Native thread main function.
++ *
++ * @param   pvThreadInt     The thread structure.
++ */
++static void rtThreadNativeMain(void *pvThreadInt)
++{
++    const struct thread *Self = curthread;
++    PRTTHREADINT pThreadInt = (PRTTHREADINT)pvThreadInt;
++    int rc;
++
++    rc = rtThreadMain(pThreadInt, (RTNATIVETHREAD)Self, &pThreadInt->szName[0]);
++
++    kproc_exit(rc);
++}
++
++
++DECLHIDDEN(int) rtThreadNativeCreate(PRTTHREADINT pThreadInt, PRTNATIVETHREAD pNativeThread)
++{
++    int rc;
++    struct proc *pProc;
++
++    rc = kproc_create(rtThreadNativeMain, pThreadInt, &pProc, RFHIGHPID, 0, "%s", pThreadInt->szName);
++    if (!rc)
++    {
++        *pNativeThread = (RTNATIVETHREAD)FIRST_THREAD_IN_PROC(pProc);
++        rc = VINF_SUCCESS;
++    }
++    else
++        rc = RTErrConvertFromErrno(rc);
++    return rc;
++}
diff --git a/virtualbox-svn/patches/patch-src_VBox_Runtime_r0drv_netbsd_time-r0drv-netbsd.c b/virtualbox-svn/patches/patch-src_VBox_Runtime_r0drv_netbsd_time-r0drv-netbsd.c
new file mode 100644
index 0000000..2e38843
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Runtime_r0drv_netbsd_time-r0drv-netbsd.c
@@ -0,0 +1,78 @@
+$NetBSD$
+
+--- src/VBox/Runtime/r0drv/netbsd/time-r0drv-netbsd.c.orig	2016-07-07 07:08:47.023047744 +0000
++++ src/VBox/Runtime/r0drv/netbsd/time-r0drv-netbsd.c
+@@ -0,0 +1,73 @@
++/*  time-r0drv-netbsd.c $ */
++/** @file
++ * IPRT - Time, Ring-0 Driver, NetBSD.
++ */
++
++/*
++ * Copyright (c) 2007 knut st. osmundsen <bird-src-spam%anduin.net@localhost>
++ *
++ * Permission is hereby granted, free of charge, to any person
++ * obtaining a copy of this software and associated documentation
++ * files (the "Software"), to deal in the Software without
++ * restriction, including without limitation the rights to use,
++ * copy, modify, merge, publish, distribute, sublicense, and/or sell
++ * copies of the Software, and to permit persons to whom the
++ * Software is furnished to do so, subject to the following
++ * conditions:
++ *
++ * The above copyright notice and this permission notice shall be
++ * included in all copies or substantial portions of the Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
++ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
++ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
++ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
++ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
++ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
++ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
++ * OTHER DEALINGS IN THE SOFTWARE.
++ */
++
++
++/*********************************************************************************************************************************
++*   Header Files                                                                                                                 *
++*********************************************************************************************************************************/
++#include "the-netbsd-kernel.h"
++#define RTTIME_INCL_TIMESPEC
++
++#include <iprt/time.h>
++
++
++RTDECL(uint64_t) RTTimeNanoTS(void)
++{
++    struct timespec tsp;
++    nanouptime(&tsp);
++    return tsp.tv_sec * RT_NS_1SEC_64
++         + tsp.tv_nsec;
++}
++
++
++RTDECL(uint64_t) RTTimeMilliTS(void)
++{
++    return RTTimeNanoTS() / RT_NS_1MS;
++}
++
++
++RTDECL(uint64_t) RTTimeSystemNanoTS(void)
++{
++    return RTTimeNanoTS();
++}
++
++
++RTDECL(uint64_t) RTTimeSystemMilliTS(void)
++{
++    return RTTimeMilliTS();
++}
++
++
++RTDECL(PRTTIMESPEC) RTTimeNow(PRTTIMESPEC pTime)
++{
++    struct timespec tsp;
++    nanotime(&tsp);
++    return RTTimeSpecSetTimespec(pTime, &tsp);
++}
diff --git a/virtualbox-svn/patches/patch-src_VBox_Runtime_r0drv_netbsd_timer-r0drv-netbsd.c b/virtualbox-svn/patches/patch-src_VBox_Runtime_r0drv_netbsd_timer-r0drv-netbsd.c
new file mode 100644
index 0000000..6939c0e
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Runtime_r0drv_netbsd_timer-r0drv-netbsd.c
@@ -0,0 +1,290 @@
+$NetBSD$
+
+--- src/VBox/Runtime/r0drv/netbsd/timer-r0drv-netbsd.c.orig	2016-07-07 07:08:47.032319693 +0000
++++ src/VBox/Runtime/r0drv/netbsd/timer-r0drv-netbsd.c
+@@ -0,0 +1,285 @@
++/*  timer-r0drv-netbsd.c $ */
++/** @file
++ * IPRT - Memory Allocation, Ring-0 Driver, NetBSD.
++ */
++
++/*
++ * Copyright (c) 2007 knut st. osmundsen <bird-src-spam%anduin.net@localhost>
++ *
++ * Permission is hereby granted, free of charge, to any person
++ * obtaining a copy of this software and associated documentation
++ * files (the "Software"), to deal in the Software without
++ * restriction, including without limitation the rights to use,
++ * copy, modify, merge, publish, distribute, sublicense, and/or sell
++ * copies of the Software, and to permit persons to whom the
++ * Software is furnished to do so, subject to the following
++ * conditions:
++ *
++ * The above copyright notice and this permission notice shall be
++ * included in all copies or substantial portions of the Software.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
++ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
++ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
++ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
++ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
++ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
++ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
++ * OTHER DEALINGS IN THE SOFTWARE.
++ */
++
++
++/*********************************************************************************************************************************
++*   Header Files                                                                                                                 *
++*********************************************************************************************************************************/
++#include "the-netbsd-kernel.h"
++
++#include <iprt/timer.h>
++#include <iprt/time.h>
++#include <iprt/spinlock.h>
++#include <iprt/err.h>
++#include <iprt/asm.h>
++#include <iprt/assert.h>
++#include <iprt/alloc.h>
++
++#include "internal/magics.h"
++
++
++/*********************************************************************************************************************************
++*   Structures and Typedefs                                                                                                      *
++*********************************************************************************************************************************/
++/**
++ * The internal representation of an NetBSD timer handle.
++ */
++typedef struct RTTIMER
++{
++    /** Magic.
++     * This is RTTIMER_MAGIC, but changes to something else before the timer
++     * is destroyed to indicate clearly that thread should exit. */
++    uint32_t volatile       u32Magic;
++    /** Flag indicating that the timer is suspended. */
++    uint8_t volatile        fSuspended;
++    /** Whether the timer must run on a specific CPU or not. */
++    uint8_t                 fSpecificCpu;
++    /** The CPU it must run on if fSpecificCpu is set. */
++    uint32_t                iCpu;
++    /** The NetBSD callout structure. */
++    struct callout          Callout;
++    /** Callback. */
++    PFNRTTIMER              pfnTimer;
++    /** User argument. */
++    void                   *pvUser;
++    /** The timer interval. 0 if one-shot. */
++    uint64_t                u64NanoInterval;
++    /** The start of the current run.
++     * This is used to calculate when the timer ought to fire the next time. */
++    uint64_t volatile       u64StartTS;
++    /** The start of the current run.
++     * This is used to calculate when the timer ought to fire the next time. */
++    uint64_t volatile       u64NextTS;
++    /** The current tick number (since u64StartTS). */
++    uint64_t volatile       iTick;
++} RTTIMER;
++
++
++/*********************************************************************************************************************************
++*   Internal Functions                                                                                                           *
++*********************************************************************************************************************************/
++static void rtTimerNetBSDCallback(void *pvTimer);
++
++
++
++RTDECL(int) RTTimerCreateEx(PRTTIMER *ppTimer, uint64_t u64NanoInterval, uint32_t fFlags, PFNRTTIMER pfnTimer, void *pvUser)
++{
++    *ppTimer = NULL;
++
++    /*
++     * Validate flags.
++     */
++    if (!RTTIMER_FLAGS_ARE_VALID(fFlags))
++        return VERR_INVALID_PARAMETER;
++    if (    (fFlags & RTTIMER_FLAGS_CPU_SPECIFIC)
++        &&  (fFlags & RTTIMER_FLAGS_CPU_ALL) != RTTIMER_FLAGS_CPU_ALL
++        &&  (fFlags & RTTIMER_FLAGS_CPU_MASK) > mp_maxid)
++        return VERR_CPU_NOT_FOUND;
++
++    /*
++     * Allocate and initialize the timer handle.
++     */
++    PRTTIMER pTimer = (PRTTIMER)RTMemAlloc(sizeof(*pTimer));
++    if (!pTimer)
++        return VERR_NO_MEMORY;
++
++    pTimer->u32Magic = RTTIMER_MAGIC;
++    pTimer->fSuspended = true;
++    pTimer->fSpecificCpu = !!(fFlags & RTTIMER_FLAGS_CPU_SPECIFIC);
++    pTimer->iCpu = fFlags & RTTIMER_FLAGS_CPU_MASK;
++    pTimer->pfnTimer = pfnTimer;
++    pTimer->pvUser = pvUser;
++    pTimer->u64NanoInterval = u64NanoInterval;
++    pTimer->u64StartTS = 0;
++    callout_init(&pTimer->Callout, CALLOUT_MPSAFE);
++
++    *ppTimer = pTimer;
++    return VINF_SUCCESS;
++}
++
++
++/**
++ * Validates the timer handle.
++ *
++ * @returns true if valid, false if invalid.
++ * @param   pTimer  The handle.
++ */
++DECLINLINE(bool) rtTimerIsValid(PRTTIMER pTimer)
++{
++    AssertReturn(VALID_PTR(pTimer), false);
++    AssertReturn(pTimer->u32Magic == RTTIMER_MAGIC, false);
++    return true;
++}
++
++
++RTDECL(int) RTTimerDestroy(PRTTIMER pTimer)
++{
++    /* It's ok to pass NULL pointer. */
++    if (pTimer == /*NIL_RTTIMER*/ NULL)
++        return VINF_SUCCESS;
++    if (!rtTimerIsValid(pTimer))
++        return VERR_INVALID_HANDLE;
++
++    /*
++     * Free the associated resources.
++     */
++    pTimer->u32Magic++;
++    callout_stop(&pTimer->Callout);
++    RTMemFree(pTimer);
++    return VINF_SUCCESS;
++}
++
++
++RTDECL(int) RTTimerStart(PRTTIMER pTimer, uint64_t u64First)
++{
++    struct timeval tv;
++
++    if (!rtTimerIsValid(pTimer))
++        return VERR_INVALID_HANDLE;
++    if (!pTimer->fSuspended)
++        return VERR_TIMER_ACTIVE;
++    if (   pTimer->fSpecificCpu
++        && !RTMpIsCpuOnline(pTimer->idCpu))
++        return VERR_CPU_OFFLINE;
++
++    /*
++     * Calc when it should start firing.
++     */
++    u64First += RTTimeNanoTS();
++
++    pTimer->fSuspended = false;
++    pTimer->iTick = 0;
++    pTimer->u64StartTS = u64First;
++    pTimer->u64NextTS = u64First;
++
++    tv.tv_sec  =  u64First / 1000000000;
++    tv.tv_usec = (u64First % 1000000000) / 1000;
++    callout_reset(&pTimer->Callout, tvtohz(&tv), rtTimerNetBSDCallback, pTimer);
++
++    return VINF_SUCCESS;
++}
++
++
++RTDECL(int) RTTimerStop(PRTTIMER pTimer)
++{
++    if (!rtTimerIsValid(pTimer))
++        return VERR_INVALID_HANDLE;
++    if (pTimer->fSuspended)
++        return VERR_TIMER_SUSPENDED;
++
++    /*
++     * Suspend the timer.
++     */
++    pTimer->fSuspended = true;
++    callout_stop(&pTimer->Callout);
++
++    return VINF_SUCCESS;
++}
++
++
++RTDECL(int) RTTimerChangeInterval(PRTTIMER pTimer, uint64_t u64NanoInterval)
++{
++    if (!rtTimerIsValid(pTimer))
++        return VERR_INVALID_HANDLE;
++    return VERR_NOT_SUPPORTED;
++}
++
++
++/**
++ * smp_rendezvous action callback.
++ *
++ * This will perform the timer callback if we're on the right CPU.
++ *
++ * @param   pvTimer The timer.
++ */
++static void rtTimerNetBSDIpiAction(void *pvTimer)
++{
++    PRTTIMER pTimer = (PRTTIMER)pvTimer;
++    if (    pTimer->iCpu == RTTIMER_FLAGS_CPU_MASK
++        ||  (u_int)pTimer->iCpu == curcpu)
++        pTimer->pfnTimer(pTimer, pTimer->pvUser, pTimer->iTick);
++}
++
++
++static void rtTimerNetBSDCallback(void *pvTimer)
++{
++    PRTTIMER pTimer = (PRTTIMER)pvTimer;
++
++    /* calculate and set the next timeout */
++    pTimer->iTick++;
++    if (!pTimer->u64NanoInterval)
++    {
++        pTimer->fSuspended = true;
++        callout_stop(&pTimer->Callout);
++    }
++    else
++    {
++        struct timeval tv;
++        const uint64_t u64NanoTS = RTTimeNanoTS();
++        pTimer->u64NextTS = pTimer->u64StartTS + pTimer->iTick * pTimer->u64NanoInterval;
++        if (pTimer->u64NextTS < u64NanoTS)
++            pTimer->u64NextTS = u64NanoTS + RTTimerGetSystemGranularity() / 2;
++
++        tv.tv_sec = pTimer->u64NextTS / 1000000000;
++        tv.tv_usec = (pTimer->u64NextTS % 1000000000) / 1000;
++        callout_reset(&pTimer->Callout, tvtohz(&tv), rtTimerNetBSDCallback, pTimer);
++    }
++
++    /* callback */
++    if (    !pTimer->fSpecificCpu
++        ||  pTimer->iCpu == curcpu)
++        pTimer->pfnTimer(pTimer, pTimer->pvUser, pTimer->iTick);
++    else
++        smp_rendezvous(NULL, rtTimerNetBSDIpiAction, NULL, pvTimer);
++}
++
++
++RTDECL(uint32_t) RTTimerGetSystemGranularity(void)
++{
++    return 1000000000 / hz; /* ns */
++}
++
++
++RTDECL(int) RTTimerRequestSystemGranularity(uint32_t u32Request, uint32_t *pu32Granted)
++{
++    return VERR_NOT_SUPPORTED;
++}
++
++
++RTDECL(int) RTTimerReleaseSystemGranularity(uint32_t u32Granted)
++{
++    return VERR_NOT_SUPPORTED;
++}
++
++
++RTDECL(bool) RTTimerCanDoHighResolution(void)
++{
++    return false;
++}
diff --git a/virtualbox-svn/patches/patch-src_VBox_Runtime_r3_init.cpp b/virtualbox-svn/patches/patch-src_VBox_Runtime_r3_init.cpp
new file mode 100644
index 0000000..26a01bd
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Runtime_r3_init.cpp
@@ -0,0 +1,18 @@
+$NetBSD$
+
+--- src/VBox/Runtime/r3/init.cpp.orig	2016-03-04 19:30:02.000000000 +0000
++++ src/VBox/Runtime/r3/init.cpp
+@@ -143,7 +143,7 @@ RTDATADECL(bool) g_fRTAlignmentChecks = 
+ 
+ 
+ #if defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD) || defined(RT_OS_HAIKU) \
+- || defined(RT_OS_LINUX)  || defined(RT_OS_OS2)     || defined(RT_OS_SOLARIS) /** @todo add host init hooks everywhere. */
++ || defined(RT_OS_LINUX)  || defined(RT_OS_OS2)     || defined(RT_OS_SOLARIS) || defined(RT_OS_NETBSD) /** @todo add host init hooks everywhere. */
+ /* Stubs */
+ DECLHIDDEN(int)  rtR3InitNativeFirst(uint32_t fFlags) { return VINF_SUCCESS; }
+ DECLHIDDEN(int)  rtR3InitNativeFinal(uint32_t fFlags) { return VINF_SUCCESS; }
+@@ -663,4 +663,3 @@ RTR3DECL(void) RTR3Term(void)
+ {
+ }
+ #endif
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_Runtime_r3_netbsd_fileaio-netbsd.cpp b/virtualbox-svn/patches/patch-src_VBox_Runtime_r3_netbsd_fileaio-netbsd.cpp
new file mode 100644
index 0000000..a78acb9
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Runtime_r3_netbsd_fileaio-netbsd.cpp
@@ -0,0 +1,676 @@
+$NetBSD$
+
+--- src/VBox/Runtime/r3/netbsd/fileaio-netbsd.cpp.orig	2016-07-07 07:08:47.041585007 +0000
++++ src/VBox/Runtime/r3/netbsd/fileaio-netbsd.cpp
+@@ -0,0 +1,671 @@
++/*  fileaio-netbsd.cpp $ */
++/** @file
++ * IPRT - File async I/O, native implementation for the NetBSD host platform.
++ */
++
++/*
++ * Copyright (C) 2006-2015 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                                                                                                                 *
++*********************************************************************************************************************************/
++#define LOG_GROUP RTLOGGROUP_FILE
++#include <iprt/asm.h>
++#include <iprt/file.h>
++#include <iprt/mem.h>
++#include <iprt/assert.h>
++#include <iprt/string.h>
++#include <iprt/err.h>
++#include <iprt/log.h>
++#include <iprt/thread.h>
++#include "internal/fileaio.h"
++
++#include <sys/types.h>
++#include <sys/event.h>
++#include <sys/time.h>
++#include <sys/sysctl.h>
++#include <aio.h>
++#include <errno.h>
++#include <unistd.h>
++#include <fcntl.h>
++
++
++/*********************************************************************************************************************************
++*   Structures and Typedefs                                                                                                      *
++*********************************************************************************************************************************/
++/**
++ * Async I/O completion context state.
++ */
++typedef struct RTFILEAIOCTXINTERNAL
++{
++    /** Handle to the kernel queue. */
++    int               iKQueue;
++    /** Current number of requests active on this context. */
++    volatile int32_t  cRequests;
++    /** The ID of the thread which is currently waiting for requests. */
++    volatile RTTHREAD hThreadWait;
++    /** Flag whether the thread was woken up. */
++    volatile bool     fWokenUp;
++    /** Flag whether the thread is currently waiting in the syscall. */
++    volatile bool     fWaiting;
++    /** Flags given during creation. */
++    uint32_t          fFlags;
++    /** Magic value (RTFILEAIOCTX_MAGIC). */
++    uint32_t          u32Magic;
++} RTFILEAIOCTXINTERNAL;
++/** Pointer to an internal context structure. */
++typedef RTFILEAIOCTXINTERNAL *PRTFILEAIOCTXINTERNAL;
++
++/**
++ * Async I/O request state.
++ */
++typedef struct RTFILEAIOREQINTERNAL
++{
++    /** The aio control block. Must be the FIRST
++     *  element. */
++    struct aiocb           AioCB;
++    /** Current state the request is in. */
++    RTFILEAIOREQSTATE      enmState;
++    /** Flag whether this is a flush request. */
++    bool                   fFlush;
++    /** Opaque user data. */
++    void                  *pvUser;
++    /** Completion context we are assigned to. */
++    PRTFILEAIOCTXINTERNAL  pCtxInt;
++    /** Number of bytes actually transferred. */
++    size_t                 cbTransfered;
++    /** Status code. */
++    int                    Rc;
++    /** Magic value  (RTFILEAIOREQ_MAGIC). */
++    uint32_t               u32Magic;
++} RTFILEAIOREQINTERNAL;
++/** Pointer to an internal request structure. */
++typedef RTFILEAIOREQINTERNAL *PRTFILEAIOREQINTERNAL;
++
++
++/*********************************************************************************************************************************
++*   Defined Constants And Macros                                                                                                 *
++*********************************************************************************************************************************/
++/** The max number of events to get in one call. */
++#define AIO_MAXIMUM_REQUESTS_PER_CONTEXT 64
++
++RTR3DECL(int) RTFileAioGetLimits(PRTFILEAIOLIMITS pAioLimits)
++{
++    int rcBSD = 0;
++    AssertPtrReturn(pAioLimits, VERR_INVALID_POINTER);
++
++    /*
++     * The AIO API is implemented in a kernel module which is not
++     * loaded by default.
++     * If it is loaded there are additional sysctl parameters.
++     */
++    int cReqsOutstandingMax = 0;
++    size_t cbParameter = sizeof(int);
++
++    rcBSD = sysctlbyname("vfs.aio.max_aio_per_proc", /* name */
++                         &cReqsOutstandingMax,       /* Where to store the old value. */
++                         &cbParameter,               /* Size of the memory pointed to. */
++                         NULL,                       /* Where the new value is located. */
++                         0);                         /* Where the size of the new value is stored. */
++    if (rcBSD == -1)
++    {
++        /* ENOENT means the value is unknown thus the module is not loaded. */
++        if (errno == ENOENT)
++            return VERR_NOT_SUPPORTED;
++        else
++            return RTErrConvertFromErrno(errno);
++    }
++
++    pAioLimits->cReqsOutstandingMax = cReqsOutstandingMax;
++    pAioLimits->cbBufferAlignment   = 0;
++
++    return VINF_SUCCESS;
++}
++
++RTR3DECL(int) RTFileAioReqCreate(PRTFILEAIOREQ phReq)
++{
++    AssertPtrReturn(phReq, VERR_INVALID_POINTER);
++
++    PRTFILEAIOREQINTERNAL pReqInt = (PRTFILEAIOREQINTERNAL)RTMemAllocZ(sizeof(RTFILEAIOREQINTERNAL));
++    if (RT_UNLIKELY(!pReqInt))
++        return VERR_NO_MEMORY;
++
++    /* Ininitialize static parts. */
++    pReqInt->AioCB.aio_sigevent.sigev_notify = SIGEV_KEVENT;
++    pReqInt->AioCB.aio_sigevent.sigev_value.sival_ptr = pReqInt;
++    pReqInt->pCtxInt                   = NULL;
++    pReqInt->u32Magic                  = RTFILEAIOREQ_MAGIC;
++    RTFILEAIOREQ_SET_STATE(pReqInt, COMPLETED);
++
++    *phReq = (RTFILEAIOREQ)pReqInt;
++
++    return VINF_SUCCESS;
++}
++
++RTDECL(int) RTFileAioReqDestroy(RTFILEAIOREQ hReq)
++{
++    /*
++     * Validate the handle and ignore nil.
++     */
++    if (hReq == NIL_RTFILEAIOREQ)
++        return VINF_SUCCESS;
++    PRTFILEAIOREQINTERNAL pReqInt = hReq;
++    RTFILEAIOREQ_VALID_RETURN(pReqInt);
++    RTFILEAIOREQ_NOT_STATE_RETURN_RC(pReqInt, SUBMITTED, VERR_FILE_AIO_IN_PROGRESS);
++
++    /*
++     * Trash the magic and free it.
++     */
++    ASMAtomicUoWriteU32(&pReqInt->u32Magic, ~RTFILEAIOREQ_MAGIC);
++    RTMemFree(pReqInt);
++    return VINF_SUCCESS;
++}
++
++/**
++ * Worker setting up the request.
++ */
++DECLINLINE(int) rtFileAioReqPrepareTransfer(RTFILEAIOREQ hReq, RTFILE hFile,
++                                            unsigned uTransferDirection,
++                                            RTFOFF off, void *pvBuf, size_t cbTransfer,
++                                            void *pvUser)
++{
++    /*
++     * Validate the input.
++     */
++    PRTFILEAIOREQINTERNAL pReqInt = hReq;
++    RTFILEAIOREQ_VALID_RETURN(pReqInt);
++    RTFILEAIOREQ_NOT_STATE_RETURN_RC(pReqInt, SUBMITTED, VERR_FILE_AIO_IN_PROGRESS);
++    Assert(hFile != NIL_RTFILE);
++    AssertPtr(pvBuf);
++    Assert(off >= 0);
++    Assert(cbTransfer > 0);
++
++    pReqInt->AioCB.aio_sigevent.sigev_notify = SIGEV_KEVENT;
++    pReqInt->AioCB.aio_sigevent.sigev_value.sival_ptr = pReqInt;
++    pReqInt->AioCB.aio_lio_opcode = uTransferDirection;
++    pReqInt->AioCB.aio_fildes     = RTFileToNative(hFile);
++    pReqInt->AioCB.aio_offset     = off;
++    pReqInt->AioCB.aio_nbytes     = cbTransfer;
++    pReqInt->AioCB.aio_buf        = pvBuf;
++    pReqInt->fFlush               = false;
++    pReqInt->pvUser               = pvUser;
++    pReqInt->pCtxInt              = NULL;
++    pReqInt->Rc                   = VERR_FILE_AIO_IN_PROGRESS;
++    RTFILEAIOREQ_SET_STATE(pReqInt, PREPARED);
++
++    return VINF_SUCCESS;
++}
++
++RTDECL(int) RTFileAioReqPrepareRead(RTFILEAIOREQ hReq, RTFILE hFile, RTFOFF off,
++                                    void *pvBuf, size_t cbRead, void *pvUser)
++{
++    return rtFileAioReqPrepareTransfer(hReq, hFile, LIO_READ,
++                                       off, pvBuf, cbRead, pvUser);
++}
++
++RTDECL(int) RTFileAioReqPrepareWrite(RTFILEAIOREQ hReq, RTFILE hFile, RTFOFF off,
++                                     void const *pvBuf, size_t cbWrite, void *pvUser)
++{
++    return rtFileAioReqPrepareTransfer(hReq, hFile, LIO_WRITE,
++                                       off, (void *)pvBuf, cbWrite, pvUser);
++}
++
++RTDECL(int) RTFileAioReqPrepareFlush(RTFILEAIOREQ hReq, RTFILE hFile, void *pvUser)
++{
++    PRTFILEAIOREQINTERNAL pReqInt = (PRTFILEAIOREQINTERNAL)hReq;
++
++    RTFILEAIOREQ_VALID_RETURN(pReqInt);
++    Assert(hFile != NIL_RTFILE);
++    RTFILEAIOREQ_NOT_STATE_RETURN_RC(pReqInt, SUBMITTED, VERR_FILE_AIO_IN_PROGRESS);
++
++    pReqInt->fFlush           = true;
++    pReqInt->AioCB.aio_fildes = RTFileToNative(hFile);
++    pReqInt->AioCB.aio_offset = 0;
++    pReqInt->AioCB.aio_nbytes = 0;
++    pReqInt->AioCB.aio_buf    = NULL;
++    pReqInt->pvUser           = pvUser;
++    RTFILEAIOREQ_SET_STATE(pReqInt, PREPARED);
++
++    return VINF_SUCCESS;
++}
++
++RTDECL(void *) RTFileAioReqGetUser(RTFILEAIOREQ hReq)
++{
++    PRTFILEAIOREQINTERNAL pReqInt = hReq;
++    RTFILEAIOREQ_VALID_RETURN_RC(pReqInt, NULL);
++
++    return pReqInt->pvUser;
++}
++
++RTDECL(int) RTFileAioReqCancel(RTFILEAIOREQ hReq)
++{
++    PRTFILEAIOREQINTERNAL pReqInt = hReq;
++    RTFILEAIOREQ_VALID_RETURN(pReqInt);
++    RTFILEAIOREQ_STATE_RETURN_RC(pReqInt, SUBMITTED, VERR_FILE_AIO_NOT_SUBMITTED);
++
++
++    int rcBSD = aio_cancel(pReqInt->AioCB.aio_fildes, &pReqInt->AioCB);
++
++    if (rcBSD == AIO_CANCELED)
++    {
++        /*
++         * Decrement request count because the request will never arrive at the
++         * completion port.
++         */
++        AssertMsg(VALID_PTR(pReqInt->pCtxInt),
++                  ("Invalid state. Request was canceled but wasn't submitted\n"));
++
++        ASMAtomicDecS32(&pReqInt->pCtxInt->cRequests);
++        pReqInt->Rc = VERR_FILE_AIO_CANCELED;
++        RTFILEAIOREQ_SET_STATE(pReqInt, COMPLETED);
++        return VINF_SUCCESS;
++    }
++    else if (rcBSD == AIO_ALLDONE)
++        return VERR_FILE_AIO_COMPLETED;
++    else if (rcBSD == AIO_NOTCANCELED)
++        return VERR_FILE_AIO_IN_PROGRESS;
++    else
++        return RTErrConvertFromErrno(errno);
++}
++
++RTDECL(int) RTFileAioReqGetRC(RTFILEAIOREQ hReq, size_t *pcbTransfered)
++{
++    PRTFILEAIOREQINTERNAL pReqInt = hReq;
++    RTFILEAIOREQ_VALID_RETURN(pReqInt);
++    AssertPtrNull(pcbTransfered);
++    RTFILEAIOREQ_NOT_STATE_RETURN_RC(pReqInt, SUBMITTED, VERR_FILE_AIO_IN_PROGRESS);
++    RTFILEAIOREQ_NOT_STATE_RETURN_RC(pReqInt, PREPARED, VERR_FILE_AIO_NOT_SUBMITTED);
++
++    if (  (RT_SUCCESS(pReqInt->Rc))
++        && (pcbTransfered))
++        *pcbTransfered = pReqInt->cbTransfered;
++
++    return pReqInt->Rc;
++}
++
++RTDECL(int) RTFileAioCtxCreate(PRTFILEAIOCTX phAioCtx, uint32_t cAioReqsMax,
++                               uint32_t fFlags)
++{
++    int rc = VINF_SUCCESS;
++    PRTFILEAIOCTXINTERNAL pCtxInt;
++    AssertPtrReturn(phAioCtx, VERR_INVALID_POINTER);
++    AssertReturn(!(fFlags & ~RTFILEAIOCTX_FLAGS_VALID_MASK), VERR_INVALID_PARAMETER);
++
++    pCtxInt = (PRTFILEAIOCTXINTERNAL)RTMemAllocZ(sizeof(RTFILEAIOCTXINTERNAL));
++    if (RT_UNLIKELY(!pCtxInt))
++        return VERR_NO_MEMORY;
++
++    /* Init the event handle. */
++    pCtxInt->iKQueue = kqueue();
++    if (RT_LIKELY(pCtxInt->iKQueue > 0))
++    {
++        pCtxInt->fFlags       = fFlags;
++        pCtxInt->u32Magic     = RTFILEAIOCTX_MAGIC;
++        *phAioCtx = (RTFILEAIOCTX)pCtxInt;
++    }
++    else
++    {
++        RTMemFree(pCtxInt);
++        rc = RTErrConvertFromErrno(errno);
++    }
++
++    return rc;
++}
++
++RTDECL(int) RTFileAioCtxDestroy(RTFILEAIOCTX hAioCtx)
++{
++    /* Validate the handle and ignore nil. */
++    if (hAioCtx == NIL_RTFILEAIOCTX)
++        return VINF_SUCCESS;
++    PRTFILEAIOCTXINTERNAL pCtxInt = hAioCtx;
++    RTFILEAIOCTX_VALID_RETURN(pCtxInt);
++
++    /* Cannot destroy a busy context. */
++    if (RT_UNLIKELY(pCtxInt->cRequests))
++        return VERR_FILE_AIO_BUSY;
++
++    close(pCtxInt->iKQueue);
++    ASMAtomicUoWriteU32(&pCtxInt->u32Magic, RTFILEAIOCTX_MAGIC_DEAD);
++    RTMemFree(pCtxInt);
++
++    return VINF_SUCCESS;
++}
++
++RTDECL(uint32_t) RTFileAioCtxGetMaxReqCount(RTFILEAIOCTX hAioCtx)
++{
++    return RTFILEAIO_UNLIMITED_REQS;
++}
++
++RTDECL(int) RTFileAioCtxAssociateWithFile(RTFILEAIOCTX hAioCtx, RTFILE hFile)
++{
++    return VINF_SUCCESS;
++}
++
++RTDECL(int) RTFileAioCtxSubmit(RTFILEAIOCTX hAioCtx, PRTFILEAIOREQ pahReqs, size_t cReqs)
++{
++    /*
++     * Parameter validation.
++     */
++    int rc = VINF_SUCCESS;
++    PRTFILEAIOCTXINTERNAL pCtxInt = hAioCtx;
++    RTFILEAIOCTX_VALID_RETURN(pCtxInt);
++    AssertReturn(cReqs > 0,  VERR_INVALID_PARAMETER);
++    AssertPtrReturn(pahReqs, VERR_INVALID_POINTER);
++
++    do
++    {
++        int rcBSD = 0;
++        size_t cReqsSubmit = 0;
++        size_t i = 0;
++        PRTFILEAIOREQINTERNAL pReqInt;
++
++        while (   (i < cReqs)
++               && (i < AIO_LISTIO_MAX))
++        {
++            pReqInt = pahReqs[i];
++            if (RTFILEAIOREQ_IS_NOT_VALID(pReqInt))
++            {
++                /* Undo everything and stop submitting. */
++                for (size_t iUndo = 0; iUndo < i; iUndo++)
++                {
++                    pReqInt = pahReqs[iUndo];
++                    RTFILEAIOREQ_SET_STATE(pReqInt, PREPARED);
++                    pReqInt->pCtxInt = NULL;
++                    pReqInt->AioCB.aio_sigevent.sigev_notify_kqueue = 0;
++                }
++                rc = VERR_INVALID_HANDLE;
++                break;
++            }
++
++            pReqInt->AioCB.aio_sigevent.sigev_notify_kqueue = pCtxInt->iKQueue;
++            pReqInt->pCtxInt                                = pCtxInt;
++            RTFILEAIOREQ_SET_STATE(pReqInt, SUBMITTED);
++
++            if (pReqInt->fFlush)
++                break;
++
++            cReqsSubmit++;
++            i++;
++        }
++
++        if (cReqsSubmit)
++        {
++            rcBSD = lio_listio(LIO_NOWAIT, (struct aiocb **)pahReqs, cReqsSubmit, NULL);
++            if (RT_UNLIKELY(rcBSD < 0))
++            {
++                if (errno == EAGAIN)
++                    rc = VERR_FILE_AIO_INSUFFICIENT_RESSOURCES;
++                else
++                    rc = RTErrConvertFromErrno(errno);
++
++                /* Check which requests got actually submitted and which not. */
++                for (i = 0; i < cReqs; i++)
++                {
++                    pReqInt = pahReqs[i];
++                    rcBSD = aio_error(&pReqInt->AioCB);
++                    if (   rcBSD == -1
++                        && errno == EINVAL)
++                    {
++                        /* Was not submitted. */
++                        RTFILEAIOREQ_SET_STATE(pReqInt, PREPARED);
++                        pReqInt->pCtxInt = NULL;
++                    }
++                    else if (rcBSD != EINPROGRESS)
++                    {
++                        /* The request encountered an error. */
++                        RTFILEAIOREQ_SET_STATE(pReqInt, COMPLETED);
++                        pReqInt->Rc = RTErrConvertFromErrno(rcBSD);
++                        pReqInt->pCtxInt      = NULL;
++                        pReqInt->cbTransfered = 0;
++                    }
++                }
++                break;
++            }
++
++            ASMAtomicAddS32(&pCtxInt->cRequests, cReqsSubmit);
++            cReqs   -= cReqsSubmit;
++            pahReqs += cReqsSubmit;
++        }
++
++        /* Check if we have a flush request now. */
++        if (cReqs && RT_SUCCESS_NP(rc))
++        {
++            pReqInt = pahReqs[0];
++            RTFILEAIOREQ_VALID_RETURN(pReqInt);
++
++            if (pReqInt->fFlush)
++            {
++                /*
++                 * lio_listio does not work with flush requests so
++                 * we have to use aio_fsync directly.
++                 */
++                 rcBSD = aio_fsync(O_SYNC, &pReqInt->AioCB);
++                 if (RT_UNLIKELY(rcBSD < 0))
++                 {
++                    if (rcBSD == EAGAIN)
++                    {
++                        /* Was not submitted. */
++                        RTFILEAIOREQ_SET_STATE(pReqInt, PREPARED);
++                        pReqInt->pCtxInt = NULL;
++                        return VERR_FILE_AIO_INSUFFICIENT_RESSOURCES;
++                    }
++                    else
++                    {
++                        RTFILEAIOREQ_SET_STATE(pReqInt, COMPLETED);
++                        pReqInt->Rc = RTErrConvertFromErrno(errno);
++                        pReqInt->cbTransfered = 0;
++                        return pReqInt->Rc;
++                    }
++                 }
++
++                ASMAtomicIncS32(&pCtxInt->cRequests);
++                cReqs--;
++                pahReqs++;
++            }
++        }
++    } while (cReqs);
++
++    return rc;
++}
++
++RTDECL(int) RTFileAioCtxWait(RTFILEAIOCTX hAioCtx, size_t cMinReqs, RTMSINTERVAL cMillies,
++                             PRTFILEAIOREQ pahReqs, size_t cReqs, uint32_t *pcReqs)
++{
++    int rc = VINF_SUCCESS;
++    int cRequestsCompleted = 0;
++
++    /*
++     * Validate the parameters, making sure to always set pcReqs.
++     */
++    AssertPtrReturn(pcReqs, VERR_INVALID_POINTER);
++    *pcReqs = 0; /* always set */
++    PRTFILEAIOCTXINTERNAL pCtxInt = hAioCtx;
++    RTFILEAIOCTX_VALID_RETURN(pCtxInt);
++    AssertPtrReturn(pahReqs, VERR_INVALID_POINTER);
++    AssertReturn(cReqs != 0, VERR_INVALID_PARAMETER);
++    AssertReturn(cReqs >= cMinReqs, VERR_OUT_OF_RANGE);
++
++    if (   RT_UNLIKELY(ASMAtomicReadS32(&pCtxInt->cRequests) == 0)
++        && !(pCtxInt->fFlags & RTFILEAIOCTX_FLAGS_WAIT_WITHOUT_PENDING_REQUESTS))
++        return VERR_FILE_AIO_NO_REQUEST;
++
++    /*
++     * Convert the timeout if specified.
++     */
++    struct timespec    *pTimeout = NULL;
++    struct timespec     Timeout = {0,0};
++    uint64_t            StartNanoTS = 0;
++    if (cMillies != RT_INDEFINITE_WAIT)
++    {
++        Timeout.tv_sec  = cMillies / 1000;
++        Timeout.tv_nsec = cMillies % 1000 * 1000000;
++        pTimeout = &Timeout;
++        StartNanoTS = RTTimeNanoTS();
++    }
++
++    /* Wait for at least one. */
++    if (!cMinReqs)
++        cMinReqs = 1;
++
++    /* For the wakeup call. */
++    Assert(pCtxInt->hThreadWait == NIL_RTTHREAD);
++    ASMAtomicWriteHandle(&pCtxInt->hThreadWait, RTThreadSelf());
++
++    while (   cMinReqs
++           && RT_SUCCESS_NP(rc))
++    {
++        struct kevent aKEvents[AIO_MAXIMUM_REQUESTS_PER_CONTEXT];
++        int cRequestsToWait = cMinReqs < AIO_MAXIMUM_REQUESTS_PER_CONTEXT ? cReqs : AIO_MAXIMUM_REQUESTS_PER_CONTEXT;
++        int rcBSD;
++        uint64_t StartTime;
++
++        ASMAtomicXchgBool(&pCtxInt->fWaiting, true);
++        rcBSD = kevent(pCtxInt->iKQueue, NULL, 0, aKEvents, cRequestsToWait, pTimeout);
++        ASMAtomicXchgBool(&pCtxInt->fWaiting, false);
++
++        if (RT_UNLIKELY(rcBSD < 0))
++        {
++            rc = RTErrConvertFromErrno(errno);
++            break;
++        }
++
++        uint32_t const cDone = rcBSD;
++
++        /* Process received events. */
++        for (uint32_t i = 0; i < cDone; i++)
++        {
++            PRTFILEAIOREQINTERNAL pReqInt = (PRTFILEAIOREQINTERNAL)aKEvents[i].udata;
++            AssertPtr(pReqInt);
++            Assert(pReqInt->u32Magic == RTFILEAIOREQ_MAGIC);
++
++            /*
++             * Retrieve the status code here already because the
++             * user may omit the RTFileAioReqGetRC() call and
++             * we will leak kernel resources then.
++             * This will result in errors during submission
++             * of other requests as soon as the max_aio_queue_per_proc
++             * limit is reached.
++             */
++            int cbTransfered = aio_return(&pReqInt->AioCB);
++
++            if (cbTransfered < 0)
++            {
++                pReqInt->Rc = RTErrConvertFromErrno(cbTransfered);
++                pReqInt->cbTransfered = 0;
++            }
++            else
++            {
++                pReqInt->Rc = VINF_SUCCESS;
++                pReqInt->cbTransfered = cbTransfered;
++            }
++            RTFILEAIOREQ_SET_STATE(pReqInt, COMPLETED);
++            pahReqs[cRequestsCompleted++] = (RTFILEAIOREQ)pReqInt;
++        }
++
++        /*
++         * Done Yet? If not advance and try again.
++         */
++        if (cDone >= cMinReqs)
++            break;
++        cMinReqs -= cDone;
++        cReqs    -= cDone;
++
++        if (cMillies != RT_INDEFINITE_WAIT)
++        {
++            /* The API doesn't return ETIMEDOUT, so we have to fix that ourselves. */
++            uint64_t NanoTS = RTTimeNanoTS();
++            uint64_t cMilliesElapsed = (NanoTS - StartNanoTS) / 1000000;
++            if (cMilliesElapsed >= cMillies)
++            {
++                rc = VERR_TIMEOUT;
++                break;
++            }
++
++            /* The syscall supposedly updates it, but we're paranoid. :-) */
++            Timeout.tv_sec  = (cMillies - (RTMSINTERVAL)cMilliesElapsed) / 1000;
++            Timeout.tv_nsec = (cMillies - (RTMSINTERVAL)cMilliesElapsed) % 1000 * 1000000;
++        }
++    }
++
++    /*
++     * Update the context state and set the return value.
++     */
++    *pcReqs = cRequestsCompleted;
++    ASMAtomicSubS32(&pCtxInt->cRequests, cRequestsCompleted);
++    Assert(pCtxInt->hThreadWait == RTThreadSelf());
++    ASMAtomicWriteHandle(&pCtxInt->hThreadWait, NIL_RTTHREAD);
++
++    /*
++     * Clear the wakeup flag and set rc.
++     */
++    if (    pCtxInt->fWokenUp
++        &&  RT_SUCCESS(rc))
++    {
++        ASMAtomicXchgBool(&pCtxInt->fWokenUp, false);
++        rc = VERR_INTERRUPTED;
++    }
++
++    return rc;
++}
++
++RTDECL(int) RTFileAioCtxWakeup(RTFILEAIOCTX hAioCtx)
++{
++    PRTFILEAIOCTXINTERNAL pCtxInt = hAioCtx;
++    RTFILEAIOCTX_VALID_RETURN(pCtxInt);
++
++    /** @todo r=bird: Define the protocol for how to resume work after calling
++     *        this function. */
++
++    bool fWokenUp = ASMAtomicXchgBool(&pCtxInt->fWokenUp, true);
++
++    /*
++     * Read the thread handle before the status flag.
++     * If we read the handle after the flag we might
++     * end up with an invalid handle because the thread
++     * waiting in RTFileAioCtxWakeup() might get scheduled
++     * before we read the flag and returns.
++     * We can ensure that the handle is valid if fWaiting is true
++     * when reading the handle before the status flag.
++     */
++    RTTHREAD hThread;
++    ASMAtomicReadHandle(&pCtxInt->hThreadWait, &hThread);
++    bool fWaiting    = ASMAtomicReadBool(&pCtxInt->fWaiting);
++    if (    !fWokenUp
++        &&  fWaiting)
++    {
++        /*
++         * If a thread waits the handle must be valid.
++         * It is possible that the thread returns from
++         * kevent() before the signal is send.
++         * This is no problem because we already set fWokenUp
++         * to true which will let the thread return VERR_INTERRUPTED
++         * and the next call to RTFileAioCtxWait() will not
++         * return VERR_INTERRUPTED because signals are not saved
++         * and will simply vanish if the destination thread can't
++         * receive it.
++         */
++        Assert(hThread != NIL_RTTHREAD);
++        RTThreadPoke(hThread);
++    }
++
++    return VINF_SUCCESS;
++}
diff --git a/virtualbox-svn/patches/patch-src_VBox_Runtime_r3_netbsd_mp-netbsd.cpp b/virtualbox-svn/patches/patch-src_VBox_Runtime_r3_netbsd_mp-netbsd.cpp
new file mode 100644
index 0000000..946272c
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Runtime_r3_netbsd_mp-netbsd.cpp
@@ -0,0 +1,205 @@
+$NetBSD$
+
+--- src/VBox/Runtime/r3/netbsd/mp-netbsd.cpp.orig	2016-07-07 07:08:47.050526272 +0000
++++ src/VBox/Runtime/r3/netbsd/mp-netbsd.cpp
+@@ -0,0 +1,200 @@
++/*  mp-netbsd.cpp $ */
++/** @file
++ * IPRT - Multiprocessor, NetBSD.
++ */
++
++/*
++ * Copyright (C) 2008-2015 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                                                                                                                 *
++*********************************************************************************************************************************/
++#define LOG_GROUP RTLOGGROUP_SYSTEM
++#include <unistd.h>
++#include <stdio.h>
++#include <errno.h>
++#include <sys/sysctl.h>
++
++#include <iprt/mp.h>
++#include <iprt/cpuset.h>
++#include <iprt/assert.h>
++#include <iprt/string.h>
++#include <iprt/alloc.h>
++#include <iprt/log.h>
++#include <iprt/once.h>
++#include <iprt/critsect.h>
++
++
++/**
++ * Internal worker that determines the max possible CPU count.
++ *
++ * @returns Max cpus.
++ */
++static RTCPUID rtMpNetBsdMaxCpus(void)
++{
++    int aiMib[2];
++    aiMib[0] = CTL_HW;
++    aiMib[1] = HW_NCPU;
++    int cCpus = -1;
++    size_t cb = sizeof(cCpus);
++    int rc = sysctl(aiMib, RT_ELEMENTS(aiMib), &cCpus, &cb, NULL, 0);
++    if (rc != -1 && cCpus >= 1)
++        return cCpus;
++    AssertFailed();
++    return 1;
++}
++
++
++RTDECL(int) RTMpCpuIdToSetIndex(RTCPUID idCpu)
++{
++    return idCpu < RTCPUSET_MAX_CPUS && idCpu < rtMpNetBsdMaxCpus() ? idCpu : -1;
++}
++
++
++RTDECL(RTCPUID) RTMpCpuIdFromSetIndex(int iCpu)
++{
++    return (unsigned)iCpu < rtMpNetBsdMaxCpus() ? iCpu : NIL_RTCPUID;
++}
++
++
++RTDECL(RTCPUID) RTMpGetMaxCpuId(void)
++{
++    return rtMpNetBsdMaxCpus() - 1;
++}
++
++
++RTDECL(bool) RTMpIsCpuOnline(RTCPUID idCpu)
++{
++    /*
++     * NetBSD doesn't support CPU hotplugging so every CPU which appears
++     * in the tree is also online.
++     */
++    char    szName[40];
++    RTStrPrintf(szName, sizeof(szName), "dev.cpu.%d.%%driver", (int)idCpu);
++
++    char    szDriver[10];
++    size_t  cbDriver = sizeof(szDriver);
++    RT_ZERO(szDriver);                  /* this shouldn't be necessary. */
++    int rcBsd = sysctlbyname(szName, szDriver, &cbDriver, NULL, 0);
++    if (rcBsd == 0)
++        return true;
++
++    return false;
++}
++
++
++RTDECL(bool) RTMpIsCpuPossible(RTCPUID idCpu)
++{
++    return idCpu != NIL_RTCPUID
++        && idCpu < rtMpNetBsdMaxCpus();
++}
++
++
++RTDECL(PRTCPUSET) RTMpGetSet(PRTCPUSET pSet)
++{
++    RTCpuSetEmpty(pSet);
++    RTCPUID cMax = rtMpNetBsdMaxCpus();
++    for (RTCPUID idCpu = 0; idCpu < cMax; idCpu++)
++        if (RTMpIsCpuPossible(idCpu))
++            RTCpuSetAdd(pSet, idCpu);
++    return pSet;
++}
++
++
++RTDECL(RTCPUID) RTMpGetCount(void)
++{
++    return rtMpNetBsdMaxCpus();
++}
++
++
++RTDECL(PRTCPUSET) RTMpGetOnlineSet(PRTCPUSET pSet)
++{
++    RTCpuSetEmpty(pSet);
++    RTCPUID cMax = rtMpNetBsdMaxCpus();
++    for (RTCPUID idCpu = 0; idCpu < cMax; idCpu++)
++        if (RTMpIsCpuOnline(idCpu))
++            RTCpuSetAdd(pSet, idCpu);
++    return pSet;
++}
++
++
++RTDECL(RTCPUID) RTMpGetOnlineCount(void)
++{
++    /*
++     * NetBSD has sysconf.
++     */
++    return sysconf(_SC_NPROCESSORS_ONLN);
++}
++
++
++RTDECL(uint32_t) RTMpGetCurFrequency(RTCPUID idCpu)
++{
++    int uFreqCurr = 0;
++    size_t cbParameter = sizeof(uFreqCurr);
++
++    if (!RTMpIsCpuOnline(idCpu))
++        return 0;
++
++    /* CPU's have a common frequency. */
++    int rc = sysctlbyname("dev.cpu.0.freq", &uFreqCurr, &cbParameter, NULL, 0);
++    if (rc)
++        return 0;
++
++    return (uint32_t)uFreqCurr;
++}
++
++
++RTDECL(uint32_t) RTMpGetMaxFrequency(RTCPUID idCpu)
++{
++    char szFreqLevels[20]; /* Should be enough to get the highest level which is always the first. */
++    size_t cbFreqLevels = sizeof(szFreqLevels);
++
++    if (!RTMpIsCpuOnline(idCpu))
++        return 0;
++
++    memset(szFreqLevels, 0, sizeof(szFreqLevels));
++
++    /*
++     * CPU 0 has the freq levels entry. ENOMEM is ok as we don't need all supported
++     * levels but only the first one.
++     */
++    int rc = sysctlbyname("dev.cpu.0.freq_levels", szFreqLevels, &cbFreqLevels, NULL, 0);
++    if (   (rc && (errno != ENOMEM))
++        || (cbFreqLevels == 0))
++        return 0;
++
++    /* Clear everything starting from the '/' */
++    unsigned i = 0;
++
++    do
++    {
++        if (szFreqLevels[i] == '/')
++        {
++            memset(&szFreqLevels[i], 0, sizeof(szFreqLevels) - i);
++            break;
++        }
++        i++;
++    } while (i < sizeof(szFreqLevels));
++
++    /* Returns 0 on failure. */
++    return RTStrToUInt32(szFreqLevels);
++}
diff --git a/virtualbox-svn/patches/patch-src_VBox_Runtime_r3_netbsd_rtProcInitExePath-netbsd.cpp b/virtualbox-svn/patches/patch-src_VBox_Runtime_r3_netbsd_rtProcInitExePath-netbsd.cpp
new file mode 100644
index 0000000..4ca53cc
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Runtime_r3_netbsd_rtProcInitExePath-netbsd.cpp
@@ -0,0 +1,77 @@
+$NetBSD$
+
+--- src/VBox/Runtime/r3/netbsd/rtProcInitExePath-netbsd.cpp.orig	2016-07-07 07:08:47.060017160 +0000
++++ src/VBox/Runtime/r3/netbsd/rtProcInitExePath-netbsd.cpp
+@@ -0,0 +1,72 @@
++/*  rtProcInitExePath-netbsd.cpp $ */
++/** @file
++ * IPRT - rtProcInitName, NetBSD.
++ */
++
++/*
++ * Copyright (C) 2006-2015 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                                                                                                                 *
++*********************************************************************************************************************************/
++#define LOG_GROUP RTLOGGROUP_PROCESS
++#include <sys/param.h>
++#include <sys/sysctl.h>
++#include <unistd.h>
++#include <errno.h>
++#include <dlfcn.h>
++#include <link.h>
++
++#include <iprt/string.h>
++#include <iprt/assert.h>
++#include <iprt/err.h>
++#include <iprt/path.h>
++#include "internal/process.h"
++#include "internal/path.h"
++
++
++DECLHIDDEN(int) rtProcInitExePath(char *pszPath, size_t cchPath)
++{
++    int aiName[4];
++    aiName[0] = CTL_KERN;
++    aiName[1] = KERN_PROC_ARGS;
++    aiName[2] = -1;                     /* Shorthand for the current process. */
++    aiName[3] = KERN_PROC_PATHNAME;
++
++    size_t cchExePath = cchPath;
++    if (sysctl(aiName, RT_ELEMENTS(aiName), pszPath, &cchExePath, NULL, 0) == 0)
++    {
++        const char *pszTmp;
++        int rc = rtPathFromNative(&pszTmp, pszPath, NULL);
++        AssertMsgRCReturn(rc, ("rc=%Rrc pszPath=\"%s\"\nhex: %.*Rhxs\n", rc, pszPath, cchExePath, pszPath), rc);
++        if (pszTmp != pszPath)
++        {
++            rc = RTStrCopy(pszPath, cchPath, pszTmp);
++            rtPathFreeIprt(pszTmp, pszPath);
++        }
++        return rc;
++    }
++
++    int rc = RTErrConvertFromErrno(errno);
++    AssertMsgFailed(("rc=%Rrc errno=%d cchExePath=%d\n", rc, errno, cchExePath));
++    return rc;
++}
diff --git a/virtualbox-svn/patches/patch-src_VBox_Runtime_r3_netbsd_systemmem-netbsd.cpp b/virtualbox-svn/patches/patch-src_VBox_Runtime_r3_netbsd_systemmem-netbsd.cpp
new file mode 100644
index 0000000..b2b4392
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Runtime_r3_netbsd_systemmem-netbsd.cpp
@@ -0,0 +1,79 @@
+$NetBSD$
+
+--- src/VBox/Runtime/r3/netbsd/systemmem-netbsd.cpp.orig	2016-07-07 07:08:47.069137512 +0000
++++ src/VBox/Runtime/r3/netbsd/systemmem-netbsd.cpp
+@@ -0,0 +1,74 @@
++/*  systemmem-netbsd.cpp $ */
++/** @file
++ * IPRT - RTSystemQueryTotalRam, NetBSD ring-3.
++ */
++
++/*
++ * Copyright (C) 2012-2015 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>
++
++#include <sys/types.h>
++#include <sys/sysctl.h>
++#include <errno.h>
++
++
++RTDECL(int) RTSystemQueryTotalRam(uint64_t *pcb)
++{
++    int rc = VINF_SUCCESS;
++    u_long cbMemPhys = 0;
++    size_t cbParameter = sizeof(cbMemPhys);
++
++    AssertPtrReturn(pcb, VERR_INVALID_POINTER);
++
++    if (!sysctlbyname("hw.physmem64", &cbMemPhys, &cbParameter, NULL, 0))
++    {
++        *pcb = cbMemPhys;
++        return VINF_SUCCESS;
++    }
++    return RTErrConvertFromErrno(errno);
++}
++
++
++RTDECL(int) RTSystemQueryAvailableRam(uint64_t *pcb)
++{
++    int rc = VINF_SUCCESS;
++    u_long cbMemPhys = 0;
++    size_t cbParameter = sizeof(cbMemPhys);
++
++    AssertPtrReturn(pcb, VERR_INVALID_POINTER);
++
++    if (!sysctlbyname("hw.usermem64", &cbMemPhys, &cbParameter, NULL, 0))
++    {
++        *pcb = cbMemPhys;
++        return VINF_SUCCESS;
++    }
++    return RTErrConvertFromErrno(errno);
++}
diff --git a/virtualbox-svn/patches/patch-src_VBox_Runtime_r3_posix_fileaio-posix.cpp b/virtualbox-svn/patches/patch-src_VBox_Runtime_r3_posix_fileaio-posix.cpp
new file mode 100644
index 0000000..0fb1cfe
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Runtime_r3_posix_fileaio-posix.cpp
@@ -0,0 +1,59 @@
+$NetBSD$
+
+--- src/VBox/Runtime/r3/posix/fileaio-posix.cpp.orig	2016-03-04 19:30:03.000000000 +0000
++++ src/VBox/Runtime/r3/posix/fileaio-posix.cpp
+@@ -40,11 +40,11 @@
+ #include <iprt/semaphore.h>
+ #include "internal/fileaio.h"
+ 
+-#if defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD)
++#if defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+ # include <sys/types.h>
+ # include <sys/sysctl.h> /* for sysctlbyname */
+ #endif
+-#if defined(RT_OS_FREEBSD)
++#if defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+ # include <fcntl.h> /* O_SYNC */
+ #endif
+ #include <aio.h>
+@@ -316,7 +316,7 @@ RTR3DECL(int) RTFileAioGetLimits(PRTFILE
+ 
+     pAioLimits->cReqsOutstandingMax = cReqsOutstandingMax;
+     pAioLimits->cbBufferAlignment   = 0;
+-#elif defined(RT_OS_FREEBSD)
++#elif defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+     /*
+      * The AIO API is implemented in a kernel module which is not
+      * loaded by default.
+@@ -710,7 +710,7 @@ RTDECL(int) RTFileAioCtxSubmit(RTFILEAIO
+                     {
+                         cReqsSubmitted--;
+ 
+-#if defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD)
++#if defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+                         if (errno == EINVAL)
+ #else
+                         if (rcPosix == EINVAL)
+@@ -729,7 +729,7 @@ RTDECL(int) RTFileAioCtxSubmit(RTFILEAIO
+                              * glibc returns the error code which would be in errno but Apple returns
+                              * -1 and sets errno to the appropriate value
+                              */
+-#if defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD)
++#if defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+                             Assert(rcPosix == -1);
+                             pReqInt->Rc = RTErrConvertFromErrno(errno);
+ #elif defined(RT_OS_LINUX)
+@@ -957,7 +957,7 @@ RTDECL(int) RTFileAioCtxWait(RTFILEAIOCT
+                     }
+                     else
+                     {
+-#if defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD)
++#if defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+                         pReq->Rc = RTErrConvertFromErrno(errno);
+ #else
+                         pReq->Rc = RTErrConvertFromErrno(rcReq);
+@@ -1059,4 +1059,3 @@ RTDECL(int) RTFileAioCtxWakeup(RTFILEAIO
+ 
+     return VINF_SUCCESS;
+ }
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_Runtime_r3_posix_fileio-posix.cpp b/virtualbox-svn/patches/patch-src_VBox_Runtime_r3_posix_fileio-posix.cpp
new file mode 100644
index 0000000..c4cd0a6
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Runtime_r3_posix_fileio-posix.cpp
@@ -0,0 +1,45 @@
+$NetBSD$
+
+--- src/VBox/Runtime/r3/posix/fileio-posix.cpp.orig	2016-03-04 19:30:03.000000000 +0000
++++ src/VBox/Runtime/r3/posix/fileio-posix.cpp
+@@ -48,7 +48,7 @@
+ #if defined(RT_OS_OS2) && (!defined(__INNOTEK_LIBC__) || __INNOTEK_LIBC__ < 0x006)
+ # include <io.h>
+ #endif
+-#if defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD)
++#if defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+ # include <sys/disk.h>
+ #endif
+ #ifdef RT_OS_SOLARIS
+@@ -154,7 +154,7 @@ RTR3DECL(int) RTFileOpen(PRTFILE pFile, 
+     if (fOpen & RTFILE_O_ASYNC_IO)
+         fOpenMode |= O_DIRECT;
+ #endif
+-#if defined(O_DIRECT) && (defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD))
++#if defined(O_DIRECT) && (defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD)|| defined(RT_OS_NETBSD))
+     /* Disable the kernel cache. */
+     if (fOpen & RTFILE_O_NO_CACHE)
+         fOpenMode |= O_DIRECT;
+@@ -559,7 +559,7 @@ RTR3DECL(int) RTFileGetSize(RTFILE hFile
+         if (   st.st_size != 0
+ #if defined(RT_OS_SOLARIS)
+             || (!S_ISBLK(st.st_mode) && !S_ISCHR(st.st_mode))
+-#elif defined(RT_OS_FREEBSD)
++#elif defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+             || !S_ISCHR(st.st_mode)
+ #else
+             || !S_ISBLK(st.st_mode)
+@@ -595,7 +595,7 @@ RTR3DECL(int) RTFileGetSize(RTFILE hFile
+         if (errno == EINVAL || errno == ENOTTY)
+             return VINF_SUCCESS;
+ 
+-#elif defined(RT_OS_FREEBSD)
++#elif defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+         off_t cbMedia = 0;
+         if (!ioctl(RTFileToNative(hFile), DIOCGMEDIASIZE, &cbMedia))
+         {
+@@ -743,4 +743,3 @@ RTR3DECL(int) RTFileRename(const char *p
+              pszSrc, pszSrc, pszDst, pszDst, fRename, rc));
+     return rc;
+ }
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_Runtime_r3_posix_fs-posix.cpp b/virtualbox-svn/patches/patch-src_VBox_Runtime_r3_posix_fs-posix.cpp
new file mode 100644
index 0000000..c2eb90e
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Runtime_r3_posix_fs-posix.cpp
@@ -0,0 +1,45 @@
+$NetBSD$
+
+--- src/VBox/Runtime/r3/posix/fs-posix.cpp.orig	2016-03-04 19:30:03.000000000 +0000
++++ src/VBox/Runtime/r3/posix/fs-posix.cpp
+@@ -35,7 +35,7 @@
+ #ifdef RT_OS_LINUX
+ # include <mntent.h>
+ #endif
+-#if defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD)
++#if defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+ # include <sys/mount.h>
+ #endif
+ 
+@@ -311,6 +311,31 @@ RTR3DECL(int) RTFsQueryType(const char *
+             }
+             else
+                 rc = RTErrConvertFromErrno(errno);
++
++#elif defined(RT_OS_NETBSD)
++            struct statvfs statfsBuf;
++            if (!statvfs(pszNativeFsPath, &statfsBuf))
++            {
++                if (!strcmp("hfs", statfsBuf.f_fstypename))
++                    *penmType = RTFSTYPE_HFS;
++                else if (   !strcmp("fat", statfsBuf.f_fstypename)
++                         || !strcmp("msdos", statfsBuf.f_fstypename))
++                    *penmType = RTFSTYPE_FAT;
++                else if (!strcmp("ntfs", statfsBuf.f_fstypename))
++                    *penmType = RTFSTYPE_NTFS;
++                else if (!strcmp("autofs", statfsBuf.f_fstypename))
++                    *penmType = RTFSTYPE_AUTOFS;
++                else if (!strcmp("devfs", statfsBuf.f_fstypename))
++                    *penmType = RTFSTYPE_DEVFS;
++                else if (!strcmp("nfs", statfsBuf.f_fstypename))
++                    *penmType = RTFSTYPE_NFS;
++                else if (!strcmp("ufs", statfsBuf.f_fstypename))
++                    *penmType = RTFSTYPE_UFS;
++                else if (!strcmp("zfs", statfsBuf.f_fstypename))
++                    *penmType = RTFSTYPE_ZFS;
++            }
++            else
++                rc = RTErrConvertFromErrno(errno);
+ #endif
+         }
+         else
diff --git a/virtualbox-svn/patches/patch-src_VBox_Runtime_r3_posix_path2-posix.cpp b/virtualbox-svn/patches/patch-src_VBox_Runtime_r3_posix_path2-posix.cpp
new file mode 100644
index 0000000..5d02316
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Runtime_r3_posix_path2-posix.cpp
@@ -0,0 +1,17 @@
+$NetBSD$
+
+--- src/VBox/Runtime/r3/posix/path2-posix.cpp.orig	2016-03-04 19:30:03.000000000 +0000
++++ src/VBox/Runtime/r3/posix/path2-posix.cpp
+@@ -189,6 +189,7 @@ RTR3DECL(int) RTPathSetTimesEx(const cha
+                 }
+ #if (defined(RT_OS_DARWIN) && MAC_OS_X_VERSION_MIN_REQUIRED >= 1050) \
+  || defined(RT_OS_FREEBSD) \
++ || defined(RT_OS_NETBSD) \
+  || defined(RT_OS_LINUX) \
+  || defined(RT_OS_OS2) /** @todo who really has lutimes? */
+                 else
+@@ -287,4 +288,3 @@ RTR3DECL(int) RTPathSetOwnerEx(const cha
+              pszPath, pszPath, uid, gid, rc));
+     return rc;
+ }
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_Runtime_r3_posix_semevent-posix.cpp b/virtualbox-svn/patches/patch-src_VBox_Runtime_r3_posix_semevent-posix.cpp
new file mode 100644
index 0000000..94c691b
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Runtime_r3_posix_semevent-posix.cpp
@@ -0,0 +1,18 @@
+$NetBSD$
+
+--- src/VBox/Runtime/r3/posix/semevent-posix.cpp.orig	2016-03-04 19:30:03.000000000 +0000
++++ src/VBox/Runtime/r3/posix/semevent-posix.cpp
+@@ -49,7 +49,7 @@
+ # define pthread_yield() pthread_yield_np()
+ #endif
+ 
+-#if defined(RT_OS_SOLARIS) || defined(RT_OS_HAIKU)
++#if defined(RT_OS_SOLARIS) || defined(RT_OS_HAIKU) || defined(RT_OS_NETBSD)
+ # include <sched.h>
+ # define pthread_yield() sched_yield()
+ #endif
+@@ -544,4 +544,3 @@ RTDECL(void) RTSemEventRemoveSignaller(R
+     RTLockValidatorRecSharedRemoveOwner(&pThis->Signallers, hThread);
+ #endif
+ }
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_Runtime_r3_posix_thread-posix.cpp b/virtualbox-svn/patches/patch-src_VBox_Runtime_r3_posix_thread-posix.cpp
new file mode 100644
index 0000000..39dbc02
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Runtime_r3_posix_thread-posix.cpp
@@ -0,0 +1,18 @@
+$NetBSD$
+
+--- src/VBox/Runtime/r3/posix/thread-posix.cpp.orig	2016-03-04 19:30:04.000000000 +0000
++++ src/VBox/Runtime/r3/posix/thread-posix.cpp
+@@ -414,7 +414,7 @@ RTR3DECL(int) RTThreadGetExecutionTimeMi
+     *pUserTime   = ts.ru_utime.tv_sec * 1000 + ts.ru_utime.tv_usec / 1000;
+     return VINF_SUCCESS;
+ 
+-#elif defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD)
++#elif defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+     /* on Linux, getrusage(RUSAGE_THREAD, ...) is available since 2.6.26 */
+     struct timespec ts;
+     int rc = clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ts);
+@@ -448,4 +448,3 @@ RTR3DECL(int) RTThreadGetExecutionTimeMi
+     return VERR_NOT_IMPLEMENTED;
+ #endif
+ }
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_Runtime_r3_posix_thread2-posix.cpp b/virtualbox-svn/patches/patch-src_VBox_Runtime_r3_posix_thread2-posix.cpp
new file mode 100644
index 0000000..ff77e9f
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Runtime_r3_posix_thread2-posix.cpp
@@ -0,0 +1,36 @@
+$NetBSD$
+
+--- src/VBox/Runtime/r3/posix/thread2-posix.cpp.orig	2016-03-04 19:30:04.000000000 +0000
++++ src/VBox/Runtime/r3/posix/thread2-posix.cpp
+@@ -62,7 +62,7 @@ RTDECL(int) RTThreadSleep(RTMSINTERVAL c
+         pthread_yield_np();
+ #elif defined(RT_OS_FREEBSD) /* void pthread_yield */
+         pthread_yield();
+-#elif defined(RT_OS_SOLARIS) || defined(RT_OS_HAIKU)
++#elif defined(RT_OS_SOLARIS) || defined(RT_OS_HAIKU) || defined(RT_OS_NETBSD)
+         sched_yield();
+ #else
+         if (!pthread_yield())
+@@ -101,7 +101,7 @@ RTDECL(int) RTThreadSleepNoLog(RTMSINTER
+         pthread_yield_np();
+ #elif defined(RT_OS_FREEBSD) /* void pthread_yield */
+         pthread_yield();
+-#elif defined(RT_OS_SOLARIS) || defined(RT_OS_HAIKU)
++#elif defined(RT_OS_SOLARIS) || defined(RT_OS_HAIKU) || defined(RT_OS_NETBSD)
+         sched_yield();
+ #else
+         if (!pthread_yield())
+@@ -130,7 +130,7 @@ RTDECL(bool) RTThreadYield(void)
+ #endif
+ #ifdef RT_OS_DARWIN
+     pthread_yield_np();
+-#elif defined(RT_OS_SOLARIS) || defined(RT_OS_HAIKU)
++#elif defined(RT_OS_SOLARIS) || defined(RT_OS_HAIKU) || defined(RT_OS_NETBSD)
+     sched_yield();
+ #else
+     pthread_yield();
+@@ -144,4 +144,3 @@ RTDECL(bool) RTThreadYield(void)
+ #endif
+     return fRc;
+ }
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_Runtime_r3_posix_utf8-posix.cpp b/virtualbox-svn/patches/patch-src_VBox_Runtime_r3_posix_utf8-posix.cpp
new file mode 100644
index 0000000..b4396b3
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Runtime_r3_posix_utf8-posix.cpp
@@ -0,0 +1,18 @@
+$NetBSD$
+
+--- src/VBox/Runtime/r3/posix/utf8-posix.cpp.orig	2016-03-04 19:30:04.000000000 +0000
++++ src/VBox/Runtime/r3/posix/utf8-posix.cpp
+@@ -173,7 +173,7 @@ static int rtstrConvertCached(const void
+         iconv_t hIconv = (iconv_t)*phIconv;
+         if (hIconv == (iconv_t)-1)
+         {
+-#ifdef RT_OS_SOLARIS
++#if defined(RT_OS_SOLARIS) || defined(RT_OS_NETBSD)
+             /* Solaris doesn't grok empty codeset strings, so help it find the current codeset. */
+             if (!*pszInputCS)
+                 pszInputCS = rtStrGetLocaleCodeset();
+@@ -494,4 +494,3 @@ RTR3DECL(int)  RTStrCurrentCPToUtf8Tag(c
+     }
+     return rtStrConvertWrapper(pszString, cch, "", ppszString, 0, "UTF-8", 2, RTSTRICONV_LOCALE_TO_UTF8);
+ }
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_Storage_testcase_Makefile.kmk b/virtualbox-svn/patches/patch-src_VBox_Storage_testcase_Makefile.kmk
new file mode 100644
index 0000000..b60b121
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_Storage_testcase_Makefile.kmk
@@ -0,0 +1,9 @@
+$NetBSD$
+
+--- src/VBox/Storage/testcase/Makefile.kmk.orig	2016-03-04 19:30:09.000000000 +0000
++++ src/VBox/Storage/testcase/Makefile.kmk
+@@ -169,4 +169,3 @@ if defined(VBOX_WITH_TESTCASES) || defin
+ endif
+ 
+ include $(FILE_KBUILD_SUB_FOOTER)
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_VMM_VMMR0_GMMR0.cpp b/virtualbox-svn/patches/patch-src_VBox_VMM_VMMR0_GMMR0.cpp
new file mode 100644
index 0000000..6146523
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_VMM_VMMR0_GMMR0.cpp
@@ -0,0 +1,18 @@
+$NetBSD$
+
+--- src/VBox/VMM/VMMR0/GMMR0.cpp.orig	2016-03-04 19:30:11.000000000 +0000
++++ src/VBox/VMM/VMMR0/GMMR0.cpp
+@@ -809,7 +809,7 @@ GMMR0DECL(int) GMMR0Init(void)
+             else
+                 SUPR0Printf("GMMR0Init: RTR0MemObjAllocPhysNC(,64K,Any) -> %d!\n", rc);
+ #else
+-# if defined(RT_OS_WINDOWS) || (defined(RT_OS_SOLARIS) && ARCH_BITS == 64) || defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD)
++# if defined(RT_OS_WINDOWS) || (defined(RT_OS_SOLARIS) && ARCH_BITS == 64) || defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+             pGMM->fLegacyAllocationMode = false;
+ #  if ARCH_BITS == 32
+             /* Don't reuse possibly partial chunks because of the virtual
+@@ -5472,4 +5472,3 @@ GMMR0DECL(int) GMMR0ResetStatisticsReq(P
+ 
+     return GMMR0ResetStatistics(&pReq->Stats, pReq->pSession, pVM);
+ }
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_VMM_VMMR0_VMMR0.cpp b/virtualbox-svn/patches/patch-src_VBox_VMM_VMMR0_VMMR0.cpp
new file mode 100644
index 0000000..9da86bc
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_VMM_VMMR0_VMMR0.cpp
@@ -0,0 +1,27 @@
+$NetBSD$
+
+--- src/VBox/VMM/VMMR0/VMMR0.cpp.orig	2016-03-04 19:30:11.000000000 +0000
++++ src/VBox/VMM/VMMR0/VMMR0.cpp
+@@ -122,7 +122,7 @@
+ *   Internal Functions                                                                                                           *
+ *********************************************************************************************************************************/
+ RT_C_DECLS_BEGIN
+-#if defined(RT_ARCH_X86) && (defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD))
++#if defined(RT_ARCH_X86) && (defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD))
+ extern uint64_t __udivdi3(uint64_t, uint64_t);
+ extern uint64_t __umoddi3(uint64_t, uint64_t);
+ #endif
+@@ -138,7 +138,7 @@ PFNRT g_VMMR0Deps[] =
+ {
+     (PFNRT)RTCrc32,
+     (PFNRT)RTOnce,
+-#if defined(RT_ARCH_X86) && (defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD))
++#if defined(RT_ARCH_X86) && (defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD))
+     (PFNRT)__udivdi3,
+     (PFNRT)__umoddi3,
+ #endif
+@@ -2284,4 +2284,3 @@ DECLEXPORT(void) RTCALL RTAssertMsg2Weak
+      */
+     RTAssertMsg2V(pszFormat, va);
+ }
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_VMM_VMMR3_PGMPhys.cpp b/virtualbox-svn/patches/patch-src_VBox_VMM_VMMR3_PGMPhys.cpp
new file mode 100644
index 0000000..1e6c737
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_VMM_VMMR3_PGMPhys.cpp
@@ -0,0 +1,36 @@
+$NetBSD$
+
+--- src/VBox/VMM/VMMR3/PGMPhys.cpp.orig	2016-03-04 19:30:12.000000000 +0000
++++ src/VBox/VMM/VMMR3/PGMPhys.cpp
+@@ -926,7 +926,7 @@ static int pgmR3PhysFreePageRange(PVM pV
+     return rc;
+ }
+ 
+-#if HC_ARCH_BITS == 64 && (defined(RT_OS_WINDOWS) || defined(RT_OS_SOLARIS) || defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD))
++#if HC_ARCH_BITS == 64 && (defined(RT_OS_WINDOWS) || defined(RT_OS_SOLARIS) || defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD))
+ 
+ /**
+  * Rendezvous callback used by PGMR3ChangeMemBalloon that changes the memory balloon size
+@@ -1071,7 +1071,7 @@ static DECLCALLBACK(void) pgmR3PhysChang
+     RTMemFree(paPhysPage);
+ }
+ 
+-#endif /* 64-bit host && (Windows || Solaris || Linux || FreeBSD) */
++#endif /* 64-bit host && (Windows || Solaris || Linux || FreeBSD || NetBSD) */
+ 
+ /**
+  * Inflate or deflate a memory balloon
+@@ -1085,7 +1085,7 @@ static DECLCALLBACK(void) pgmR3PhysChang
+ VMMR3DECL(int) PGMR3PhysChangeMemBalloon(PVM pVM, bool fInflate, unsigned cPages, RTGCPHYS *paPhysPage)
+ {
+     /* This must match GMMR0Init; currently we only support memory ballooning on all 64-bit hosts except Mac OS X */
+-#if HC_ARCH_BITS == 64 && (defined(RT_OS_WINDOWS) || defined(RT_OS_SOLARIS) || defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD))
++#if HC_ARCH_BITS == 64 && (defined(RT_OS_WINDOWS) || defined(RT_OS_SOLARIS) || defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD))
+     int rc;
+ 
+     /* Older additions (ancient non-functioning balloon code) pass wrong physical addresses. */
+@@ -4652,4 +4652,3 @@ VMMR3DECL(int) PGMR3PhysTlbGCPhys2Ptr(PV
+     pgmUnlock(pVM);
+     return rc;
+ }
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_VMM_VMMR3_SSM.cpp b/virtualbox-svn/patches/patch-src_VBox_VMM_VMMR3_SSM.cpp
new file mode 100644
index 0000000..ffc1297
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_VMM_VMMR3_SSM.cpp
@@ -0,0 +1,442 @@
+$NetBSD$
+
+--- src/VBox/VMM/VMMR3/SSM.cpp.orig	2016-03-04 19:30:12.000000000 +0000
++++ src/VBox/VMM/VMMR3/SSM.cpp
+@@ -456,7 +456,7 @@ typedef struct SSMHANDLE
+     SSMSTRM                 Strm;
+ 
+     /** Pointer to the VM. */
+-    PVM                     pVM;
++    vbox_PVM                     pVM;
+     /** The current operation. */
+     SSMSTATE                enmOp;
+     /** What to do after save completes. (move the enum) */
+@@ -877,12 +877,12 @@ static uint8_t const    g_abZero[_1K] = 
+ *   Internal Functions                                                                                                           *
+ *********************************************************************************************************************************/
+ #ifndef SSM_STANDALONE
+-static int                  ssmR3LazyInit(PVM pVM);
+-static DECLCALLBACK(int)    ssmR3SelfLiveExec(PVM pVM, PSSMHANDLE pSSM, uint32_t uPass);
+-static DECLCALLBACK(int)    ssmR3SelfSaveExec(PVM pVM, PSSMHANDLE pSSM);
+-static DECLCALLBACK(int)    ssmR3SelfLoadExec(PVM pVM, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass);
+-static DECLCALLBACK(int)    ssmR3LiveControlLoadExec(PVM pVM, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass);
+-static int                  ssmR3Register(PVM pVM, const char *pszName, uint32_t uInstance, uint32_t uVersion, size_t cbGuess, const char *pszBefore, PSSMUNIT *ppUnit);
++static int                  ssmR3LazyInit(vbox_PVM pVM);
++static DECLCALLBACK(int)    ssmR3SelfLiveExec(vbox_PVM pVM, PSSMHANDLE pSSM, uint32_t uPass);
++static DECLCALLBACK(int)    ssmR3SelfSaveExec(vbox_PVM pVM, PSSMHANDLE pSSM);
++static DECLCALLBACK(int)    ssmR3SelfLoadExec(vbox_PVM pVM, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass);
++static DECLCALLBACK(int)    ssmR3LiveControlLoadExec(vbox_PVM pVM, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass);
++static int                  ssmR3Register(vbox_PVM pVM, const char *pszName, uint32_t uInstance, uint32_t uVersion, size_t cbGuess, const char *pszBefore, PSSMUNIT *ppUnit);
+ static int                  ssmR3LiveControlEmit(PSSMHANDLE pSSM, long double lrdPct, uint32_t uPass);
+ #endif
+ 
+@@ -902,7 +902,7 @@ static int                  ssmR3DataRea
+  *
+  * @param   pVM                 The cross context VM structure.
+  */
+-VMMR3_INT_DECL(void) SSMR3Term(PVM pVM)
++VMMR3_INT_DECL(void) SSMR3Term(vbox_PVM pVM)
+ {
+     if (pVM->ssm.s.fInitialized)
+     {
+@@ -918,7 +918,7 @@ VMMR3_INT_DECL(void) SSMR3Term(PVM pVM)
+  * @returns VBox status code.
+  * @param   pVM         The cross context VM structure.
+  */
+-static int ssmR3LazyInit(PVM pVM)
++static int ssmR3LazyInit(vbox_PVM pVM)
+ {
+     /*
+      * Register a saved state unit which we use to put the VirtualBox version,
+@@ -958,7 +958,7 @@ static int ssmR3LazyInit(PVM pVM)
+  * @param   pSSM            The SSM handle.
+  * @param   uPass           The data pass number.
+  */
+-static DECLCALLBACK(int) ssmR3SelfLiveExec(PVM pVM, PSSMHANDLE pSSM, uint32_t uPass)
++static DECLCALLBACK(int) ssmR3SelfLiveExec(vbox_PVM pVM, PSSMHANDLE pSSM, uint32_t uPass)
+ {
+     if (uPass == 0)
+     {
+@@ -980,7 +980,7 @@ static DECLCALLBACK(int) ssmR3SelfLiveEx
+  * @param   pVM             The cross context VM structure.
+  * @param   pSSM            The SSM handle.
+  */
+-static DECLCALLBACK(int) ssmR3SelfSaveExec(PVM pVM, PSSMHANDLE pSSM)
++static DECLCALLBACK(int) ssmR3SelfSaveExec(vbox_PVM pVM, PSSMHANDLE pSSM)
+ {
+     NOREF(pVM);
+ 
+@@ -1012,7 +1012,7 @@ static DECLCALLBACK(int) ssmR3SelfSaveEx
+  * @param   uVersion        The version (1).
+  * @param   uPass           The pass.
+  */
+-static DECLCALLBACK(int) ssmR3SelfLoadExec(PVM pVM, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass)
++static DECLCALLBACK(int) ssmR3SelfLoadExec(vbox_PVM pVM, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass)
+ {
+     AssertLogRelMsgReturn(uVersion == 1, ("%d\n", uVersion), VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION);
+     NOREF(pVM); NOREF(uPass);
+@@ -1076,7 +1076,7 @@ static DECLCALLBACK(int) ssmR3SelfLoadEx
+  * @param   uVersion        The version (1).
+  * @param   uPass           The pass.
+  */
+-static DECLCALLBACK(int) ssmR3LiveControlLoadExec(PVM pVM, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass)
++static DECLCALLBACK(int) ssmR3LiveControlLoadExec(vbox_PVM pVM, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass)
+ {
+     AssertLogRelMsgReturn(uVersion == 1, ("%d\n", uVersion), VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION);
+     NOREF(uPass);
+@@ -1115,7 +1115,7 @@ static DECLCALLBACK(int) ssmR3LiveContro
+  * @param   ppUnit          Where to store the inserted unit node.
+  *                          Caller must fill in the missing details.
+  */
+-static int ssmR3Register(PVM pVM, const char *pszName, uint32_t uInstance,
++static int ssmR3Register(vbox_PVM pVM, const char *pszName, uint32_t uInstance,
+                          uint32_t uVersion, size_t cbGuess, const char *pszBefore, PSSMUNIT *ppUnit)
+ {
+     /*
+@@ -1235,7 +1235,7 @@ static int ssmR3Register(PVM pVM, const 
+  * @param   pfnLoadDone     Done load callback, optional.
+  */
+ VMMR3_INT_DECL(int)
+-SSMR3RegisterDevice(PVM pVM, PPDMDEVINS pDevIns, const char *pszName,
++SSMR3RegisterDevice(vbox_PVM pVM, PPDMDEVINS pDevIns, const char *pszName,
+                     uint32_t uInstance, uint32_t uVersion, size_t cbGuess, const char *pszBefore,
+                     PFNSSMDEVLIVEPREP pfnLivePrep, PFNSSMDEVLIVEEXEC pfnLiveExec, PFNSSMDEVLIVEVOTE pfnLiveVote,
+                     PFNSSMDEVSAVEPREP pfnSavePrep, PFNSSMDEVSAVEEXEC pfnSaveExec, PFNSSMDEVSAVEDONE pfnSaveDone,
+@@ -1289,7 +1289,7 @@ SSMR3RegisterDevice(PVM pVM, PPDMDEVINS 
+  * @param   pfnLoadDone     Done load callback, optional.
+  */
+ VMMR3_INT_DECL(int)
+-SSMR3RegisterDriver(PVM pVM, PPDMDRVINS pDrvIns, const char *pszName, uint32_t uInstance, uint32_t uVersion, size_t cbGuess,
++SSMR3RegisterDriver(vbox_PVM pVM, PPDMDRVINS pDrvIns, const char *pszName, uint32_t uInstance, uint32_t uVersion, size_t cbGuess,
+                     PFNSSMDRVLIVEPREP pfnLivePrep, PFNSSMDRVLIVEEXEC pfnLiveExec, PFNSSMDRVLIVEVOTE pfnLiveVote,
+                     PFNSSMDRVSAVEPREP pfnSavePrep, PFNSSMDRVSAVEEXEC pfnSaveExec, PFNSSMDRVSAVEDONE pfnSaveDone,
+                     PFNSSMDRVLOADPREP pfnLoadPrep, PFNSSMDRVLOADEXEC pfnLoadExec, PFNSSMDRVLOADDONE pfnLoadDone)
+@@ -1341,7 +1341,7 @@ SSMR3RegisterDriver(PVM pVM, PPDMDRVINS 
+  * @param   pfnLoadDone     Done load callback, optional.
+  */
+ VMMR3_INT_DECL(int)
+-SSMR3RegisterUsb(PVM pVM, PPDMUSBINS pUsbIns, const char *pszName, uint32_t uInstance, uint32_t uVersion, size_t cbGuess,
++SSMR3RegisterUsb(vbox_PVM pVM, PPDMUSBINS pUsbIns, const char *pszName, uint32_t uInstance, uint32_t uVersion, size_t cbGuess,
+                  PFNSSMUSBLIVEPREP pfnLivePrep, PFNSSMUSBLIVEEXEC pfnLiveExec, PFNSSMUSBLIVEVOTE pfnLiveVote,
+                  PFNSSMUSBSAVEPREP pfnSavePrep, PFNSSMUSBSAVEEXEC pfnSaveExec, PFNSSMUSBSAVEDONE pfnSaveDone,
+                  PFNSSMUSBLOADPREP pfnLoadPrep, PFNSSMUSBLOADEXEC pfnLoadExec, PFNSSMUSBLOADDONE pfnLoadDone)
+@@ -1391,7 +1391,7 @@ SSMR3RegisterUsb(PVM pVM, PPDMUSBINS pUs
+  * @param   pfnLoadExec     Execute load callback, optional.
+  * @param   pfnLoadDone     Done load callback, optional.
+  */
+-VMMR3DECL(int) SSMR3RegisterInternal(PVM pVM, const char *pszName, uint32_t uInstance, uint32_t uVersion, size_t cbGuess,
++VMMR3DECL(int) SSMR3RegisterInternal(vbox_PVM pVM, const char *pszName, uint32_t uInstance, uint32_t uVersion, size_t cbGuess,
+     PFNSSMINTLIVEPREP pfnLivePrep, PFNSSMINTLIVEEXEC pfnLiveExec, PFNSSMINTLIVEVOTE pfnLiveVote,
+     PFNSSMINTSAVEPREP pfnSavePrep, PFNSSMINTSAVEEXEC pfnSaveExec, PFNSSMINTSAVEDONE pfnSaveDone,
+     PFNSSMINTLOADPREP pfnLoadPrep, PFNSSMINTLOADEXEC pfnLoadExec, PFNSSMINTLOADDONE pfnLoadDone)
+@@ -1447,7 +1447,7 @@ VMMR3DECL(int) SSMR3RegisterExternal(PUV
+     PFNSSMEXTLOADPREP pfnLoadPrep, PFNSSMEXTLOADEXEC pfnLoadExec, PFNSSMEXTLOADDONE pfnLoadDone, void *pvUser)
+ {
+     UVM_ASSERT_VALID_EXT_RETURN(pUVM, VERR_INVALID_VM_HANDLE);
+-    PVM pVM = pUVM->pVM;
++    vbox_PVM pVM = pUVM->pVM;
+     VM_ASSERT_VALID_EXT_RETURN(pVM, VERR_INVALID_VM_HANDLE);
+ 
+     PSSMUNIT pUnit;
+@@ -1474,7 +1474,7 @@ VMMR3DECL(int) SSMR3RegisterExternal(PUV
+  * @callback_method_impl{FNSSMINTLOADEXEC,
+  * Stub that skips the whole unit (see SSMR3RegisterStub).}
+  */
+-static DECLCALLBACK(int) ssmR3LoadExecStub(PVM pVM, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass)
++static DECLCALLBACK(int) ssmR3LoadExecStub(vbox_PVM pVM, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass)
+ {
+     NOREF(pVM); NOREF(uVersion); NOREF(uPass);
+     return SSMR3SkipToEndOfUnit(pSSM);
+@@ -1492,7 +1492,7 @@ static DECLCALLBACK(int) ssmR3LoadExecSt
+  * @param   pszName             Data unit name.
+  * @param   uInstance           Instance number.
+  */
+-VMMR3DECL(int) SSMR3RegisterStub(PVM pVM, const char *pszName, uint32_t uInstance)
++VMMR3DECL(int) SSMR3RegisterStub(vbox_PVM pVM, const char *pszName, uint32_t uInstance)
+ {
+     return SSMR3RegisterInternal(pVM, pszName, uInstance, UINT32_MAX, 0,
+                                  NULL, NULL, NULL,
+@@ -1514,7 +1514,7 @@ VMMR3DECL(int) SSMR3RegisterStub(PVM pVM
+  *                          This must together with the name be unique.
+  * @remark  Only for dynamic data units and dynamic unloaded modules.
+  */
+-VMMR3_INT_DECL(int) SSMR3DeregisterDevice(PVM pVM, PPDMDEVINS pDevIns, const char *pszName, uint32_t uInstance)
++VMMR3_INT_DECL(int) SSMR3DeregisterDevice(vbox_PVM pVM, PPDMDEVINS pDevIns, const char *pszName, uint32_t uInstance)
+ {
+     /*
+      * Validate input.
+@@ -1590,7 +1590,7 @@ VMMR3_INT_DECL(int) SSMR3DeregisterDevic
+  *                          This must together with the name be unique. Ignored if pszName is NULL.
+  * @remark  Only for dynamic data units and dynamic unloaded modules.
+  */
+-VMMR3_INT_DECL(int) SSMR3DeregisterDriver(PVM pVM, PPDMDRVINS pDrvIns, const char *pszName, uint32_t uInstance)
++VMMR3_INT_DECL(int) SSMR3DeregisterDriver(vbox_PVM pVM, PPDMDRVINS pDrvIns, const char *pszName, uint32_t uInstance)
+ {
+     /*
+      * Validate input.
+@@ -1664,7 +1664,7 @@ VMMR3_INT_DECL(int) SSMR3DeregisterDrive
+  *                          This must together with the name be unique. Ignored if pszName is NULL.
+  * @remark  Only for dynamic data units and dynamic unloaded modules.
+  */
+-VMMR3_INT_DECL(int) SSMR3DeregisterUsb(PVM pVM, PPDMUSBINS pUsbIns, const char *pszName, uint32_t uInstance)
++VMMR3_INT_DECL(int) SSMR3DeregisterUsb(vbox_PVM pVM, PPDMUSBINS pUsbIns, const char *pszName, uint32_t uInstance)
+ {
+     /*
+      * Validate input.
+@@ -1731,7 +1731,7 @@ VMMR3_INT_DECL(int) SSMR3DeregisterUsb(P
+  * @param   pszName         Data unit name.
+  * @remark  Only for dynamic data units.
+  */
+-static int ssmR3DeregisterByNameAndType(PVM pVM, const char *pszName, SSMUNITTYPE enmType)
++static int ssmR3DeregisterByNameAndType(vbox_PVM pVM, const char *pszName, SSMUNITTYPE enmType)
+ {
+     /*
+      * Validate input.
+@@ -1787,7 +1787,7 @@ static int ssmR3DeregisterByNameAndType(
+  * @param   pszName         Data unit name.
+  * @remark  Only for dynamic data units.
+  */
+-VMMR3DECL(int) SSMR3DeregisterInternal(PVM pVM, const char *pszName)
++VMMR3DECL(int) SSMR3DeregisterInternal(vbox_PVM pVM, const char *pszName)
+ {
+     return ssmR3DeregisterByNameAndType(pVM, pszName, SSMUNITTYPE_INTERNAL);
+ }
+@@ -1804,7 +1804,7 @@ VMMR3DECL(int) SSMR3DeregisterInternal(P
+ VMMR3DECL(int) SSMR3DeregisterExternal(PUVM pUVM, const char *pszName)
+ {
+     UVM_ASSERT_VALID_EXT_RETURN(pUVM, VERR_INVALID_VM_HANDLE);
+-    PVM pVM = pUVM->pVM;
++    vbox_PVM pVM = pUVM->pVM;
+     VM_ASSERT_VALID_EXT_RETURN(pVM, VERR_INVALID_VM_HANDLE);
+ 
+     return ssmR3DeregisterByNameAndType(pVM, pszName, SSMUNITTYPE_EXTERNAL);
+@@ -3206,7 +3206,7 @@ static void ssmR3ProgressByByte(PSSMHAND
+  * @param   pSSM            The saved state handle. (SSMHANDLE::rc may be set.)
+  * @param   fCancellable    The new state.
+  */
+-static void ssmR3SetCancellable(PVM pVM, PSSMHANDLE pSSM, bool fCancellable)
++static void ssmR3SetCancellable(vbox_PVM pVM, PSSMHANDLE pSSM, bool fCancellable)
+ {
+     RTCritSectEnter(&pVM->ssm.s.CancelCritSect);
+     if (fCancellable)
+@@ -4508,7 +4508,7 @@ DECLINLINE(void) ssmR3UnitCritSectLeave(
+  * @param   pVM                 The cross context VM structure.
+  * @param   pSSM                The saved state handle.
+  */
+-static int ssmR3SaveDoDoneRun(PVM pVM, PSSMHANDLE pSSM)
++static int ssmR3SaveDoDoneRun(vbox_PVM pVM, PSSMHANDLE pSSM)
+ {
+     VM_ASSERT_EMT0(pVM);
+ 
+@@ -4569,7 +4569,7 @@ static int ssmR3SaveDoDoneRun(PVM pVM, P
+  * @param   pVM                 The cross context VM structure.
+  * @param   pSSM                The saved state handle.
+  */
+-static int ssmR3SaveDoClose(PVM pVM, PSSMHANDLE pSSM)
++static int ssmR3SaveDoClose(vbox_PVM pVM, PSSMHANDLE pSSM)
+ {
+     VM_ASSERT_EMT0(pVM);
+     pVM->ssm.s.uPass = 0;
+@@ -4642,7 +4642,7 @@ VMMR3_INT_DECL(int) SSMR3LiveDone(PSSMHA
+      * Validate input.
+      */
+     AssertPtrReturn(pSSM, VERR_INVALID_POINTER);
+-    PVM pVM = pSSM->pVM;
++    vbox_PVM pVM = pSSM->pVM;
+     VM_ASSERT_VALID_EXT_RETURN(pVM, VERR_INVALID_VM_HANDLE);
+     VM_ASSERT_EMT0(pVM);
+     AssertMsgReturn(   pSSM->enmAfter == SSMAFTER_DESTROY
+@@ -4669,7 +4669,7 @@ VMMR3_INT_DECL(int) SSMR3LiveDone(PSSMHA
+  * @param   pSSM                The SSM handle.
+  * @param   pcEntries           Where to return the number of directory entries.
+  */
+-static int ssmR3WriteDirectory(PVM pVM, PSSMHANDLE pSSM, uint32_t *pcEntries)
++static int ssmR3WriteDirectory(vbox_PVM pVM, PSSMHANDLE pSSM, uint32_t *pcEntries)
+ {
+     VM_ASSERT_EMT0(pVM);
+ 
+@@ -4723,7 +4723,7 @@ static int ssmR3WriteDirectory(PVM pVM, 
+  * @param   pVM                 The cross context VM structure.
+  * @param   pSSM                The saved state handle.
+  */
+-static int ssmR3SaveDoFinalization(PVM pVM, PSSMHANDLE pSSM)
++static int ssmR3SaveDoFinalization(vbox_PVM pVM, PSSMHANDLE pSSM)
+ {
+     VM_ASSERT_EMT0(pVM);
+     Assert(RT_SUCCESS(pSSM->rc));
+@@ -4814,7 +4814,7 @@ static void ssmR3ProgressByUnit(PSSMHAND
+  * @param   pVM                 The cross context VM structure.
+  * @param   pSSM                The saved state handle.
+  */
+-static int ssmR3SaveDoExecRun(PVM pVM, PSSMHANDLE pSSM)
++static int ssmR3SaveDoExecRun(vbox_PVM pVM, PSSMHANDLE pSSM)
+ {
+     VM_ASSERT_EMT0(pVM);
+     AssertRC(pSSM->rc);
+@@ -4959,7 +4959,7 @@ static int ssmR3SaveDoExecRun(PVM pVM, P
+  * @param   pVM                 The cross context VM structure.
+  * @param   pSSM                The saved state handle.
+  */
+-static int ssmR3SaveDoPrepRun(PVM pVM, PSSMHANDLE pSSM)
++static int ssmR3SaveDoPrepRun(vbox_PVM pVM, PSSMHANDLE pSSM)
+ {
+     VM_ASSERT_EMT0(pVM);
+     Assert(RT_SUCCESS(pSSM->rc));
+@@ -5027,7 +5027,7 @@ static int ssmR3SaveDoPrepRun(PVM pVM, P
+  *
+  * @thread  EMT(0)
+  */
+-static int ssmR3SaveDoCommon(PVM pVM, PSSMHANDLE pSSM)
++static int ssmR3SaveDoCommon(vbox_PVM pVM, PSSMHANDLE pSSM)
+ {
+     VM_ASSERT_EMT0(pVM);
+ 
+@@ -5067,7 +5067,7 @@ VMMR3_INT_DECL(int) SSMR3LiveDoStep2(PSS
+      * Validate input.
+      */
+     AssertPtrReturn(pSSM, VERR_INVALID_POINTER);
+-    PVM pVM = pSSM->pVM;
++    vbox_PVM pVM = pSSM->pVM;
+     VM_ASSERT_VALID_EXT_RETURN(pVM, VERR_INVALID_VM_HANDLE);
+     VM_ASSERT_EMT0(pVM);
+     AssertMsgReturn(   pSSM->enmAfter == SSMAFTER_DESTROY
+@@ -5092,7 +5092,7 @@ VMMR3_INT_DECL(int) SSMR3LiveDoStep2(PSS
+  * @param   pVM                 The cross context VM structure.
+  * @param   pSSM                The SSM handle.
+  */
+-static int ssmR3WriteHeaderAndClearPerUnitData(PVM pVM, PSSMHANDLE pSSM)
++static int ssmR3WriteHeaderAndClearPerUnitData(vbox_PVM pVM, PSSMHANDLE pSSM)
+ {
+     /*
+      * Write the header.
+@@ -5148,7 +5148,7 @@ static int ssmR3WriteHeaderAndClearPerUn
+  *                              handle upon successful return.  Free it using
+  *                              RTMemFree after closing the stream.
+  */
+-static int ssmR3SaveDoCreateFile(PVM pVM, const char *pszFilename, PCSSMSTRMOPS pStreamOps, void *pvStreamOpsUser,
++static int ssmR3SaveDoCreateFile(vbox_PVM pVM, const char *pszFilename, PCSSMSTRMOPS pStreamOps, void *pvStreamOpsUser,
+                                  SSMAFTER enmAfter, PFNVMPROGRESS pfnProgress, void *pvProgressUser, PSSMHANDLE *ppSSM)
+ {
+     PSSMHANDLE pSSM = (PSSMHANDLE)RTMemAllocZ(sizeof(*pSSM));
+@@ -5212,7 +5212,7 @@ static int ssmR3SaveDoCreateFile(PVM pVM
+  *
+  * @thread  EMT
+  */
+-VMMR3DECL(int) SSMR3Save(PVM pVM, const char *pszFilename, PCSSMSTRMOPS pStreamOps, void *pvStreamOpsUser,
++VMMR3DECL(int) SSMR3Save(vbox_PVM pVM, const char *pszFilename, PCSSMSTRMOPS pStreamOps, void *pvStreamOpsUser,
+                          SSMAFTER enmAfter, PFNVMPROGRESS pfnProgress, void *pvUser)
+ {
+     LogFlow(("SSMR3Save: pszFilename=%p:{%s} enmAfter=%d pfnProgress=%p pvUser=%p\n", pszFilename, pszFilename, enmAfter, pfnProgress, pvUser));
+@@ -5299,7 +5299,7 @@ VMMR3DECL(void) SSMR3HandleReportLivePer
+  * @param   pSSM                The saved state handle.
+  * @param   uPass               The current pass.
+  */
+-static int ssmR3LiveDoVoteRun(PVM pVM, PSSMHANDLE pSSM, uint32_t uPass)
++static int ssmR3LiveDoVoteRun(vbox_PVM pVM, PSSMHANDLE pSSM, uint32_t uPass)
+ {
+     int rcRet = VINF_SUCCESS;
+     AssertRC(pSSM->rc);
+@@ -5405,7 +5405,7 @@ static int ssmR3LiveDoVoteRun(PVM pVM, P
+  * @param   pSSM                The saved state handle.
+  * @param   uPass               The current pass.
+  */
+-static int ssmR3LiveDoExecRun(PVM pVM, PSSMHANDLE pSSM, uint32_t uPass)
++static int ssmR3LiveDoExecRun(vbox_PVM pVM, PSSMHANDLE pSSM, uint32_t uPass)
+ {
+     AssertRC(pSSM->rc);
+     pSSM->rc = VINF_SUCCESS;
+@@ -5536,7 +5536,7 @@ static int ssmR3LiveDoExecRun(PVM pVM, P
+  * @param   pVM                 The cross context VM structure.
+  * @param   pSSM                The saved state handle.
+  */
+-static int ssmR3DoLiveExecVoteLoop(PVM pVM, PSSMHANDLE pSSM)
++static int ssmR3DoLiveExecVoteLoop(vbox_PVM pVM, PSSMHANDLE pSSM)
+ {
+     /*
+      * Calc the max saved state size before we should give up because of insane
+@@ -5608,7 +5608,7 @@ static int ssmR3DoLiveExecVoteLoop(PVM p
+  * @param   pVM                 The cross context VM structure.
+  * @param   pSSM                The saved state handle.
+  */
+-static int ssmR3DoLivePrepRun(PVM pVM, PSSMHANDLE pSSM)
++static int ssmR3DoLivePrepRun(vbox_PVM pVM, PSSMHANDLE pSSM)
+ {
+     /*
+      * Do the prepare run.
+@@ -5686,7 +5686,7 @@ VMMR3_INT_DECL(int) SSMR3LiveDoStep1(PSS
+      * Validate input.
+      */
+     AssertPtrReturn(pSSM, VERR_INVALID_POINTER);
+-    PVM pVM = pSSM->pVM;
++    vbox_PVM pVM = pSSM->pVM;
+     VM_ASSERT_VALID_EXT_RETURN(pVM, VERR_INVALID_VM_HANDLE);
+     VM_ASSERT_OTHER_THREAD(pVM);
+     AssertMsgReturn(   pSSM->enmAfter == SSMAFTER_DESTROY
+@@ -5731,7 +5731,7 @@ VMMR3_INT_DECL(int) SSMR3LiveDoStep1(PSS
+  *
+  * @thread  EMT0
+  */
+-VMMR3_INT_DECL(int) SSMR3LiveSave(PVM pVM, uint32_t cMsMaxDowntime,
++VMMR3_INT_DECL(int) SSMR3LiveSave(vbox_PVM pVM, uint32_t cMsMaxDowntime,
+                                   const char *pszFilename, PCSSMSTRMOPS pStreamOps, void *pvStreamOpsUser,
+                                   SSMAFTER enmAfter, PFNVMPROGRESS pfnProgress, void *pvProgressUser,
+                                   PSSMHANDLE *ppSSM)
+@@ -8011,7 +8011,7 @@ static int ssmR3HeaderAndValidate(PSSMHA
+  *                              completely initialized on success.
+  * @param   cBuffers            The number of stream buffers.
+  */
+-static int ssmR3OpenFile(PVM pVM, const char *pszFilename, PCSSMSTRMOPS pStreamOps, void *pvUser,
++static int ssmR3OpenFile(vbox_PVM pVM, const char *pszFilename, PCSSMSTRMOPS pStreamOps, void *pvUser,
+                          bool fChecksumIt, bool fChecksumOnRead, uint32_t cBuffers, PSSMHANDLE pSSM)
+ {
+     /*
+@@ -8283,7 +8283,7 @@ static void ssmR3StrmLogUnitContent(PSSM
+  * @param   pszName         Data unit name.
+  * @param   uInstance       The data unit instance id.
+  */
+-static PSSMUNIT ssmR3Find(PVM pVM, const char *pszName, uint32_t uInstance)
++static PSSMUNIT ssmR3Find(vbox_PVM pVM, const char *pszName, uint32_t uInstance)
+ {
+     size_t   cchName = strlen(pszName);
+     PSSMUNIT pUnit = pVM->ssm.s.pHead;
+@@ -8303,7 +8303,7 @@ static PSSMUNIT ssmR3Find(PVM pVM, const
+  * @param   pVM                 The cross context VM structure.
+  * @param   pSSM                The saved state handle.
+  */
+-static int ssmR3LoadExecV1(PVM pVM, PSSMHANDLE pSSM)
++static int ssmR3LoadExecV1(vbox_PVM pVM, PSSMHANDLE pSSM)
+ {
+     int     rc;
+     char   *pszName = NULL;
+@@ -8566,7 +8566,7 @@ static int ssmR3LoadDirectoryAndFooter(P
+  * @param   pVM                 The cross context VM structure.
+  * @param   pSSM                The saved state handle.
+  */
+-static int ssmR3LoadExecV2(PVM pVM, PSSMHANDLE pSSM)
++static int ssmR3LoadExecV2(vbox_PVM pVM, PSSMHANDLE pSSM)
+ {
+     pSSM->enmOp = SSMSTATE_LOAD_EXEC;
+     for (;;)
+@@ -8757,7 +8757,7 @@ static int ssmR3LoadExecV2(PVM pVM, PSSM
+  *
+  * @thread  EMT
+  */
+-VMMR3DECL(int) SSMR3Load(PVM pVM, const char *pszFilename, PCSSMSTRMOPS pStreamOps, void *pvStreamOpsUser,
++VMMR3DECL(int) SSMR3Load(vbox_PVM pVM, const char *pszFilename, PCSSMSTRMOPS pStreamOps, void *pvStreamOpsUser,
+                          SSMAFTER enmAfter, PFNVMPROGRESS pfnProgress, void *pvProgressUser)
+ {
+     LogFlow(("SSMR3Load: pszFilename=%p:{%s} pStreamOps=%p pvStreamOpsUser=%p enmAfter=%d pfnProgress=%p pvProgressUser=%p\n",
+@@ -9641,7 +9641,7 @@ VMMR3DECL(const char *) SSMR3HandleHostO
+ VMMR3DECL(int) SSMR3Cancel(PUVM pUVM)
+ {
+     UVM_ASSERT_VALID_EXT_RETURN(pUVM, VERR_INVALID_VM_HANDLE);
+-    PVM pVM = pUVM->pVM;
++    vbox_PVM pVM = pUVM->pVM;
+     VM_ASSERT_VALID_EXT_RETURN(pVM, VERR_INVALID_VM_HANDLE);
+ 
+     int rc = RTCritSectEnter(&pVM->ssm.s.CancelCritSect);
+@@ -9671,4 +9671,3 @@ VMMR3DECL(int) SSMR3Cancel(PUVM pUVM)
+     return rc;
+ }
+ #endif /* !SSM_STANDALONE */
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_VMM_VMMR3_VM.cpp b/virtualbox-svn/patches/patch-src_VBox_VMM_VMMR3_VM.cpp
new file mode 100644
index 0000000..01b248f
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_VMM_VMMR3_VM.cpp
@@ -0,0 +1,18 @@
+$NetBSD$
+
+--- src/VBox/VMM/VMMR3/VM.cpp.orig	2016-03-04 19:30:12.000000000 +0000
++++ src/VBox/VMM/VMMR3/VM.cpp
+@@ -410,7 +410,7 @@ VMMR3DECL(int)   VMR3Create(uint32_t cCp
+                                   "you the permission you need to access the device.");
+ # elif defined(RT_OS_WINDOWS)
+                     pszError = N_("VirtualBox kernel driver is not accessible, permission problem.");
+-# else /* solaris, freebsd, ++. */
++# else /* solaris, freebsd, netbsd, ++. */
+                     pszError = N_("VirtualBox kernel module is not accessible, permission problem. "
+                                   "If you have built VirtualBox yourself, make sure that you do "
+                                   "not have the vboxdrv kernel module from a different install loaded.");
+@@ -4510,4 +4510,3 @@ VMMR3DECL(int) VMR3SetPowerOffInsteadOfR
+     pVM->vm.s.fPowerOffInsteadOfReset = fPowerOffInsteadOfReset;
+     return VINF_SUCCESS;
+ }
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_VMM_VMMRC_VMMRCDeps.cpp b/virtualbox-svn/patches/patch-src_VBox_VMM_VMMRC_VMMRCDeps.cpp
new file mode 100644
index 0000000..6a40ed3
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_VMM_VMMRC_VMMRCDeps.cpp
@@ -0,0 +1,32 @@
+$NetBSD$
+
+--- src/VBox/VMM/VMMRC/VMMRCDeps.cpp.orig	2016-03-04 19:30:13.000000000 +0000
++++ src/VBox/VMM/VMMRC/VMMRCDeps.cpp
+@@ -18,12 +18,12 @@
+ #include <iprt/crc.h>
+ #include <iprt/string.h>
+ 
+-#if defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD)
++#if defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+ RT_C_DECLS_BEGIN
+ extern uint64_t __udivdi3(uint64_t, uint64_t);
+ extern uint64_t __umoddi3(uint64_t, uint64_t);
+ RT_C_DECLS_END
+-#endif // RT_OS_SOLARIS || RT_OS_FREEBSD
++#endif // RT_OS_SOLARIS || RT_OS_FREEBSD || RT_OS_NETBSD
+ 
+ PFNRT g_VMMRCDeps[] =
+ {
+@@ -32,10 +32,9 @@ PFNRT g_VMMRCDeps[] =
+     (PFNRT)memchr,
+     (PFNRT)memcmp,
+     (PFNRT)RTCrc32,
+-#if defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD)
++#if defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+     (PFNRT)__udivdi3,
+     (PFNRT)__umoddi3,
+-#endif // RT_OS_SOLARIS || RT_OS_FREEBSD
++#endif // RT_OS_SOLARIS || RT_OS_FREEBSD || RT_OS_NETBSD
+     NULL
+ };
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_VMM_include_CPUMInternal.h b/virtualbox-svn/patches/patch-src_VBox_VMM_include_CPUMInternal.h
new file mode 100644
index 0000000..3e3176d
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_VMM_include_CPUMInternal.h
@@ -0,0 +1,9 @@
+$NetBSD$
+
+--- src/VBox/VMM/include/CPUMInternal.h.orig	2016-07-10 20:46:01.000000000 +0000
++++ src/VBox/VMM/include/CPUMInternal.h
+@@ -562,4 +562,3 @@ RT_C_DECLS_END
+ /** @} */
+ 
+ #endif
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_VMM_testcase_mkdsk.sh b/virtualbox-svn/patches/patch-src_VBox_VMM_testcase_mkdsk.sh
new file mode 100644
index 0000000..96b374c
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_VMM_testcase_mkdsk.sh
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- src/VBox/VMM/testcase/mkdsk.sh.orig	2016-03-04 19:30:15.000000000 +0000
++++ src/VBox/VMM/testcase/mkdsk.sh
+@@ -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]"
diff --git a/virtualbox-svn/patches/patch-src_VBox_VMM_testcase_tstX86-1.cpp b/virtualbox-svn/patches/patch-src_VBox_VMM_testcase_tstX86-1.cpp
new file mode 100644
index 0000000..e8047bf
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_VMM_testcase_tstX86-1.cpp
@@ -0,0 +1,23 @@
+$NetBSD$
+
+--- src/VBox/VMM/testcase/tstX86-1.cpp.orig	2016-03-04 19:30:15.000000000 +0000
++++ src/VBox/VMM/testcase/tstX86-1.cpp
+@@ -112,6 +112,13 @@ static void sigHandler(int iSig, siginfo
+     uintptr_t   uErr    = ~(uintptr_t)0;
+     uintptr_t   uCr2    = ~(uintptr_t)0;
+ 
++# elif defined(RT_ARCH_AMD64) && defined(RT_OS_NETBSD)
++    uintptr_t  *puPC    = (uintptr_t *)&pCtx->pc;
++    uintptr_t  *puSP    = (uintptr_t *)&pCtx->sp;
++    uintptr_t   uTrapNo = ~(uintptr_t)0;
++    uintptr_t   uErr    = ~(uintptr_t)0;
++    uintptr_t   uCr2    = ~(uintptr_t)0;
++
+ # elif defined(RT_ARCH_AMD64)
+     uintptr_t  *puPC    = (uintptr_t *)&pCtx->uc_mcontext.gregs[REG_RIP];
+     uintptr_t  *puSP    = (uintptr_t *)&pCtx->uc_mcontext.gregs[REG_RSP];
+@@ -267,4 +274,3 @@ int main()
+ 
+     return RTTestSummaryAndDestroy(hTest);
+ }
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_ValidationKit_Makefile.kmk b/virtualbox-svn/patches/patch-src_VBox_ValidationKit_Makefile.kmk
new file mode 100644
index 0000000..dcf28e7
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_ValidationKit_Makefile.kmk
@@ -0,0 +1,45 @@
+$NetBSD$
+
+--- src/VBox/ValidationKit/Makefile.kmk.orig	2016-03-04 19:30:15.000000000 +0000
++++ src/VBox/ValidationKit/Makefile.kmk
+@@ -99,7 +99,7 @@ ifndef VBOX_WITHOUT_VALIDATIONKIT_ZIP
+ 			$$(filter $(PATH_STAGE)/$(INST_VALIDATIONKIT)%, $$($$(inst)_2_STAGE_TARGETS)))
+ 	$(call MSG_L1,Packing the Test Suite $@)
+ 	$(QUIET)$(RM) -f $@
+-	$(foreach os, darwin freebsd linux os2 solaris win,$(foreach arch, x86 amd64 \
++	$(foreach os, darwin freebsd netbsd linux os2 solaris win,$(foreach arch, x86 amd64 \
+ 	,$(if-expr defined(VBOX_WITH_VALIDATIONKIT_PACKING.$(os).$(arch))\
+ 		,$(NLTAB)$(QUIET)$(REDIRECT) -C $(PATH_OUT_BASE)/$(os).$(arch)/$(KBUILD_TYPE)/ \
+ 			-- zip$(HOSTSUFF_EXE) -r9 $@ $(INST_VALIDATIONKIT) -x '*.pyc',)))
+@@ -114,7 +114,7 @@ ifndef VBOX_WITHOUT_VALIDATIONKIT_ZIP
+  		$$(TestBoxHelper_2_STAGE_TARGETS)
+ 	$(call MSG_L1,Packing the TestBox Script files to $@)
+ 	$(QUIET)$(RM) -f $@
+-	$(foreach os, darwin freebsd linux os2 solaris win,$(foreach arch, x86 amd64 \
++	$(foreach os, darwin freebsd netbsd linux os2 solaris win,$(foreach arch, x86 amd64 \
+ 	,$(if-expr defined(VBOX_WITH_VALIDATIONKIT_PACKING.$(os).$(arch))\
+ 		,$(NLTAB)$(QUIET)$(REDIRECT) -C $(PATH_OUT_BASE)/$(os).$(arch)/$(KBUILD_TYPE)/ \
+ 			-- zip$(HOSTSUFF_EXE) -r9 $@ $(INST_TESTBOXSCRIPT) -x '*.pyc',)))
+@@ -153,7 +153,7 @@ ifneq ($(KBUILD_HOST),os2)
+ endif
+ 
+ # Generate VBOX_PATH_VALIDATIONKIT.os.arch variables.
+-$(foreach os, darwin freebsd linux os2 solaris win,$(foreach arch, x86 amd64, \
++$(foreach os, darwin freebsd netbsd linux os2 solaris win,$(foreach arch, x86 amd64, \
+ 	$(eval VBOX_PATH_VALIDATIONKIT.$(os).$(arch) = $(PATH_OUT_BASE)/$(os).$(arch)/$(KBUILD_TYPE)/$(INST_VALIDATIONKIT)$(os)/$(arch)) \
+ ))
+ 
+@@ -179,7 +179,7 @@ $(foreach os, os2 win,$(foreach arch, x8
+ 	$(eval $(def_vbox_validationkit_common_files)) \
+ ))
+ TMP_SUFF_EXE=
+-$(foreach os, darwin freebsd linux solaris,$(foreach arch, x86 amd64, \
++$(foreach os, darwin freebsd netbsd linux solaris,$(foreach arch, x86 amd64, \
+ 	$(eval $(def_vbox_validationkit_common_files)) \
+ ))
+ 
+@@ -269,4 +269,3 @@ endif
+ # Alias for creating the iso.
+ .PHONY: validationkit-iso
+ validationkit-iso: $(VBOX_PATH_VALIDATIONKIT)/VBoxValidationKit.iso
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_ValidationKit_testboxscript_testboxscript__real.py b/virtualbox-svn/patches/patch-src_VBox_ValidationKit_testboxscript_testboxscript__real.py
new file mode 100644
index 0000000..4a69d35
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_ValidationKit_testboxscript_testboxscript__real.py
@@ -0,0 +1,18 @@
+$NetBSD$
+
+--- src/VBox/ValidationKit/testboxscript/testboxscript_real.py.orig	2016-07-10 20:49:53.000000000 +0000
++++ src/VBox/ValidationKit/testboxscript/testboxscript_real.py
+@@ -267,7 +267,7 @@ class TestBoxScript(object):
+         # Platform specific mount code.
+         #
+         sHostOs = utils.getHostOs()
+-        if sHostOs in ('darwin', 'freebsd'):
++        if sHostOs in ('darwin', 'freebsd', 'netbsd'):
+             utils.sudoProcessCall(['/sbin/umount', sMountPoint]);
+             utils.sudoProcessCall(['/bin/mkdir', '-p', sMountPoint]);
+             utils.sudoProcessCall(['/usr/sbin/chown', str(os.getuid()), sMountPoint]); # pylint: disable=E1101
+@@ -1033,4 +1033,3 @@ class TestBoxScript(object):
+ if __name__ == '__main__':
+     sys.exit(TestBoxScript.main());
+ 
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_ValidationKit_testdriver_base.py b/virtualbox-svn/patches/patch-src_VBox_ValidationKit_testdriver_base.py
new file mode 100644
index 0000000..c1ad3cf
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_ValidationKit_testdriver_base.py
@@ -0,0 +1,17 @@
+$NetBSD$
+
+--- src/VBox/ValidationKit/testdriver/base.py.orig	2016-03-04 19:30:17.000000000 +0000
++++ src/VBox/ValidationKit/testdriver/base.py
+@@ -827,6 +827,7 @@ class TestDriverBase(object): # pylint: 
+         if self.sResourcePath is None:
+             if self.sHost == 'darwin':      self.sResourcePath = "/Volumes/testrsrc/";
+             elif self.sHost == 'freebsd':   self.sResourcePath = "/mnt/testrsrc/";
++            elif self.sHost == 'netbsd':   self.sResourcePath = "/mnt/testrsrc/";
+             elif self.sHost == 'linux':     self.sResourcePath = "/mnt/testrsrc/";
+             elif self.sHost == 'os2':       self.sResourcePath = "T:/";
+             elif self.sHost == 'solaris':   self.sResourcePath = "/mnt/testrsrc/";
+@@ -1719,4 +1720,3 @@ class TestDriverBaseTestCase(unittest.Te
+ if __name__ == '__main__':
+     unittest.main();
+     # not reached.
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_ValidationKit_testdriver_vbox.py b/virtualbox-svn/patches/patch-src_VBox_ValidationKit_testdriver_vbox.py
new file mode 100644
index 0000000..99a8a3c
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_ValidationKit_testdriver_vbox.py
@@ -0,0 +1,36 @@
+$NetBSD$
+
+--- src/VBox/ValidationKit/testdriver/vbox.py.orig	2016-03-04 19:30:17.000000000 +0000
++++ src/VBox/ValidationKit/testdriver/vbox.py
+@@ -1015,7 +1015,7 @@ class TestDriver(base.TestDriver):      
+         cMsFudge      = 1;
+         sVBoxSVC      = '%s/VBoxSVC' % (self.oBuild.sInstallPath,); ## @todo .exe and stuff.
+         if self.fVBoxSvcInDebugger:
+-            if self.sHost in ('darwin', 'freebsd', 'linux', 'solaris', ):
++            if self.sHost in ('darwin', 'freebsd', 'linux', 'solaris', 'netbsd'):
+                 # Start VBoxSVC in gdb in a new terminal.
+                 #sTerm = '/usr/bin/gnome-terminal'; - doesn't work, some fork+exec stuff confusing us.
+                 sTerm = '/usr/bin/xterm';
+@@ -1057,7 +1057,7 @@ class TestDriver(base.TestDriver):      
+             else:
+                 reporter.error('Port me!');
+         else: # Run without a debugger attached.
+-            if self.sHost in ('darwin', 'freebsd', 'linux', 'solaris', ):
++            if self.sHost in ('darwin', 'freebsd', 'linux', 'solaris', 'netbsd'):
+                 #
+                 # XPCOM - We can use a pipe to let VBoxSVC notify us when it's ready.
+                 #
+@@ -1689,7 +1689,7 @@ class TestDriver(base.TestDriver):      
+                 if os.path.isfile(sVBoxSvcRelLog + sSuff):
+                     reporter.addLogFile(sVBoxSvcRelLog + sSuff, 'log/release/svc', 'Release log file for VBoxSVC');
+             # Testbox debugging - START - TEMPORARY, REMOVE ASAP.
+-            if self.sHost in ('darwin', 'freebsd', 'linux', 'solaris', ):
++            if self.sHost in ('darwin', 'freebsd', 'linux', 'solaris', 'netbsd'):
+                 try:
+                     print '> ls -la %s' % (os.path.join(self.sScratchPath, 'VBoxUserHome'),);
+                     utils.processCall(['ls', '-la', os.path.join(self.sScratchPath, 'VBoxUserHome')]);
+@@ -3289,4 +3289,3 @@ class TestDriver(base.TestDriver):      
+         return fRc;
+ 
+     # pylint: enable=R0914,R0913
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_ValidationKit_testdriver_vboxtestvms.py b/virtualbox-svn/patches/patch-src_VBox_ValidationKit_testdriver_vboxtestvms.py
new file mode 100644
index 0000000..f8ca409
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_ValidationKit_testdriver_vboxtestvms.py
@@ -0,0 +1,55 @@
+$NetBSD$
+
+--- src/VBox/ValidationKit/testdriver/vboxtestvms.py.orig	2016-03-04 19:30:17.000000000 +0000
++++ src/VBox/ValidationKit/testdriver/vboxtestvms.py
+@@ -102,7 +102,8 @@ g_aaNameToDetails = \
+     [ 'Solaris',        'Solaris',               g_k32,    1, 256, ['sol10',  'sol10u[0-9]']],
+     [ 'Solaris_64',     'Solaris_64',            g_k64,    1, 256, ['sol10-64', 'sol10u-64[0-9]']],
+     [ 'Solaris_64',     'Solaris11_64',          g_k64,    1, 256, ['sol11u1']],
+-    [ 'BSD',            'FreeBSD_64',            g_k32_64, 1, 1, ['bs-.*']], # boot sectors, wanted 64-bit type.
++    [ 'FreeBSD',        'FreeBSD_64',            g_k32_64, 1, 1, ['bs-.*']], # boot sectors, wanted 64-bit type.
++    [ 'NetBSD',         'NetBSD_64',             g_k32_64, 1, 1, ['bs-.*']], # boot sectors, wanted 64-bit type.
+ ];
+ 
+ 
+@@ -110,6 +111,7 @@ g_aaNameToDetails = \
+ ## @{
+ g_ksGuestOsTypeDarwin  = 'darwin';
+ g_ksGuestOsTypeFreeBSD = 'freebsd';
++g_ksGuestOsTypeNetBSD  = 'netbsd';
+ g_ksGuestOsTypeLinux   = 'linux';
+ g_ksGuestOsTypeOS2     = 'os2';
+ g_ksGuestOsTypeSolaris = 'solaris';
+@@ -134,6 +136,7 @@ g_kasParavirtProviders = ( g_ksParavirtP
+ #g_kdaParavirtProvidersSupported = {
+ #    g_ksGuestOsTypeDarwin  : ( g_ksParavirtProviderMinimal, ),
+ #    g_ksGuestOsTypeFreeBSD : ( g_ksParavirtProviderNone, g_ksParavirtProviderMinimal, ),
++#    g_ksGuestOsTypeNetBSD : ( g_ksParavirtProviderNone, g_ksParavirtProviderMinimal, ),
+ #    g_ksGuestOsTypeLinux   : ( g_ksParavirtProviderNone, g_ksParavirtProviderMinimal, g_ksParavirtProviderHyperV, g_ksParavirtProviderKVM),
+ #    g_ksGuestOsTypeOS2     : ( g_ksParavirtProviderNone, ),
+ #    g_ksGuestOsTypeSolaris : ( g_ksParavirtProviderNone, ),
+@@ -146,6 +149,7 @@ g_kasParavirtProviders = ( g_ksParavirtP
+ g_kdaParavirtProvidersSupported = {
+     g_ksGuestOsTypeDarwin  : ( g_ksParavirtProviderMinimal, ),
+     g_ksGuestOsTypeFreeBSD : ( g_ksParavirtProviderNone, ),
++    g_ksGuestOsTypeNetBSD : ( g_ksParavirtProviderNone, ),
+     g_ksGuestOsTypeLinux   : ( g_ksParavirtProviderNone, g_ksParavirtProviderHyperV, g_ksParavirtProviderKVM),
+     g_ksGuestOsTypeOS2     : ( g_ksParavirtProviderNone, ),
+     g_ksGuestOsTypeSolaris : ( g_ksParavirtProviderNone, ),
+@@ -207,8 +211,10 @@ class TestVm(object):
+         """
+         if sType.lower().startswith('darwin'):
+             return g_ksGuestOsTypeDarwin
+-        if sType.lower().startswith('bsd'):
++        if sType.lower().startswith('freebsd'):
+             return g_ksGuestOsTypeFreeBSD
++        if sType.lower().startswith('netbsd'):
++            return g_ksGuestOsTypeNetBSD
+         if sType.lower().startswith('linux'):
+             return g_ksGuestOsTypeLinux
+         if sType.lower().startswith('os2'):
+@@ -954,4 +960,3 @@ class TestVmManager(object):
+     def shutUpPyLint(self):
+         """ Shut up already! """
+         return self.sResourcePath;
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_ValidationKit_testmanager_core_coreconsts.py b/virtualbox-svn/patches/patch-src_VBox_ValidationKit_testmanager_core_coreconsts.py
new file mode 100644
index 0000000..01f3a06
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_ValidationKit_testmanager_core_coreconsts.py
@@ -0,0 +1,28 @@
+$NetBSD$
+
+--- src/VBox/ValidationKit/testmanager/core/coreconsts.py.orig	2016-03-04 19:30:17.000000000 +0000
++++ src/VBox/ValidationKit/testmanager/core/coreconsts.py
+@@ -33,5 +33,5 @@ g_ksOsAgnostic      = 'os-agnostic';
+ ## All known OSes, except the agnostic one.
+ # See KBUILD_OSES in kBuild/header.kmk for reference.
+-g_kasOses           = ['darwin', 'dos', 'dragonfly', 'freebsd', 'haiku', 'l4', 'linux', 'netbsd', 'nt', 'openbsd', 'os2',
++g_kasOses           = ['darwin', 'dos', 'dragonfly', 'freebsd', 'netbsd', 'haiku', 'l4', 'linux', 'netbsd', 'nt', 'openbsd', 'os2',
+                        'solaris', 'win'];
+ ## All known OSes, including the agnostic one.
+@@ -65,4 +65,5 @@ g_kasOsDotCpus = \
+     'freebsd.amd64', 'freebsd.x86', 'freebsd.sparc64', 'freebsd.ia64', 'freebsd.ppc32', 'freebsd.ppc64', 'freebsd.arm',
+     'freebsd.mips32', 'freebsd.mips64',
++    'netbsd.amd64', 'netbsd.x86',
+     'haiku.amd64', 'haiku.x86',
+     'l4.amd64', 'l4.x86', 'l4.ppc32', 'l4.ppc64', 'l4.arm',
+@@ -73,5 +74,5 @@ g_kasOsDotCpus = \
+ ];
+ for sOs in g_kasOses:
+-    if sOs not in ['darwin', 'dos', 'dragonfly', 'freebsd', 'haiku', 'l4', 'nt', 'win', 'os2', 'solaris']:
++    if sOs not in ['darwin', 'dos', 'dragonfly', 'freebsd', 'netbsd', 'haiku', 'l4', 'nt', 'win', 'os2', 'solaris']:
+         for sArch in g_kasCpuArches:
+             g_kasOsDotCpus.append(sOs + '.' + sArch);
+@@ -86,3 +87,2 @@ for sArch in g_kasCpuArchesAll:
+     g_kasOsDotCpusAll.append(g_ksOsAgnostic + '.' + sArch);
+ g_kasOsDotCpusAll.sort();
+-
diff --git a/virtualbox-svn/patches/patch-src_VBox_ValidationKit_tests_autostart_tdAutostart1.py b/virtualbox-svn/patches/patch-src_VBox_ValidationKit_tests_autostart_tdAutostart1.py
new file mode 100644
index 0000000..34286bf
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_VBox_ValidationKit_tests_autostart_tdAutostart1.py
@@ -0,0 +1,17 @@
+$NetBSD$
+
+--- src/VBox/ValidationKit/tests/autostart/tdAutostart1.py.orig	2016-03-04 19:30:19.000000000 +0000
++++ src/VBox/ValidationKit/tests/autostart/tdAutostart1.py
+@@ -461,6 +461,7 @@ class tdAutostart(vbox.TestDriver):     
+     ksOsDarwin  = 'tst-darwin'
+     ksOsSolaris = 'tst-solaris'
+     ksOsFreeBSD = 'tst-freebsd'
++    ksOsNetBSD = 'tst-netbsd'
+ 
+     def __init__(self):
+         vbox.TestDriver.__init__(self);
+@@ -703,4 +704,3 @@ class tdAutostart(vbox.TestDriver):     
+ 
+ if __name__ == '__main__':
+     sys.exit(tdAutostart().main(sys.argv));
+-
diff --git a/virtualbox-svn/patches/patch-src_apps_Makefile.kmk b/virtualbox-svn/patches/patch-src_apps_Makefile.kmk
new file mode 100644
index 0000000..d75ddd7
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_apps_Makefile.kmk
@@ -0,0 +1,17 @@
+$NetBSD$
+
+--- src/apps/Makefile.kmk.orig	2016-03-04 19:30:20.000000000 +0000
++++ src/apps/Makefile.kmk
+@@ -28,11 +28,10 @@ ifeq ($(KBUILD_TARGET),linux)
+   include $(PATH_SUB_CURRENT)/tunctl/Makefile.kmk
+  endif
+ endif
+-if1of ($(KBUILD_TARGET),darwin solaris linux freebsd)
++if1of ($(KBUILD_TARGET),darwin solaris linux freebsd netbsd)
+  ifneq ($(wildcard $(PATH_SUB_CURRENT)/adpctl),)
+   include $(PATH_SUB_CURRENT)/adpctl/Makefile.kmk
+  endif
+ endif
+ 
+ include $(FILE_KBUILD_SUB_FOOTER)
+-
diff --git a/virtualbox-svn/patches/patch-src_libs_libxml2-2.9.2_include_vboxconfig.h b/virtualbox-svn/patches/patch-src_libs_libxml2-2.9.2_include_vboxconfig.h
new file mode 100644
index 0000000..79bf2aa
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_libs_libxml2-2.9.2_include_vboxconfig.h
@@ -0,0 +1,18 @@
+$NetBSD$
+
+--- src/libs/libxml2-2.9.2/include/vboxconfig.h.orig	2016-03-04 19:30:26.000000000 +0000
++++ src/libs/libxml2-2.9.2/include/vboxconfig.h
+@@ -9,7 +9,7 @@
+ #undef SUPPORT_IP6
+ 
+ /* Define if getaddrinfo is there */
+-#if defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD)
++#if defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD) || defined(RT_OS_NETBSD)
+ # define HAVE_GETADDRINFO 1
+ #else
+ # undef HAVE_GETADDRINFO
+@@ -434,4 +434,3 @@
+ /* make sure LIBXML_ICONV_ENABLED is killed */
+ #include <libxml/xmlversion.h>
+ #undef LIBXML_ICONV_ENABLED
+-
diff --git a/virtualbox-svn/patches/patch-src_libs_xpcom18a4_nsprpub_pr_include_md___netbsd.cfg b/virtualbox-svn/patches/patch-src_libs_xpcom18a4_nsprpub_pr_include_md___netbsd.cfg
new file mode 100644
index 0000000..022b369
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_libs_xpcom18a4_nsprpub_pr_include_md___netbsd.cfg
@@ -0,0 +1,13 @@
+$NetBSD$
+
+--- src/libs/xpcom18a4/nsprpub/pr/include/md/_netbsd.cfg.orig	2016-03-04 19:30:36.000000000 +0000
++++ src/libs/xpcom18a4/nsprpub/pr/include/md/_netbsd.cfg
+@@ -140,7 +140,7 @@
+ #define PR_ALIGN_OF_DOUBLE  8
+ #define PR_ALIGN_OF_POINTER 4
+ 
+-#elif defined(__alpha__)
++#elif defined(__alpha__) || defined(__x86_64__)
+ #define IS_LITTLE_ENDIAN 1
+ #undef  IS_BIG_ENDIAN
+ #define	HAVE_LONG_LONG
diff --git a/virtualbox-svn/patches/patch-src_recompiler_Makefile.kmk b/virtualbox-svn/patches/patch-src_recompiler_Makefile.kmk
new file mode 100644
index 0000000..838ad42
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_recompiler_Makefile.kmk
@@ -0,0 +1,17 @@
+$NetBSD$
+
+--- src/recompiler/Makefile.kmk.orig	2016-03-04 19:31:09.000000000 +0000
++++ src/recompiler/Makefile.kmk
+@@ -83,6 +83,7 @@ else
+  VBoxRemPrimary_DEFS.solaris   = CONFIG_SOLARIS_VERSION=11
+ endif
+ VBoxRemPrimary_DEFS.freebsd   += _BSD
++VBoxRemPrimary_DEFS.netbsd    += _BSD
+ VBoxRemPrimary_DEFS.amd64     += __x86_64__
+ VBoxRemPrimary_DEFS.x86       += __i386__
+ 
+@@ -339,4 +340,3 @@ testmath_SOURCES        = Sun/testmath.c
+ 
+ 
+ include $(FILE_KBUILD_SUB_FOOTER)
+-
diff --git a/virtualbox-svn/patches/patch-src_recompiler_exec.c b/virtualbox-svn/patches/patch-src_recompiler_exec.c
new file mode 100644
index 0000000..19152a7
--- /dev/null
+++ b/virtualbox-svn/patches/patch-src_recompiler_exec.c
@@ -0,0 +1,35 @@
+$NetBSD$
+
+--- src/recompiler/exec.c.orig	2016-03-04 19:31:10.000000000 +0000
++++ src/recompiler/exec.c
+@@ -64,6 +64,7 @@
+ #if defined(CONFIG_USER_ONLY)
+ #include <qemu.h>
+ #include <signal.h>
++
+ #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
+ #include <sys/param.h>
+ #if __FreeBSD_version >= 700104
+@@ -79,6 +80,13 @@
+ #include <libutil.h>
+ #endif
+ #endif
++
++#if defined(__NetBSD__)
++#include <sys/param.h>
++#include <sys/time.h>
++#include <sys/proc.h>
++#endif
++
+ #endif
+ 
+ //#define DEBUG_TB_INVALIDATE
+@@ -603,7 +611,7 @@ static void code_gen_alloc(uintptr_t tb_
+             exit(1);
+         }
+     }
+-#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
++#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) || defined(__NetBSD__)
+     {
+         int flags;
+         void *addr = NULL;
diff --git a/virtualbox-svn/patches/patch-tools_bin_gen-slickedit-workspace.sh b/virtualbox-svn/patches/patch-tools_bin_gen-slickedit-workspace.sh
new file mode 100644
index 0000000..5ebde2f
--- /dev/null
+++ b/virtualbox-svn/patches/patch-tools_bin_gen-slickedit-workspace.sh
@@ -0,0 +1,12 @@
+$NetBSD$
+
+--- tools/bin/gen-slickedit-workspace.sh.orig	2016-07-10 19:40:35.000000000 +0000
++++ tools/bin/gen-slickedit-workspace.sh
+@@ -980,6 +980,7 @@ my_generate_project "REM"           "src
+ 
+ # src/VBox/Additions
+ my_generate_project "Add-freebsd"   "src/VBox/Additions/freebsd"            --begin-incs "include" "src/VBox/Additions/freebsd"             --end-includes "src/VBox/Additions/freebsd"
++my_generate_project "Add-netbsd"    "src/VBox/Additions/netbsd"             --begin-incs "include" "src/VBox/Additions/netbsd"             --end-includes "src/VBox/Additions/netbsd"
+ my_generate_project "Add-linux"     "src/VBox/Additions/linux"              --begin-incs "include" "src/VBox/Additions/linux"               --end-includes "src/VBox/Additions/linux"
+ my_generate_project "Add-os2"       "src/VBox/Additions/os2"                --begin-incs "include" "src/VBox/Additions/os2"                 --end-includes "src/VBox/Additions/os2"
+ my_generate_project "Add-solaris"   "src/VBox/Additions/solaris"            --begin-incs "include" "src/VBox/Additions/solaris"             --end-includes "src/VBox/Additions/solaris"


Home | Main Index | Thread Index | Old Index