├── .gitignore ├── Balloon ├── COPYING ├── LICENSE ├── app │ ├── COPYING │ ├── LICENSE │ ├── buildOne.bat │ ├── cleanAll.bat │ ├── device.cpp │ ├── device.h │ ├── main.cpp │ ├── makefile │ ├── memstat.cpp │ ├── memstat.h │ ├── packOne.bat │ ├── service.cpp │ ├── service.h │ ├── sources │ ├── utils.cpp │ └── utils.h ├── buildAll.bat ├── cleanAll.bat ├── dirs └── sys │ ├── COPYING │ ├── Device.c │ ├── Driver.c │ ├── LICENSE │ ├── ProtoTypes.h │ ├── balloon.c │ ├── balloon.inx │ ├── balloon.rc │ ├── balloon.vcxproj │ ├── balloon.vcxproj.filters │ ├── buildOne.bat │ ├── cleanAll.bat │ ├── makefile │ ├── makefile.inc │ ├── packOne.bat │ ├── precomp.h │ ├── public.h │ ├── queue.c │ ├── sources │ ├── trace.h │ └── utils.c ├── COPYING ├── LICENSE ├── NetKVM ├── COPYING ├── CoInstaller │ ├── COPYING │ ├── Exception.cpp │ ├── Exception.h │ ├── LICENSE │ ├── NetKVMAux.cpp │ ├── NetKVMAux.h │ ├── NetKVMCo.c │ ├── NetKVMCo.h │ ├── NetKVMnetsh.cpp │ ├── NetKVMnetsh.h │ ├── QA-guidelines.doc │ ├── RegAccess.cpp │ ├── RegAccess.h │ ├── RegParam.cpp │ ├── RegParam.h │ ├── clean.bat │ ├── netco.rc │ ├── netkvmco.vcxproj │ ├── readme.doc │ ├── resource.h │ ├── sources.props │ ├── stdafx.c │ ├── stdafx.h │ ├── targetver.h │ ├── tstrings.cpp │ └── tstrings.h ├── Common │ ├── DebugData.h │ ├── ParaNdis-AbstractPath.cpp │ ├── ParaNdis-AbstractPath.h │ ├── ParaNdis-CX.cpp │ ├── ParaNdis-CX.h │ ├── ParaNdis-Common.cpp │ ├── ParaNdis-Debug.cpp │ ├── ParaNdis-Oid.cpp │ ├── ParaNdis-Oid.h │ ├── ParaNdis-RSS.h │ ├── ParaNdis-RX.cpp │ ├── ParaNdis-RX.h │ ├── ParaNdis-TX.cpp │ ├── ParaNdis-TX.h │ ├── ParaNdis-Util.cpp │ ├── ParaNdis-Util.h │ ├── ParaNdis-VirtQueue.cpp │ ├── ParaNdis-VirtQueue.h │ ├── ParaNdis_Debug.h │ ├── ParaNdis_DebugHistory.h │ ├── common.inf.h │ ├── ethernetutils.h │ ├── ndis56common.h │ ├── osdep.h │ ├── quverp.h │ ├── sw-offload.cpp │ └── virtio_net.h ├── DebugTools │ ├── HCKParser │ │ ├── COPYING │ │ ├── LICENSE │ │ ├── Makefile │ │ ├── README.txt │ │ └── hck_seq.cpp │ ├── NetKVMDumpParser │ │ ├── COPYING │ │ ├── DebugSdk.vsprops │ │ ├── LICENSE │ │ ├── NetKVMDumpParser.cpp │ │ ├── NetKVMDumpParser.h │ │ ├── NetKVMDumpParser.rc │ │ ├── NetKVMDumpParser.sln │ │ ├── NetKVMDumpParser.vcproj │ │ ├── ReadMe.txt │ │ ├── Resource.h │ │ ├── debug.cmd │ │ ├── main.cpp │ │ ├── stdafx.cpp │ │ └── stdafx.h │ ├── Netchecksum │ │ ├── COPYING │ │ ├── LICENSE │ │ ├── ReadMe.txt │ │ ├── netchecksum.cpp │ │ ├── netchecksum.sln │ │ ├── netchecksum.vcproj │ │ ├── netchecksum.vcxproj │ │ ├── netchecksum.vcxproj.filters │ │ ├── run.cmd │ │ ├── stdafx.cpp │ │ ├── stdafx.h │ │ ├── tcp-badcs.txt │ │ ├── tcp-cs.txt │ │ ├── tcp-ph.txt │ │ ├── tcp-short.txt │ │ ├── tcpv6-cs.txt │ │ └── udpv6-cs.txt │ ├── RSS-Toeplitz │ │ ├── COPYING │ │ ├── LICENSE │ │ ├── RSS-Toeplitz.cpp │ │ ├── RSS-Toeplitz.vcxproj │ │ ├── RSS-Toeplitz.vcxproj.filters │ │ ├── ReadMe.txt │ │ ├── WinToeplitz.c │ │ ├── WinToeplitz.h │ │ ├── clean.bat │ │ ├── stdafx.cpp │ │ ├── stdafx.h │ │ └── targetver.h │ └── VirtioConsoleSimulation │ │ ├── COPYING │ │ ├── ConsoleSim.cpp │ │ ├── ConsoleSim.h │ │ ├── ConsoleSim.rc │ │ ├── ConsoleSim.vcxproj │ │ ├── ConsoleSim.vcxproj.filters │ │ ├── Device │ │ ├── block_int.h │ │ ├── event_notifier.h │ │ ├── hw.h │ │ ├── inttypes.h │ │ ├── net.h │ │ ├── qdev.h │ │ ├── qemu-error.h │ │ ├── sysemu.h │ │ ├── trace.h │ │ ├── virtio-net.c │ │ ├── virtio-net.h │ │ ├── virtio-pci.c │ │ ├── virtio-pci.h │ │ ├── virtio.c │ │ └── virtio.h │ │ ├── Hardware │ │ ├── Hardware.c │ │ ├── Hardware.h │ │ └── HardwareTypes.h │ │ ├── IONetDescriptor.h │ │ ├── LICENSE │ │ ├── ReadMe.txt │ │ ├── Resource.h │ │ ├── VirtIO_Win.h │ │ ├── clean.bat │ │ ├── engine.c │ │ ├── external_os_dep.h │ │ ├── kdebugprint.h │ │ ├── osdep.h │ │ ├── stdafx.cpp │ │ ├── stdafx.h │ │ ├── targetver.h │ │ ├── test.txt │ │ ├── testCommands.cpp │ │ └── testcommands.h ├── LICENSE ├── NDIS5 │ ├── COPYING │ ├── Common │ │ ├── DebugData.h │ │ ├── IONetDescriptor.h │ │ ├── ParaNdis-Common.c │ │ ├── ParaNdis-Debug.c │ │ ├── ParaNdis-Oid.c │ │ ├── ParaNdis-Oid.h │ │ ├── common.inf.h │ │ ├── common.mak │ │ ├── ethernetutils.h │ │ ├── kdebugprint.h │ │ ├── makefile │ │ ├── ndis56common.h │ │ ├── osdep.h │ │ ├── quverp.h │ │ ├── sources │ │ └── sw-offload.c │ ├── LICENSE │ ├── NetKVM-NDIS5.vcxproj │ ├── NetKVM-NDIS5.vcxproj.filters │ ├── NetKVM.yaml │ ├── ReadMe.txt │ ├── RunCheckInf.cmd │ ├── VirtIO │ │ ├── COPYING │ │ ├── LICENSE │ │ ├── VirtIO.h │ │ ├── VirtIOPCI.c │ │ ├── VirtIORing.c │ │ ├── makefile │ │ ├── osdep.h │ │ ├── sources │ │ ├── virtio_pci.h │ │ └── virtio_ring.h │ ├── buildAll.bat │ ├── clean.bat │ ├── dirs │ ├── tools │ │ ├── README.TXT │ │ ├── cleanemptystrings.vbs │ │ ├── makeinstall.bat │ │ └── signing.cmd │ └── wxp │ │ ├── ParaNdis5-Driver.c │ │ ├── ParaNdis5-Impl.c │ │ ├── ParaNdis5-Oid.c │ │ ├── ParaNdis5.h │ │ ├── makefile │ │ ├── netkvm.inf │ │ ├── parandis.rc │ │ └── sources ├── NetKVM Package │ ├── NetKVM Package.vcxproj │ ├── NetKVM Package.vcxproj.filters │ └── NetKVM Package.vcxproj.user ├── NetKVM.sln ├── NetKVM.vcxproj ├── NetKVM.vcxproj.filters ├── NetKVM.vcxproj.user ├── NetKVM.yaml ├── ReadMe.txt ├── Tests │ ├── COPYING │ ├── LICENSE │ ├── iperf_wrapper.rb │ ├── netperf_log_parser.rb │ └── netperf_wrapper.rb ├── buildAll.bat ├── clean.bat ├── clean_dvl_log.cmd ├── create_dvl_log.cmd ├── linux │ └── if_ether.h ├── tools │ ├── InstallCertificate.bat │ ├── NetKVMTemporaryCert.cer │ ├── NetKVMTemporaryCert.pfx │ ├── cleanemptystrings.vbs │ ├── make_inf.bat │ └── set_version.bat └── wlh │ ├── ParaNdis6-Driver.cpp │ ├── ParaNdis6-Impl.cpp │ ├── ParaNdis6-Oid.cpp │ ├── ParaNdis6-RSS.cpp │ ├── ParaNdis6.h │ ├── Parandis6.rc │ └── netkvm.inf ├── RunSdv.bat ├── SDVTOOL.bat ├── Tools ├── NetKVMTemporaryCert.cer ├── NetKVMTemporaryCert.pfx ├── RunSdv.js ├── SetVsEnv.bat ├── callVisualStudio.bat ├── checkWin8Tools.bat ├── getVisualStudioCmdLine.vbs └── xdate.exe ├── VirtIO ├── COPYING ├── LICENSE ├── VirtIO.h ├── VirtIO.sln ├── VirtIO.vcxproj ├── VirtIO.vcxproj.filters ├── VirtIOPCI.c ├── VirtIORing.c ├── VirtioLib-win8.vcxproj ├── VirtioLib-win8.vcxproj.filters ├── buildAll.bat ├── clean.bat ├── kdebugprint.h ├── linux │ ├── types.h │ ├── virtio_ids.h │ └── virtio_types.h ├── makefile ├── osdep.h ├── sources ├── virtio_config.h ├── virtio_pci.h ├── virtio_ring.h └── windows │ └── virtio_ring_allocation.h ├── buildAll.bat ├── clean.bat ├── pciserial ├── buildall.bat ├── clean.bat └── qemupciserial.inf ├── pvpanic ├── COPYING ├── LICENSE ├── PVPanic Package │ ├── PVPanic Package.filters │ └── PVPanic Package.vcxproj ├── buildall.bat ├── clean.bat ├── dirs ├── pvpanic.sln └── pvpanic │ ├── bugcheck.c │ ├── makefile │ ├── makefile.inc │ ├── power.c │ ├── pvpanic.c │ ├── pvpanic.ctl │ ├── pvpanic.h │ ├── pvpanic.inf │ ├── pvpanic.rc │ ├── pvpanic.vcxproj │ ├── sources │ └── trace.h ├── rmwhite.rb ├── status.txt ├── viorng ├── VirtRNG Package │ ├── VirtRNG Package.vcxproj │ └── VirtRNG Package.vcxproj.filters ├── buildall.bat ├── clean.bat ├── cng │ └── um │ │ ├── viorngum.c │ │ ├── viorngum.def │ │ ├── viorngum.h │ │ ├── viorngum.rc │ │ └── viorngum.vcxproj ├── coinstaller │ ├── viorngci.c │ ├── viorngci.def │ ├── viorngci.h │ ├── viorngci.rc │ └── viorngci.vcxproj ├── dirs ├── viorng.sln ├── viorng │ ├── isrdpc.c │ ├── makefile.inc │ ├── power.c │ ├── read.c │ ├── sources │ ├── trace.h │ ├── viorng.c │ ├── viorng.ctl │ ├── viorng.h │ ├── viorng.inf │ ├── viorng.rc │ ├── viorng.vcxproj │ ├── viorng.vcxproj.filters │ └── virtio.c ├── viorngum.sln └── virtiolib │ ├── virtiolib.vcxproj │ └── virtiolib.vcxproj.filters ├── vioscsi ├── COPYING ├── LICENSE ├── MAKEFILE ├── SOURCES ├── buildAll.bat ├── buildOne.bat ├── clean.bat ├── helper.c ├── helper.h ├── makefile.inc ├── packOne.bat ├── utils.c ├── utils.h ├── vioscsi.c ├── vioscsi.h ├── vioscsi.inx ├── vioscsi.mof ├── vioscsi.rc ├── vioscsi.vcxproj ├── vioscsi.vcxproj.Filters ├── vioscsidt.h └── virtio_pci.c ├── vioserial ├── COPYING ├── LICENSE ├── app │ ├── COPYING │ ├── LICENSE │ ├── buildOne.bat │ ├── cleanAll.bat │ ├── device.cpp │ ├── device.h │ ├── main.cpp │ ├── makefile │ ├── notifier.cpp │ ├── notifier.h │ ├── packOne.bat │ └── sources ├── buildAll.bat ├── cleanAll.bat ├── dirs ├── lib │ ├── COPYING │ ├── LICENSE │ ├── PnPAll.h │ ├── PnPControl.cpp │ ├── main.cpp │ ├── makefile │ ├── port.cpp │ ├── readme.txt │ ├── sources │ ├── stdafx.cpp │ ├── stdafx.h │ ├── vioser.h │ └── vioserlb.def ├── libtestapp │ ├── COPYING │ ├── LICENSE │ ├── main.cpp │ ├── makefile │ └── sources ├── libtestsvc │ ├── COPYING │ ├── LICENSE │ ├── main.cpp │ ├── makefile │ ├── service.cpp │ ├── service.h │ ├── sources │ ├── utils.cpp │ └── utils.h └── sys │ ├── Buffer.c │ ├── COPYING │ ├── Control.c │ ├── Device.c │ ├── Driver.c │ ├── IsrDpc.c │ ├── LICENSE │ ├── Port.c │ ├── buildOne.bat │ ├── cleanAll.bat │ ├── makefile │ ├── makefile.inc │ ├── packOne.bat │ ├── precomp.h │ ├── public.h │ ├── sources │ ├── trace.h │ ├── utils.c │ ├── vioser.h │ ├── vioser.inx │ ├── vioser.rc │ ├── vioser.vcxproj │ └── vioser.vcxproj.filters └── viostor ├── COPYING ├── LICENSE ├── MAKEFILE ├── SOURCES ├── WinLH.inx ├── WinNET.inx ├── WinXP.inx ├── buildAll.bat ├── buildOne.bat ├── clean.bat ├── disk1 ├── makefile.inc ├── packOne.bat ├── txtsetup-amd64.oem ├── txtsetup-i386.oem ├── txtsetup.oem ├── viostor.vcxproj ├── viostor.vcxproj.filters ├── virtio_pci.c ├── virtio_stor.c ├── virtio_stor.h ├── virtio_stor.rc ├── virtio_stor_hw_helper.c ├── virtio_stor_hw_helper.h ├── virtio_stor_utils.c └── virtio_stor_utils.h /.gitignore: -------------------------------------------------------------------------------- 1 | *.ncb 2 | *.suo 3 | *.vcproj.* 4 | *.wrn 5 | *.log 6 | *.err 7 | *.pfx 8 | *.cer 9 | *.bak 10 | *.user 11 | *.sln 12 | *.sdf 13 | *.opensdf 14 | *objchk_* 15 | *objfre_* 16 | *Win?Debug* 17 | *Win?Release* 18 | *Win?.?Debug* 19 | *Win?.?Release* 20 | *VistaDebug* 21 | *VistaRelease* 22 | Install 23 | NetKVM/Install_Debug -------------------------------------------------------------------------------- /Balloon/app/buildOne.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | if "%DDKVER%"=="" set DDKVER=7600.16385.1 3 | set BUILDROOT=C:\WINDDK\%DDKVER% 4 | 5 | set DDKBUILDENV= 6 | pushd %BUILDROOT% 7 | call %BUILDROOT%\bin\setenv.bat %BUILDROOT% %2 fre %1 no_oacr 8 | popd 9 | build -cZg 10 | 11 | set DDKVER= 12 | set BUILDROOT= 13 | 14 | 15 | -------------------------------------------------------------------------------- /Balloon/app/cleanAll.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | rmdir /S /Q objfre_wxp_x86 4 | rmdir /S /Q objfre_wnet_x86 5 | rmdir /S /Q objfre_wnet_amd64 6 | rmdir /S /Q objfre_wlh_x86 7 | rmdir /S /Q objfre_wlh_amd64 8 | rmdir /S /Q objfre_win7_x86 9 | rmdir /S /Q objfre_win7_amd64 10 | 11 | del /F *.log *.wrn *.err 12 | 13 | 14 | -------------------------------------------------------------------------------- /Balloon/app/device.h: -------------------------------------------------------------------------------- 1 | #ifndef DEVICE_H 2 | #define DEVICE_H 3 | 4 | #include 5 | 6 | class CMemStat; 7 | 8 | class CDevice { 9 | public: 10 | CDevice(); 11 | ~CDevice(); 12 | BOOL Init(SERVICE_STATUS_HANDLE hService); 13 | VOID Fini(); 14 | BOOL Start(); 15 | VOID Stop(); 16 | 17 | protected: 18 | PTCHAR GetDevicePath(IN LPGUID InterfaceGuid); 19 | DWORD Run(); 20 | private: 21 | static DWORD WINAPI DeviceThread(LPDWORD lParam); 22 | VOID WriteLoop(HANDLE hDevice); 23 | CMemStat* m_pMemStat; 24 | SERVICE_STATUS_HANDLE m_hService; 25 | HANDLE m_hThread; 26 | HANDLE m_evtTerminate; 27 | HANDLE m_evtWrite; 28 | }; 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /Balloon/app/makefile: -------------------------------------------------------------------------------- 1 | # 2 | # DO NOT EDIT THIS FILE!!! Edit .\sources. if you want to add a new source 3 | # file to this component. This file merely indirects to the real make file 4 | # that is shared by all the components of Windows NT 5 | # 6 | !INCLUDE $(NTMAKEENV)\makefile.def 7 | 8 | -------------------------------------------------------------------------------- /Balloon/app/memstat.h: -------------------------------------------------------------------------------- 1 | #ifndef MEMSTAT_H 2 | #define MEMSTAT_H 3 | 4 | #include "Wbemidl.h" 5 | #include "coguid.h" 6 | #include "atlbase.h" 7 | #include "comdef.h" 8 | #include "comutil.h" 9 | #include "public.h" 10 | 11 | class CMemStat { 12 | public: 13 | CMemStat(); 14 | ~CMemStat(); 15 | BOOL Init(); 16 | BOOL Update(); 17 | 18 | PVOID GetBuffer() { 19 | return m_Stats; 20 | } 21 | 22 | size_t GetSize() { 23 | return sizeof(m_Stats); 24 | } 25 | 26 | private: 27 | BOOL initialized; 28 | CComPtr< IWbemLocator > locator; 29 | CComPtr< IWbemServices > service; 30 | BALLOON_STAT m_Stats[VIRTIO_BALLOON_S_NR]; 31 | }; 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /Balloon/app/packOne.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | : Param1 - Win7 | Wlh | Wnet | XP 3 | : Param2 - x86|x64 4 | : Param3 - file name 5 | 6 | if "%2"=="x64" set %%2=amd64 7 | 8 | if /i "%1"=="Win7" goto :checkarch 9 | if /i "%1"=="Wlh" goto :checkarch 10 | if /i "%1"=="Wnet" goto :checkarch 11 | if /i "%1"=="WXp" goto :checkarch 12 | goto :printerr 13 | :checkarch 14 | if /i "%2"=="x86" goto :makeinstall 15 | if /i "%2"=="x64" goto :makeinstall 16 | :printerr 17 | echo wrong parameters (1)%1 (2)%2 (3)%3 18 | pause 19 | goto :eof 20 | 21 | :makeinstall 22 | set INST_OS=%1 23 | set INST_ARC=%2 24 | set FILE_NAME=%3 25 | rem set INST_EXT=INST_ARC 26 | 27 | if /i "%INST_ARC%"=="x64" goto :set_x64 28 | 29 | set INST_EXT=i386 30 | goto :startcopy 31 | 32 | :set_x64 33 | set INST_ARC=amd64 34 | set INST_EXT=amd64 35 | 36 | :startcopy 37 | set EXE_PATH_AND_NAME=objfre_%INST_OS%_%INST_ARC%\%INST_EXT%\%FILE_NAME%.exe 38 | set PDB_PATH_AND_NAME=objfre_%INST_OS%_%INST_ARC%\%INST_EXT%\%FILE_NAME%.pdb 39 | 40 | echo makeinstall %1 %2 %3 41 | mkdir ..\Install\%INST_OS%\%INST_ARC% 42 | del /Q ..\Install\%INST_OS%\%INST_ARC%\%FILE_NAME%.* 43 | copy /Y %EXE_PATH_AND_NAME% ..\Install\%INST_OS%\%INST_ARC% 44 | copy /Y %PDB_PATH_AND_NAME% ..\Install\%INST_OS%\%INST_ARC% 45 | 46 | set INST_OS= 47 | set INST_ARC= 48 | set FILE_NAME= 49 | set EXE_PATH_AND_NAME= 50 | set PDB_PATH_AND_NAME= 51 | 52 | 53 | -------------------------------------------------------------------------------- /Balloon/app/service.h: -------------------------------------------------------------------------------- 1 | #ifndef SERVICE_H 2 | #define SERVICE_H 3 | 4 | #include 5 | #include 6 | 7 | class CDevice; 8 | 9 | class CService 10 | { 11 | public: 12 | CService(); 13 | ~CService(); 14 | BOOL InitService(); 15 | void GetStatus(SC_HANDLE service); 16 | static DWORD __stdcall HandlerExThunk(CService* service, DWORD ctlcode, DWORD evtype, PVOID evdata); 17 | static void __stdcall ServiceMainThunk(CService* service, DWORD argc, TCHAR* argv[]); 18 | SERVICE_STATUS_HANDLE m_StatusHandle; 19 | 20 | private: 21 | BOOL SendStatusToSCM(DWORD dwCurrentState, DWORD dwWin32ExitCode, DWORD dwServiceSpecificExitCode, DWORD dwCheckPoint, DWORD dwWaitHint); 22 | void StopService(); 23 | void terminate(DWORD error); 24 | void ServiceCtrlHandler(DWORD controlCode); 25 | void ServiceMain(DWORD argc, LPTSTR *argv); 26 | DWORD ServiceHandleDeviceChange(DWORD evtype, _DEV_BROADCAST_HEADER* dbhdr); 27 | DWORD ServiceHandlePowerEvent(DWORD evtype, DWORD flags); 28 | 29 | HDEVNOTIFY m_hDevNotify; 30 | HANDLE m_evTerminate; 31 | BOOL m_bRunningService; 32 | DWORD m_Status; 33 | CDevice* m_pDev; 34 | }; 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /Balloon/app/sources: -------------------------------------------------------------------------------- 1 | TARGETNAME=blnsvr 2 | TARGETTYPE=PROGRAM 3 | 4 | _NT_TARGET_VERSION= $(_NT_TARGET_VERSION_WINXP) 5 | 6 | USE_MSVCRT=1 7 | 8 | UMTYPE=console 9 | UMENTRY=wmain 10 | 11 | SOURCES=main.cpp \ 12 | memstat.cpp \ 13 | device.cpp \ 14 | service.cpp \ 15 | utils.cpp 16 | 17 | TARGETLIBS=$(SDK_LIB_PATH)\ole32.lib \ 18 | $(SDK_LIB_PATH)\oleaut32.lib \ 19 | $(SDK_LIB_PATH)\uuid.lib \ 20 | $(SDK_LIB_PATH)\wbemuuid.lib \ 21 | $(SDK_LIB_PATH)\setupapi.lib \ 22 | $(SDK_LIB_PATH)\user32.lib \ 23 | $(SDK_LIB_PATH)\strsafe.lib 24 | 25 | C_DEFINES=$(C_DEFINES) /D_UNICODE /DUNICODE /D_WIN32_DCOM 26 | 27 | USE_MSVCRT=1 28 | USE_VCCOM=1 29 | USE_ATL=1 30 | ATL_VER=71 31 | 32 | INCLUDES = $(INCLUDES);..\sys 33 | 34 | 35 | -------------------------------------------------------------------------------- /Balloon/app/utils.h: -------------------------------------------------------------------------------- 1 | #ifndef UTILS_H 2 | #define UTILS_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | BOOL InstallService(); 9 | BOOL UninstallService(); 10 | BOOL GetConfiguration(); 11 | BOOL ChangeConfig(); 12 | BOOL ServiceRun(); 13 | BOOL ServiceControl(int ctrl); 14 | 15 | void ShowUsage(); 16 | void ErrorHandler(char *s, int err); 17 | void PrintMessage(char *s); 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /Balloon/cleanAll.bat: -------------------------------------------------------------------------------- 1 | @echo on 2 | 3 | rmdir /S /Q Install 4 | 5 | del /F *.log *.wrn *.err 6 | 7 | cd app 8 | call cleanAll.bat 9 | cd .. 10 | 11 | cd sys 12 | call cleanAll.bat 13 | cd .. 14 | 15 | -------------------------------------------------------------------------------- /Balloon/dirs: -------------------------------------------------------------------------------- 1 | DIRS= \ 2 | sys \ 3 | app 4 | -------------------------------------------------------------------------------- /Balloon/sys/balloon.rc: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * Copyright (c) 2009-2015 Red Hat, Inc. 3 | * 4 | * File: balloon.rc 5 | * 6 | * This file contains resource (version) definitions for viostor driver. 7 | * 8 | * This work is licensed under the terms of the GNU GPL, version 2. See 9 | * the COPYING file in the top-level directory. 10 | * 11 | **********************************************************************/ 12 | #include 13 | #include 14 | 15 | #define VER_FILETYPE VFT_DRV 16 | #define VER_FILESUBTYPE VFT2_DRV_SYSTEM 17 | #define VER_FILEDESCRIPTION_STR "Red Hat VirtIO Balloon driver" 18 | #define VER_INTERNALNAME_STR "balloon.sys" 19 | #define VER_ORIGINALFILENAME_STR "balloon.sys" 20 | 21 | #undef VER_PRODUCTBUILD 22 | #undef VER_PRODUCTBUILD_QFE 23 | #undef VER_PRODUCTMAJORVERSION 24 | #undef VER_PRODUCTMINORVERSION 25 | 26 | #undef VER_LEGALCOPYRIGHT_STR 27 | #define VER_LEGALCOPYRIGHT_STR "Copyright (C) 2009-2015 Red Hat, Inc." 28 | 29 | #undef VER_COMPANYNAME_STR 30 | #define VER_COMPANYNAME_STR "Red Hat, Inc." 31 | 32 | #undef VER_PRODUCTNAME_STR 33 | #define VER_PRODUCTNAME_STR "Red Hat VirtIO Balloon controller" 34 | 35 | #define VER_LANGNEUTRAL 36 | 37 | #define VER_PRODUCTBUILD _MAJORVERSION_ 38 | #define VER_PRODUCTBUILD_QFE _MINORVERSION_ 39 | #define VER_PRODUCTMAJORVERSION _NT_TARGET_MAJ 40 | #define VER_PRODUCTMINORVERSION _NT_TARGET_MIN 41 | 42 | #if !defined(_NT_TARGET_MAJ) 43 | #include "2012-defines.h" 44 | #endif 45 | #include "common.ver" 46 | -------------------------------------------------------------------------------- /Balloon/sys/cleanAll.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | rmdir /S /Q objfre_wxp_x86 4 | rmdir /S /Q objfre_wnet_x86 5 | rmdir /S /Q objfre_wnet_amd64 6 | rmdir /S /Q objfre_wlh_x86 7 | rmdir /S /Q objfre_wlh_amd64 8 | rmdir /S /Q objfre_win7_x86 9 | rmdir /S /Q objfre_win7_amd64 10 | rmdir /S /Q objfre_win8_x86 11 | rmdir /S /Q objfre_win8_amd64 12 | 13 | del /F *.log *.wrn *.err 14 | 15 | del 2012-defines.h 16 | 17 | -------------------------------------------------------------------------------- /Balloon/sys/makefile: -------------------------------------------------------------------------------- 1 | # 2 | # DO NOT EDIT THIS FILE!!! Edit .\sources. if you want to add a new source 3 | # file to this component. This file merely indirects to the real make file 4 | # that is shared by all the driver components of the Windows NT DDK 5 | # 6 | 7 | !INCLUDE $(NTMAKEENV)\makefile.def 8 | 9 | 10 | -------------------------------------------------------------------------------- /Balloon/sys/makefile.inc: -------------------------------------------------------------------------------- 1 | _LNG=$(LANGUAGE) 2 | _INX=. 3 | STAMP=stampinf -f $@ -d * -a $(_BUILDARCH) -k $(KMDF_VERSION_MAJOR).$(KMDF_VERSION_MINOR) 4 | 5 | $(OBJ_PATH)\$(O)\$(INF_NAME).inf: $(_INX)\$(INF_NAME).inx 6 | copy $(_INX)\$(@B).inx $@ 7 | $(STAMP) 8 | -------------------------------------------------------------------------------- /Balloon/sys/precomp.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * Copyright (c) 2009-2015 Red Hat, Inc. 3 | * 4 | * File: precomp.h 5 | * 6 | * Author(s): 7 | * 8 | * Pre-compiled header file for balloon driver. 9 | * 10 | * This work is licensed under the terms of the GNU GPL, version 2. See 11 | * the COPYING file in the top-level directory. 12 | * 13 | **********************************************************************/ 14 | #include 15 | #include 16 | #include 17 | #include 18 | #define NTSTRSAFE_LIB 19 | #include 20 | #include // required for GUID definitions 21 | #include // required for WMILIB_CONTEXT 22 | #include 23 | #include 24 | #include 25 | #include "osdep.h" 26 | 27 | #include "virtio_pci.h" 28 | #include "virtio_config.h" 29 | #include "virtio.h" 30 | 31 | #include "ProtoTypes.h" 32 | #include "public.h" 33 | #include "trace.h" 34 | -------------------------------------------------------------------------------- /Balloon/sys/public.h: -------------------------------------------------------------------------------- 1 | #ifndef PUBLIC_H 2 | #define PUBLIC_H 3 | 4 | // {E18B5FB3-04E4-42fc-9601-8395C217391B} 5 | DEFINE_GUID(GUID_DEVINTERFACE_BALLOON, 6 | 0xe18b5fb3, 0x4e4, 0x42fc, 0x96, 0x1, 0x83, 0x95, 0xc2, 0x17, 0x39, 0x1b); 7 | 8 | #define VIRTIO_BALLOON_S_SWAP_IN 0 /* Amount of memory swapped in */ 9 | #define VIRTIO_BALLOON_S_SWAP_OUT 1 /* Amount of memory swapped out */ 10 | #define VIRTIO_BALLOON_S_MAJFLT 2 /* Number of major faults */ 11 | #define VIRTIO_BALLOON_S_MINFLT 3 /* Number of minor faults */ 12 | #define VIRTIO_BALLOON_S_MEMFREE 4 /* Total amount of free memory */ 13 | #define VIRTIO_BALLOON_S_MEMTOT 5 /* Total amount of memory */ 14 | #define VIRTIO_BALLOON_S_NR 6 15 | 16 | #pragma pack (push) 17 | #pragma pack (1) 18 | 19 | typedef struct { 20 | USHORT tag; 21 | UINT64 val; 22 | } BALLOON_STAT, *PBALLOON_STAT; 23 | #pragma pack (pop) 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /Balloon/sys/sources: -------------------------------------------------------------------------------- 1 | TARGETNAME=balloon 2 | TARGETTYPE=DRIVER 3 | 4 | C_DEFINES = -D_MAJORVERSION_=$(_BUILD_MAJOR_VERSION_) $(C_DEFINES) 5 | C_DEFINES = -D_MINORVERSION_=$(_BUILD_MINOR_VERSION_) $(C_DEFINES) 6 | C_DEFINES = -D_NT_TARGET_MAJ=$(_NT_TARGET_MAJ) $(C_DEFINES) 7 | C_DEFINES = -D_NT_TARGET_MIN=$(_RHEL_RELEASE_VERSION_) $(C_DEFINES) 8 | 9 | KMDF_VERSION_MAJOR=1 10 | 11 | INF_NAME=balloon 12 | 13 | MSC_WARNING_LEVEL=-W3 -WX 14 | 15 | TARGETLIBS=$(TARGETLIBS) \ 16 | $(DDK_LIB_PATH)\ntstrsafe.lib \ 17 | ..\..\VirtIO\$(O)\virtiolib.lib 18 | 19 | 20 | MISCFILES=$(OBJ_PATH)\$(O)\$(INF_NAME).inf 21 | 22 | INCLUDES = $(INCLUDES);..\..\VirtIO 23 | 24 | NTTARGETFILES= 25 | 26 | SOURCES= \ 27 | Balloon.rc \ 28 | Driver.c \ 29 | Device.c \ 30 | Balloon.c \ 31 | queue.c \ 32 | utils.c 33 | 34 | PRECOMPILED_INCLUDE=precomp.h 35 | PRECOMPILED_PCH=precomp.pch 36 | PRECOMPILED_OBJ=precomp.obj 37 | 38 | #ENABLE_EVENT_TRACING=1 39 | 40 | # select one or none of those 41 | #ENABLE_COM_DEBUG=1 42 | ENABLE_PRINT_DEBUG=1 43 | 44 | !IFDEF ENABLE_EVENT_TRACING 45 | C_DEFINES = $(C_DEFINES) -DEVENT_TRACING 46 | RUN_WPP= $(SOURCES) \ 47 | -km \ 48 | -func:TraceEvents(LEVEL,FLAGS,MSG,...) \ 49 | -gen:{km-WdfDefault.tpl}*.tmh 50 | !ENDIF 51 | 52 | !IFDEF ENABLE_COM_DEBUG 53 | C_DEFINES = $(C_DEFINES) -DCOM_DEBUG 54 | !ENDIF 55 | 56 | !IFDEF ENABLE_PRINT_DEBUG 57 | C_DEFINES = $(C_DEFINES) -DPRINT_DEBUG 58 | !ENDIF 59 | 60 | TARGET_DESTINATION=wdf 61 | -------------------------------------------------------------------------------- /NetKVM/CoInstaller/Exception.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "tstrings.h" 4 | 5 | using std::exception; 6 | 7 | class neTKVMException : public exception 8 | { 9 | public: 10 | neTKVMException(); 11 | neTKVMException(LPCTSTR lpzMessage); 12 | neTKVMException(const tstring &Message); 13 | neTKVMException(const neTKVMException &Other); 14 | virtual ~neTKVMException(); 15 | 16 | virtual const char *what() const; 17 | virtual LPCTSTR twhat() const; 18 | 19 | protected: 20 | void SetMessage(const tstring &Message); 21 | 22 | private: 23 | tstring m_Message; 24 | string m_MBCSMessage; 25 | }; 26 | 27 | class neTKVMNumErrorException : public neTKVMException 28 | { 29 | public: 30 | neTKVMNumErrorException(LPCTSTR lpzDescription, DWORD dwErrorCode); 31 | neTKVMNumErrorException(const tstring &Description, DWORD dwErrorCode); 32 | neTKVMNumErrorException(const neTKVMNumErrorException& Other); 33 | 34 | DWORD GetErrorCode(void) { return m_dwErrorCode; } 35 | 36 | protected: 37 | DWORD m_dwErrorCode; 38 | }; 39 | 40 | class neTKVMCRTErrorException : public neTKVMNumErrorException 41 | { 42 | public: 43 | neTKVMCRTErrorException(int nErrorCode = errno); 44 | neTKVMCRTErrorException(LPCTSTR lpzDescription, int nErrorCode = errno); 45 | neTKVMCRTErrorException(const tstring &Description, int nErrorCode = errno); 46 | neTKVMCRTErrorException(const neTKVMCRTErrorException &Other); 47 | 48 | protected: 49 | static tstring GetErrorString(DWORD dwErrorCode); 50 | }; 51 | 52 | #ifdef WIN32 53 | class neTKVMW32ErrorException : public neTKVMNumErrorException 54 | { 55 | public: 56 | neTKVMW32ErrorException(DWORD dwErrorCode = GetLastError()); 57 | neTKVMW32ErrorException(LPCTSTR lpzDescription, DWORD dwErrorCode = GetLastError()); 58 | neTKVMW32ErrorException(const tstring &Description, DWORD dwErrorCode = GetLastError()); 59 | neTKVMW32ErrorException(const neTKVMW32ErrorException &Other); 60 | 61 | protected: 62 | static tstring GetErrorString(DWORD dwErrorCode); 63 | }; 64 | #endif 65 | 66 | -------------------------------------------------------------------------------- /NetKVM/CoInstaller/NetKVMAux.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "NetKVMAux.h" 3 | 4 | typedef LONG NTSTATUS; 5 | 6 | #ifndef STATUS_BUFFER_TOO_SMALL 7 | #define STATUS_BUFFER_TOO_SMALL ((NTSTATUS)0xC0000023L) 8 | #endif 9 | 10 | #ifndef STATUS_SUCCESS 11 | #define STATUS_SUCCESS ((NTSTATUS)0x00000000L) 12 | #endif 13 | 14 | wstring NetKVMGetKeyPathFromKKEY(HKEY hKey) 15 | { 16 | std::wstring wstrKeyPath; 17 | if (hKey != NULL) 18 | { 19 | HMODULE hNTDll = LoadLibrary(TEXT("ntdll.dll")); 20 | if (hNTDll != NULL) { 21 | typedef DWORD (__stdcall *ZwQueryKeyType)(HANDLE KeyHandle, 22 | int KeyInformationClass, 23 | PVOID KeyInformation, 24 | ULONG Length, 25 | PULONG ResultLength); 26 | 27 | ZwQueryKeyType pZwQueryKey = reinterpret_cast(::GetProcAddress(hNTDll, "ZwQueryKey")); 28 | 29 | if (pZwQueryKey != NULL) { 30 | DWORD dwSize = 0; 31 | DWORD dwResult = 0; 32 | dwResult = pZwQueryKey(hKey, 3, 0, 0, &dwSize); 33 | if (dwResult == STATUS_BUFFER_TOO_SMALL) 34 | { 35 | dwSize += sizeof(wchar_t); 36 | wchar_t* szNameBuf = new wchar_t[dwSize]; 37 | dwResult = pZwQueryKey(hKey, 3, szNameBuf, dwSize, &dwSize); 38 | if (dwResult == STATUS_SUCCESS) 39 | { 40 | szNameBuf[dwSize / sizeof(wchar_t)] = L'\0'; 41 | wstrKeyPath = wstring(szNameBuf + 2); 42 | } 43 | 44 | delete[] szNameBuf; 45 | } 46 | } 47 | 48 | FreeLibrary(hNTDll); 49 | } 50 | } 51 | return wstrKeyPath; 52 | } 53 | 54 | -------------------------------------------------------------------------------- /NetKVM/CoInstaller/NetKVMAux.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | wstring NetKVMGetKeyPathFromKKEY(HKEY hKey); 4 | -------------------------------------------------------------------------------- /NetKVM/CoInstaller/NetKVMCo.h: -------------------------------------------------------------------------------- 1 | // The following ifdef block is the standard way of creating macros which make exporting 2 | // from a DLL simpler. All files within this DLL are compiled with the NETCO_EXPORTS 3 | // symbol defined on the command line. this symbol should not be defined on any project 4 | // that uses this DLL. This way any other project whose source files include this file see 5 | // NETCO_API functions as being imported from a DLL, whereas this DLL sees symbols 6 | // defined with this macro as being exported. 7 | #ifdef NETCO_EXPORTS 8 | #define NETCO_API __declspec(dllexport) 9 | #else 10 | #define NETCO_API __declspec(dllimport) 11 | #endif 12 | 13 | NETCO_API DWORD CALLBACK NetCoinstaller (__in DI_FUNCTION InstallFunction, 14 | __in HDEVINFO DeviceInfoSet, 15 | __in PSP_DEVINFO_DATA DeviceInfoData, 16 | OPTIONAL __inout PCOINSTALLER_CONTEXT_DATA Context); 17 | 18 | -------------------------------------------------------------------------------- /NetKVM/CoInstaller/NetKVMnetsh.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // The following ifdef block is the standard way of creating macros which make exporting 4 | // from a DLL simpler. All files within this DLL are compiled with the NETCO_EXPORTS 5 | // symbol defined on the command line. this symbol should not be defined on any project 6 | // that uses this DLL. This way any other project whose source files include this file see 7 | // NETCO_API functions as being imported from a DLL, whereas this DLL sees symbols 8 | // defined with this macro as being exported. 9 | #ifdef NETCO_EXPORTS 10 | #define NETCO_API __declspec(dllexport) 11 | #else 12 | #define NETCO_API __declspec(dllimport) 13 | #endif 14 | 15 | #ifdef __cplusplus 16 | extern "C" { 17 | #endif 18 | 19 | DWORD NETCO_API InitHelperDll(__in DWORD dwNetshVersion, 20 | PVOID pReserved); 21 | 22 | //Register NetKVM NetSH helper in NetSH framework 23 | //Returns ERROR_SUCCESS or corresponding error value 24 | //WARNING: Uses DLL file pathname, 25 | // must be called after DLL copied to its final location 26 | DWORD NETCO_API RegisterNetKVMNetShHelper(void); 27 | //Unregister RedHat NetSH helper 28 | //Returns ERROR_SUCCESS or corresponding error value 29 | DWORD NETCO_API UnregisterNetKVMNetShHelper(void); 30 | 31 | #ifdef __cplusplus 32 | } // extern "C" 33 | #endif 34 | -------------------------------------------------------------------------------- /NetKVM/CoInstaller/QA-guidelines.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vrozenfe/virtio-win/71667c799db2e53d3da301af1dd36dce6f6e20ef/NetKVM/CoInstaller/QA-guidelines.doc -------------------------------------------------------------------------------- /NetKVM/CoInstaller/clean.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | goto start 3 | :rmdir 4 | if exist "%~1" rmdir "%~1" /s /q 5 | goto :eof 6 | 7 | :rmfiles 8 | if "%~1"=="" goto :eof 9 | if exist "%~1" del "%~1" 10 | shift 11 | goto rmfiles 12 | 13 | :start 14 | 15 | call :rmdir x64 16 | call :rmdir VistaDebug 17 | call :rmdir VistaRelease 18 | call :rmdir Win7Debug 19 | call :rmdir Win7Release 20 | call :rmdir Win8Debug 21 | call :rmdir Win8Release 22 | -------------------------------------------------------------------------------- /NetKVM/CoInstaller/readme.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vrozenfe/virtio-win/71667c799db2e53d3da301af1dd36dce6f6e20ef/NetKVM/CoInstaller/readme.doc -------------------------------------------------------------------------------- /NetKVM/CoInstaller/sources.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | netkvmco 5 | DYNLINK 6 | 1 7 | /W4 /WX 8 | $(C_DEFINES) /D_UNICODE /DUNICODE /DNETCO_EXPORTS 9 | _DllMainCRTStartup 10 | 11 | $(PSDK_INC_PATH);$(MFC_INC_PATH);$(INCLUDES); 12 | stdafx.h 13 | 1 14 | 1 15 | 70 16 | 1 17 | $(USER_C_FLAGS) /nologo 18 | netco.rc Exception.cpp NetKVMAux.cpp NetKVMnetsh.cpp RegAccess.cpp RegParam.cpp tstrings.cpp netkvmco.c \ 19 | $(PSDK_LIB_PATH)\Netsh.lib $(PSDK_LIB_PATH)\x64\Netsh.lib $(SDK_LIB_PATH)\Setupapi.lib $(SDK_LIB_PATH)\advapi32.lib $(SDK_LIB_PATH)\kernel32.lib 20 | 21 | -------------------------------------------------------------------------------- /NetKVM/CoInstaller/stdafx.c: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // netco.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /NetKVM/CoInstaller/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #include "targetver.h" 9 | #include "resource.h" 10 | 11 | #ifndef WIN32_LEAN_AND_MEAN 12 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 13 | #endif 14 | 15 | // Windows Header Files: 16 | #pragma warning(push, 3) 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #pragma warning(pop) 26 | 27 | #ifdef __cplusplus 28 | #include "tstrings.h" 29 | #include "Exception.h" 30 | 31 | #pragma warning(push, 3) 32 | #pragma warning(disable:4995) //name was marked as #pragma deprecated 33 | #include 34 | #include 35 | #pragma warning(pop) 36 | 37 | using namespace std; 38 | #endif 39 | #pragma warning(disable:4512) //assignment operator could not be generated 40 | 41 | 42 | #ifdef _DEBUG 43 | #define NETCO_DEBUG_PRINT(x) { tcout << TEXT("NETKVM: ") << x << endl;} 44 | #else 45 | #define NETCO_DEBUG_PRINT(x) 46 | #endif 47 | 48 | #ifndef ARRAY_SIZE 49 | #define ARRAY_SIZE(a) (sizeof(a)/sizeof((a)[0])) 50 | #endif 51 | 52 | // TODO: reference additional headers your program requires here 53 | -------------------------------------------------------------------------------- /NetKVM/CoInstaller/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // The following macros define the minimum required platform. The minimum required platform 4 | // is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run 5 | // your application. The macros work by enabling all features available on platform versions up to and 6 | // including the version specified. 7 | 8 | // Modify the following defines if you have to target a platform prior to the ones specified below. 9 | // Refer to MSDN for the latest info on corresponding values for different platforms. 10 | #ifndef WINVER // Specifies that the minimum required platform is Windows Vista. 11 | #define WINVER 0x0600 // Change this to the appropriate value to target other versions of Windows. 12 | #endif 13 | 14 | #ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista. 15 | #define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows. 16 | #endif 17 | 18 | #ifndef _WIN32_WINDOWS // Specifies that the minimum required platform is Windows 98. 19 | #define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later. 20 | #endif 21 | 22 | #ifndef _WIN32_IE // Specifies that the minimum required platform is Internet Explorer 7.0. 23 | #define _WIN32_IE 0x0700 // Change this to the appropriate value to target other versions of IE. 24 | #endif 25 | -------------------------------------------------------------------------------- /NetKVM/CoInstaller/tstrings.cpp: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | 3 | string __wstring2string(const wstring& str) 4 | { 5 | size_t buf_length = str.length() + 1; 6 | char* buf = new (std::nothrow) char[buf_length]; 7 | size_t nCount; 8 | 9 | if(NULL == buf) 10 | { 11 | return string(); 12 | } 13 | 14 | if( 0 != wcstombs_s(&nCount, buf, buf_length, str.c_str(), buf_length) ) 15 | {// Return empty string in case of failure 16 | buf[0] = 0; 17 | } 18 | 19 | string result(buf); 20 | delete [] buf; 21 | return result; 22 | } 23 | 24 | wstring __string2wstring(const string& str) 25 | { 26 | size_t buf_length = str.length() + 1; 27 | wchar_t* buf = new (std::nothrow) wchar_t[buf_length]; 28 | size_t nCount; 29 | 30 | if(NULL == buf) 31 | { 32 | return wstring(); 33 | } 34 | 35 | if( 0 != mbstowcs_s(&nCount, buf, buf_length, str.c_str(), buf_length) ) 36 | {// Return empty string in case of failure 37 | buf[0] = 0; 38 | } 39 | 40 | wstring result(buf); 41 | delete [] buf; 42 | return result; 43 | } 44 | -------------------------------------------------------------------------------- /NetKVM/CoInstaller/tstrings.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #pragma warning(push, 3) 4 | #pragma warning(disable:4995) //name was marked as #pragma deprecated 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #pragma warning(pop) 12 | 13 | using std::string; 14 | using std::wstring; 15 | using std::stringstream; 16 | using std::wstringstream; 17 | using std::wcout; 18 | using std::cout; 19 | using std::list; 20 | using std::allocator; 21 | 22 | string __wstring2string(const wstring& str); 23 | wstring __string2wstring(const string& str); 24 | 25 | #if defined(UNICODE) 26 | typedef wstring tstring; 27 | typedef wstringstream tstringstream; 28 | # define tcout wcout 29 | # define tstring2string(str) __wstring2string(str) 30 | # define string2tstring(str) __string2wstring(str) 31 | # define tstring2wstring(str) (str) 32 | # define wstring2tstring(str) (str) 33 | #else 34 | typedef string tstring; 35 | typedef stringstream tstringstream; 36 | # define tcout cout 37 | # define tstring2string(str) (str) 38 | # define string2tstring(str) (str) 39 | # define tstring2wstring(str) __string2wstring(str) 40 | # define wstring2tstring(str) __wstring2string(str) 41 | #endif 42 | 43 | 44 | typedef list> neTKVMTStrList; 45 | 46 | #define TBUF_SIZEOF(a) ARRAY_SIZE(a) 47 | 48 | 49 | -------------------------------------------------------------------------------- /NetKVM/Common/ParaNdis-AbstractPath.cpp: -------------------------------------------------------------------------------- 1 | #include "ndis56common.h" 2 | #include "ParaNdis-AbstractPath.h" 3 | #include "kdebugprint.h" 4 | 5 | NDIS_STATUS CParaNdisAbstractPath::SetupMessageIndex(u16 queueCardinal) 6 | { 7 | u16 val; 8 | 9 | WriteVirtIODeviceWord(m_Context->IODevice->addr + VIRTIO_PCI_QUEUE_SEL, (u16)queueCardinal); 10 | WriteVirtIODeviceWord(m_Context->IODevice->addr + VIRTIO_MSI_QUEUE_VECTOR, (u16)queueCardinal); 11 | val = ReadVirtIODeviceWord(m_Context->IODevice->addr + VIRTIO_MSI_QUEUE_VECTOR); 12 | if (val != queueCardinal) 13 | { 14 | DPrintf(0, ("[%s] - read/write mismatch, %u vs %u\n", val, queueCardinal)); 15 | return NDIS_STATUS_DEVICE_FAILED; 16 | } 17 | 18 | m_messageIndex = queueCardinal; 19 | return NDIS_STATUS_SUCCESS; 20 | } 21 | 22 | ULONG CParaNdisAbstractPath::getCPUIndex() 23 | { 24 | #if NDIS_SUPPORT_NDIS620 25 | PROCESSOR_NUMBER procNumber = { 0 }; 26 | 27 | procNumber.Group = DPCAffinity.Group; 28 | ULONG number = ParaNdis_GetIndexFromAffinity(DPCAffinity.Mask); 29 | if (number == INVALID_PROCESSOR_INDEX) 30 | { 31 | DPrintf(0, ("[%s] : bad in-group processor index: mask 0x%lx\n", __FUNCTION__, (ULONG)DPCAffinity.Mask)); 32 | ASSERT(FALSE); 33 | return INVALID_PROCESSOR_INDEX; 34 | } 35 | 36 | procNumber.Number = (UCHAR)number; 37 | procNumber.Reserved = 0; 38 | 39 | ULONG procIndex = KeGetProcessorIndexFromNumber(&procNumber); 40 | ASSERTMSG("Bad processor Index", procIndex != INVALID_PROCESSOR_INDEX); 41 | return procIndex; 42 | #else 43 | return ParaNdis_GetIndexFromAffinity(DPCTargetProcessor); 44 | #endif 45 | } 46 | -------------------------------------------------------------------------------- /NetKVM/Common/ParaNdis-AbstractPath.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ParaNdis-VirtQueue.h" 3 | 4 | class CParaNdisAbstractPath 5 | { 6 | public: 7 | #if NDIS_SUPPORT_NDIS620 8 | CParaNdisAbstractPath() 9 | { 10 | memset(&DPCAffinity, 0, sizeof(DPCAffinity)); 11 | } 12 | #else 13 | CParaNdisAbstractPath() : DPCTargetProcessor(0) {} 14 | #endif 15 | 16 | bool WasInterruptReported() 17 | { 18 | return m_interruptReported; 19 | } 20 | 21 | void ClearInterruptReport() 22 | { 23 | m_interruptReported = false; 24 | } 25 | 26 | void ReportInterrupt() { 27 | m_interruptReported = true; 28 | } 29 | 30 | UINT getMessageIndex() { 31 | return m_messageIndex; 32 | } 33 | 34 | UINT getQueueIndex() { 35 | return m_queueIndex; 36 | } 37 | 38 | virtual NDIS_STATUS SetupMessageIndex(u16 queueCardinal); 39 | 40 | /* TODO - Path classes should inherit from CVirtQueue*/ 41 | virtual void DisableInterrupts() 42 | { 43 | m_pVirtQueue->DisableInterrupts(); 44 | } 45 | 46 | void EnableInterrupts() 47 | { 48 | m_pVirtQueue->EnableInterrupts(); 49 | } 50 | 51 | void Renew() 52 | { 53 | m_pVirtQueue->Renew(); 54 | } 55 | 56 | bool IsInterruptEnabled() 57 | { 58 | return m_pVirtQueue->IsInterruptEnabled(); 59 | } 60 | 61 | ULONG getCPUIndex(); 62 | 63 | #if NDIS_SUPPORT_NDIS620 64 | GROUP_AFFINITY DPCAffinity; 65 | #else 66 | KAFFINITY DPCTargetProcessor = 0; 67 | #endif 68 | 69 | protected: 70 | PPARANDIS_ADAPTER m_Context; 71 | CVirtQueue *m_pVirtQueue; 72 | 73 | u16 m_messageIndex = (u16)-1; 74 | u16 m_queueIndex = (u16)-1; 75 | bool m_interruptReported; 76 | }; 77 | 78 | 79 | template class CParaNdisTemplatePath : public CParaNdisAbstractPath { 80 | public: 81 | CParaNdisTemplatePath() { 82 | m_pVirtQueue = &m_VirtQueue; 83 | } 84 | 85 | 86 | void Shutdown() 87 | { 88 | TSpinLocker LockedContext(m_Lock); 89 | m_VirtQueue.Shutdown(); 90 | } 91 | 92 | protected: 93 | CNdisSpinLock m_Lock; 94 | 95 | VQ m_VirtQueue; 96 | tCompletePhysicalAddress m_VirtQueueRing; 97 | }; 98 | -------------------------------------------------------------------------------- /NetKVM/Common/ParaNdis-CX.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ParaNdis-VirtQueue.h" 3 | #include "ndis56common.h" 4 | #include "ParaNdis-AbstractPath.h" 5 | 6 | class CParaNdisCX : public CParaNdisTemplatePath, public CNdisAllocatable < CParaNdisCX, 'CXHR' > { 7 | public: 8 | CParaNdisCX(); 9 | ~CParaNdisCX(); 10 | 11 | bool Create(PPARANDIS_ADAPTER Context, UINT DeviceQueueIndex); 12 | 13 | virtual NDIS_STATUS SetupMessageIndex(u16 queueCardinal); 14 | 15 | BOOLEAN CParaNdisCX::SendControlMessage( 16 | UCHAR cls, 17 | UCHAR cmd, 18 | PVOID buffer1, 19 | ULONG size1, 20 | PVOID buffer2, 21 | ULONG size2, 22 | int levelIfOK 23 | ); 24 | 25 | protected: 26 | tCompletePhysicalAddress m_ControlData; 27 | }; 28 | -------------------------------------------------------------------------------- /NetKVM/Common/ParaNdis-RX.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ParaNdis-VirtQueue.h" 3 | #include "ParaNdis-AbstractPath.h" 4 | 5 | class CParaNdisRX : public CParaNdisTemplatePath, public CNdisAllocatable < CParaNdisRX, 'XRHR' > { 6 | public: 7 | CParaNdisRX(); 8 | ~CParaNdisRX(); 9 | 10 | bool Create(PPARANDIS_ADAPTER Context, UINT DeviceQueueIndex); 11 | 12 | BOOLEAN AddRxBufferToQueue(pRxNetDescriptor pBufferDescriptor); 13 | 14 | void PopulateQueue(); 15 | 16 | void FreeRxDescriptorsFromList(); 17 | 18 | void ReuseReceiveBuffer(pRxNetDescriptor pBuffersDescriptor) 19 | { 20 | CLockedContext autoLock(m_Lock); 21 | 22 | ReuseReceiveBufferNoLock(pBuffersDescriptor); 23 | } 24 | 25 | VOID ProcessRxRing(CCHAR nCurrCpuReceiveQueue); 26 | 27 | BOOLEAN RestartQueue(); 28 | 29 | void Shutdown() 30 | { 31 | CLockedContext autoLock(m_Lock); 32 | 33 | m_VirtQueue.Shutdown(); 34 | m_Reinsert = false; 35 | } 36 | 37 | PARANDIS_RECEIVE_QUEUE &UnclassifiedPacketsQueue() { return m_UnclassifiedPacketsQueue; } 38 | 39 | private: 40 | /* list of Rx buffers available for data (under VIRTIO management) */ 41 | LIST_ENTRY m_NetReceiveBuffers; 42 | UINT m_NetNofReceiveBuffers; 43 | 44 | UINT m_nReusedRxBuffersCounter, m_nReusedRxBuffersLimit; 45 | 46 | bool m_Reinsert = true; 47 | 48 | PARANDIS_RECEIVE_QUEUE m_UnclassifiedPacketsQueue; 49 | 50 | void ReuseReceiveBufferNoLock(pRxNetDescriptor pBuffersDescriptor); 51 | private: 52 | int PrepareReceiveBuffers(); 53 | pRxNetDescriptor CreateRxDescriptorOnInit(); 54 | 55 | static BOOLEAN _Function_class_(MINIPORT_SYNCHRONIZE_INTERRUPT) RestartQueueSynchronously(tSynchronizedContext *ctx); 56 | }; 57 | -------------------------------------------------------------------------------- /NetKVM/Common/ParaNdis_Debug.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void ParaNdis_DebugInitialize(); 4 | void ParaNdis_DebugCleanup(PDRIVER_OBJECT pDriverObject); 5 | void ParaNdis_DebugRegisterMiniport(PARANDIS_ADAPTER *pContext, BOOLEAN bRegister); 6 | -------------------------------------------------------------------------------- /NetKVM/Common/ParaNdis_DebugHistory.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | //#define ENABLE_HISTORY_LOG 4 | #if !defined(ENABLE_HISTORY_LOG) 5 | 6 | void FORCEINLINE ParaNdis_DebugHistory( 7 | PARANDIS_ADAPTER *pContext, 8 | eHistoryLogOperation op, 9 | PVOID pParam1, 10 | ULONG lParam2, 11 | ULONG lParam3, 12 | ULONG lParam4) 13 | { 14 | UNREFERENCED_PARAMETER(pContext); 15 | UNREFERENCED_PARAMETER(op); 16 | UNREFERENCED_PARAMETER(pParam1); 17 | UNREFERENCED_PARAMETER(lParam2); 18 | UNREFERENCED_PARAMETER(lParam3); 19 | UNREFERENCED_PARAMETER(lParam4); 20 | } 21 | 22 | #else 23 | 24 | void ParaNdis_DebugHistory( 25 | PARANDIS_ADAPTER *pContext, 26 | eHistoryLogOperation op, 27 | PVOID pParam1, 28 | ULONG lParam2, 29 | ULONG lParam3, 30 | ULONG lParam4); 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /NetKVM/Common/osdep.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * Copyright (c) 2008-2015 Red Hat, Inc. 3 | * 4 | * File: osdep.h 5 | * 6 | * This file contains highest level definitions, mainly for non-NDIS modules, 7 | * when they are involved into NDIS driver 8 | * 9 | * This work is licensed under the terms of the GNU GPL, version 2. See 10 | * the COPYING file in the top-level directory. 11 | * 12 | **********************************************************************/ 13 | #ifndef __OS_DEP_H 14 | #define __OS_DEP_H 15 | 16 | #pragma warning (push) 17 | #pragma warning (disable:4201) 18 | #pragma warning (disable:28301) 19 | #pragma warning (disable:28252) 20 | #pragma warning (disable:28251) 21 | #include 22 | #pragma warning (pop) 23 | 24 | #pragma warning (push) 25 | #pragma warning (disable:6102) 26 | #include 27 | #pragma warning (pop) 28 | 29 | #if NTDDI_VERSION <= NTDDI_VISTA 30 | #define _Requires_lock_held_(lock) 31 | #define _Acquires_shared_lock_(lock) 32 | #define _Acquires_exclusive_lock_(lock) 33 | #endif 34 | 35 | #define mb() KeMemoryBarrier() 36 | #define rmb() KeMemoryBarrier() 37 | #define wmb() KeMemoryBarrier() 38 | #define smp_wmb() KeMemoryBarrier() 39 | 40 | #ifndef min 41 | #define min(_a, _b) (((_a) < (_b)) ? (_a) : (_b)) 42 | #endif 43 | 44 | #ifndef max 45 | #define max(_a, _b) (((_a) > (_b)) ? (_a) : (_b)) 46 | #endif 47 | 48 | #ifndef PARANDIS_MAJOR_DRIVER_VERSION 49 | #error PARANDIS_MAJOR_DRIVER_VERSION not defined 50 | #endif 51 | 52 | #ifndef PARANDIS_MINOR_DRIVER_VERSION 53 | #error PARANDIS_MINOR_DRIVER_VERSION not defined 54 | #endif 55 | 56 | #if (7-PARANDIS_MAJOR_DRIVER_VERSION-7) == 14 57 | #undef PARANDIS_MAJOR_DRIVER_VERSION 58 | #define PARANDIS_MAJOR_DRIVER_VERSION 101 59 | #endif 60 | 61 | #if (7-PARANDIS_MINOR_DRIVER_VERSION-7) == 14 62 | #undef PARANDIS_MINOR_DRIVER_VERSION 63 | #define PARANDIS_MINOR_DRIVER_VERSION 58000 64 | #endif 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /NetKVM/DebugTools/HCKParser/Makefile: -------------------------------------------------------------------------------- 1 | PROGRAMS=hck_seq 2 | CXXFLAGS=-g 3 | LDLIBS= -lpcap 4 | 5 | 6 | all: ${PROGRAMS} 7 | 8 | clean: 9 | rm ${PROGRAMS} *.o *~ core 10 | -------------------------------------------------------------------------------- /NetKVM/DebugTools/HCKParser/README.txt: -------------------------------------------------------------------------------- 1 | The hck_seq utility parses the pcap file and verifies the 2 | correctness of the HCK packets order. The utility may be useful for 3 | trouble-shooting the HCK error when HCK complains about missing and/or 4 | out of order packet delivery by the NetKVM network driver. 5 | 6 | The utility is bases on partial HCK packet 7 | formaet reverse-engineering: it assumes that all HCK packet include 8 | the HCK content marked by "NDIS" prefix, the sequence number can be 9 | found as 16-bit little-endian number in 12th an 13th bytes of the HCK 10 | content and session number is 16-bit little-endian number at offset 22 11 | and 23. 12 | 13 | The utility has the single and mandatory argument, name of pcap file. 14 | 15 | The pcap files may be collected both inside the Windows guests 16 | with wireshark and on host, by listening on the 'tap' networking 17 | device with wireshark or tcpdump. 18 | 19 | Please, notice that when running wireshark inside Windows guest 20 | alongside the HCK requires manual intervention: HCK disables and 21 | enables the networking device, and the wireshark capture to be resumed 22 | manually. Wireshark capture resume is easier when unsaved capture 23 | files confirmation is disabled; with wireshark 1.12.2, it may be 24 | accomplished by selecting Edit->Preferences->User Interface. 25 | 26 | The utility's building requires pcap development library. 27 | 28 | -------------------------------------------------------------------------------- /NetKVM/DebugTools/HCKParser/hck_seq.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | using namespace std; 8 | 9 | char errbuf[PCAP_ERRBUF_SIZE]; 10 | 11 | typedef vector byte_array; 12 | u_char ndis_bytes[] = {'N', 'D', 'I', 'S'}; 13 | 14 | uint16_t sessions[256]; 15 | 16 | int main(int argc, char **argv) 17 | { 18 | pcap_t *handle; 19 | const u_char *packet; 20 | struct pcap_pkthdr header; 21 | unsigned long counter = 0; 22 | 23 | if (argc != 2) { 24 | cerr << "Unexpected args" << endl <<"Usage: hck_seq " << endl; 25 | return -1; 26 | } 27 | 28 | handle = pcap_open_offline(argv[1], errbuf); 29 | if (handle == NULL) { 30 | cerr << argv[1] << ":" << errbuf << endl; 31 | return -1; 32 | } 33 | while (packet = pcap_next(handle,&header)) { 34 | byte_array content(packet, packet + header.caplen); 35 | 36 | byte_array::iterator it = search(content.begin(), content.end(), ndis_bytes, ndis_bytes + 4); 37 | 38 | if (it != content.end() && (it-content.begin() + 22) < content.size()) { 39 | advance(it, 12); 40 | uint8_t b1 = *it++; 41 | uint8_t b2 = *it; 42 | uint16_t sequence_number = b2 << 8 | b1; 43 | 44 | advance(it, 9); 45 | 46 | b1 = *it++; 47 | b2 = *it; 48 | uint16_t session_number = b2 << 8 | b1; 49 | 50 | if (sequence_number != sessions[session_number]) { 51 | if (sequence_number == 0) { 52 | cout << counter << ": "<< "Session " << session_number << " reset" << endl; 53 | } else { 54 | cout << counter << ": " << "Sequence mismatch for session " << session_number << 55 | ": expected " << sessions[session_number] << " got " << 56 | sequence_number << endl; 57 | } 58 | } 59 | 60 | sessions[session_number] = sequence_number + 1; 61 | } 62 | counter ++; 63 | } 64 | 65 | pcap_close(handle); 66 | return 0; 67 | } 68 | 69 | -------------------------------------------------------------------------------- /NetKVM/DebugTools/NetKVMDumpParser/DebugSdk.vsprops: -------------------------------------------------------------------------------- 1 | 2 | 7 | 11 | 12 | -------------------------------------------------------------------------------- /NetKVM/DebugTools/NetKVMDumpParser/NetKVMDumpParser.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | /********************************************************************** 3 | * Copyright (c) 2008-2015 Red Hat, Inc. 4 | * 5 | * File: NetKVMDumpParser.h 6 | * 7 | * This file contains ParseDumpFile function declaration 8 | * 9 | * This work is licensed under the terms of the GNU GPL, version 2. See 10 | * the COPYING file in the top-level directory. 11 | * 12 | **********************************************************************/ 13 | 14 | 15 | #include "resource.h" 16 | 17 | extern int ParseDumpFile(int argc, TCHAR* argv[]); 18 | -------------------------------------------------------------------------------- /NetKVM/DebugTools/NetKVMDumpParser/NetKVMDumpParser.rc: -------------------------------------------------------------------------------- 1 | //Microsoft Visual C++ generated resource script. 2 | // 3 | #include "resource.h" 4 | 5 | #define APSTUDIO_READONLY_SYMBOLS 6 | ///////////////////////////////////////////////////////////////////////////// 7 | // 8 | // Generated from the TEXTINCLUDE 2 resource. 9 | // 10 | #include "afxres.h" 11 | ///////////////////////////////////////////////////////////////////////////// 12 | #undef APSTUDIO_READONLY_SYMBOLS 13 | 14 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_RUS) 15 | LANGUAGE 25, 1 16 | #pragma code_page(1251) 17 | 18 | 19 | #ifdef APSTUDIO_INVOKED 20 | ///////////////////////////////////////////////////////////////////////////// 21 | // 22 | // TEXTINCLUDE 23 | // 24 | 25 | 1 TEXTINCLUDE 26 | BEGIN 27 | "resource.h\0" 28 | END 29 | 30 | 2 TEXTINCLUDE 31 | BEGIN 32 | "#include ""afxres.h""\r\n" 33 | "\0" 34 | END 35 | 36 | 3 TEXTINCLUDE 37 | BEGIN 38 | "\r\n" 39 | "\0" 40 | END 41 | 42 | #endif // APSTUDIO_INVOKED 43 | 44 | ///////////////////////////////////////////////////////////////////////////// 45 | // 46 | // String Table 47 | // 48 | 49 | STRINGTABLE 50 | BEGIN 51 | IDS_APP_TITLE "NetKVMDumpParser" 52 | END 53 | 54 | #endif 55 | ///////////////////////////////////////////////////////////////////////////// 56 | 57 | 58 | 59 | #ifndef APSTUDIO_INVOKED 60 | ///////////////////////////////////////////////////////////////////////////// 61 | // 62 | // Generated from the TEXTINCLUDE 3 resource. 63 | // 64 | #ifndef _AFXDLL 65 | #include "afxres.rc" 66 | #endif 67 | 68 | ///////////////////////////////////////////////////////////////////////////// 69 | #endif // not APSTUDIO_INVOKED 70 | -------------------------------------------------------------------------------- /NetKVM/DebugTools/NetKVMDumpParser/NetKVMDumpParser.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 9.00 3 | # Visual Studio 2005 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NetKVMDumpParser", "NetKVMDumpParser.vcproj", "{EE008D99-FE23-46E6-A4DE-43259E2F2614}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | Release|Win32 = Release|Win32 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {EE008D99-FE23-46E6-A4DE-43259E2F2614}.Debug|Win32.ActiveCfg = Debug|Win32 13 | {EE008D99-FE23-46E6-A4DE-43259E2F2614}.Debug|Win32.Build.0 = Debug|Win32 14 | {EE008D99-FE23-46E6-A4DE-43259E2F2614}.Release|Win32.ActiveCfg = Release|Win32 15 | {EE008D99-FE23-46E6-A4DE-43259E2F2614}.Release|Win32.Build.0 = Release|Win32 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /NetKVM/DebugTools/NetKVMDumpParser/ReadMe.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | CONSOLE APPLICATION : NetKVMDumpParser Project Overview 3 | ======================================================================== 4 | 5 | Usage currently is trivial: 6 | NetKVMDumpParser dump-file 7 | 8 | To be useful, must process dumps from latest version of NETKVM, 9 | in future - from any version supporting crash callback. 10 | 11 | Currently there is no advantage of having correct PDB file available. 12 | It will be loaded if available at native path (where it was built) or in current directory. 13 | (NetKVMDumpParser now does not use it, just checks whether symbols are loaded). 14 | 15 | (of course, when analyzing the dump in WinDBG, there is AN ADVANTAGE). 16 | 17 | In order to compile the tool please make sure that WinDBG SDK is installed. 18 | Point include and libraries paths to appropriate locations. 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /NetKVM/DebugTools/NetKVMDumpParser/Resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by NetKVMDumpParser.rc 4 | // 5 | 6 | #define IDS_APP_TITLE 103 7 | 8 | // Next default values for new objects 9 | // 10 | #ifdef APSTUDIO_INVOKED 11 | #ifndef APSTUDIO_READONLY_SYMBOLS 12 | #define _APS_NEXT_RESOURCE_VALUE 101 13 | #define _APS_NEXT_COMMAND_VALUE 40001 14 | #define _APS_NEXT_CONTROL_VALUE 1000 15 | #define _APS_NEXT_SYMED_VALUE 101 16 | #endif 17 | #endif 18 | -------------------------------------------------------------------------------- /NetKVM/DebugTools/NetKVMDumpParser/debug.cmd: -------------------------------------------------------------------------------- 1 | debug\NetKVMDumpParser.exe D:\SVN\Qumranet\drivers\Logs\CrashHandler\memory.dmp > log.txt 2 | 3 | -------------------------------------------------------------------------------- /NetKVM/DebugTools/NetKVMDumpParser/main.cpp: -------------------------------------------------------------------------------- 1 | // NetKVMDumpParser.cpp : Defines the entry point for the console application. 2 | // 3 | 4 | #include "stdafx.h" 5 | /********************************************************************** 6 | * Copyright (c) 2008-2015 Red Hat, Inc. 7 | * 8 | * File: main.cpp 9 | * 10 | * Contains entry point to console application 11 | * 12 | * This work is licensed under the terms of the GNU GPL, version 2. See 13 | * the COPYING file in the top-level directory. 14 | * 15 | **********************************************************************/ 16 | 17 | #include "NetKVMDumpParser.h" 18 | 19 | #ifdef _DEBUG 20 | #define new DEBUG_NEW 21 | #endif 22 | 23 | 24 | // The one and only application object 25 | 26 | CWinApp theApp; 27 | 28 | using namespace std; 29 | 30 | int _tmain(int argc, TCHAR* argv[], TCHAR* envp[]) 31 | { 32 | int nRetCode = 0; 33 | 34 | // initialize MFC and print and error on failure 35 | if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0)) 36 | { 37 | // TODO: change error code to suit your needs 38 | _tprintf(_T("Fatal Error: MFC initialization failed\n")); 39 | nRetCode = 1; 40 | } 41 | else 42 | { 43 | nRetCode = ParseDumpFile(argc, argv); 44 | } 45 | 46 | return nRetCode; 47 | } 48 | -------------------------------------------------------------------------------- /NetKVM/DebugTools/NetKVMDumpParser/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // NetKVMDumpParser.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /NetKVM/DebugTools/NetKVMDumpParser/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #define _CRT_SECURE_NO_WARNINGS 9 | 10 | // Modify the following defines if you have to target a platform prior to the ones specified below. 11 | // Refer to MSDN for the latest info on corresponding values for different platforms. 12 | #ifndef WINVER // Allow use of features specific to Windows XP or later. 13 | #define WINVER 0x0501 // Change this to the appropriate value to target other versions of Windows. 14 | #endif 15 | 16 | #ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later. 17 | #define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows. 18 | #endif 19 | 20 | #ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later. 21 | #define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later. 22 | #endif 23 | 24 | #ifndef _WIN32_IE // Allow use of features specific to IE 6.0 or later. 25 | #define _WIN32_IE 0x0600 // Change this to the appropriate value to target other versions of IE. 26 | #endif 27 | 28 | #include 29 | #include 30 | #define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit 31 | 32 | #ifndef VC_EXTRALEAN 33 | #define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers 34 | #endif 35 | 36 | #include 37 | #include // MFC core and standard components 38 | #include // MFC extensions 39 | #ifndef _AFX_NO_OLE_SUPPORT 40 | #include // MFC support for Internet Explorer 4 Common Controls 41 | #endif 42 | #ifndef _AFX_NO_AFXCMN_SUPPORT 43 | #include // MFC support for Windows Common Controls 44 | #endif // _AFX_NO_AFXCMN_SUPPORT 45 | 46 | #include 47 | 48 | 49 | 50 | // TODO: reference additional headers your program requires here 51 | #include 52 | #include 53 | -------------------------------------------------------------------------------- /NetKVM/DebugTools/Netchecksum/ReadMe.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | CONSOLE APPLICATION : netchecksum Project Overview 3 | ======================================================================== 4 | 5 | This offline tester of sw-offload.c USES files from NETKVM projects: 6 | ethernetutils.h 7 | ndis56common.h 8 | sw-offload.c 9 | 10 | Preparing input files (each one expected to contain one packet) - 11 | see the format of TXT files, source files are WireShark records. 12 | (some cuts from the WS record required). 13 | 14 | When they are prepared, add them to Jobs array (netchecksum.cpp). 15 | -------------------------------------------------------------------------------- /NetKVM/DebugTools/Netchecksum/netchecksum.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "netchecksum", "netchecksum.vcxproj", "{B9D81752-EA28-475B-B758-F7CE1D627A8D}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | EndGlobalSection 10 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 11 | {B9D81752-EA28-475B-B758-F7CE1D627A8D}.Debug|Win32.ActiveCfg = Debug|Win32 12 | {B9D81752-EA28-475B-B758-F7CE1D627A8D}.Debug|Win32.Build.0 = Debug|Win32 13 | EndGlobalSection 14 | GlobalSection(SolutionProperties) = preSolution 15 | HideSolutionNode = FALSE 16 | EndGlobalSection 17 | EndGlobal 18 | -------------------------------------------------------------------------------- /NetKVM/DebugTools/Netchecksum/netchecksum.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | 29 | 30 | Header Files 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /NetKVM/DebugTools/Netchecksum/run.cmd: -------------------------------------------------------------------------------- 1 | Debug\netchecksum.exe > log.txt 2 | -------------------------------------------------------------------------------- /NetKVM/DebugTools/Netchecksum/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // netchecksum.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /NetKVM/DebugTools/Netchecksum/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later. 9 | #define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows. 10 | #endif 11 | 12 | #include 13 | #include 14 | 15 | 16 | 17 | // TODO: reference additional headers your program requires here 18 | -------------------------------------------------------------------------------- /NetKVM/DebugTools/Netchecksum/tcp-ph.txt: -------------------------------------------------------------------------------- 1 | 2 | 00 14 7c ae ee c0 a0 1c dd 30 84 3d 08 00 45 00 3 | 00 28 04 6d 40 00 80 06 55 9a c0 a8 63 8f cf 44 4 | ad 4c 04 6a 00 50 2a e9 4a 0e e8 ba 07 fb 50 10 5 | ff ff a0 e3 00 00 6 | 7 | zz 8 | 9 | 0000 00 14 7c ae ee c0 a0 1c dd 30 84 3d 08 00 45 00 ..|......0.=..E. 10 | 0010 00 28 04 6d 40 00 80 06 55 9a c0 a8 63 8f cf 44 .(.m@...U...c..D 11 | 0020 ad 4c 04 6a 00 50 2a e9 4a 0e e8 ba 07 fb 50 10 .L.j.P*.J.....P. 12 | 0030 ff ff a0 e3 00 00 ...... 13 | Checksum: 0xa0e3 [incorrect, should be 0xa4a4 (maybe caused by "TCP checksum offload"?)] 14 | Header checksum: 0x559a [correct] 15 | -------------------------------------------------------------------------------- /NetKVM/DebugTools/Netchecksum/tcpv6-cs.txt: -------------------------------------------------------------------------------- 1 | 00 11 25 82 95 b5 00 d0 09 e3 e8 de 86 dd 60 00 2 | 00 00 01 04 06 40 20 01 06 f8 10 2d 00 00 02 d0 3 | 09 ff fe e3 e8 de 20 01 06 f8 09 00 07 c0 00 00 4 | 00 00 00 00 00 02 e7 41 00 50 ab dc d6 61 01 4a 5 | 73 9f 50 18 16 80 f4 48 00 00 47 45 54 20 2f 20 6 | 48 54 54 50 2f 31 2e 30 0d 0a 48 6f 73 74 3a 20 7 | 63 6c 2d 31 39 38 35 2e 68 61 6d 2d 30 31 2e 64 8 | 65 2e 73 69 78 78 73 2e 6e 65 74 0d 0a 41 63 63 9 | 65 70 74 3a 20 74 65 78 74 2f 68 74 6d 6c 2c 20 10 | 74 65 78 74 2f 70 6c 61 69 6e 2c 20 74 65 78 74 11 | 2f 63 73 73 2c 20 74 65 78 74 2f 73 67 6d 6c 2c 12 | 20 2a 2f 2a 3b 71 3d 30 2e 30 31 0d 0a 41 63 63 13 | 65 70 74 2d 45 6e 63 6f 64 69 6e 67 3a 20 67 7a 14 | 69 70 2c 20 62 7a 69 70 32 0d 0a 41 63 63 65 70 15 | 74 2d 4c 61 6e 67 75 61 67 65 3a 20 65 6e 0d 0a 16 | 55 73 65 72 2d 41 67 65 6e 74 3a 20 4c 79 6e 78 17 | 2f 32 2e 38 2e 36 72 65 6c 2e 32 20 6c 69 62 77 18 | 77 77 2d 46 4d 2f 32 2e 31 34 20 53 53 4c 2d 4d 19 | 4d 2f 31 2e 34 2e 31 20 4f 70 65 6e 53 53 4c 2f 20 | 30 2e 39 2e 38 62 0d 0a 0d 0a 21 | 22 | zz 23 | -------------------------------------------------------------------------------- /NetKVM/DebugTools/RSS-Toeplitz/RSS-Toeplitz.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | Header Files 23 | 24 | 25 | Header Files 26 | 27 | 28 | Header Files 29 | 30 | 31 | 32 | 33 | Source Files 34 | 35 | 36 | Source Files 37 | 38 | 39 | Source Files 40 | 41 | 42 | -------------------------------------------------------------------------------- /NetKVM/DebugTools/RSS-Toeplitz/ReadMe.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | CONSOLE APPLICATION : RSS-Toeplitz 3 | ======================================================================== 4 | 5 | See Toeplitz test vectors at 6 | http://msdn.microsoft.com/en-us/windows/hardware/ff571021 7 | 8 | Currently only little endian version. 9 | 10 | TODO: measurement and optimization 11 | TODO: big endian when it will be actual 12 | -------------------------------------------------------------------------------- /NetKVM/DebugTools/RSS-Toeplitz/WinToeplitz.c: -------------------------------------------------------------------------------- 1 | #include "stdafx.h" 2 | #include "winToeplitz.h" 3 | 4 | uint8_t workingkey[WTEP_MAX_KEY_SIZE]; 5 | 6 | void toeplitzw_initialize(uint8_t *key, int keysize) 7 | { 8 | if (keysize > WTEP_MAX_KEY_SIZE) keysize = WTEP_MAX_KEY_SIZE; 9 | memcpy(workingkey, key, keysize); 10 | } 11 | 12 | #define RtlUlongByteSwap(ul) _byteswap_ulong(ul) 13 | 14 | // Little Endian version ONLY 15 | UINT32 ToeplitsHash(const PHASH_CALC_SG_BUF_ENTRY sgBuff, int sgEntriesNum, UINT8 *fullKey) 16 | { 17 | #define TOEPLITZ_MAX_BIT_NUM (7) 18 | #define TOEPLITZ_BYTE_HAS_BIT(byte, bit) ((byte) & (1 << (TOEPLITZ_MAX_BIT_NUM - (bit)))) 19 | #define TOEPLITZ_BYTE_BIT_STATE(byte, bit) (((byte) >> (TOEPLITZ_MAX_BIT_NUM - (bit))) & 1) 20 | 21 | UINT32 firstKeyWord, res = 0; 22 | UINT byte, bit; 23 | PHASH_CALC_SG_BUF_ENTRY sgEntry; 24 | UINT8 *next_key_byte = fullKey + sizeof(firstKeyWord); 25 | firstKeyWord = RtlUlongByteSwap(*(UINT32*)fullKey); 26 | 27 | for(sgEntry = sgBuff; sgEntry < sgBuff + sgEntriesNum; ++sgEntry) 28 | { 29 | for (byte = 0; byte < sgEntry->chunkLen; ++byte) 30 | { 31 | for (bit = 0; bit <= TOEPLITZ_MAX_BIT_NUM; ++bit) 32 | { 33 | if (TOEPLITZ_BYTE_HAS_BIT(sgEntry->chunkPtr[byte], bit)) 34 | { 35 | res ^= firstKeyWord; 36 | } 37 | firstKeyWord = (firstKeyWord << 1) | TOEPLITZ_BYTE_BIT_STATE(*next_key_byte, bit); 38 | } 39 | ++next_key_byte; 40 | } 41 | } 42 | return res; 43 | 44 | #undef TOEPLITZ_BYTE_HAS_BIT 45 | #undef TOEPLITZ_BYTE_BIT_STATE 46 | #undef TOEPLITZ_MAX_BIT_NUM 47 | } 48 | 49 | 50 | -------------------------------------------------------------------------------- /NetKVM/DebugTools/RSS-Toeplitz/WinToeplitz.h: -------------------------------------------------------------------------------- 1 | #ifndef win_toeplitz_h 2 | #define win_toeplitz_h 3 | 4 | #ifndef EXTERN_C 5 | #ifdef __cplusplus 6 | #define EXTERN_C extern "C" 7 | #else 8 | #define EXTERN_C 9 | #endif 10 | #endif 11 | 12 | #define WTEP_MAX_KEY_SIZE 40 13 | 14 | typedef unsigned char uint8_t; 15 | typedef unsigned short uint16_t; 16 | typedef unsigned long uint32_t; 17 | 18 | typedef struct _tagHASH_CALC_SG_BUF_ENTRY 19 | { 20 | PBYTE chunkPtr; 21 | ULONG chunkLen; 22 | } HASH_CALC_SG_BUF_ENTRY, *PHASH_CALC_SG_BUF_ENTRY; 23 | 24 | EXTERN_C void toeplitzw_initialize(uint8_t *key, int keysize); 25 | EXTERN_C UINT32 ToeplitsHash(const PHASH_CALC_SG_BUF_ENTRY sgBuff, int sgEntriesNum, UINT8 *fullKey); 26 | 27 | EXTERN_C uint8_t workingkey[]; 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /NetKVM/DebugTools/RSS-Toeplitz/clean.bat: -------------------------------------------------------------------------------- 1 | rmdir /S /Q ipch 2 | rmdir /S /Q Debug 3 | rmdir /S /Q Release 4 | -------------------------------------------------------------------------------- /NetKVM/DebugTools/RSS-Toeplitz/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // RSS-Toeplitz.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /NetKVM/DebugTools/RSS-Toeplitz/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #include "targetver.h" 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | 16 | 17 | // TODO: reference additional headers your program requires here 18 | -------------------------------------------------------------------------------- /NetKVM/DebugTools/RSS-Toeplitz/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Including SDKDDKVer.h defines the highest available Windows platform. 4 | 5 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and 6 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. 7 | 8 | #include 9 | -------------------------------------------------------------------------------- /NetKVM/DebugTools/VirtioConsoleSimulation/ConsoleSim.cpp: -------------------------------------------------------------------------------- 1 | // ConsoleSim.cpp : Defines the entry point for the console application. 2 | // 3 | 4 | #include "stdafx.h" 5 | #include "ConsoleSim.h" 6 | #include "testcommands.h" 7 | 8 | 9 | #ifdef _DEBUG 10 | #define new DEBUG_NEW 11 | #endif 12 | 13 | 14 | // The one and only application object 15 | 16 | CWinApp theApp; 17 | 18 | using namespace std; 19 | 20 | static FILE *f; 21 | 22 | EXTERN_C void DoPrint(const char *format, ...) 23 | { 24 | va_list list; 25 | va_start(list, format); 26 | vprintf(format, list); 27 | if (!f) f = fopen("test.log", "w+t"); 28 | if (f) vfprintf(f, format, list); 29 | if (f) fflush(f); 30 | } 31 | 32 | void OnScriptEvent(PVOID ref, tScriptEvent evt, const char *format, ...) 33 | { 34 | switch(evt) 35 | { 36 | case escriptEvtPreprocessOK: 37 | break; 38 | case escriptEvtPreprocessFail: 39 | break; 40 | case escriptEvtPreprocessStep: 41 | break; 42 | case escriptEvtProcessStep: 43 | break; 44 | case escriptEvtProcessOK: 45 | break; 46 | case escriptEvtProcessFail: 47 | break; 48 | default: 49 | break; 50 | } 51 | } 52 | 53 | 54 | int _tmain(int argc, TCHAR* argv[], TCHAR* envp[]) 55 | { 56 | int nRetCode = 0; 57 | 58 | HMODULE hModule = ::GetModuleHandle(NULL); 59 | 60 | if (hModule != NULL) 61 | { 62 | // initialize MFC and print and error on failure 63 | if (!AfxWinInit(hModule, NULL, ::GetCommandLine(), 0)) 64 | { 65 | // TODO: change error code to suit your needs 66 | _tprintf(_T("Fatal Error: MFC initialization failed\n")); 67 | nRetCode = 1; 68 | } 69 | else 70 | { 71 | // TODO: code your application's behavior here. 72 | if (argc > 1) 73 | { 74 | RunScript(argv[1], NULL, OnScriptEvent); 75 | } 76 | else 77 | { 78 | RunScript("test.txt", NULL, OnScriptEvent); 79 | } 80 | } 81 | } 82 | else 83 | { 84 | // TODO: change error code to suit your needs 85 | _tprintf(_T("Fatal Error: GetModuleHandle failed\n")); 86 | nRetCode = 1; 87 | } 88 | 89 | return nRetCode; 90 | } 91 | 92 | 93 | -------------------------------------------------------------------------------- /NetKVM/DebugTools/VirtioConsoleSimulation/ConsoleSim.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "resource.h" 4 | -------------------------------------------------------------------------------- /NetKVM/DebugTools/VirtioConsoleSimulation/ConsoleSim.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vrozenfe/virtio-win/71667c799db2e53d3da301af1dd36dce6f6e20ef/NetKVM/DebugTools/VirtioConsoleSimulation/ConsoleSim.rc -------------------------------------------------------------------------------- /NetKVM/DebugTools/VirtioConsoleSimulation/Device/block_int.h: -------------------------------------------------------------------------------- 1 | #ifndef block_int_h 2 | #define block_int_h 3 | 4 | #endif 5 | -------------------------------------------------------------------------------- /NetKVM/DebugTools/VirtioConsoleSimulation/Device/event_notifier.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vrozenfe/virtio-win/71667c799db2e53d3da301af1dd36dce6f6e20ef/NetKVM/DebugTools/VirtioConsoleSimulation/Device/event_notifier.h -------------------------------------------------------------------------------- /NetKVM/DebugTools/VirtioConsoleSimulation/Device/hw.h: -------------------------------------------------------------------------------- 1 | #ifndef hw_h 2 | #define hw_h 3 | 4 | #include 5 | 6 | #define inline __inline 7 | 8 | typedef ULONGLONG target_phys_addr_t; 9 | 10 | struct iovec 11 | { 12 | void *iov_base; /* BSD uses caddr_t (1003.1g requires void *) */ 13 | size_t iov_len; /* Must be size_t (1003.1g) */ 14 | }; 15 | 16 | #define cpu_physical_memory_unmap(...) 17 | #define cpu_physical_memory_map(addr, plen, is_write) addr 18 | 19 | uint64_t inline ldq_phys(target_phys_addr_t pa) 20 | { 21 | return *(uint64_t *)pa; 22 | } 23 | 24 | uint32_t inline ldl_phys(target_phys_addr_t pa) 25 | { 26 | return *(uint32_t *)pa; 27 | } 28 | 29 | uint16_t inline lduw_phys(target_phys_addr_t pa) 30 | { 31 | return *(uint16_t *)pa; 32 | } 33 | 34 | void inline stl_phys(target_phys_addr_t pa, uint32_t val) 35 | { 36 | *(uint32_t *)pa = val; 37 | } 38 | 39 | void inline stw_phys(target_phys_addr_t pa, uint16_t val) 40 | { 41 | *(uint16_t *)pa = val; 42 | } 43 | 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /NetKVM/DebugTools/VirtioConsoleSimulation/Device/inttypes.h: -------------------------------------------------------------------------------- 1 | #ifndef intttypes_h 2 | #define intttypes_h 3 | 4 | typedef unsigned short uint16_t; 5 | typedef short int16_t; 6 | typedef unsigned char uint8_t; 7 | typedef unsigned long uint32_t; 8 | typedef unsigned __int64 uint64_t; 9 | typedef long int32_t; 10 | 11 | typedef void QEMUFile; 12 | typedef int bool; 13 | 14 | #define offsetof(TYPE, ELEMENT) ((size_t)&(((TYPE *)0)->ELEMENT)) 15 | 16 | #define MIN(x,y) (((x) < (y)) ? (x) : (y)) 17 | 18 | #define unlikely(x) (x) 19 | #define true TRUE 20 | #define false FALSE 21 | 22 | #define ARRAY_SIZE(x) (sizeof(x)/sizeof((x)[0])) 23 | #define __attribute__(...) 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /NetKVM/DebugTools/VirtioConsoleSimulation/Device/net.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vrozenfe/virtio-win/71667c799db2e53d3da301af1dd36dce6f6e20ef/NetKVM/DebugTools/VirtioConsoleSimulation/Device/net.h -------------------------------------------------------------------------------- /NetKVM/DebugTools/VirtioConsoleSimulation/Device/qdev.h: -------------------------------------------------------------------------------- 1 | #ifndef qdev_h 2 | #define qdev_h 3 | 4 | 5 | typedef struct DeviceState 6 | { 7 | uint32_t reserved; 8 | }DeviceState; 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /NetKVM/DebugTools/VirtioConsoleSimulation/Device/qemu-error.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vrozenfe/virtio-win/71667c799db2e53d3da301af1dd36dce6f6e20ef/NetKVM/DebugTools/VirtioConsoleSimulation/Device/qemu-error.h -------------------------------------------------------------------------------- /NetKVM/DebugTools/VirtioConsoleSimulation/Device/sysemu.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vrozenfe/virtio-win/71667c799db2e53d3da301af1dd36dce6f6e20ef/NetKVM/DebugTools/VirtioConsoleSimulation/Device/sysemu.h -------------------------------------------------------------------------------- /NetKVM/DebugTools/VirtioConsoleSimulation/Device/trace.h: -------------------------------------------------------------------------------- 1 | #ifndef dev_trace_h 2 | #define dev_trace_h 3 | 4 | #define trace_virtqueue_fill(...) 5 | #define trace_virtqueue_flush(...) 6 | #define trace_virtqueue_pop(...) 7 | #define error_report(...) 8 | #define trace_virtio_queue_notify(...) 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /NetKVM/DebugTools/VirtioConsoleSimulation/Device/virtio-pci.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Virtio PCI Bindings 3 | * 4 | * Copyright IBM, Corp. 2007 5 | * Copyright (c) 2009 CodeSourcery 6 | * 7 | * Authors: 8 | * Anthony Liguori 9 | * Paul Brook 10 | * 11 | * This work is licensed under the terms of the GNU GPL, version 2. See 12 | * the COPYING file in the top-level directory. 13 | */ 14 | 15 | #ifndef QEMU_VIRTIO_PCI_H 16 | #define QEMU_VIRTIO_PCI_H 17 | 18 | #include "virtio-net.h" 19 | #include "virtio-serial.h" 20 | 21 | typedef struct { 22 | PCIDevice pci_dev; 23 | VirtIODevice *vdev; 24 | uint32_t flags; 25 | uint32_t addr; 26 | uint32_t class_code; 27 | uint32_t nvectors; 28 | BlockConf block; 29 | char *block_serial; 30 | NICConf nic; 31 | uint32_t host_features; 32 | #ifdef CONFIG_LINUX 33 | V9fsConf fsconf; 34 | #endif 35 | virtio_serial_conf serial; 36 | virtio_net_conf net; 37 | bool ioeventfd_disabled; 38 | bool ioeventfd_started; 39 | } VirtIOPCIProxy; 40 | 41 | void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev); 42 | 43 | /* Virtio ABI version, if we increment this, we break the guest driver. */ 44 | #define VIRTIO_PCI_ABI_VERSION 0 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /NetKVM/DebugTools/VirtioConsoleSimulation/Hardware/Hardware.h: -------------------------------------------------------------------------------- 1 | #ifndef _virtio_hw_h 2 | #define _virtio_hw_h 3 | 4 | #include "..\osdep.h" 5 | 6 | void *hwCreateDevice(void *pHostDevice); 7 | void hwDestroyDevice(void *pd); 8 | unsigned short hwGetQueueSize(void *pHw, unsigned short queueIndex); 9 | ULONG hwGetQueuePfn(void *pHw, unsigned short queueIndex); 10 | void hwSetQueuePfn(void *pHw, unsigned short queueIndex, ULONG val); 11 | BYTE hwReadInterruptStatus(void *pHw); 12 | BYTE hwGetDeviceStatus(void *pHw); 13 | void hwSetDeviceStatus(void *pHw, BYTE val); 14 | void hwQueueNotify(void *pHw, WORD wValue); 15 | 16 | void hwReceiveBuffer(void *pHw, void *buffer, size_t size); 17 | void hwCompleteTx(void *pHw, int num); 18 | void hwGetInterrups(void *pHw, unsigned long *ptx, unsigned long *prx); 19 | void hwCheckInterrupt(void *pHw); 20 | 21 | bool hwReadDeviceData(void *pHw, ULONG reg, BYTE *pval); 22 | bool hwWriteDeviceData(void *pHw, ULONG reg, BYTE val); 23 | 24 | 25 | #define RXQ_INTERRUPT_VECTOR 1 26 | #define TXQ_INTERRUPT_VECTOR 2 27 | #define CTL_INTERRUPT_VECTOR 4 28 | #define AUX_INTERRUPT_VECTOR 8 29 | 30 | #define RX_QUEUE_NUMBER 0 31 | #define TX_QUEUE_NUMBER 1 32 | #define CTL_QUEUE_NUMBER 2 33 | #define AUX_QUEUE_NUMBER 22 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /NetKVM/DebugTools/VirtioConsoleSimulation/Hardware/HardwareTypes.h: -------------------------------------------------------------------------------- 1 | #ifndef hardwaretypes_h 2 | #define hardwaretypes_h 3 | 4 | typedef unsigned short uint16_t, u16; 5 | typedef short int16_t; 6 | typedef unsigned char uint8_t, u8; 7 | typedef unsigned long uint32_t; 8 | typedef unsigned __int64 uint64_t; 9 | typedef long int32_t; 10 | 11 | typedef uint64_t target_phys_addr_t; 12 | 13 | #define offsetof(TYPE, ELEMENT) ((size_t)&(((TYPE *)0)->ELEMENT)) 14 | #define inline __inline 15 | #define MIN(x,y) ((x) < (y) ? (x) : (y)) 16 | #define unlikely(x) (x) 17 | #define false FALSE 18 | #define ARRAY_SIZE(x) sizeof(x)/sizeof(x[0]) 19 | 20 | static inline uint64_t ldq_phys(target_phys_addr_t pa) 21 | { 22 | return *(uint64_t *)pa; 23 | } 24 | 25 | static inline uint32_t ldl_phys(target_phys_addr_t pa) 26 | { 27 | return *(uint32_t *)pa; 28 | } 29 | 30 | static inline uint16_t lduw_phys(target_phys_addr_t pa) 31 | { 32 | return *(uint16_t *)pa; 33 | } 34 | 35 | static inline void stl_phys(target_phys_addr_t pa, uint32_t val) 36 | { 37 | *(uint32_t *)pa = val; 38 | } 39 | 40 | static inline void stw_phys(target_phys_addr_t pa, uint16_t val) 41 | { 42 | *(uint16_t *)pa = val; 43 | } 44 | 45 | static inline void stw_p(uint16_t *va, uint16_t val) 46 | { 47 | *va = val; 48 | } 49 | 50 | static inline void stb_p(uint8_t *va, uint8_t val) 51 | { 52 | *va = val; 53 | } 54 | 55 | static inline uint8_t ldub_p(uint8_t *va) 56 | { 57 | return *va; 58 | } 59 | 60 | static inline uint32_t ldl_p(void *va) 61 | { 62 | return *(uint32_t *)va; 63 | } 64 | 65 | static inline uint16_t lduw_p(void *va) 66 | { 67 | return *(uint16_t *)va; 68 | } 69 | 70 | #define cpu_physical_memory_unmap(...) 71 | #define cpu_physical_memory_map(a,b,c) ((PVOID)(a)) 72 | #define error_report FailCase 73 | 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /NetKVM/DebugTools/VirtioConsoleSimulation/Resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by ConsoleSim.rc 4 | // 5 | 6 | #define IDS_APP_TITLE 103 7 | 8 | // Next default values for new objects 9 | // 10 | #ifdef APSTUDIO_INVOKED 11 | #ifndef APSTUDIO_READONLY_SYMBOLS 12 | #define _APS_NEXT_RESOURCE_VALUE 101 13 | #define _APS_NEXT_COMMAND_VALUE 40001 14 | #define _APS_NEXT_CONTROL_VALUE 1000 15 | #define _APS_NEXT_SYMED_VALUE 101 16 | #endif 17 | #endif 18 | -------------------------------------------------------------------------------- /NetKVM/DebugTools/VirtioConsoleSimulation/VirtIO_Win.h: -------------------------------------------------------------------------------- 1 | #ifndef SIMULATION_VIRTIO_WIN_H 2 | #define SIMULATION_VIRTIO_WIN_H 3 | 4 | #include "..\..\..\VirtIO\virtio_pci.h" 5 | #include "..\..\..\VirtIO\virtio_config.h" 6 | 7 | #endif /* _LINUX_VIRTIO_H */ 8 | -------------------------------------------------------------------------------- /NetKVM/DebugTools/VirtioConsoleSimulation/clean.bat: -------------------------------------------------------------------------------- 1 | rmdir /S /Q ipch 2 | rmdir /S /Q Debug 3 | rmdir /S /Q Release 4 | -------------------------------------------------------------------------------- /NetKVM/DebugTools/VirtioConsoleSimulation/external_os_dep.h: -------------------------------------------------------------------------------- 1 | #include "osdep.h" 2 | -------------------------------------------------------------------------------- /NetKVM/DebugTools/VirtioConsoleSimulation/kdebugprint.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vrozenfe/virtio-win/71667c799db2e53d3da301af1dd36dce6f6e20ef/NetKVM/DebugTools/VirtioConsoleSimulation/kdebugprint.h -------------------------------------------------------------------------------- /NetKVM/DebugTools/VirtioConsoleSimulation/osdep.h: -------------------------------------------------------------------------------- 1 | #ifndef osdep_sim_h 2 | #define osdep_sim_h 3 | 4 | #include 5 | #include 6 | 7 | #define PAGE_SIZE 0x1000 8 | #define PAGE_SHIFT 12 9 | 10 | #ifdef __cplusplus 11 | #else 12 | typedef BOOLEAN bool; 13 | #endif 14 | typedef ULONG u32, uint32_t; 15 | typedef UCHAR u8, uint8_t; 16 | typedef USHORT u16; 17 | typedef ULONGLONG u64; 18 | typedef LARGE_INTEGER PHYSICAL_ADDRESS; 19 | 20 | EXTERN_C int debugLevel; 21 | 22 | EXTERN_C void DoPrint(const char *format, ...); 23 | 24 | #define DPrintf(level, statement) if (debugLevel < level) {} else DoPrint statement 25 | 26 | #define wmb() 27 | #define mb() 28 | #define rmb() 29 | 30 | #define malloc AllocateMemory 31 | #define free DeallocateMemory 32 | 33 | EXTERN_C void *AllocateMemory(size_t size); 34 | EXTERN_C void DeallocateMemory(void *); 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /NetKVM/DebugTools/VirtioConsoleSimulation/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // ConsoleSim.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /NetKVM/DebugTools/VirtioConsoleSimulation/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | #define _CRT_SECURE_NO_WARNINGS 8 | #include "targetver.h" 9 | 10 | #include 11 | #include 12 | #define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit 13 | 14 | #ifndef VC_EXTRALEAN 15 | #define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers 16 | #endif 17 | 18 | #include 19 | #include // MFC core and standard components 20 | #include // MFC extensions 21 | #ifndef _AFX_NO_OLE_SUPPORT 22 | #include // MFC support for Internet Explorer 4 Common Controls 23 | #endif 24 | #ifndef _AFX_NO_AFXCMN_SUPPORT 25 | #include // MFC support for Windows Common Controls 26 | #endif // _AFX_NO_AFXCMN_SUPPORT 27 | 28 | #include 29 | 30 | 31 | 32 | // TODO: reference additional headers your program requires here 33 | #define ELEMENTS_IN(x) (sizeof(x)/sizeof(x[0])) 34 | -------------------------------------------------------------------------------- /NetKVM/DebugTools/VirtioConsoleSimulation/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Including SDKDDKVer.h defines the highest available Windows platform. 4 | 5 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and 6 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. 7 | 8 | #include 9 | -------------------------------------------------------------------------------- /NetKVM/NDIS5/Common/common.mak: -------------------------------------------------------------------------------- 1 | 2 | C_DEFINES=$(C_DEFINES) -DNDIS_MINIPORT_DRIVER -DBINARY_COMPATIBLE=0 3 | USER_C_FLAGS=$(USER_C_FLAGS) /nologo 4 | MSC_WARNING_LEVEL=/W3 /WX 5 | 6 | !if "$(DDK_TARGET_OS)"=="WinXP" 7 | C_DEFINES=$(C_DEFINES) -DNDIS51_MINIPORT=1 8 | !elseif "$(DDK_TARGET_OS)"=="WinNET" 9 | C_DEFINES=$(C_DEFINES) -DNDIS51_MINIPORT=1 10 | !else 11 | !error DDK_TARGET_OS defined as "$(DDK_TARGET_OS)" (unsupported) 12 | !endif 13 | 14 | C_DEFINES=$(C_DEFINES) -DPARANDIS_MAJOR_DRIVER_VERSION=$(_MAJORVERSION_) -DPARANDIS_MINOR_DRIVER_VERSION=$(_MINORVERSION_) 15 | RCOPTIONS=-D_MAJORVERSION_=$(_MAJORVERSION_) -D_MINORVERSION_=$(_MINORVERSION_) -D_NT_TARGET_MAJ=$(_NT_TARGET_MAJ) -D_NT_TARGET_MIN=$(_NT_TARGET_MIN) 16 | 17 | #ENABLE_EVENT_TRACING=1 18 | 19 | !IF "$(ENABLE_EVENT_TRACING)"=="1" && "$(DISABLE_WPP)"=="" 20 | 21 | C_DEFINES = $(C_DEFINES) -DWPP_EVENT_TRACING 22 | 23 | RUN_WPP=$(SOURCES)\ 24 | -km\ 25 | -func:DPrintf(LEVEL,(MSG,...)) 26 | 27 | 28 | !ENDIF 29 | -------------------------------------------------------------------------------- /NetKVM/NDIS5/Common/makefile: -------------------------------------------------------------------------------- 1 | !include $(NTMAKEENV)\makefile.def 2 | -------------------------------------------------------------------------------- /NetKVM/NDIS5/Common/osdep.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * Copyright (c) 2008-2015 Red Hat, Inc. 3 | * 4 | * File: osdep.h 5 | * 6 | * This file contains highest level definitions, mainly for non-NDIS modules, 7 | * when they are involved into NDIS driver 8 | * 9 | * This work is licensed under the terms of the GNU GPL, version 2. See 10 | * the COPYING file in the top-level directory. 11 | * 12 | **********************************************************************/ 13 | #ifndef __OS_DEP_H 14 | #define __OS_DEP_H 15 | 16 | #include 17 | 18 | #define u8 unsigned char 19 | #define u16 unsigned short 20 | #define u32 unsigned long 21 | #define u64 ULONGLONG 22 | 23 | #ifndef bool 24 | #define bool int 25 | #endif 26 | 27 | #define mb() KeMemoryBarrier() 28 | #define rmb() KeMemoryBarrier() 29 | #define wmb() KeMemoryBarrier() 30 | #define smp_wmb() KeMemoryBarrier() 31 | 32 | #ifndef min 33 | #define min(_a, _b) (((_a) < (_b)) ? (_a) : (_b)) 34 | #endif 35 | 36 | #ifndef max 37 | #define max(_a, _b) (((_a) > (_b)) ? (_a) : (_b)) 38 | #endif 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /NetKVM/NDIS5/Common/quverp.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * Copyright (c) 2008-2015 Red Hat, Inc. 3 | * 4 | * File: quverp.h 5 | * 6 | * This file contains version resource related definitions 7 | * 8 | * This work is licensed under the terms of the GNU GPL, version 2. See 9 | * the COPYING file in the top-level directory. 10 | * 11 | **********************************************************************/ 12 | #include 13 | #include "ntverp.h" 14 | 15 | #ifdef VER_COMPANYNAME_STR 16 | #undef VER_COMPANYNAME_STR 17 | #endif 18 | #ifdef VER_LEGALTRADEMARKS_STR 19 | #undef VER_LEGALTRADEMARKS_STR 20 | #endif 21 | #ifdef VER_PRODUCTBUILD 22 | #undef VER_PRODUCTBUILD 23 | #endif 24 | #ifdef VER_PRODUCTBUILD_QFE 25 | #undef VER_PRODUCTBUILD_QFE 26 | #endif 27 | #ifdef VER_PRODUCTMAJORVERSION 28 | #undef VER_PRODUCTMAJORVERSION 29 | #endif 30 | #ifdef VER_PRODUCTMINORVERSION 31 | #undef VER_PRODUCTMINORVERSION 32 | #endif 33 | #ifdef VER_PRODUCTNAME_STR 34 | #undef VER_PRODUCTNAME_STR 35 | #endif 36 | #define VER_COMPANYNAME_STR "Red Hat, Inc." 37 | #define VER_LEGALTRADEMARKS_STR "" 38 | #define VER_LEGALCOPYRIGHT_STR "Copyright (C) 2008-2015 Red Hat Inc." 39 | 40 | #ifndef _NT_TARGET_MAJ 41 | #include "NetKVM-2012.h" 42 | #endif 43 | 44 | #define VER_PRODUCTBUILD _MAJORVERSION_ 45 | #define VER_PRODUCTBUILD_QFE _MINORVERSION_ 46 | #define VER_PRODUCTMAJORVERSION _NT_TARGET_MAJ 47 | #define VER_PRODUCTMINORVERSION _NT_TARGET_MIN 48 | #undef __BUILDMACHINE__ 49 | 50 | #define VER_LANGNEUTRAL 51 | 52 | #define VER_FILETYPE VFT_DRV 53 | #define VER_FILESUBTYPE VFT2_DRV_SYSTEM 54 | #define VER_FILEDESCRIPTION_STR "Red Hat NDIS Miniport Driver" 55 | #define VER_INTERNALNAME_STR "netkvm.sys" 56 | #define VER_PRODUCTNAME_STR "Red Hat VirtIO Ethernet Adapter" 57 | 58 | #include "common.ver" 59 | -------------------------------------------------------------------------------- /NetKVM/NDIS5/Common/sources: -------------------------------------------------------------------------------- 1 | TARGETNAME=ndiscommon 2 | TARGETTYPE=DRIVER_LIBRARY 3 | TARGETPATH=obj 4 | 5 | !include "common.mak" 6 | 7 | INCLUDES=.;..\VirtIO 8 | 9 | SOURCES = $(SOURCES) ParaNdis-Common.c ParaNdis-Debug.c ParaNdis-Oid.c sw-offload.c 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /NetKVM/NDIS5/ReadMe.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | For any queries/suggestion/complains please contact me yvugenfi-redhat-dot-com 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /NetKVM/NDIS5/RunCheckInf.cmd: -------------------------------------------------------------------------------- 1 | mkdir htm 2 | del /q htm\* 3 | call c:\winddk\7600.16385.1\tools\chkinf\chkinf.bat Install\Vista\amd64\netkvm.inf Install\Vista\x86\netkvm.inf Install\XP\amd64\netkvm.inf Install\XP\x86\netkvm.inf 4 | start htm\summary.htm 5 | 6 | 7 | -------------------------------------------------------------------------------- /NetKVM/NDIS5/VirtIO/makefile: -------------------------------------------------------------------------------- 1 | !include $(NTMAKEENV)\makefile.def 2 | -------------------------------------------------------------------------------- /NetKVM/NDIS5/VirtIO/osdep.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) 2007 Qumranet All Rights Reserved 3 | // 4 | // Module Name: 5 | // osdep.h 6 | // 7 | // Abstract: 8 | // Windows OS dependent definitions of data types 9 | // 10 | // Author: 11 | // Yan Vugenfirer - February 2007. 12 | // 13 | ////////////////////////////////////////////////////////////////////////////////////////// 14 | 15 | #if defined(IGNORE_VIRTIO_OSDEP_H) 16 | // to make simulation environment easy 17 | #include "external_os_dep.h" 18 | #else 19 | 20 | #ifndef __OS_DEP_H 21 | #define __OS_DEP_H 22 | 23 | #include 24 | 25 | #define u8 unsigned char 26 | #define u16 unsigned short 27 | #define u32 unsigned long 28 | #define u64 ULONGLONG 29 | 30 | #ifndef bool 31 | #define bool int 32 | #endif 33 | 34 | #define mb() KeMemoryBarrier() 35 | #define rmb() KeMemoryBarrier() 36 | #define wmb() KeMemoryBarrier() 37 | #define smp_wmb() KeMemoryBarrier() 38 | 39 | #ifndef min 40 | #define min(_a, _b) (((_a) < (_b)) ? (_a) : (_b)) 41 | #endif 42 | 43 | #ifndef max 44 | #define max(_a, _b) (((_a) > (_b)) ? (_a) : (_b)) 45 | #endif 46 | 47 | #endif 48 | #endif 49 | -------------------------------------------------------------------------------- /NetKVM/NDIS5/VirtIO/sources: -------------------------------------------------------------------------------- 1 | TARGETNAME=virtiolib 2 | TARGETTYPE=DRIVER_LIBRARY 3 | TARGETPATH=obj 4 | 5 | MSC_WARNING_LEVEL=/W3 /WX 6 | SOURCES=VirtIOPCI.c \ 7 | VirtIORing.c 8 | 9 | 10 | 11 | #for NETKVM project until full merge 12 | !message VirtIO build for NETKVM 13 | INCLUDES=..\Common 14 | !include "..\Common\common.mak" 15 | 16 | -------------------------------------------------------------------------------- /NetKVM/NDIS5/clean.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | goto start 4 | :rmdir 5 | if exist "%~1" rmdir "%~1" /s /q 6 | goto :eof 7 | 8 | :rmfiles 9 | if "%~1"=="" goto :eof 10 | if exist "%~1" del /f "%~1" 11 | shift 12 | goto rmfiles 13 | 14 | :start 15 | for /d %%d in (VirtIO\obj*) do call :rmdir %%d 16 | for /d %%d in (wxp\objfre*) do call :rmdir %%d 17 | for /d %%d in (common\objfre*) do call :rmdir %%d 18 | for /d %%d in (wxp\objchk*) do call :rmdir %%d 19 | for /d %%d in (common\objchk*) do call :rmdir %%d 20 | call :rmdir Install 21 | call :rmdir Install_Checked 22 | call :rmfiles wxp\BuildLog.htm 23 | call :rmfiles *.log *.err *.wrn 24 | -------------------------------------------------------------------------------- /NetKVM/NDIS5/dirs: -------------------------------------------------------------------------------- 1 | DIRS=Common wxp VirtIO 2 | -------------------------------------------------------------------------------- /NetKVM/NDIS5/tools/README.TXT: -------------------------------------------------------------------------------- 1 | Files in this directory used during build procedure for: 2 | 3 | - creating of CAT files for driver installation package 4 | - copying driver's installation package to NetKvm\Install 5 | 6 | Notes: 7 | makeinstall.bat is called from buildAll.bat after 8 | after binary files are linked. It calls signing.cmd 9 | to create CAT files. 10 | 11 | -------------------------------------------------------------------------------- /NetKVM/NDIS5/tools/cleanemptystrings.vbs: -------------------------------------------------------------------------------- 1 | CONST ForReading = 1 2 | CONST ForWriting = 2 3 | 4 | Dim objFSObject, strLineBuffer 5 | 6 | ' Lines 4-5: Assign input file to variable 7 | 8 | Dim strInputFile, strOutputFile 9 | 10 | strInputFile = Wscript.Arguments(0) 11 | 12 | ' 0 - is empty, 1 - non-empty line 13 | 14 | LineIsEmpty = 1 15 | Dense = 0 16 | 17 | ' Lines 6-7: Set up File System object and read input file 18 | 19 | Set objFSOObject = CreateObject("Scripting.FileSystemObject") 20 | 21 | Set objCurrentFile = objFSOObject.OpenTextFile(strInputFile, ForReading) 22 | 23 | ' Processing Loop - Store non-blank lines in temporary buffer 24 | 25 | Do Until objCurrentFile.AtEndOfStream 26 | 27 | tempLine = objCurrentFile.Readline 28 | 29 | tempLine = Trim(tempLIne) 30 | 31 | If (InStr(1, tempLine,";") = 1) Then 32 | Dense = 1 33 | tempLine = "" 34 | End If 35 | 36 | If (InStr(1, tempLine,";") = 1) Then 37 | Dense = 0 38 | tempLine = "" 39 | End If 40 | 41 | 42 | If Len(tempLine) > 0 Or (LineIsEmpty = 0 And Dense = 0) Then 43 | 44 | strLineBuffer = strLineBuffer & tempLine & " " & vbCrLf 45 | 46 | LineIsEmpty = (Len(tempLine) = 0) 47 | 48 | End If 49 | 50 | Loop 51 | 52 | ' Write buffer to input file 53 | 54 | objCurrentFile.Close 55 | 56 | ' Set objCurrentFile = objFSOObject.CreateTextFile(strOutputFile, ForWriting) 57 | 58 | ' objCurrentFile.Write strLineBuffer 59 | 60 | ' Console.Write strLineBuffer 61 | 62 | WScript.Echo strLineBuffer 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /NetKVM/NDIS5/tools/makeinstall.bat: -------------------------------------------------------------------------------- 1 | : Param1 - x86|amd64|ia64|x64|64 2 | : Param2 - path to SYS file 3 | : Param3 - path to INF file 4 | : Param4 - version in x.x.x.x form 5 | : Param5 - XP 6 | : Param6 - Install | InstallChk | (or any other folder name) 7 | 8 | set folder_name=%6 9 | 10 | if /i "%1"=="x86" goto makeinstall 11 | if /i "%1"=="amd64" goto makeinstall 12 | if /i "%1"=="x64" goto makeinstall 13 | echo wrong parameters (1)%1 (2)%2 (3)%3 14 | goto :eof 15 | 16 | :prepareinf 17 | ::original inf %1, copy to %2, define OS %3 18 | echo processing %1 for %3 19 | cl /nologo -DINCLUDE_TEST_PARAMS -D%3 /I. /EP %1 > %~nx1 20 | cscript /nologo tools\cleanemptystrings.vbs %~nx1 > %2\%~nx1 21 | del %~nx1 22 | goto :eof 23 | 24 | :makeinstall 25 | echo makeinstall %1 %2 %3 %4 %5 26 | mkdir %folder_name%\%5\%1 27 | del /Q %folder_name%\%5\%1\* 28 | copy /Y %2 %folder_name%\%5\%1 29 | copy /Y %~dpn2.pdb %folder_name%\%5\%1 30 | call :prepareinf %3 %folder_name%\%5\%1 %5 31 | call "%~dp0\signing.cmd" sign%5 %1 %folder_name%\%5\%1\%~nx3 %4 32 | -------------------------------------------------------------------------------- /NetKVM/NDIS5/tools/signing.cmd: -------------------------------------------------------------------------------- 1 | : Param1=signXP 2 | : Param2=x86 | amd64 3 | : Param3=path to INF file (SYS must be is in the same place) 4 | : Param4=version string to patch INF 5 | 6 | set _OSMASK_= 7 | if exist %BUILDROOT%\bin\SelfSign\signability.exe set USESIGNABILITY=old 8 | if /i "%1"=="signXP" goto signXP%USESIGNABILITY% 9 | echo unsupported parameter %1 10 | goto :eof 11 | :create 12 | rem This section should not be used 13 | rem set _CERTSTORE_=NetKVMTemporaryCertStore 14 | rem certmgr -del -all -s %_CERTSTORE_% 15 | rem Makecert -r -pe -ss %_CERTSTORE_% -n "CN=NetKVMTemporaryCert" NetKVMTemporaryCert.cer 16 | goto :eof 17 | 18 | :signXP 19 | shift 20 | if /i "%1"=="x86" set _OSMASK_=XP_X86,Server2003_X86 21 | if /i "%1"=="amd64" set _OSMASK_=XP_X64,Server2003_X64 22 | if /i "%1"=="x64" set _OSMASK_=XP_X64,Server2003_X64 23 | call :dosign %1 %2 %3 24 | goto :eof 25 | 26 | :_stampinf 27 | ..\..\Tools\xdate.exe -u > timestamp.txt 28 | set /p STAMPINF_DATE= < timestamp.txt 29 | del timestamp.txt 30 | stampinf -f %1 -v %2 -a %_BUILDARCH%.%_NT_TARGET_MAJ_ARCH%.%_NT_TARGET_MIN_ARCH% 31 | goto :eof 32 | 33 | :dosign 34 | echo system %1 35 | echo INF file %2 36 | echo VERSION file %3 37 | echo Target OS mask %_OSMASK_% 38 | call :_stampinf %2 %3 39 | inf2cat /driver:%~dp2 /os:%_OSMASK_% 40 | goto :eof 41 | 42 | :signXPold 43 | shift 44 | echo system %1 45 | echo INF file %2 46 | echo VERSION file %3 47 | set _OSMASK_=0 48 | rem (32+8=40) xp32 + 2003-32 49 | if /i "%1"=="x86" set _OSMASK_=40 50 | rem (128+16=144) xp64 + 2003-64 51 | if /i "%1"=="amd64" set _OSMASK_=144 52 | if /i "%1"=="x64" set _OSMASK_=144 53 | echo Target OS mask %_OSMASK_% 54 | call :_stampinf %2 %3 55 | signability /driver:%~dp2 /auto /cat /os:%_OSMASK_% 56 | taskkill /FI "WINDOWTITLE eq signability*" 57 | goto :eof 58 | 59 | -------------------------------------------------------------------------------- /NetKVM/NDIS5/wxp/makefile: -------------------------------------------------------------------------------- 1 | !include $(NTMAKEENV)\makefile.def 2 | -------------------------------------------------------------------------------- /NetKVM/NDIS5/wxp/parandis.rc: -------------------------------------------------------------------------------- 1 | 2 | /********************************************************************** 3 | * Copyright (c) 2008-2015 Red Hat, Inc. 4 | * 5 | * File: parandis.rc 6 | * 7 | * This file contains resource (version) definitions for NDIS 5 driver. 8 | * 9 | * This work is licensed under the terms of the GNU GPL, version 2. See 10 | * the COPYING file in the top-level directory. 11 | * 12 | **********************************************************************/ 13 | 14 | #include 15 | 16 | -------------------------------------------------------------------------------- /NetKVM/NDIS5/wxp/sources: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # 3 | # Copyright (c) 2008-2015 Red Hat, Inc. All rights reserved. 4 | # 5 | # Red Hat Paravirtualized NDIS-WDM Miniport Driver 6 | # 7 | # 8 | ################################################################################ 9 | 10 | TARGETNAME=netkvm 11 | TARGETPATH=obj 12 | TARGETTYPE=DRIVER 13 | 14 | TARGETLIBS=$(DDK_LIB_PATH)\ndis.lib \ 15 | ..\Common\$O\ndiscommon.lib \ 16 | ..\VirtIO\$O\virtiolib.lib 17 | 18 | INCLUDES=..\VirtIO;..\Common 19 | 20 | SOURCES = $(SOURCES) ParaNdis5-Driver.c ParaNdis5-Impl.c ParaNdis5-Oid.c parandis.rc 21 | 22 | !include "..\Common\common.mak" 23 | -------------------------------------------------------------------------------- /NetKVM/NetKVM Package/NetKVM Package.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {8E41214B-6785-4CFE-B992-037D68949A14} 6 | inf;inv;inx;mof;mc; 7 | 8 | 9 | -------------------------------------------------------------------------------- /NetKVM/ReadMe.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | For any queries/suggestion/complains please contact me yvugenfi-redhat-dot-com 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /NetKVM/Tests/netperf_log_parser.rb: -------------------------------------------------------------------------------- 1 | #!/usr/bin/ruby 2 | 3 | if ARGV[0].to_s == "" 4 | print "error: syntax netperf_log_parser \n" 5 | exit 6 | end 7 | 8 | print "Parsing: " + ARGV[0] + "\n" 9 | 10 | file = File.open(ARGV[0], "r") 11 | 12 | if(!file) 13 | print "error: cannot open " + ARGV[0] 14 | exit 15 | end 16 | 17 | line_count = 0 18 | test_type = "TCP" 19 | print test_type + "\n" 20 | print "size, throughput\n" 21 | 22 | while(line = file.gets) 23 | #print line 24 | if(line["Executing"]) #reset line scan 25 | line_count = 0 26 | if(line["UDP"]) #this is UDP test 27 | if(test_type == "TCP" ) 28 | print "UDP" + "\n" 29 | print "size, throughput\n" 30 | end 31 | test_type = "UDP" 32 | else 33 | test_type = "TCP" 34 | end 35 | 36 | if(size_index = line.index("-m")) 37 | print line[size_index + 3 ... line.size].strip + ",\t" 38 | else 39 | print "default,\t" 40 | end 41 | 42 | else 43 | line_count = line_count + 1 44 | if(line_count == 7) # results are on the 7th line 45 | results = line.split; 46 | if(results != nil) 47 | if(test_type == "TCP") 48 | print results[4] +"\n" 49 | else 50 | print results[3] +"\n" 51 | end 52 | end 53 | end 54 | end 55 | 56 | end 57 | 58 | file.close 59 | -------------------------------------------------------------------------------- /NetKVM/clean.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | goto start 4 | :rmdir 5 | if exist "%~1" rmdir "%~1" /s /q 6 | goto :eof 7 | 8 | :rmfiles 9 | if "%~1"=="" goto :eof 10 | if exist "%~1" del /f "%~1" 11 | shift 12 | goto rmfiles 13 | 14 | :start 15 | call :rmdir Install 16 | call :rmdir Install_Debug 17 | call :rmdir "NetKVM Package\VistaRelease" 18 | call :rmdir "NetKVM Package\VistaDebug" 19 | call :rmdir "NetKVM Package\Win8Release" 20 | call :rmdir "NetKVM Package\Win8Debug" 21 | call :rmdir "NetKVM Package\Win7Release" 22 | call :rmdir "NetKVM Package\Win7Debug" 23 | call :rmdir "NetKVM Package\x64" 24 | call :rmdir x64 25 | call :rmdir x86 26 | del build.err 27 | del build.log 28 | del buildfre_*.log 29 | del buildchk_*.log 30 | del msbuild.log 31 | del netkvm.DVL.XML 32 | call clean_dvl_log.cmd 33 | 34 | pushd CoInstaller 35 | call clean.bat 36 | popd 37 | 38 | pushd NDIS5 39 | call clean.bat 40 | popd 41 | -------------------------------------------------------------------------------- /NetKVM/clean_dvl_log.cmd: -------------------------------------------------------------------------------- 1 | setlocal 2 | call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" x64 3 | msbuild.exe netkvm.vcxproj /t:clean /p:Configuration="Win8 Release" /P:Platform=x64 4 | msbuild.exe netkvm.vcxproj /t:sdv /p:inputs="/clean" /p:Configuration="Win8 Release" /P:Platform=x64 5 | endlocal 6 | -------------------------------------------------------------------------------- /NetKVM/create_dvl_log.cmd: -------------------------------------------------------------------------------- 1 | setlocal 2 | call tools\set_version.bat 0x0620 3 | call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" x64 4 | msbuild.exe netkvm.vcxproj /t:clean /p:Configuration="Win8 Release" /P:Platform=x64 5 | msbuild.exe netkvm.vcxproj /t:sdv /p:inputs="/clean" /p:Configuration="Win8 Release" /P:platform=x64 6 | msbuild.exe netkvm.vcxproj /p:Configuration="Win8 Release" /P:Platform=x64 /P:RunCodeAnalysisOnce=True 7 | msbuild.exe netkvm.vcxproj /t:sdv /p:inputs="/check" /p:Configuration="Win8 Release" /P:platform=x64 8 | msbuild.exe netkvm.vcxproj /t:dvl /p:Configuration="Win8 Release" /P:platform=x64 9 | copy netkvm.DVL.XML .\Install\win8\amd64\ 10 | endlocal 11 | -------------------------------------------------------------------------------- /NetKVM/linux/if_ether.h: -------------------------------------------------------------------------------- 1 | #ifndef _IF_ETHER_H 2 | #define _IF_ETHER_H 3 | 4 | #define ETH_ALEN 6 5 | 6 | #endif 7 | 8 | -------------------------------------------------------------------------------- /NetKVM/tools/InstallCertificate.bat: -------------------------------------------------------------------------------- 1 | rem certmgr.exe -add NetKVMTemporaryCert.cer -s -r localMachine root 2 | rem certmgr.exe -add NetKVMTemporaryCert.cer -s -r localMachine trustedpublisher 3 | -------------------------------------------------------------------------------- /NetKVM/tools/NetKVMTemporaryCert.cer: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vrozenfe/virtio-win/71667c799db2e53d3da301af1dd36dce6f6e20ef/NetKVM/tools/NetKVMTemporaryCert.cer -------------------------------------------------------------------------------- /NetKVM/tools/NetKVMTemporaryCert.pfx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vrozenfe/virtio-win/71667c799db2e53d3da301af1dd36dce6f6e20ef/NetKVM/tools/NetKVMTemporaryCert.pfx -------------------------------------------------------------------------------- /NetKVM/tools/cleanemptystrings.vbs: -------------------------------------------------------------------------------- 1 | CONST ForReading = 1 2 | CONST ForWriting = 2 3 | 4 | Dim objFSObject, strLineBuffer 5 | 6 | ' Lines 4-5: Assign input file to variable 7 | 8 | Dim strInputFile, strOutputFile 9 | 10 | strInputFile = Wscript.Arguments(0) 11 | 12 | ' 0 - is empty, 1 - non-empty line 13 | 14 | LineIsEmpty = 1 15 | Dense = 0 16 | 17 | ' Lines 6-7: Set up File System object and read input file 18 | 19 | Set objFSOObject = CreateObject("Scripting.FileSystemObject") 20 | 21 | Set objCurrentFile = objFSOObject.OpenTextFile(strInputFile, ForReading) 22 | 23 | ' Processing Loop - Store non-blank lines in temporary buffer 24 | 25 | Do Until objCurrentFile.AtEndOfStream 26 | 27 | tempLine = objCurrentFile.Readline 28 | 29 | tempLine = Trim(tempLIne) 30 | 31 | If (InStr(1, tempLine,";") = 1) Then 32 | Dense = 1 33 | tempLine = "" 34 | End If 35 | 36 | If (InStr(1, tempLine,";") = 1) Then 37 | Dense = 0 38 | tempLine = "" 39 | End If 40 | 41 | 42 | If Len(tempLine) > 0 Or (LineIsEmpty = 0 And Dense = 0) Then 43 | 44 | strLineBuffer = strLineBuffer & tempLine & " " & vbCrLf 45 | 46 | LineIsEmpty = (Len(tempLine) = 0) 47 | 48 | End If 49 | 50 | Loop 51 | 52 | ' Write buffer to input file 53 | 54 | objCurrentFile.Close 55 | 56 | ' Set objCurrentFile = objFSOObject.CreateTextFile(strOutputFile, ForWriting) 57 | 58 | ' objCurrentFile.Write strLineBuffer 59 | 60 | ' Console.Write strLineBuffer 61 | 62 | WScript.Echo strLineBuffer 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /NetKVM/tools/make_inf.bat: -------------------------------------------------------------------------------- 1 | : Param1 - DirectoryOfINF 2 | : Param2 - DDKSpec 3 | 4 | goto makeinf 5 | 6 | :prepareinf 7 | ::original inf %1, copy to %2, define OS %3 8 | echo processing %1 for %3 9 | cl /nologo -DINCLUDE_TEST_PARAMS -D%3 /I. /EP %1 > %~nx1 10 | echo cleaning INF file... 11 | cscript /nologo .\tools\cleanemptystrings.vbs %~nx1 > %2\%~nx1 12 | del %~nx1 13 | goto :eof 14 | 15 | :makeinf 16 | echo calling prepareinf 17 | call :prepareinf %1NetKVM.inf %1 %2 18 | -------------------------------------------------------------------------------- /NetKVM/tools/set_version.bat: -------------------------------------------------------------------------------- 1 | :: Param 1 - Current WinNT version (Macro $(CURRENT_WIN32_WINNT_VERSION) from Visual Studio) 2 | 3 | if "%_BUILD_MAJOR_VERSION_%"=="" set _BUILD_MAJOR_VERSION_=101 4 | if "%_BUILD_MINOR_VERSION_%"=="" set _BUILD_MINOR_VERSION_=58000 5 | if "%_RHEL_RELEASE_VERSION_%"=="" set _RHEL_RELEASE_VERSION_=65 6 | 7 | set STAMPINF_RHEL_VERSION=.%_RHEL_RELEASE_VERSION_%.%_BUILD_MAJOR_VERSION_%.%_BUILD_MINOR_VERSION_% 8 | -------------------------------------------------------------------------------- /NetKVM/wlh/Parandis6.rc: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * Copyright (c) 2008-2015 Red Hat, Inc. 3 | * 4 | * File: Parandis6.rc 5 | * 6 | * This file contains resource (version) definitions for NDIS 6 driver. 7 | * 8 | * This work is licensed under the terms of the GNU GPL, version 2. See 9 | * the COPYING file in the top-level directory. 10 | * 11 | **********************************************************************/ 12 | 13 | #include 14 | -------------------------------------------------------------------------------- /Tools/NetKVMTemporaryCert.cer: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vrozenfe/virtio-win/71667c799db2e53d3da301af1dd36dce6f6e20ef/Tools/NetKVMTemporaryCert.cer -------------------------------------------------------------------------------- /Tools/NetKVMTemporaryCert.pfx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vrozenfe/virtio-win/71667c799db2e53d3da301af1dd36dce6f6e20ef/Tools/NetKVMTemporaryCert.pfx -------------------------------------------------------------------------------- /Tools/SetVsEnv.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | REM Set NATIVE ENV for running SDV Tool. 3 | set vsVer=%1 4 | set arc=%2 5 | 6 | set query='reg query "HKLM\Software\Microsoft\VisualStudio\%vsVer%.0" /v ShellFolder' 7 | for /F "tokens=2*" %%A in (%query%) do ( 8 | set env=%%B 9 | if not "%%B"=="" GOTO SET 10 | ) 11 | 12 | set query='reg query "HKLM\Software\Wow6432Node\Microsoft\VisualStudio\%vsVer%.0" /v ShellFolder' 13 | 14 | for /F "tokens=2*" %%A in (%query%) do ( 15 | set env=%%B 16 | if not "%%B"=="" GOTO SET 17 | ) 18 | ECHO ERROR Couldn't find VisualStudio installation. 19 | exit /B 1 20 | 21 | :SET 22 | set cmdEnv="%env%VC\vcvarsall.bat" 23 | call %cmdEnv% %arc% 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Tools/callVisualStudio.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | call %~dp0\checkWin8Tools.bat %1 4 | 5 | for /f "tokens=*" %%a in ( 6 | 'cscript.exe /nologo "%~dp0\getVisualStudioCmdLine.vbs" %*' 7 | ) do ( 8 | set vs_cmd=%%a 9 | ) 10 | 11 | IF NOT DEFINED vs_cmd ( 12 | echo Visual Studio not found 13 | EXIT /b 1 14 | ) 15 | 16 | SET vs_cmd_no_quotes="%vs_cmd:"=%" 17 | IF "vs_cmd_no_quotes" == "" ( 18 | echo Visual Studio not found 19 | EXIT /b 2 20 | ) 21 | 22 | call %vs_cmd% 23 | if %ERRORLEVEL% GEQ 1 ( 24 | echo Build with Visual Studio FAILED 25 | exit /b %ERRORLEVEL% 26 | ) 27 | 28 | exit /b 0 29 | -------------------------------------------------------------------------------- /Tools/checkWin8Tools.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | :checkVS11 4 | reg query HKLM\Software\Microsoft\VisualStudio\%1.0 /v InstallDir > nul 2>nul 5 | if %ERRORLEVEL% EQU 0 exit /b 0 6 | reg query HKLM\Software\Wow6432Node\Microsoft\VisualStudio\%1.0 /v InstallDir > nul 2>nul 7 | if %ERRORLEVEL% EQU 0 exit /b 0 8 | echo ERROR building Win8 drivers: VS11 is not installed 9 | exit /b 2 -------------------------------------------------------------------------------- /Tools/getVisualStudioCmdLine.vbs: -------------------------------------------------------------------------------- 1 | ' $1 - Visual studio version to run (10 or 11) 2 | ' $2 ... Parameters to pass 3 | 4 | Dim strCmdLine, strTemp 5 | Set WshShell = Wscript.CreateObject("Wscript.Shell") 6 | 7 | On Error Resume Next 8 | strCmdLine = WshShell.RegRead("HKLM\SOFTWARE\Microsoft\VisualStudio\" + Wscript.Arguments(0) + ".0\InstallDir") 9 | ' In case of error assume WoW64 case 10 | If Err <> 0 Then 11 | On Error Goto 0 12 | strCmdLine = WshShell.RegRead("HKLM\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\" + Wscript.Arguments(0) + ".0\InstallDir") 13 | End If 14 | 15 | On Error Goto 0 16 | strCmdLine = chr(34) + strCmdLine + "devenv.com" + chr(34) 17 | For i = 0 to (Wscript.Arguments.Count - 1) 18 | If i > 0 Then 19 | strTemp = Wscript.Arguments(i) 20 | If InStr(strTemp, " ") Or InStr(strTemp, "|") Then 21 | strCmdLine = strCmdLine + " " + chr(34) + strTemp + chr(34) 22 | Else 23 | strCmdLine = strCmdLine + " " + strTemp 24 | End If 25 | End If 26 | Next 27 | 28 | WScript.Echo strCmdLine + vbCrLf 29 | -------------------------------------------------------------------------------- /Tools/xdate.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vrozenfe/virtio-win/71667c799db2e53d3da301af1dd36dce6f6e20ef/Tools/xdate.exe -------------------------------------------------------------------------------- /VirtIO/VirtIO.h: -------------------------------------------------------------------------------- 1 | #ifndef _LINUX_VIRTIO_H 2 | #define _LINUX_VIRTIO_H 3 | 4 | #define virtio_device VirtIODevice 5 | #define scatterlist VirtIOBufferDescriptor 6 | 7 | typedef struct TypeVirtIODevice VirtIODevice; 8 | struct VirtIOBufferDescriptor { 9 | PHYSICAL_ADDRESS physAddr; 10 | ULONG length; 11 | }; 12 | 13 | /** 14 | * virtqueue - a queue to register buffers for sending or receiving. 15 | * @list: the chain of virtqueues for this device 16 | * @callback: the function to call when buffers are consumed (can be NULL). 17 | * @name: the name of this virtqueue (mainly for debugging) 18 | * @vdev: the virtio device this queue was created for. 19 | * @priv: a pointer for the virtqueue implementation to use. 20 | * @index: the zero-based ordinal number for this queue. 21 | * @num_free: number of elements we expect to be able to fit. 22 | * 23 | * A note on @num_free: with indirect buffers, each buffer needs one 24 | * element in the queue, otherwise a buffer will need one element per 25 | * sg element. 26 | */ 27 | struct virtqueue { 28 | // struct list_head list; 29 | // void (*callback)(struct virtqueue *vq); 30 | const char *name; 31 | virtio_device *vdev; 32 | unsigned int index; 33 | unsigned int num_free; 34 | void *priv; 35 | }; 36 | 37 | int virtqueue_add_buf(struct virtqueue *vq, 38 | struct scatterlist sg[], 39 | unsigned int out_num, 40 | unsigned int in_num, 41 | void *data, 42 | void *va_indirect, 43 | ULONGLONG phys_indirect); 44 | 45 | void virtqueue_kick(struct virtqueue *vq); 46 | 47 | bool virtqueue_kick_prepare(struct virtqueue *vq); 48 | 49 | void virtqueue_notify(struct virtqueue *vq); 50 | 51 | void *virtqueue_get_buf(struct virtqueue *vq, unsigned int *len); 52 | 53 | void virtqueue_disable_cb(struct virtqueue *vq); 54 | 55 | bool virtqueue_enable_cb(struct virtqueue *vq); 56 | 57 | bool virtqueue_enable_cb_delayed(struct virtqueue *vq); 58 | 59 | void *virtqueue_detach_unused_buf(struct virtqueue *vq); 60 | 61 | unsigned int virtqueue_get_vring_size(struct virtqueue *vq); 62 | 63 | BOOLEAN virtqueue_is_interrupt_enabled(struct virtqueue *_vq); 64 | 65 | void virtqueue_shutdown(struct virtqueue *_vq); 66 | 67 | #endif /* _LINUX_VIRTIO_H */ 68 | -------------------------------------------------------------------------------- /VirtIO/VirtIO.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "VirtIO", "VirtIO.vcxproj", "{15DC9616-56BC-474A-90C2-38DBAF64BA06}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | Release|Win32 = Release|Win32 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {15DC9616-56BC-474A-90C2-38DBAF64BA06}.Debug|Win32.ActiveCfg = Debug|Win32 13 | {15DC9616-56BC-474A-90C2-38DBAF64BA06}.Debug|Win32.Build.0 = Debug|Win32 14 | {15DC9616-56BC-474A-90C2-38DBAF64BA06}.Release|Win32.ActiveCfg = Release|Win32 15 | {15DC9616-56BC-474A-90C2-38DBAF64BA06}.Release|Win32.Build.0 = Release|Win32 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /VirtIO/VirtIO.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav 15 | 16 | 17 | {2118a073-43d0-4c21-908f-2d1a01c30b63} 18 | 19 | 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | 29 | 30 | Header Files 31 | 32 | 33 | Header Files 34 | 35 | 36 | Header Files 37 | 38 | 39 | Header Files 40 | 41 | 42 | Header Files 43 | 44 | 45 | 46 | 47 | Build 48 | 49 | 50 | Build 51 | 52 | 53 | Build 54 | 55 | 56 | Build 57 | 58 | 59 | -------------------------------------------------------------------------------- /VirtIO/clean.bat: -------------------------------------------------------------------------------- 1 | rmdir /S /Q Debug 2 | rmdir /S /Q Release 3 | rmdir /S /Q objfre_wxp_x86 4 | rmdir /S /Q objfre_wnet_x86 5 | rmdir /S /Q objfre_wnet_amd64 6 | rmdir /S /Q objfre_w2k_x86 7 | rmdir /S /Q objfre_wlh_x86 8 | rmdir /S /Q objfre_wlh_amd64 9 | rmdir /S /Q objfre_win7_x86 10 | rmdir /S /Q objfre_win7_amd64 11 | rmdir /S /Q objfre_win8_x86 12 | rmdir /S /Q objfre_win8_amd64 13 | rmdir /S /Q Win8Release 14 | rmdir /S /Q Win8Debug 15 | rmdir /S /Q x64 16 | 17 | del /F *.log *.wrn *.err 18 | 19 | 20 | -------------------------------------------------------------------------------- /VirtIO/kdebugprint.h: -------------------------------------------------------------------------------- 1 | #if defined(IGNORE_VIRTIO_OSDEP_H) 2 | // to make simulation environment easy 3 | #include "external_os_dep.h" 4 | #else 5 | 6 | #ifndef _K_DEBUG_PRINT_H 7 | #define _K_DEBUG_PRINT_H 8 | 9 | extern int virtioDebugLevel; 10 | extern int bDebugPrint; 11 | typedef void (*tDebugPrintFunc)(const char *format, ...); 12 | extern tDebugPrintFunc VirtioDebugPrintProc; 13 | 14 | #define DPrintf(Level, Fmt) if ((!bDebugPrint) || Level > virtioDebugLevel) {} else VirtioDebugPrintProc Fmt 15 | 16 | #define DEBUG_ENTRY(level) DPrintf(level, ("[%s]=>\n", __FUNCTION__)) 17 | #define DEBUG_EXIT_STATUS(level, status) DPrintf((status == NDIS_STATUS_SUCCESS ? level : 0), ("[%s]<=0x%X\n", __FUNCTION__, (status))) 18 | 19 | #endif 20 | #endif 21 | -------------------------------------------------------------------------------- /VirtIO/linux/types.h: -------------------------------------------------------------------------------- 1 | #ifndef _LINUX_TYPES_H 2 | #define _LINUX_TYPES_H 3 | 4 | #define __bitwise__ 5 | #define __attribute__(x) 6 | 7 | #define u8 unsigned char 8 | #define u16 unsigned short 9 | #define u32 unsigned long 10 | #define u64 ULONGLONG 11 | 12 | #define __u8 unsigned char 13 | #define __u16 unsigned short 14 | #define __le16 unsigned short 15 | #define __u32 unsigned long 16 | #define __le32 unsigned long 17 | #define __u64 ULONGLONG 18 | 19 | #endif /* _LINUX_TYPES_H */ 20 | -------------------------------------------------------------------------------- /VirtIO/linux/virtio_types.h: -------------------------------------------------------------------------------- 1 | #ifndef _UAPI_LINUX_VIRTIO_TYPES_H 2 | #define _UAPI_LINUX_VIRTIO_TYPES_H 3 | /* Type definitions for virtio implementations. 4 | * 5 | * This header is BSD licensed so anyone can use the definitions to implement 6 | * compatible drivers/servers. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 1. Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * 2. Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * 3. Neither the name of IBM nor the names of its contributors 17 | * may be used to endorse or promote products derived from this software 18 | * without specific prior written permission. 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 | * ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE 23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | * SUCH DAMAGE. 30 | * 31 | * Copyright (C) 2014 Red Hat, Inc. 32 | * Author: Michael S. Tsirkin 33 | */ 34 | #include 35 | 36 | /* 37 | * __virtio{16,32,64} have the following meaning: 38 | * - __u{16,32,64} for virtio devices in legacy mode, accessed in native endian 39 | * - __le{16,32,64} for standard-compliant virtio devices 40 | */ 41 | 42 | typedef __u16 __bitwise__ __virtio16; 43 | typedef __u32 __bitwise__ __virtio32; 44 | typedef __u64 __bitwise__ __virtio64; 45 | 46 | #endif /* _UAPI_LINUX_VIRTIO_TYPES_H */ 47 | -------------------------------------------------------------------------------- /VirtIO/makefile: -------------------------------------------------------------------------------- 1 | !INCLUDE $(NTMAKEENV)\makefile.def 2 | 3 | -------------------------------------------------------------------------------- /VirtIO/osdep.h: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////////////////// 2 | // Copyright (c) 2007 Qumranet All Rights Reserved 3 | // 4 | // Module Name: 5 | // osdep.h 6 | // 7 | // Abstract: 8 | // Windows OS dependent definitions of data types 9 | // 10 | // Author: 11 | // Yan Vugenfirer - February 2007. 12 | // 13 | ////////////////////////////////////////////////////////////////////////////////////////// 14 | 15 | #if defined(IGNORE_VIRTIO_OSDEP_H) 16 | // to make simulation environment easy 17 | #include "external_os_dep.h" 18 | #else 19 | 20 | #ifndef __OS_DEP_H 21 | #define __OS_DEP_H 22 | 23 | #include 24 | 25 | #define ktime_t ULONGLONG 26 | #define ktime_get() KeQueryPerformanceCounter(NULL).QuadPart 27 | 28 | #define likely(x) x 29 | #define unlikely(x) x 30 | 31 | #define ENOSPC 1 32 | #define BUG_ON(a) 33 | #define WARN_ON(a) 34 | 35 | #ifndef bool 36 | #define bool int 37 | #define false FALSE 38 | #define true TRUE 39 | #define inline __forceinline 40 | #endif 41 | 42 | #ifdef DBG 43 | #define DEBUG 44 | #endif 45 | 46 | #define mb() KeMemoryBarrier() 47 | #define rmb() KeMemoryBarrier() 48 | #define wmb() KeMemoryBarrier() 49 | #define smp_wmb() KeMemoryBarrier() 50 | 51 | #ifndef min 52 | #define min(_a, _b) (((_a) < (_b)) ? (_a) : (_b)) 53 | #endif 54 | 55 | #ifndef max 56 | #define max(_a, _b) (((_a) > (_b)) ? (_a) : (_b)) 57 | #endif 58 | 59 | #endif 60 | #endif 61 | -------------------------------------------------------------------------------- /VirtIO/sources: -------------------------------------------------------------------------------- 1 | TARGETNAME=virtiolib 2 | TARGETTYPE=DRIVER_LIBRARY 3 | TARGETPATH=obj 4 | 5 | 6 | MSC_WARNING_LEVEL=/W3 /WX 7 | INCLUDES=..\Kutils\CPUHypercall;..\Kutils\inc;..\Kutils\Kutils 8 | 9 | SOURCES=VirtIOPCI.c \ 10 | VirtIORing.c 11 | 12 | -------------------------------------------------------------------------------- /VirtIO/windows/virtio_ring_allocation.h: -------------------------------------------------------------------------------- 1 | #ifndef _VIRTIO_RING_ALLOCATION_H 2 | #define _VIRTIO_RING_ALLOCATION_H 3 | 4 | struct virtqueue *vring_new_virtqueue(unsigned int index, 5 | unsigned int num, 6 | unsigned int vring_align, 7 | virtio_device *vdev, 8 | bool event, 9 | void *pages, 10 | void(*notify)(struct virtqueue *), 11 | void *control, 12 | const char *name); 13 | 14 | unsigned int vring_control_block_size(); 15 | 16 | #endif /* _VIRTIO_RING_ALLOCATION_H */ 17 | -------------------------------------------------------------------------------- /buildAll.bat: -------------------------------------------------------------------------------- 1 | cd VirtIO 2 | call buildall.bat 3 | cd .. 4 | 5 | cd NetKVM 6 | call buildall.bat 7 | cd .. 8 | 9 | cd viostor 10 | call buildall.bat 11 | cd .. 12 | 13 | cd vioscsi 14 | call buildall.bat 15 | cd .. 16 | 17 | cd Balloon 18 | call buildall.bat 19 | cd .. 20 | 21 | cd vioserial 22 | call buildall.bat 23 | cd .. 24 | 25 | cd viorng 26 | call buildall.bat 27 | cd .. 28 | 29 | cd pvpanic 30 | call buildall.bat 31 | cd .. 32 | -------------------------------------------------------------------------------- /clean.bat: -------------------------------------------------------------------------------- 1 | cd VirtIO 2 | call clean.bat 3 | cd .. 4 | 5 | cd NetKVM 6 | call clean.bat 7 | cd .. 8 | 9 | cd viostor 10 | call clean.bat 11 | cd .. 12 | 13 | cd Balloon 14 | call cleanall.bat 15 | cd .. 16 | 17 | cd vioserial 18 | call cleanall.bat 19 | cd .. 20 | 21 | cd viorng 22 | call clean.bat 23 | cd .. 24 | -------------------------------------------------------------------------------- /pciserial/buildall.bat: -------------------------------------------------------------------------------- 1 | setlocal 2 | call clean.bat 3 | call ..\Tools\SetVsEnv 12 x64 4 | 5 | inf2cat /driver:. /os:XP_X86,Server2003_X86,XP_X64,Server2003_X64,Vista_X86,Server2008_X86,Vista_X64,Server2008_X64,7_X86,7_X64,Server2008R2_X64,8_X86,8_X64,Server8_X64,6_3_X86,6_3_X64,Server6_3_X64 6 | 7 | mkdir Install 8 | copy qemupciserial.* .\Install\ 9 | 10 | endlocal -------------------------------------------------------------------------------- /pciserial/clean.bat: -------------------------------------------------------------------------------- 1 | del /f /s /q .\Install\* 2 | del /f /s /q qemupciserial.cat 3 | rmdir Install 4 | -------------------------------------------------------------------------------- /pvpanic/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2015 Red Hat, Inc. 2 | 3 | This software is licensed under the GNU General Public License, 4 | version 2 (GPLv2) (see COPYING for details), subject to the following 5 | clarification. 6 | 7 | With respect to binaries built using the Microsoft(R) Windows Driver 8 | Kit (WDK), GPLv2 does not extend to any code contained in or derived 9 | from the WDK ("WDK Code"). As to WDK Code, by using or distributing 10 | such binaries you agree to be bound by the Microsoft Software License 11 | Terms for the WDK. All WDK Code is considered by the GPLv2 licensors 12 | to qualify for the special exception stated in section 3 of GPLv2 13 | (commonly known as the system library exception). 14 | 15 | There is NO WARRANTY for this software, express or implied, 16 | including the implied warranties of NON-INFRINGEMENT, TITLE, 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 18 | 19 | Redistribution and use in source and binary forms, with or without 20 | modification, are permitted provided that the following conditions 21 | are met: 22 | 23 | Redistributions of source code must retain the above copyright 24 | notice, this list of conditions and the following disclaimer. 25 | 26 | Redistributions in binary form must reproduce the above copyright 27 | notice, this list of conditions and the following disclaimer in the 28 | documentation and/or other materials provided with the 29 | distribution. 30 | 31 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 32 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 33 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 34 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 35 | COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 36 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 37 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 38 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 39 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 40 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 41 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 42 | OF THE POSSIBILITY OF SUCH DAMAGE. 43 | -------------------------------------------------------------------------------- /pvpanic/PVPanic Package/PVPanic Package.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {8E41214B-6785-4CFE-B992-037D68949A14} 6 | inf;inv;inx;mof;mc; 7 | 8 | 9 | -------------------------------------------------------------------------------- /pvpanic/clean.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | call :rmdir Install 4 | call :rmdir Install_Debug 5 | call :rmfiles *.log 6 | call :rmfiles *.err 7 | call :rmfiles 2012-defines.h 8 | call :cleandir 9 | 10 | pushd pvpanic 11 | call :cleandir 12 | for /D %%D IN (objchk_*) do call call :rmdir %%D 13 | for /D %%D IN (objfre_*) do call call :rmdir %%D 14 | popd 15 | 16 | pushd "PVPanic Package" 17 | call :cleandir 18 | popd 19 | 20 | goto :eof 21 | 22 | :rmdir 23 | if exist "%~1" rmdir "%~1" /s /q 24 | goto :eof 25 | 26 | :rmfiles 27 | if "%~1"=="" goto :eof 28 | if exist "%~1" del /f "%~1" 29 | shift 30 | goto rmfiles 31 | 32 | :cleandir 33 | call :rmdir Win32 34 | call :rmdir x64 35 | goto :eof 36 | -------------------------------------------------------------------------------- /pvpanic/dirs: -------------------------------------------------------------------------------- 1 | DIRS = pvpanic 2 | -------------------------------------------------------------------------------- /pvpanic/pvpanic/bugcheck.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Red Hat, Inc. 3 | * 4 | * This software is licensed under the GNU General Public License, 5 | * version 2 (GPLv2) (see COPYING for details), subject to the following 6 | * clarification. 7 | * 8 | * With respect to binaries built using the Microsoft(R) Windows Driver 9 | * Kit (WDK), GPLv2 does not extend to any code contained in or derived 10 | * from the WDK ("WDK Code"). As to WDK Code, by using or distributing 11 | * such binaries you agree to be bound by the Microsoft Software License 12 | * Terms for the WDK. All WDK Code is considered by the GPLv2 licensors 13 | * to qualify for the special exception stated in section 3 of GPLv2 14 | * (commonly known as the system library exception). 15 | * 16 | * There is NO WARRANTY for this software, express or implied, 17 | * including the implied warranties of NON-INFRINGEMENT, TITLE, 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 19 | * 20 | * Refer to the LICENSE file for full details of the license. 21 | * 22 | * Written By: Gal Hammer 23 | * 24 | */ 25 | 26 | #include "pvpanic.h" 27 | #include "bugcheck.tmh" 28 | 29 | static KBUGCHECK_CALLBACK_RECORD CallbackRecord; 30 | 31 | KBUGCHECK_CALLBACK_ROUTINE PVPanicOnBugCheck; 32 | 33 | VOID PVPanicOnBugCheck(IN PVOID Buffer, IN ULONG Length) 34 | { 35 | if ((Buffer != NULL) && (Length == sizeof(PVOID))) 36 | { 37 | PUCHAR PortAddress = (PUCHAR)Buffer; 38 | WRITE_PORT_UCHAR(PortAddress, (UCHAR)(PVPANIC_PANICKED)); 39 | } 40 | } 41 | 42 | BOOLEAN PVPanicRegisterBugCheckCallback(IN PVOID PortAddress) 43 | { 44 | KeInitializeCallbackRecord(&CallbackRecord); 45 | 46 | return KeRegisterBugCheckCallback(&CallbackRecord, PVPanicOnBugCheck, 47 | (PVOID)PortAddress, sizeof(PVOID), (PUCHAR)("PVPanic")); 48 | } 49 | 50 | BOOLEAN PVPanicDeregisterBugCheckCallback() 51 | { 52 | return KeDeregisterBugCheckCallback(&CallbackRecord); 53 | } 54 | -------------------------------------------------------------------------------- /pvpanic/pvpanic/makefile: -------------------------------------------------------------------------------- 1 | !INCLUDE $(NTMAKEENV)\makefile.def 2 | 3 | -------------------------------------------------------------------------------- /pvpanic/pvpanic/makefile.inc: -------------------------------------------------------------------------------- 1 | _LNG=$(LANGUAGE) 2 | _INX=. 3 | STAMP=stampinf -f $@ -a $(_BUILDARCH) -k $(KMDF_VERSION_MAJOR).$(KMDF_VERSION_MINOR) 4 | 5 | $(OBJ_PATH)\$(O)\$(INF_NAME).inf: $(_INX)\$(INF_NAME).inf 6 | copy $(_INX)\$(@B).inf $@ 7 | $(STAMP) 8 | -------------------------------------------------------------------------------- /pvpanic/pvpanic/pvpanic.ctl: -------------------------------------------------------------------------------- 1 | 5eeabb8c-be9a-40d0-99fd-86f2a0b21378 PVPanicTraceGuid -------------------------------------------------------------------------------- /pvpanic/pvpanic/pvpanic.rc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Red Hat, Inc. 3 | * 4 | * This software is licensed under the GNU General Public License, 5 | * version 2 (GPLv2) (see COPYING for details), subject to the following 6 | * clarification. 7 | * 8 | * With respect to binaries built using the Microsoft(R) Windows Driver 9 | * Kit (WDK), GPLv2 does not extend to any code contained in or derived 10 | * from the WDK ("WDK Code"). As to WDK Code, by using or distributing 11 | * such binaries you agree to be bound by the Microsoft Software License 12 | * Terms for the WDK. All WDK Code is considered by the GPLv2 licensors 13 | * to qualify for the special exception stated in section 3 of GPLv2 14 | * (commonly known as the system library exception). 15 | * 16 | * There is NO WARRANTY for this software, express or implied, 17 | * including the implied warranties of NON-INFRINGEMENT, TITLE, 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 19 | * 20 | * Refer to the LICENSE file for full details of the license. 21 | * 22 | * Written By: Gal Hammer 23 | * 24 | */ 25 | 26 | #include 27 | 28 | #include 29 | #include 30 | 31 | #define VER_FILETYPE VFT_DRV 32 | #define VER_FILESUBTYPE VFT2_DRV_SYSTEM 33 | #define VER_FILEDESCRIPTION_STR "Red Hat PVPanic Driver" 34 | #define VER_INTERNALNAME_STR "pvpanic.sys" 35 | #define VER_ORIGINALFILENAME_STR "pvpanic.sys" 36 | 37 | #undef VER_PRODUCTBUILD 38 | #undef VER_PRODUCTBUILD_QFE 39 | #undef VER_PRODUCTMAJORVERSION 40 | #undef VER_PRODUCTMINORVERSION 41 | 42 | #undef VER_LEGALCOPYRIGHT_STR 43 | #define VER_LEGALCOPYRIGHT_STR "Copyright (C) 2015 Red Hat Inc." 44 | 45 | #undef VER_COMPANYNAME_STR 46 | #define VER_COMPANYNAME_STR "Red Hat Inc." 47 | 48 | #undef VER_PRODUCTNAME_STR 49 | #define VER_PRODUCTNAME_STR "QEMU PVPanic Device" 50 | 51 | #define VER_LANGNEUTRAL 52 | 53 | #ifndef _NT_TARGET_MAJ 54 | #include "..\2012-defines.h" 55 | #endif 56 | 57 | #define VER_PRODUCTBUILD _MAJORVERSION_ 58 | #define VER_PRODUCTBUILD_QFE _MINORVERSION_ 59 | #define VER_PRODUCTMAJORVERSION _NT_TARGET_MAJ 60 | #define VER_PRODUCTMINORVERSION _NT_TARGET_MIN 61 | 62 | #include "common.ver" 63 | -------------------------------------------------------------------------------- /pvpanic/pvpanic/sources: -------------------------------------------------------------------------------- 1 | TARGETNAME=pvpanic 2 | TARGETTYPE=DRIVER 3 | 4 | TARGET_DESTINATION=wdf 5 | 6 | KMDF_VERSION_MAJOR=1 7 | 8 | MSC_WARNING_LEVEL=-W4 -WX 9 | 10 | INCLUDES = $(INCLUDES); 11 | 12 | TARGETLIBS=$(TARGETLIBS) \ 13 | $(DDK_LIB_PATH)\ntstrsafe.lib 14 | 15 | SOURCES= \ 16 | pvpanic.c \ 17 | power.c \ 18 | bugcheck.c \ 19 | pvpanic.rc 20 | 21 | INF_NAME=pvpanic 22 | 23 | NTTARGETFILES=$(OBJ_PATH)\$(O)\$(INF_NAME).inf 24 | 25 | ENABLE_EVENT_TRACING=1 26 | 27 | !IFDEF ENABLE_EVENT_TRACING 28 | 29 | C_DEFINES = $(C_DEFINES) -DEVENT_TRACING 30 | 31 | # 32 | # Generate WPP tracing code 33 | # $(SOURCES) -- run software preprocessor on files listed in SOURCES 34 | # -km -- use kernel mode 35 | # -func -- define function we'll use for tracing 36 | # This would map all TraceEvents calls to 37 | # DoTraceMessage. 38 | # 39 | RUN_WPP= $(SOURCES) \ 40 | -km \ 41 | -func:TraceEvents(LEVEL,FLAGS,MSG,...) \ 42 | -func:Hexdump((LEVEL,FLAGS,MSG,...)) \ 43 | -gen:{km-WdfDefault.tpl}*.tmh 44 | 45 | !ENDIF 46 | -------------------------------------------------------------------------------- /pvpanic/pvpanic/trace.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Red Hat, Inc. 3 | * 4 | * This software is licensed under the GNU General Public License, 5 | * version 2 (GPLv2) (see COPYING for details), subject to the following 6 | * clarification. 7 | * 8 | * With respect to binaries built using the Microsoft(R) Windows Driver 9 | * Kit (WDK), GPLv2 does not extend to any code contained in or derived 10 | * from the WDK ("WDK Code"). As to WDK Code, by using or distributing 11 | * such binaries you agree to be bound by the Microsoft Software License 12 | * Terms for the WDK. All WDK Code is considered by the GPLv2 licensors 13 | * to qualify for the special exception stated in section 3 of GPLv2 14 | * (commonly known as the system library exception). 15 | * 16 | * There is NO WARRANTY for this software, express or implied, 17 | * including the implied warranties of NON-INFRINGEMENT, TITLE, 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 19 | * 20 | * Refer to the LICENSE file for full details of the license. 21 | * 22 | * Written By: Gal Hammer 23 | * 24 | */ 25 | 26 | // 27 | // Define the tracing flags. 28 | // 29 | // Tracing GUID - 5eeabb8c-be9a-40d0-99fd-86f2a0b21378 30 | // 31 | 32 | #define WPP_CONTROL_GUIDS \ 33 | WPP_DEFINE_CONTROL_GUID( \ 34 | PVPanicTraceGuid, (5eeabb8c,be9a,40d0,99fd,86f2a0b21378), \ 35 | WPP_DEFINE_BIT(DBG_ALL) \ 36 | WPP_DEFINE_BIT(DBG_INIT) \ 37 | WPP_DEFINE_BIT(DBG_POWER) \ 38 | ) 39 | 40 | #define WPP_FLAG_LEVEL_LOGGER(flag, level) \ 41 | WPP_LEVEL_LOGGER(flag) 42 | 43 | #define WPP_FLAG_LEVEL_ENABLED(flag, level) \ 44 | (WPP_LEVEL_ENABLED(flag) && WPP_CONTROL(WPP_BIT_ ## flag).Level >= level) 45 | 46 | #define WPP_LEVEL_FLAGS_LOGGER(lvl,flags) \ 47 | WPP_LEVEL_LOGGER(flags) 48 | 49 | #define WPP_LEVEL_FLAGS_ENABLED(lvl, flags) \ 50 | (WPP_LEVEL_ENABLED(flags) && WPP_CONTROL(WPP_BIT_ ## flags).Level >= lvl) 51 | 52 | // 53 | // This comment block is scanned by the trace preprocessor to define our 54 | // Trace function. 55 | // 56 | // begin_wpp config 57 | // FUNC Trace{FLAG=MYDRIVER_ALL_INFO}(LEVEL, MSG, ...); 58 | // FUNC TraceEvents(LEVEL, FLAGS, MSG, ...); 59 | // end_wpp 60 | // 61 | 62 | -------------------------------------------------------------------------------- /viorng/VirtRNG Package/VirtRNG Package.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {8E41214B-6785-4CFE-B992-037D68949A14} 6 | inf;inv;inx;mof;mc; 7 | 8 | 9 | -------------------------------------------------------------------------------- /viorng/clean.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | call :rmdir Install 4 | call :rmdir Install_Debug 5 | call :rmfiles *.log 6 | call :rmfiles *.err 7 | call :rmfiles 2012-defines.h 8 | call :cleandir 9 | 10 | pushd cng\um 11 | call :cleandir 12 | popd 13 | 14 | pushd coinstaller 15 | call :cleandir 16 | popd 17 | 18 | pushd viorng 19 | call :cleandir 20 | for /D %%D IN (objchk_*) do call call :rmdir %%D 21 | for /D %%D IN (objfre_*) do call call :rmdir %%D 22 | popd 23 | 24 | pushd virtiolib 25 | call :cleandir 26 | popd 27 | 28 | pushd "VirtRNG Package" 29 | call :cleandir 30 | popd 31 | 32 | goto :eof 33 | 34 | :rmdir 35 | if exist "%~1" rmdir "%~1" /s /q 36 | goto :eof 37 | 38 | :rmfiles 39 | if "%~1"=="" goto :eof 40 | if exist "%~1" del /f "%~1" 41 | shift 42 | goto rmfiles 43 | 44 | :cleandir 45 | call :rmdir Win32 46 | call :rmdir x64 47 | goto :eof 48 | -------------------------------------------------------------------------------- /viorng/cng/um/viorngum.def: -------------------------------------------------------------------------------- 1 | 2 | LIBRARY "viorngum" 3 | 4 | EXPORTS 5 | 6 | GetRngInterface 7 | 8 | -------------------------------------------------------------------------------- /viorng/cng/um/viorngum.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014-2015 Red Hat, Inc. 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License 6 | * as published by the Free Software Foundation; either version 2 7 | * of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 17 | * 02110-1301, USA. 18 | * 19 | * Refer to the LICENSE file for full details of the license. 20 | * 21 | * Written By: Gal Hammer 22 | * 23 | */ 24 | 25 | #ifndef NT_SUCCESS 26 | #define NT_SUCCESS(status) (status >= 0) 27 | #endif 28 | 29 | #ifndef STATUS_SUCCESS 30 | #define STATUS_SUCCESS ((NTSTATUS)0x00000000L) 31 | #define STATUS_UNSUCCESSFUL ((NTSTATUS)0xC0000001L) 32 | #define STATUS_NOT_IMPLEMENTED ((NTSTATUS)0xC0000002L) 33 | #define STATUS_NOT_SUPPORTED ((NTSTATUS)0xC00000BBL) 34 | #define STATUS_PORT_UNREACHABLE ((NTSTATUS)0xC000023FL) 35 | #endif 36 | 37 | #ifndef STATUS_INVALID_PARAMETER 38 | #define STATUS_INVALID_PARAMETER ((NTSTATUS)0xC000000DL) 39 | #endif 40 | 41 | // CNG RNG Provider Interface. 42 | 43 | NTSTATUS WINAPI VirtRngOpenAlgorithmProvider(OUT BCRYPT_ALG_HANDLE *Algorithm, 44 | IN LPCWSTR AlgId, IN ULONG Flags); 45 | 46 | NTSTATUS WINAPI VirtRngGetProperty(IN BCRYPT_HANDLE Object, 47 | IN LPCWSTR Property, OUT PUCHAR Output, IN ULONG Length, 48 | OUT ULONG *Result, IN ULONG Flags); 49 | 50 | NTSTATUS WINAPI VirtRngSetProperty(IN OUT BCRYPT_HANDLE Object, 51 | IN LPCWSTR Property, IN PUCHAR Input, IN ULONG Length, IN ULONG Flags); 52 | 53 | NTSTATUS WINAPI VirtRngCloseAlgorithmProvider( 54 | IN OUT BCRYPT_ALG_HANDLE Algorithm, IN ULONG Flags); 55 | 56 | NTSTATUS WINAPI VirtRngGenRandom(IN OUT BCRYPT_ALG_HANDLE Algorithm, 57 | IN OUT PUCHAR Buffer, IN ULONG Length, IN ULONG Flags); 58 | -------------------------------------------------------------------------------- /viorng/cng/um/viorngum.rc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014-2015 Red Hat, Inc. 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License 6 | * as published by the Free Software Foundation; either version 2 7 | * of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 17 | * 02110-1301, USA. 18 | * 19 | * Refer to the LICENSE file for full details of the license. 20 | * 21 | * Written By: Gal Hammer 22 | * 23 | */ 24 | 25 | #include 26 | #include 27 | 28 | #define VER_FILETYPE VFT_DRV 29 | #define VER_FILESUBTYPE VFT2_DRV_SYSTEM 30 | #define VER_FILEDESCRIPTION_STR "Red Hat VirtIO RNG Provider" 31 | #define VER_INTERNALNAME_STR "viorngum.dll" 32 | #define VER_ORIGINALFILENAME_STR "viorngum.dll" 33 | 34 | #undef VER_PRODUCTBUILD 35 | #undef VER_PRODUCTBUILD_QFE 36 | #undef VER_PRODUCTMAJORVERSION 37 | #undef VER_PRODUCTMINORVERSION 38 | 39 | #undef VER_LEGALCOPYRIGHT_STR 40 | #define VER_LEGALCOPYRIGHT_STR "Copyright (C) 2014-2015 Red Hat, Inc." 41 | 42 | #undef VER_COMPANYNAME_STR 43 | #define VER_COMPANYNAME_STR "Red Hat, Inc." 44 | 45 | #undef VER_PRODUCTNAME_STR 46 | #define VER_PRODUCTNAME_STR "Red Hat VirtIO RNG Provider" 47 | 48 | #define VER_LANGNEUTRAL 49 | 50 | #ifndef _NT_TARGET_MAJ 51 | #include "..\..\2012-defines.h" 52 | #endif 53 | 54 | #define VER_PRODUCTBUILD _MAJORVERSION_ 55 | #define VER_PRODUCTBUILD_QFE _MINORVERSION_ 56 | #define VER_PRODUCTMAJORVERSION _NT_TARGET_MAJ 57 | #define VER_PRODUCTMINORVERSION _NT_TARGET_MIN 58 | 59 | #include "common.ver" 60 | -------------------------------------------------------------------------------- /viorng/coinstaller/viorngci.def: -------------------------------------------------------------------------------- 1 | 2 | LIBRARY "viorngci" 3 | 4 | EXPORTS 5 | 6 | VirtRngCoInstaller 7 | 8 | RegisterProvider 9 | UnregisterProvider 10 | -------------------------------------------------------------------------------- /viorng/coinstaller/viorngci.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014-2015 Red Hat, Inc. 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License 6 | * as published by the Free Software Foundation; either version 2 7 | * of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 17 | * 02110-1301, USA. 18 | * 19 | * Refer to the LICENSE file for full details of the license. 20 | * 21 | * Written By: Gal Hammer 22 | * 23 | */ 24 | 25 | #define VIRTRNG_PROVIDER_NAME L"QEMU VirtIO RNG Provider" 26 | 27 | #ifndef NT_SUCCESS 28 | #define NT_SUCCESS(status) (status >= 0) 29 | #endif 30 | 31 | #ifndef STATUS_SUCCESS 32 | #define STATUS_SUCCESS ((NTSTATUS)0x00000000L) 33 | #endif 34 | -------------------------------------------------------------------------------- /viorng/coinstaller/viorngci.rc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014-2015 Red Hat, Inc. 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License 6 | * as published by the Free Software Foundation; either version 2 7 | * of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 17 | * 02110-1301, USA. 18 | * 19 | * Refer to the LICENSE file for full details of the license. 20 | * 21 | * Written By: Gal Hammer 22 | * 23 | */ 24 | 25 | #include 26 | #include 27 | 28 | #define VER_FILETYPE VFT_DRV 29 | #define VER_FILESUBTYPE VFT2_DRV_SYSTEM 30 | #define VER_FILEDESCRIPTION_STR "Red Hat VirtIO RNG CoInstaller" 31 | #define VER_INTERNALNAME_STR "viorngci.dll" 32 | #define VER_ORIGINALFILENAME_STR "viorngci.dll" 33 | 34 | #undef VER_PRODUCTBUILD 35 | #undef VER_PRODUCTBUILD_QFE 36 | #undef VER_PRODUCTMAJORVERSION 37 | #undef VER_PRODUCTMINORVERSION 38 | 39 | #undef VER_LEGALCOPYRIGHT_STR 40 | #define VER_LEGALCOPYRIGHT_STR "Copyright (C) 2014-2015 Red Hat, Inc." 41 | 42 | #undef VER_COMPANYNAME_STR 43 | #define VER_COMPANYNAME_STR "Red Hat, Inc." 44 | 45 | #undef VER_PRODUCTNAME_STR 46 | #define VER_PRODUCTNAME_STR "Red Hat VirtIO RNG CoInstaller" 47 | 48 | #define VER_LANGNEUTRAL 49 | 50 | #ifndef _NT_TARGET_MAJ 51 | #include "..\2012-defines.h" 52 | #endif 53 | 54 | #define VER_PRODUCTBUILD _MAJORVERSION_ 55 | #define VER_PRODUCTBUILD_QFE _MINORVERSION_ 56 | #define VER_PRODUCTMAJORVERSION _NT_TARGET_MAJ 57 | #define VER_PRODUCTMINORVERSION _NT_TARGET_MIN 58 | 59 | #include "common.ver" 60 | -------------------------------------------------------------------------------- /viorng/dirs: -------------------------------------------------------------------------------- 1 | DIRS = viorng 2 | -------------------------------------------------------------------------------- /viorng/viorng/makefile.inc: -------------------------------------------------------------------------------- 1 | _LNG=$(LANGUAGE) 2 | _INX=. 3 | STAMP=stampinf -f $@ -a $(_BUILDARCH) -k $(KMDF_VERSION_MAJOR).$(KMDF_VERSION_MINOR) 4 | 5 | $(OBJ_PATH)\$(O)\$(INF_NAME).inf: $(_INX)\$(INF_NAME).inf 6 | copy $(_INX)\$(@B).inf $@ 7 | $(STAMP) 8 | -------------------------------------------------------------------------------- /viorng/viorng/sources: -------------------------------------------------------------------------------- 1 | TARGETNAME = viorng 2 | TARGETTYPE = DRIVER 3 | 4 | TARGET_DESTINATION = wdf 5 | 6 | KMDF_VERSION_MAJOR = 1 7 | 8 | MSC_WARNING_LEVEL = /W4 /WX 9 | 10 | ENABLE_EVENT_TRACING = 1 11 | 12 | INF_NAME = viorng 13 | NTTARGETFILE0 = $(OBJ_PATH)\$(O)\$(INF_NAME).inf 14 | 15 | TARGETLIBS = $(TARGETLIBS) \ 16 | ..\..\VirtIO\$(O)\virtiolib.lib 17 | 18 | INCLUDES = $(INCLUDES);..\..\VirtIO; 19 | 20 | SOURCES = \ 21 | isrdpc.c \ 22 | power.c \ 23 | read.c \ 24 | viorng.c \ 25 | virtio.c \ 26 | viorng.rc 27 | 28 | !IFDEF ENABLE_EVENT_TRACING 29 | C_DEFINES = $(C_DEFINES) -DEVENT_TRACING 30 | RUN_WPP= $(SOURCES) \ 31 | -km \ 32 | -func:TraceEvents(LEVEL,FLAGS,MSG,...) \ 33 | -gen:{km-WdfDefault.tpl}*.tmh 34 | !ENDIF 35 | -------------------------------------------------------------------------------- /viorng/viorng/trace.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014-2015 Red Hat, Inc. 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License 6 | * as published by the Free Software Foundation; either version 2 7 | * of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 17 | * 02110-1301, USA. 18 | * 19 | * Refer to the LICENSE file for full details of the license. 20 | * 21 | * Written By: Gal Hammer 22 | * 23 | */ 24 | 25 | // 26 | // Define the tracing flags. 27 | // 28 | // Tracing GUID - bf2944ce-30ec-4a52-8380-8d0915003294 29 | // 30 | 31 | #define WPP_CONTROL_GUIDS \ 32 | WPP_DEFINE_CONTROL_GUID( \ 33 | VirtRngTraceGuid, (bf2944ce,30ec,4a52,8380,8d0915003294), \ 34 | WPP_DEFINE_BIT(DBG_ALL) \ 35 | WPP_DEFINE_BIT(DBG_INIT) \ 36 | WPP_DEFINE_BIT(DBG_POWER) \ 37 | WPP_DEFINE_BIT(DBG_INTERRUPT) \ 38 | WPP_DEFINE_BIT(DBG_DPC) \ 39 | WPP_DEFINE_BIT(DBG_READ) \ 40 | ) 41 | 42 | #define WPP_FLAG_LEVEL_LOGGER(flag, level) \ 43 | WPP_LEVEL_LOGGER(flag) 44 | 45 | #define WPP_FLAG_LEVEL_ENABLED(flag, level) \ 46 | (WPP_LEVEL_ENABLED(flag) && WPP_CONTROL(WPP_BIT_ ## flag).Level >= level) 47 | 48 | #define WPP_LEVEL_FLAGS_LOGGER(lvl,flags) \ 49 | WPP_LEVEL_LOGGER(flags) 50 | 51 | #define WPP_LEVEL_FLAGS_ENABLED(lvl, flags) \ 52 | (WPP_LEVEL_ENABLED(flags) && WPP_CONTROL(WPP_BIT_ ## flags).Level >= lvl) 53 | 54 | // 55 | // This comment block is scanned by the trace preprocessor to define our 56 | // Trace function. 57 | // 58 | // begin_wpp config 59 | // FUNC Trace{FLAG=MYDRIVER_ALL_INFO}(LEVEL, MSG, ...); 60 | // FUNC TraceEvents(LEVEL, FLAGS, MSG, ...); 61 | // end_wpp 62 | // 63 | -------------------------------------------------------------------------------- /viorng/viorng/viorng.ctl: -------------------------------------------------------------------------------- 1 | bf2944ce-30ec-4a52-8380-8d0915003294 VirtRngTraceGuid -------------------------------------------------------------------------------- /viorng/viorng/viorng.rc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014-2015 Red Hat, Inc. 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License 6 | * as published by the Free Software Foundation; either version 2 7 | * of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 17 | * 02110-1301, USA. 18 | * 19 | * Refer to the LICENSE file for full details of the license. 20 | * 21 | * Written By: Gal Hammer 22 | * 23 | */ 24 | 25 | #include 26 | #include 27 | 28 | #define VER_FILETYPE VFT_DRV 29 | #define VER_FILESUBTYPE VFT2_DRV_SYSTEM 30 | #define VER_FILEDESCRIPTION_STR "Red Hat VirtIO RNG Driver" 31 | #define VER_INTERNALNAME_STR "viorng.sys" 32 | #define VER_ORIGINALFILENAME_STR "viorng.sys" 33 | 34 | #undef VER_PRODUCTBUILD 35 | #undef VER_PRODUCTBUILD_QFE 36 | #undef VER_PRODUCTMAJORVERSION 37 | #undef VER_PRODUCTMINORVERSION 38 | 39 | #undef VER_LEGALCOPYRIGHT_STR 40 | #define VER_LEGALCOPYRIGHT_STR "Copyright (C) 2014-2015 Red Hat, Inc." 41 | 42 | #undef VER_COMPANYNAME_STR 43 | #define VER_COMPANYNAME_STR "Red Hat, Inc." 44 | 45 | #undef VER_PRODUCTNAME_STR 46 | #define VER_PRODUCTNAME_STR "Red Hat VirtIO RNG Device" 47 | 48 | #define VER_LANGNEUTRAL 49 | 50 | #ifndef _NT_TARGET_MAJ 51 | #include "..\2012-defines.h" 52 | #endif 53 | 54 | #define VER_PRODUCTBUILD _MAJORVERSION_ 55 | #define VER_PRODUCTBUILD_QFE _MINORVERSION_ 56 | #define VER_PRODUCTMAJORVERSION _NT_TARGET_MAJ 57 | #define VER_PRODUCTMINORVERSION _NT_TARGET_MIN 58 | 59 | #include "common.ver" 60 | -------------------------------------------------------------------------------- /viorng/viorng/viorng.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | {8E41214B-6785-4CFE-B992-037D68949A14} 18 | inf;inv;inx;mof;mc; 19 | 20 | 21 | 22 | 23 | Driver Files 24 | 25 | 26 | 27 | 28 | Source Files 29 | 30 | 31 | Source Files 32 | 33 | 34 | Source Files 35 | 36 | 37 | Source Files 38 | 39 | 40 | Source Files 41 | 42 | 43 | 44 | 45 | Header Files 46 | 47 | 48 | Header Files 49 | 50 | 51 | 52 | 53 | Resource Files 54 | 55 | 56 | -------------------------------------------------------------------------------- /viorng/viorng/virtio.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014-2015 Red Hat, Inc. 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public License 6 | * as published by the Free Software Foundation; either version 2 7 | * of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 17 | * 02110-1301, USA. 18 | * 19 | * Refer to the LICENSE file for full details of the license. 20 | * 21 | * Written By: Gal Hammer 22 | * 23 | */ 24 | 25 | #include "viorng.h" 26 | 27 | #include "virtio.tmh" 28 | 29 | static void NoDebugPrintFunc(const char *format, ...) 30 | { 31 | UNREFERENCED_PARAMETER(format); 32 | } 33 | 34 | typedef void (*tDebugPrintFunc)(const char *format, ...); 35 | tDebugPrintFunc VirtioDebugPrintProc = NoDebugPrintFunc; 36 | 37 | int virtioDebugLevel = 0; 38 | int bDebugPrint = 0; 39 | 40 | u32 ReadVirtIODeviceRegister(ULONG_PTR ulRegister) 41 | { 42 | return READ_PORT_ULONG((PULONG)(ulRegister)); 43 | } 44 | 45 | void WriteVirtIODeviceRegister(ULONG_PTR ulRegister, u32 ulValue) 46 | { 47 | WRITE_PORT_ULONG((PULONG)(ulRegister), (ULONG)(ulValue)); 48 | } 49 | 50 | u8 ReadVirtIODeviceByte(ULONG_PTR ulRegister) 51 | { 52 | return READ_PORT_UCHAR((PUCHAR)(ulRegister)); 53 | } 54 | 55 | void WriteVirtIODeviceByte(ULONG_PTR ulRegister, u8 bValue) 56 | { 57 | WRITE_PORT_UCHAR((PUCHAR)(ulRegister), (UCHAR)(bValue)); 58 | } 59 | 60 | u16 ReadVirtIODeviceWord(ULONG_PTR ulRegister) 61 | { 62 | return READ_PORT_USHORT((PUSHORT)(ulRegister)); 63 | } 64 | 65 | void WriteVirtIODeviceWord(ULONG_PTR ulRegister, u16 wValue) 66 | { 67 | WRITE_PORT_USHORT((PUSHORT)(ulRegister), (USHORT)(wValue)); 68 | } 69 | -------------------------------------------------------------------------------- /viorng/viorngum.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2012 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "viorngum", "cng\um\viorngum.vcxproj", "{E81CB0C6-F255-4A79-B972-8E49D15D957E}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | Debug|x64 = Debug|x64 10 | Release|Win32 = Release|Win32 11 | Release|x64 = Release|x64 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {E81CB0C6-F255-4A79-B972-8E49D15D957E}.Debug|Win32.ActiveCfg = Debug|Win32 15 | {E81CB0C6-F255-4A79-B972-8E49D15D957E}.Debug|Win32.Build.0 = Debug|Win32 16 | {E81CB0C6-F255-4A79-B972-8E49D15D957E}.Debug|Win32.Deploy.0 = Debug|Win32 17 | {E81CB0C6-F255-4A79-B972-8E49D15D957E}.Debug|x64.ActiveCfg = Debug|x64 18 | {E81CB0C6-F255-4A79-B972-8E49D15D957E}.Debug|x64.Build.0 = Debug|x64 19 | {E81CB0C6-F255-4A79-B972-8E49D15D957E}.Debug|x64.Deploy.0 = Debug|x64 20 | {E81CB0C6-F255-4A79-B972-8E49D15D957E}.Release|Win32.ActiveCfg = Release|Win32 21 | {E81CB0C6-F255-4A79-B972-8E49D15D957E}.Release|Win32.Build.0 = Release|Win32 22 | {E81CB0C6-F255-4A79-B972-8E49D15D957E}.Release|Win32.Deploy.0 = Release|Win32 23 | {E81CB0C6-F255-4A79-B972-8E49D15D957E}.Release|x64.ActiveCfg = Release|x64 24 | {E81CB0C6-F255-4A79-B972-8E49D15D957E}.Release|x64.Build.0 = Release|x64 25 | {E81CB0C6-F255-4A79-B972-8E49D15D957E}.Release|x64.Deploy.0 = Release|x64 26 | EndGlobalSection 27 | GlobalSection(SolutionProperties) = preSolution 28 | HideSolutionNode = FALSE 29 | EndGlobalSection 30 | EndGlobal 31 | -------------------------------------------------------------------------------- /viorng/virtiolib/virtiolib.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Header Files 20 | 21 | 22 | Header Files 23 | 24 | 25 | Header Files 26 | 27 | 28 | Header Files 29 | 30 | 31 | Header Files 32 | 33 | 34 | Header Files 35 | 36 | 37 | 38 | 39 | Source Files 40 | 41 | 42 | Source Files 43 | 44 | 45 | -------------------------------------------------------------------------------- /vioscsi/MAKEFILE: -------------------------------------------------------------------------------- 1 | # 2 | # DO NOT EDIT THIS FILE!!! Edit .\sources. if you want to add a new source 3 | # file to this component. This file merely indirects to the real make file 4 | # that is shared by all the driver components of the Windows NT DDK 5 | # 6 | MINIMUM_NT_TARGET_VERSION=0x501 7 | !INCLUDE $(NTMAKEENV)\makefile.def 8 | 9 | -------------------------------------------------------------------------------- /vioscsi/SOURCES: -------------------------------------------------------------------------------- 1 | TARGETNAME=vioscsi 2 | TARGETTYPE=MINIPORT 3 | 4 | C_DEFINES = -D_MAJORVERSION_=$(_BUILD_MAJOR_VERSION_) $(C_DEFINES) 5 | C_DEFINES = -D_MINORVERSION_=$(_BUILD_MINOR_VERSION_) $(C_DEFINES) 6 | C_DEFINES = -D_NT_TARGET_MAJ=$(_NT_TARGET_MAJ) $(C_DEFINES) 7 | C_DEFINES = -D_NT_TARGET_MIN=$(_RHEL_RELEASE_VERSION_) $(C_DEFINES) 8 | 9 | C_DEFINES = -DMSI_SUPPORTED=1 $(C_DEFINES) 10 | C_DEFINES = -DINDIRECT_SUPPORTED=1 $(C_DEFINES) 11 | TARGETLIBS=$(SDK_LIB_PATH)\storport.lib $(SDK_LIB_PATH)\scsiwmi.lib ..\VirtIO\$(O)\virtiolib.lib 12 | 13 | INF_NAME=vioscsi 14 | NTTARGETFILE0=$(OBJ_PATH)\$(O)\$(INF_NAME).inf 15 | #NTTARGETFILE1=vioscsidt.h 16 | #NTTARGETFILE2=vioscsi.html 17 | #NTTARGETFILE2=vioscsi.vbs 18 | PASS0_BINPLACE=$(NTTARGETFILE0) 19 | 20 | SOURCES= vioscsi.mof \ 21 | vioscsi.c \ 22 | utils.c \ 23 | helper.c \ 24 | vioscsi.rc \ 25 | virtio_pci.c 26 | 27 | MAJORCOMP=ntos 28 | 29 | TARGETLIBS=$(TARGETLIBS) \ 30 | $(SDK_LIB_PATH)\ntoskrnl.lib\ 31 | $(SDK_LIB_PATH)\bufferoverflowk.lib\ 32 | $(SDK_LIB_PATH)\wdm.lib 33 | 34 | INCLUDES = $(INCLUDES);..\VirtIO; 35 | 36 | BUFFER_OVERFLOW_CHECKS=1 37 | MSC_WARNING_LEVEL=/W3 /WX 38 | 39 | C_DEFINES = -DINDIRECT_SUPPORTED=1 $(C_DEFINES) 40 | 41 | #ENABLE_EVENT_TRACING=1 42 | 43 | # select one or none of those 44 | #ENABLE_COM_DEBUG=1 45 | #ENABLE_PRINT_DEBUG=1 46 | 47 | !IFDEF ENABLE_COM_DEBUG 48 | C_DEFINES = $(C_DEFINES) -DCOM_DEBUG 49 | !ENDIF 50 | 51 | !IFDEF ENABLE_PRINT_DEBUG 52 | C_DEFINES = $(C_DEFINES) -DPRINT_DEBUG 53 | !ENDIF 54 | 55 | -------------------------------------------------------------------------------- /vioscsi/buildOne.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | if "%DDKVER%"=="" set DDKVER=7600.16385.1 4 | set BUILDROOT=C:\WINDDK\%DDKVER% 5 | 6 | if "%_BUILD_MAJOR_VERSION_%"=="" set _BUILD_MAJOR_VERSION_=101 7 | if "%_BUILD_MINOR_VERSION_%"=="" set _BUILD_MINOR_VERSION_=58000 8 | if "%_RHEL_RELEASE_VERSION_%"=="" set _RHEL_RELEASE_VERSION_=61 9 | 10 | set DDKBUILDENV= 11 | pushd %BUILDROOT% 12 | call %BUILDROOT%\bin\setenv.bat %BUILDROOT% %2 fre %1 no_oacr 13 | popd 14 | 15 | set /a _NT_TARGET_MAJ="(%_NT_TARGET_VERSION% >> 8) * 10 + (%_NT_TARGET_VERSION% & 255)" 16 | set STAMPINF_VERSION=%_NT_TARGET_MAJ%.%_RHEL_RELEASE_VERSION_%.%_BUILD_MAJOR_VERSION_%.%_BUILD_MINOR_VERSION_% 17 | 18 | build -cZg 19 | 20 | set DDKVER= 21 | set BUILDROOT= 22 | -------------------------------------------------------------------------------- /vioscsi/clean.bat: -------------------------------------------------------------------------------- 1 | @echo on 2 | 3 | rmdir /S /Q .\Install 4 | 5 | rmdir /S /Q objchk_wlh_x86 6 | rmdir /S /Q objchk_wlh_amd64 7 | rmdir /S /Q objchk_win7_x86 8 | rmdir /S /Q objchk_win7_amd64 9 | rmdir /S /Q objfre_wlh_x86 10 | rmdir /S /Q objfre_wlh_amd64 11 | rmdir /S /Q objfre_win7_x86 12 | rmdir /S /Q objfre_win7_amd64 13 | rmdir /S /Q objfre_win8_x86 14 | rmdir /S /Q objfre_win8_amd64 15 | rmdir /S /Q .\sdv 16 | rmdir /S /Q .\sdv.temp 17 | 18 | del /F *.log *.wrn *.err 19 | del vioscsi-2012.h 20 | del vioscsi.dvl.xml 21 | del sdv-map.h 22 | 23 | 24 | -------------------------------------------------------------------------------- /vioscsi/makefile.inc: -------------------------------------------------------------------------------- 1 | clean: 2 | del $(O)\vioscsidt.h $(O)\vioscsi.bmf 3 | 4 | _LNG=$(LANGUAGE) 5 | _INX=. 6 | STAMP=stampinf -f $@ -d * -a $(_BUILDARCH) 7 | 8 | 9 | $(OBJ_PATH)\$(O)\$(INF_NAME).inf: $(_INX)\$(INF_NAME).inx 10 | copy $(_INX)\$(@B).inx $@ 11 | $(STAMP) 12 | 13 | $(O)\vioscsi.bmf: vioscsi.mof 14 | mofcomp -B:$(O)\vioscsi.bmf vioscsi.mof 15 | 16 | vioscsidt.h: $(O)\vioscsi.bmf 17 | wmimofck -h$(O)\vioscsidt.h $(O)\vioscsi.bmf 18 | 19 | vioscsi.html: $(O)\vioscsi.bmf 20 | wmimofck -w$(O)\vioscsi.html $(O)\vioscsi.bmf 21 | 22 | vioscsi.vbs: $(O)\vioscsi.bmf 23 | wmimofck -t$(O)\vioscsi.vbs $(O)\vioscsi.bmf 24 | -------------------------------------------------------------------------------- /vioscsi/vioscsi.mof: -------------------------------------------------------------------------------- 1 | [ 2 | Dynamic, Provider("WMIProv"), 3 | WMI, 4 | Description ("VirtIO SCSI Extended Information"), 5 | guid ("{5CDAC4F6-3D46-44E2-8DEE-01606E11E265}"), 6 | HeaderName("VioScsiExtendedInfo"), 7 | GuidName1("VioScsiWmi_ExtendedInfo_Guid"), 8 | WmiExpense(0) 9 | ] 10 | class VioScsiExtendedInfoGuid 11 | { 12 | [read,key] String InstanceName; 13 | [read] boolean Active; 14 | 15 | [read, WmiDataId(1), WmiVersion(1)] uint32 QueueDepth; 16 | [read, WmiDataId(2), WmiVersion(1)] uint8 QueuesCount; 17 | [read, WmiDataId(3), WmiVersion(1)] boolean Indirect; 18 | [read, WmiDataId(4), WmiVersion(1)] boolean EventIndex; 19 | [read, WmiDataId(5), WmiVersion(1)] boolean DpcRedirection; 20 | [read, WmiDataId(6), WmiVersion(1)] boolean ConcurentChannels; 21 | [read, WmiDataId(7), WmiVersion(1)] boolean InterruptMsgRanges; 22 | [read, WmiDataId(8), WmiVersion(1)] boolean CompletionDuringStartIo; 23 | }; 24 | -------------------------------------------------------------------------------- /vioscsi/vioscsi.rc: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * Copyright (c) 2012-2015 Red Hat, Inc. 3 | * 4 | * File: vioscsi.rc 5 | * 6 | * This file contains resource (version) definitions for vioscsi driver. 7 | * 8 | * This work is licensed under the terms of the GNU GPL, version 2. See 9 | * the COPYING file in the top-level directory. 10 | * 11 | **********************************************************************/ 12 | #include 13 | #include 14 | 15 | #define VER_FILETYPE VFT_DRV 16 | #define VER_FILESUBTYPE VFT2_DRV_SYSTEM 17 | #define VER_FILEDESCRIPTION_STR "Red Hat VirtIO SCSI pass-through driver" 18 | #define VER_INTERNALNAME_STR "vioscsi.sys" 19 | #define VER_ORIGINALFILENAME_STR "vioscsi.sys" 20 | 21 | #undef VER_PRODUCTBUILD 22 | #undef VER_PRODUCTBUILD_QFE 23 | #undef VER_PRODUCTMAJORVERSION 24 | #undef VER_PRODUCTMINORVERSION 25 | 26 | #undef VER_LEGALCOPYRIGHT_STR 27 | #define VER_LEGALCOPYRIGHT_STR "Copyright (C) 2012-2015 Red, Hat Inc." 28 | 29 | #undef VER_COMPANYNAME_STR 30 | #define VER_COMPANYNAME_STR "Red Hat, Inc." 31 | 32 | #undef VER_PRODUCTNAME_STR 33 | #define VER_PRODUCTNAME_STR "Red Hat VirtIO SCSI pass-through controller" 34 | 35 | #define VER_LANGNEUTRAL 36 | 37 | #ifndef _NT_TARGET_MAJ 38 | #include "vioscsi-2012.h" 39 | #endif 40 | 41 | #define VER_PRODUCTBUILD _MAJORVERSION_ 42 | #define VER_PRODUCTBUILD_QFE _MINORVERSION_ 43 | #define VER_PRODUCTMAJORVERSION _NT_TARGET_MAJ 44 | #define VER_PRODUCTMINORVERSION _NT_TARGET_MIN 45 | 46 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 47 | MOFRESOURCE MOFDATA MOVEABLE PURE "vioscsi.bmf" 48 | 49 | #include "common.ver" 50 | 51 | 52 | -------------------------------------------------------------------------------- /vioscsi/vioscsi.vcxproj.Filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | {8E41214B-6785-4CFE-B992-037D68949A14} 18 | inf;inv;inx;mof;mc; 19 | 20 | 21 | 22 | 23 | Driver Files 24 | 25 | 26 | 27 | 28 | Header Files 29 | 30 | 31 | Header Files 32 | 33 | 34 | Header Files 35 | 36 | 37 | 38 | 39 | Resource Files 40 | 41 | 42 | 43 | 44 | Source Files 45 | 46 | 47 | Source Files 48 | 49 | 50 | Source Files 51 | 52 | 53 | Source Files 54 | 55 | 56 | -------------------------------------------------------------------------------- /vioscsi/vioscsidt.h: -------------------------------------------------------------------------------- 1 | #ifndef _vioscsidt_h_ 2 | #define _vioscsidt_h_ 3 | 4 | // VioScsiExtendedInfoGuid - VioScsiExtendedInfo 5 | // VirtIO SCSI Extended Information 6 | #define VioScsiWmi_ExtendedInfo_Guid \ 7 | { 0x5cdac4f6,0x3d46,0x44e2, { 0x8d,0xee,0x01,0x60,0x6e,0x11,0xe2,0x65 } } 8 | 9 | #if ! (defined(MIDL_PASS)) 10 | DEFINE_GUID(VioScsiExtendedInfoGuid_GUID, \ 11 | 0x5cdac4f6,0x3d46,0x44e2,0x8d,0xee,0x01,0x60,0x6e,0x11,0xe2,0x65); 12 | #endif 13 | 14 | 15 | typedef struct _VioScsiExtendedInfo 16 | { 17 | // 18 | ULONG QueueDepth; 19 | #define VioScsiExtendedInfo_QueueDepth_SIZE sizeof(ULONG) 20 | #define VioScsiExtendedInfo_QueueDepth_ID 1 21 | 22 | // 23 | UCHAR QueuesCount; 24 | #define VioScsiExtendedInfo_QueuesCount_SIZE sizeof(UCHAR) 25 | #define VioScsiExtendedInfo_QueuesCount_ID 2 26 | 27 | // 28 | BOOLEAN Indirect; 29 | #define VioScsiExtendedInfo_Indirect_SIZE sizeof(BOOLEAN) 30 | #define VioScsiExtendedInfo_Indirect_ID 3 31 | 32 | // 33 | BOOLEAN EventIndex; 34 | #define VioScsiExtendedInfo_EventIndex_SIZE sizeof(BOOLEAN) 35 | #define VioScsiExtendedInfo_EventIndex_ID 4 36 | 37 | // 38 | BOOLEAN DpcRedirection; 39 | #define VioScsiExtendedInfo_DpcRedirection_SIZE sizeof(BOOLEAN) 40 | #define VioScsiExtendedInfo_DpcRedirection_ID 5 41 | 42 | // 43 | BOOLEAN ConcurentChannels; 44 | #define VioScsiExtendedInfo_ConcurentChannels_SIZE sizeof(BOOLEAN) 45 | #define VioScsiExtendedInfo_ConcurentChannels_ID 6 46 | 47 | // 48 | BOOLEAN InterruptMsgRanges; 49 | #define VioScsiExtendedInfo_InterruptMsgRanges_SIZE sizeof(BOOLEAN) 50 | #define VioScsiExtendedInfo_InterruptMsgRanges_ID 7 51 | 52 | // 53 | BOOLEAN CompletionDuringStartIo; 54 | #define VioScsiExtendedInfo_CompletionDuringStartIo_SIZE sizeof(BOOLEAN) 55 | #define VioScsiExtendedInfo_CompletionDuringStartIo_ID 8 56 | 57 | } VioScsiExtendedInfo, *PVioScsiExtendedInfo; 58 | 59 | #define VioScsiExtendedInfo_SIZE (FIELD_OFFSET(VioScsiExtendedInfo, CompletionDuringStartIo) + VioScsiExtendedInfo_CompletionDuringStartIo_SIZE) 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /vioscsi/virtio_pci.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Virtio PCI driver 3 | * 4 | * This module allows virtio devices to be used over a virtual PCI device. 5 | * This can be used with QEMU based VMMs like KVM or Xen. 6 | * 7 | * Copyright IBM Corp. 2007 8 | * 9 | * Authors: 10 | * Anthony Liguori 11 | * Windows porting - Yan Vugenfirer 12 | * StorPort/ScsiPort code adjustment Vadim Rozenfeld 13 | * 14 | * This work is licensed under the terms of the GNU GPL, version 2. See 15 | * the COPYING file in the top-level directory. 16 | * 17 | */ 18 | /********************************************************************** 19 | * Copyright (c) 2012-2015 Red Hat, Inc. 20 | * 21 | * This work is licensed under the terms of the GNU GPL, version 2. See 22 | * the COPYING file in the top-level directory. 23 | * 24 | **********************************************************************/ 25 | #include "osdep.h" 26 | #include "VirtIO_PCI.h" 27 | #include "utils.h" 28 | #include "vioscsi.h" 29 | 30 | 31 | u32 ReadVirtIODeviceRegister(ULONG_PTR ulRegister) 32 | { 33 | return StorPortReadPortUlong(NULL, (PULONG)(ulRegister)); 34 | } 35 | 36 | void WriteVirtIODeviceRegister(ULONG_PTR ulRegister, u32 ulValue) 37 | { 38 | StorPortWritePortUlong(NULL, (PULONG)(ulRegister),(ULONG)(ulValue) ); 39 | } 40 | 41 | u8 ReadVirtIODeviceByte(ULONG_PTR ulRegister) 42 | { 43 | return StorPortReadPortUchar(NULL, (PUCHAR)(ulRegister)); 44 | } 45 | 46 | void WriteVirtIODeviceByte(ULONG_PTR ulRegister, u8 bValue) 47 | { 48 | StorPortWritePortUchar(NULL, (PUCHAR)(ulRegister),(UCHAR)(bValue)); 49 | } 50 | 51 | u16 ReadVirtIODeviceWord(ULONG_PTR ulRegister) 52 | { 53 | return StorPortReadPortUshort(NULL, (PUSHORT)(ulRegister)); 54 | } 55 | 56 | void WriteVirtIODeviceWord(ULONG_PTR ulRegister, u16 wValue) 57 | { 58 | StorPortWritePortUshort(NULL, (PUSHORT)(ulRegister),(USHORT)(wValue)); 59 | } 60 | -------------------------------------------------------------------------------- /vioserial/app/buildOne.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | if "%DDKVER%"=="" set DDKVER=7600.16385.1 3 | set BUILDROOT=C:\WINDDK\%DDKVER% 4 | 5 | set DDKBUILDENV= 6 | pushd %BUILDROOT% 7 | call %BUILDROOT%\bin\setenv.bat %BUILDROOT% %2 fre %1 no_oacr 8 | popd 9 | build -cZg 10 | 11 | set DDKVER= 12 | set BUILDROOT= 13 | 14 | 15 | -------------------------------------------------------------------------------- /vioserial/app/cleanAll.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | rmdir /S /Q objfre_wxp_x86 4 | rmdir /S /Q objfre_wnet_x86 5 | rmdir /S /Q objfre_wnet_amd64 6 | rmdir /S /Q objfre_wlh_x86 7 | rmdir /S /Q objfre_wlh_amd64 8 | rmdir /S /Q objfre_win7_x86 9 | rmdir /S /Q objfre_win7_amd64 10 | 11 | del /F *.log *.wrn *.err 12 | 13 | 14 | -------------------------------------------------------------------------------- /vioserial/app/device.h: -------------------------------------------------------------------------------- 1 | #ifndef DEVICE_H 2 | #define DEVICE_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include "..\sys\public.h" 12 | #pragma warning(disable:4201) 13 | 14 | #include 15 | #include 16 | 17 | #pragma warning(default:4201) 18 | 19 | 20 | 21 | class CDevice { 22 | public: 23 | CDevice(); 24 | ~CDevice(); 25 | BOOL Init(BOOL ovrl); 26 | BOOL Write(PVOID buf, size_t* size); 27 | BOOL WriteEx(PVOID buf, size_t* size); 28 | BOOL Read(PVOID buf, size_t* size); 29 | BOOL ReadEx(PVOID buf, size_t* size); 30 | BOOL GetInfo(PVOID buf, size_t* size); 31 | protected: 32 | HANDLE m_hDevice; 33 | PTCHAR GetDevicePath( IN LPGUID InterfaceGuid ); 34 | }; 35 | 36 | #endif 37 | 38 | -------------------------------------------------------------------------------- /vioserial/app/makefile: -------------------------------------------------------------------------------- 1 | # 2 | # DO NOT EDIT THIS FILE!!! Edit .\sources. if you want to add a new source 3 | # file to this component. This file merely indirects to the real make file 4 | # that is shared by all the components of Windows NT 5 | # 6 | !INCLUDE $(NTMAKEENV)\makefile.def 7 | 8 | -------------------------------------------------------------------------------- /vioserial/app/notifier.cpp: -------------------------------------------------------------------------------- 1 | #include "notifier.h" 2 | #include "assert.h" 3 | 4 | CNotifier::CNotifier() 5 | { 6 | m_hThread = INVALID_HANDLE_VALUE; 7 | m_hEvent = INVALID_HANDLE_VALUE; 8 | m_bRunning = TRUE; 9 | } 10 | 11 | CNotifier::~CNotifier() 12 | { 13 | if (m_hThread != INVALID_HANDLE_VALUE) 14 | { 15 | CloseHandle(m_hThread); 16 | m_hThread = INVALID_HANDLE_VALUE; 17 | } 18 | if (m_hEvent != INVALID_HANDLE_VALUE) 19 | { 20 | CloseHandle(m_hEvent); 21 | m_hEvent = INVALID_HANDLE_VALUE; 22 | } 23 | } 24 | 25 | BOOL CNotifier::Init() 26 | { 27 | DWORD id; 28 | 29 | m_hThread = CreateThread( 30 | NULL, 31 | 0, 32 | (LPTHREAD_START_ROUTINE) ServiceThread, 33 | (LPVOID)this, 34 | 0, 35 | &id); 36 | 37 | if (m_hThread == NULL) { 38 | printf("Cannot create thread.\n"); 39 | return FALSE; 40 | } 41 | m_bRunning = TRUE; 42 | return TRUE; 43 | } 44 | 45 | BOOL CNotifier::Stop() 46 | { 47 | BOOL res = FALSE; 48 | return res; 49 | } 50 | 51 | 52 | DWORD WINAPI CNotifier::ServiceThread(CNotifier* ptr) 53 | { 54 | ptr->Run(); 55 | return 0; 56 | } 57 | 58 | void CNotifier::Run() 59 | { 60 | } 61 | -------------------------------------------------------------------------------- /vioserial/app/notifier.h: -------------------------------------------------------------------------------- 1 | #ifndef NOTIFYER_H 2 | #define NOTIFYER_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include "..\sys\public.h" 12 | #pragma warning(disable:4201) 13 | 14 | #include 15 | #include 16 | 17 | #pragma warning(default:4201) 18 | 19 | class CNotifier { 20 | public: 21 | CNotifier(); 22 | ~CNotifier(); 23 | BOOL Init(); 24 | BOOL Stop(); 25 | protected: 26 | static DWORD WINAPI ServiceThread(CNotifier* ); 27 | void Run(); 28 | HANDLE m_hThread; 29 | HANDLE m_hEvent; 30 | HWND m_hWnd; 31 | BOOL m_bRunning; 32 | }; 33 | 34 | #endif 35 | 36 | -------------------------------------------------------------------------------- /vioserial/app/packOne.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | : Param1 - Win7 | Wlh | Wnet | XP 3 | : Param2 - x86|x64 4 | : Param3 - file name 5 | 6 | if "%2"=="x64" set %%2=amd64 7 | 8 | if /i "%1"=="Win7" goto :checkarch 9 | if /i "%1"=="Wlh" goto :checkarch 10 | if /i "%1"=="Wnet" goto :checkarch 11 | if /i "%1"=="WXp" goto :checkarch 12 | goto :printerr 13 | :checkarch 14 | if /i "%2"=="x86" goto :makeinstall 15 | if /i "%2"=="x64" goto :makeinstall 16 | :printerr 17 | echo wrong parameters (1)%1 (2)%2 (3)%3 18 | pause 19 | goto :eof 20 | 21 | :makeinstall 22 | set INST_OS=%1 23 | set INST_ARC=%2 24 | set FILE_NAME=%3 25 | rem set INST_EXT=INST_ARC 26 | 27 | if /i "%INST_ARC%"=="x64" goto :set_x64 28 | 29 | set INST_EXT=i386 30 | goto :startcopy 31 | 32 | :set_x64 33 | set INST_ARC=amd64 34 | set INST_EXT=amd64 35 | 36 | :startcopy 37 | set EXE_PATH_AND_NAME=objfre_%INST_OS%_%INST_ARC%\%INST_EXT%\%FILE_NAME%.exe 38 | set PDB_PATH_AND_NAME=objfre_%INST_OS%_%INST_ARC%\%INST_EXT%\%FILE_NAME%.pdb 39 | 40 | echo makeinstall %1 %2 %3 41 | mkdir ..\Install\%INST_OS%\%INST_ARC% 42 | del /Q ..\Install\%INST_OS%\%INST_ARC%\%FILE_NAME%.* 43 | copy /Y %EXE_PATH_AND_NAME% ..\Install\%INST_OS%\%INST_ARC% 44 | copy /Y %PDB_PATH_AND_NAME% ..\Install\%INST_OS%\%INST_ARC% 45 | 46 | set INST_OS= 47 | set INST_ARC= 48 | set FILE_NAME= 49 | set EXE_PATH_AND_NAME= 50 | set PDB_PATH_AND_NAME= 51 | 52 | 53 | -------------------------------------------------------------------------------- /vioserial/app/sources: -------------------------------------------------------------------------------- 1 | TARGETNAME=vioser-test 2 | TARGETTYPE=PROGRAM 3 | 4 | _NT_TARGET_VERSION= $(_NT_TARGET_VERSION_WINXP) 5 | 6 | USE_MSVCRT=1 7 | 8 | UMTYPE=console 9 | UMENTRY=wmain 10 | 11 | SOURCES=main.cpp \ 12 | device.cpp \ 13 | notifier.cpp 14 | 15 | TARGETLIBS=$(SDK_LIB_PATH)\setupapi.lib \ 16 | $(SDK_LIB_PATH)\user32.lib \ 17 | $(SDK_LIB_PATH)\uuid.lib \ 18 | $(SDK_LIB_PATH)\strsafe.lib 19 | 20 | C_DEFINES=$(C_DEFINES) /D_UNICODE /DUNICODE 21 | 22 | USE_MSVCRT=1 23 | USE_VCCOM=1 24 | USE_ATL=1 25 | ATL_VER=71 26 | 27 | INCLUDES=$(INCLUDES);$(DDK_INC_PATH) 28 | 29 | #TARGET_DESTINATION=wdf 30 | 31 | -------------------------------------------------------------------------------- /vioserial/cleanAll.bat: -------------------------------------------------------------------------------- 1 | @echo on 2 | 3 | rmdir /S /Q Install 4 | 5 | del /F *.log *.wrn *.err 6 | 7 | cd app 8 | call cleanAll.bat 9 | cd .. 10 | 11 | cd sys 12 | call cleanAll.bat 13 | cd .. 14 | 15 | 16 | -------------------------------------------------------------------------------- /vioserial/dirs: -------------------------------------------------------------------------------- 1 | DIRS= \ 2 | sys \ 3 | app 4 | -------------------------------------------------------------------------------- /vioserial/lib/makefile: -------------------------------------------------------------------------------- 1 | # 2 | # DO NOT EDIT THIS FILE!!! Edit .\sources. if you want to add a new source 3 | # file to this component. This file merely indirects to the real make file 4 | # that is shared by all the components of Windows NT 5 | # 6 | !INCLUDE $(NTMAKEENV)\makefile.def 7 | 8 | -------------------------------------------------------------------------------- /vioserial/lib/sources: -------------------------------------------------------------------------------- 1 | TARGETNAME = vioserlb 2 | TARGETTYPE = DYNLINK 3 | DLLDEF = vioserlb.def 4 | 5 | #_NT_TARGET_VERSION= $(_NT_TARGET_VERSION_WINXP) 6 | 7 | USE_MSVCRT=1 8 | 9 | SOURCES=main.cpp \ 10 | PnPControl.cpp \ 11 | Port.cpp 12 | 13 | TARGETLIBS=$(SDK_LIB_PATH)\setupapi.lib \ 14 | $(SDK_LIB_PATH)\user32.lib \ 15 | $(SDK_LIB_PATH)\uuid.lib \ 16 | $(SDK_LIB_PATH)\advapi32.lib \ 17 | $(SDK_LIB_PATH)\kernel32.lib 18 | 19 | C_DEFINES=$(C_DEFINES) -DUNICODE -DWIN32 -DDLL_EXPORTS 20 | 21 | USE_MSVCRT=1 22 | USE_STL=1 23 | STL_VER=70 24 | USER_C_FLAGS= $(USER_C_FLAGS) /EHa 25 | 26 | INCLUDES=$(INCLUDES);$(DDK_INC_PATH);..\sys\ 27 | 28 | MSC_WARNING_LEVEL = /W4 /WX 29 | 30 | DLLENTRY=_DllMainCRTStartup 31 | PRECOMPILED_CXX=1 32 | PRECOMPILED_INCLUDE=stdafx.h 33 | PRECOMPILED_PCH=stdafx.pch 34 | PRECOMPILED_OBJ=stdafx.obj 35 | -------------------------------------------------------------------------------- /vioserial/lib/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // notifier.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /vioserial/lib/stdafx.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef _WIN32_WINNT 4 | #define _WIN32_WINNT 0x0501 5 | #endif 6 | 7 | #define INITGUID 8 | 9 | #include 10 | #include 11 | #include "public.h" 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | #include 18 | #include 19 | #include 20 | 21 | 22 | #include "PnPAll.h" 23 | #include "vioser.h" 24 | 25 | 26 | -------------------------------------------------------------------------------- /vioserial/lib/vioser.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #ifdef DLL_EXPORTS 6 | #define DLL_API extern "C" __declspec(dllexport) 7 | #else 8 | #define DLL_API extern "C" __declspec(dllimport) 9 | #endif 10 | 11 | typedef BOOL (WINAPI VIOSERIALNOTIFYCALLBACK)(PVOID pRef); 12 | 13 | DLL_API BOOL VIOSStartup(void); 14 | DLL_API VOID VIOSCleanup(void); 15 | DLL_API BOOL FindPort(const wchar_t* name); 16 | DLL_API PVOID OpenPortByName(const wchar_t* name); 17 | DLL_API PVOID OpenPortById(UINT id); 18 | DLL_API BOOL ReadPort(PVOID port, PVOID buf, PULONG size); 19 | DLL_API BOOL WritePort(PVOID port, PVOID buf, ULONG size); 20 | DLL_API VOID ClosePort(PVOID port); 21 | DLL_API UINT NumPorts(); 22 | DLL_API wchar_t* PortSymbolicName(int index); 23 | DLL_API VOID RegisterNotification(PVOID port, VIOSERIALNOTIFYCALLBACK pfn, PVOID ptr); 24 | -------------------------------------------------------------------------------- /vioserial/lib/vioserlb.def: -------------------------------------------------------------------------------- 1 | LIBRARY "VIOSerLb.DLL" 2 | 3 | EXPORTS 4 | ; VIOSStartup PRIVATE 5 | ; VIOSCleanup PRIVATE 6 | ; FindPort PRIVATE 7 | ; OpenPort PRIVATE 8 | ; ReadPort PRIVATE 9 | ; WritePort PRIVATE 10 | ; ClosePort PRIVATE 11 | ; NumPorts PRIVATE 12 | ; PortSymbolicName PRIVATE 13 | -------------------------------------------------------------------------------- /vioserial/libtestapp/makefile: -------------------------------------------------------------------------------- 1 | # 2 | # DO NOT EDIT THIS FILE!!! Edit .\sources. if you want to add a new source 3 | # file to this component. This file merely indirects to the real make file 4 | # that is shared by all the components of Windows NT 5 | # 6 | !INCLUDE $(NTMAKEENV)\makefile.def 7 | 8 | -------------------------------------------------------------------------------- /vioserial/libtestapp/sources: -------------------------------------------------------------------------------- 1 | TARGETNAME=libtestapp 2 | TARGETTYPE=PROGRAM 3 | 4 | #_NT_TARGET_VERSION= $(_NT_TARGET_VERSION_WINXP) 5 | 6 | USE_MSVCRT=1 7 | 8 | UMTYPE=console 9 | UMENTRY=wmain 10 | 11 | SOURCES=main.cpp 12 | 13 | TARGETLIBS=$(SDK_LIB_PATH)\setupapi.lib \ 14 | $(SDK_LIB_PATH)\user32.lib \ 15 | $(SDK_LIB_PATH)\uuid.lib \ 16 | $(SDK_LIB_PATH)\strsafe.lib \ 17 | ..\lib\$(O)\vioserlb.lib 18 | 19 | INCLUDES = $(INCLUDES);..\lib; 20 | 21 | C_DEFINES=$(C_DEFINES) /D_UNICODE /DUNICODE 22 | 23 | USE_MSVCRT=1 24 | USE_VCCOM=1 25 | USE_ATL=1 26 | ATL_VER=71 27 | 28 | INCLUDES=$(INCLUDES);$(DDK_INC_PATH) 29 | 30 | #TARGET_DESTINATION=wdf 31 | 32 | -------------------------------------------------------------------------------- /vioserial/libtestsvc/makefile: -------------------------------------------------------------------------------- 1 | # 2 | # DO NOT EDIT THIS FILE!!! Edit .\sources. if you want to add a new source 3 | # file to this component. This file merely indirects to the real make file 4 | # that is shared by all the components of Windows NT 5 | # 6 | !INCLUDE $(NTMAKEENV)\makefile.def 7 | 8 | -------------------------------------------------------------------------------- /vioserial/libtestsvc/service.h: -------------------------------------------------------------------------------- 1 | #ifndef SERVICE_H 2 | #define SERVICE_H 3 | 4 | #include 5 | #include 6 | 7 | 8 | class CService 9 | { 10 | public: 11 | CService(); 12 | ~CService(); 13 | BOOL InitService(); 14 | void GetStatus(SC_HANDLE service); 15 | static void __stdcall HandlerThunk(CService* service, DWORD ctlcode); 16 | static DWORD __stdcall HandlerExThunk(CService* service, DWORD ctlcode, DWORD evtype, PVOID evdata); 17 | static void __stdcall ServiceMainThunk(CService* service, DWORD argc, TCHAR* argv[]); 18 | SERVICE_STATUS_HANDLE m_StatusHandle; 19 | 20 | private: 21 | static DWORD WINAPI ServiceThread( LPDWORD lParam); 22 | void Run(); 23 | BOOL SendStatusToSCM(DWORD dwCurrentState, DWORD dwWin32ExitCode, DWORD dwServiceSpecificExitCode, DWORD dwCheckPoint, DWORD dwWaitHint); 24 | void ResumeService(); 25 | void PauseService(); 26 | void StopService(); 27 | void terminate(DWORD error); 28 | void ServiceCtrlHandler(DWORD controlCode); 29 | void ServiceMain(DWORD argc, LPTSTR *argv); 30 | DWORD ServiceHandleDeviceChange(DWORD evtype, _DEV_BROADCAST_HEADER* dbhdr); 31 | DWORD ServiceHandlePowerEvent(DWORD evtype, DWORD flags); 32 | 33 | HANDLE m_evTerminate; 34 | HANDLE m_evWakeUp; 35 | HANDLE m_thHandle; 36 | BOOL m_bPauseService; 37 | BOOL m_bRunningService; 38 | CRITICAL_SECTION m_scWrite; 39 | }; 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /vioserial/libtestsvc/sources: -------------------------------------------------------------------------------- 1 | TARGETNAME=libtestsvc 2 | TARGETTYPE=PROGRAM 3 | 4 | #_NT_TARGET_VERSION= $(_NT_TARGET_VERSION_WINXP) 5 | 6 | USE_MSVCRT=1 7 | 8 | UMTYPE=console 9 | UMENTRY=wmain 10 | 11 | SOURCES=main.cpp \ 12 | service.cpp \ 13 | utils.cpp 14 | 15 | TARGETLIBS=$(SDK_LIB_PATH)\setupapi.lib \ 16 | $(SDK_LIB_PATH)\user32.lib \ 17 | $(SDK_LIB_PATH)\uuid.lib \ 18 | $(SDK_LIB_PATH)\strsafe.lib \ 19 | ..\lib\$(O)\vioserlb.lib 20 | 21 | INCLUDES = $(INCLUDES);..\lib; 22 | 23 | C_DEFINES=$(C_DEFINES) /D_UNICODE /DUNICODE /D_WIN32_DCOM 24 | 25 | USE_MSVCRT=1 26 | USE_VCCOM=1 27 | USE_ATL=1 28 | ATL_VER=71 29 | 30 | INCLUDES=$(INCLUDES);$(DDK_INC_PATH) 31 | 32 | #TARGET_DESTINATION=wdf 33 | 34 | -------------------------------------------------------------------------------- /vioserial/libtestsvc/utils.h: -------------------------------------------------------------------------------- 1 | #ifndef UTILS_H 2 | #define UTILS_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | BOOL InstallService(); 9 | BOOL UninstallService(); 10 | BOOL GetConfiguration(); 11 | BOOL ChangeConfig(); 12 | BOOL ServiceRun(); 13 | BOOL ServiceControl(int ctrl); 14 | 15 | void ShowUsage(); 16 | void ErrorHandler(char *s, int err); 17 | void PrintMessage(char *s); 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /vioserial/sys/cleanAll.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | rmdir /S /Q objfre_wxp_x86 4 | rmdir /S /Q objfre_wnet_x86 5 | rmdir /S /Q objfre_wnet_amd64 6 | rmdir /S /Q objfre_wlh_x86 7 | rmdir /S /Q objfre_wlh_amd64 8 | rmdir /S /Q objfre_win7_x86 9 | rmdir /S /Q objfre_win7_amd64 10 | rmdir /S /Q objfre_win8_x86 11 | rmdir /S /Q objfre_win8_amd64 12 | rmdir /S /Q Win8Release 13 | rmdir /S /Q Win8Debug 14 | rmdir /S /Q x64 15 | 16 | del /F *.log *.wrn *.err 17 | del 2012-defines.h 18 | 19 | -------------------------------------------------------------------------------- /vioserial/sys/makefile: -------------------------------------------------------------------------------- 1 | # 2 | # DO NOT EDIT THIS FILE!!! Edit .\sources. if you want to add a new source 3 | # file to this component. This file merely indirects to the real make file 4 | # that is shared by all the driver components of the Windows NT DDK 5 | # 6 | 7 | !INCLUDE $(NTMAKEENV)\makefile.def 8 | 9 | 10 | -------------------------------------------------------------------------------- /vioserial/sys/makefile.inc: -------------------------------------------------------------------------------- 1 | _LNG=$(LANGUAGE) 2 | _INX=. 3 | 4 | STAMP=stampinf -f $@ -a $(_BUILDARCH) -k $(KMDF_VERSION_MAJOR).$(KMDF_VERSION_MINOR) 5 | 6 | $(OBJ_PATH)\$(O)\$(INF_NAME).inf: $(_INX)\$(INF_NAME).inx 7 | copy $(_INX)\$(@B).inx $@ 8 | $(STAMP) 9 | -------------------------------------------------------------------------------- /vioserial/sys/precomp.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * Copyright (c) 2010-2015 Red Hat, Inc. 3 | * 4 | * File: precomp.h 5 | * 6 | * Author(s): 7 | * 8 | * Pre-compiled header file for vioserial driver. 9 | * 10 | * This work is licensed under the terms of the GNU GPL, version 2. See 11 | * the COPYING file in the top-level directory. 12 | * 13 | **********************************************************************/ 14 | #include 15 | #include 16 | #include 17 | #include 18 | #define NTSTRSAFE_LIB 19 | #include 20 | #include // required for GUID definitions 21 | #include // required for WMILIB_CONTEXT 22 | #include 23 | #include 24 | #include 25 | 26 | 27 | #ifndef u8 28 | #define u8 UCHAR 29 | #endif 30 | 31 | #ifndef u16 32 | #define u16 USHORT 33 | #endif 34 | 35 | #ifndef u32 36 | #define u32 ULONG 37 | #endif 38 | 39 | #ifndef bool 40 | #define bool INT 41 | #endif 42 | 43 | #include "virtio_pci.h" 44 | #include "virtio_config.h" 45 | #include "virtio.h" 46 | 47 | #include "trace.h" 48 | -------------------------------------------------------------------------------- /vioserial/sys/public.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * Copyright (c) 2010-2015 Red Hat, Inc. 3 | * 4 | * File: public.h 5 | * 6 | * Author(s): 7 | * 8 | * Public include file 9 | * This file contains 10 | * 11 | * This work is licensed under the terms of the GNU GPL, version 2. See 12 | * the COPYING file in the top-level directory. 13 | * 14 | **********************************************************************/ 15 | #if !defined(VIOS_PUBLIC_H) 16 | #define VIOS_PUBLIC_H 17 | 18 | DEFINE_GUID (GUID_VIOSERIAL_CONTROLLER, 19 | 0xF55F7844, 0x6A0C, 0x11d2, 0xB8, 0x41, 0x00, 0xC0, 0x4F, 0xAD, 0x51, 0x71); 20 | // {F55F7844-6A0C-11d2-B841-00C04FAD5171} 21 | 22 | DEFINE_GUID(GUID_VIOSERIAL_PORT, 23 | 0x6fde7521, 0x1b65, 0x48ae, 0xb6, 0x28, 0x80, 0xbe, 0x62, 0x1, 0x60, 0x26); 24 | // {6FDE7521-1B65-48ae-B628-80BE62016026} 25 | 26 | #define IOCTL_GET_INFORMATION CTL_CODE(FILE_DEVICE_UNKNOWN, 0x800, METHOD_BUFFERED, FILE_ANY_ACCESS) 27 | 28 | typedef struct _tagVirtioPortInfo { 29 | UINT Id; 30 | BOOLEAN OutVqFull; 31 | BOOLEAN HostConnected; 32 | BOOLEAN GuestConnected; 33 | CHAR Name[1]; 34 | }VIRTIO_PORT_INFO, * PVIRTIO_PORT_INFO; 35 | 36 | DEFINE_GUID(GUID_VIOSERIAL_PORT_CHANGE_STATUS, 37 | 0x2c0f39ac, 0xb156, 0x4237, 0x9c, 0x64, 0x89, 0x91, 0xa1, 0x8b, 0xf3, 0x5c); 38 | // {2C0F39AC-B156-4237-9C64-8991A18BF35C} 39 | 40 | typedef struct _tagVirtioPortStatusChange { 41 | ULONG Version; 42 | ULONG Reason; 43 | } VIRTIO_PORT_STATUS_CHANGE, *PVIRTIO_PORT_STATUS_CHANGE; 44 | 45 | #endif /* VIOS_PUBLIC_H */ 46 | -------------------------------------------------------------------------------- /vioserial/sys/sources: -------------------------------------------------------------------------------- 1 | TARGETNAME=vioser 2 | TARGETTYPE=DRIVER 3 | 4 | C_DEFINES = -D_MAJORVERSION_=$(_BUILD_MAJOR_VERSION_) $(C_DEFINES) 5 | C_DEFINES = -D_MINORVERSION_=$(_BUILD_MINOR_VERSION_) $(C_DEFINES) 6 | C_DEFINES = -D_NT_TARGET_MAJ=$(_NT_TARGET_MAJ) $(C_DEFINES) 7 | C_DEFINES = -D_NT_TARGET_MIN=$(_RHEL_RELEASE_VERSION_) $(C_DEFINES) 8 | 9 | 10 | KMDF_VERSION_MAJOR=1 11 | MSC_WARNING_LEVEL=-W3 -WX 12 | 13 | INF_NAME=vioser 14 | NTTARGETFILE0=$(OBJ_PATH)\$(O)\$(INF_NAME).inf 15 | PASS0_BINPLACE=$(NTTARGETFILE0) 16 | 17 | TARGETLIBS=$(TARGETLIBS) \ 18 | $(DDK_LIB_PATH)\ntstrsafe.lib \ 19 | $(DDK_LIB_PATH)\wdmsec.lib \ 20 | ..\..\VirtIO\$(O)\virtiolib.lib 21 | 22 | INCLUDES = $(INCLUDES);..\..\VirtIO; 23 | 24 | SOURCES= Driver.c \ 25 | Device.c \ 26 | IsrDpc.c \ 27 | Port.c \ 28 | Buffer.c \ 29 | utils.c \ 30 | Control.c \ 31 | vioser.rc 32 | 33 | TARGET_DESTINATION=wdf 34 | 35 | PRECOMPILED_INCLUDE=precomp.h 36 | PRECOMPILED_PCH=precomp.pch 37 | PRECOMPILED_OBJ=precomp.obj 38 | 39 | #ENABLE_EVENT_TRACING=1 40 | 41 | # select one or none of those 42 | #ENABLE_COM_DEBUG=1 43 | #ENABLE_PRINT_DEBUG=1 44 | 45 | 46 | !IFDEF ENABLE_EVENT_TRACING 47 | C_DEFINES = $(C_DEFINES) -DEVENT_TRACING 48 | RUN_WPP= $(SOURCES) \ 49 | -km \ 50 | -func:TraceEvents(LEVEL,FLAGS,MSG,...) \ 51 | -gen:{km-WdfDefault.tpl}*.tmh 52 | !ENDIF 53 | 54 | !IFDEF ENABLE_COM_DEBUG 55 | C_DEFINES = $(C_DEFINES) -DCOM_DEBUG 56 | !ENDIF 57 | 58 | !IFDEF ENABLE_PRINT_DEBUG 59 | C_DEFINES = $(C_DEFINES) -DPRINT_DEBUG 60 | !ENDIF 61 | -------------------------------------------------------------------------------- /vioserial/sys/vioser.rc: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * Copyright (c) 2010-2015 Red Hat, Inc. 3 | * 4 | * File: vioser.rc 5 | * 6 | * This file contains resource (version) definitions for viostor driver. 7 | * 8 | * This work is licensed under the terms of the GNU GPL, version 2. See 9 | * the COPYING file in the top-level directory. 10 | * 11 | **********************************************************************/ 12 | #include 13 | #include 14 | 15 | #define VER_FILETYPE VFT_DRV 16 | #define VER_FILESUBTYPE VFT2_DRV_SYSTEM 17 | #define VER_FILEDESCRIPTION_STR "Red Hat VirtIO Serial driver" 18 | #define VER_INTERNALNAME_STR "vioser.sys" 19 | #define VER_ORIGINALFILENAME_STR "vioser.sys" 20 | 21 | #undef VER_PRODUCTBUILD 22 | #undef VER_PRODUCTBUILD_QFE 23 | #undef VER_PRODUCTMAJORVERSION 24 | #undef VER_PRODUCTMINORVERSION 25 | 26 | #undef VER_LEGALCOPYRIGHT_STR 27 | #define VER_LEGALCOPYRIGHT_STR "Copyright (C) 2010-2015 Red Hat, Inc." 28 | 29 | #undef VER_COMPANYNAME_STR 30 | #define VER_COMPANYNAME_STR "Red Hat, Inc." 31 | 32 | #undef VER_PRODUCTNAME_STR 33 | #define VER_PRODUCTNAME_STR "Red Hat VirtIO Serial controller" 34 | 35 | #define VER_LANGNEUTRAL 36 | 37 | #ifndef _NT_TARGET_MAJ 38 | #include "2012-defines.h" 39 | #endif 40 | #define VER_PRODUCTBUILD _MAJORVERSION_ 41 | #define VER_PRODUCTBUILD_QFE _MINORVERSION_ 42 | #define VER_PRODUCTMAJORVERSION _NT_TARGET_MAJ 43 | #define VER_PRODUCTMINORVERSION _NT_TARGET_MIN 44 | 45 | 46 | #include "common.ver" 47 | -------------------------------------------------------------------------------- /viostor/MAKEFILE: -------------------------------------------------------------------------------- 1 | # 2 | # DO NOT EDIT THIS FILE!!! Edit .\sources. if you want to add a new source 3 | # file to this component. This file merely indirects to the real make file 4 | # that is shared by all the driver components of the Windows NT DDK 5 | # 6 | MINIMUM_NT_TARGET_VERSION=0x501 7 | !INCLUDE $(NTMAKEENV)\makefile.def 8 | 9 | -------------------------------------------------------------------------------- /viostor/SOURCES: -------------------------------------------------------------------------------- 1 | TARGETNAME=viostor 2 | TARGETTYPE=MINIPORT 3 | 4 | C_DEFINES = -D_MAJORVERSION_=$(_BUILD_MAJOR_VERSION_) $(C_DEFINES) 5 | C_DEFINES = -D_MINORVERSION_=$(_BUILD_MINOR_VERSION_) $(C_DEFINES) 6 | C_DEFINES = -D_NT_TARGET_MAJ=$(_NT_TARGET_MAJ) $(C_DEFINES) 7 | C_DEFINES = -D_NT_TARGET_MIN=$(_RHEL_RELEASE_VERSION_) $(C_DEFINES) 8 | 9 | !if "$(DDK_TARGET_OS)" == "WinLH" 10 | INF_NAME=WinLH 11 | C_DEFINES = -DUSE_STORPORT=1 $(C_DEFINES) 12 | C_DEFINES = -DMSI_SUPPORTED=1 $(C_DEFINES) 13 | TARGETLIBS=$(SDK_LIB_PATH)\storport.lib ..\VirtIO\$(O)\virtiolib.lib 14 | !elseif "$(DDK_TARGET_OS)" == "Win7" 15 | INF_NAME=WinLH 16 | C_DEFINES = -DUSE_STORPORT=1 $(C_DEFINES) 17 | C_DEFINES = -DMSI_SUPPORTED=1 $(C_DEFINES) 18 | TARGETLIBS=$(SDK_LIB_PATH)\storport.lib ..\VirtIO\$(O)\virtiolib.lib 19 | !elseif "$(DDK_TARGET_OS)" == "WinNET" 20 | INF_NAME=WinNET 21 | C_DEFINES = -DUSE_STORPORT=1 $(C_DEFINES) 22 | TARGETLIBS=$(SDK_LIB_PATH)\storport.lib ..\VirtIO\$(O)\virtiolib.lib 23 | !elseif "$(DDK_TARGET_OS)" == "WinXP" 24 | INF_NAME=WinXP 25 | TARGETLIBS=$(SDK_LIB_PATH)\scsiport.lib ..\VirtIO\$(O)\virtiolib.lib 26 | !else 27 | INF_NAME=WinLH 28 | C_DEFINES = -DMSI_SUPPORTED=1 $(C_DEFINES) 29 | C_DEFINES = -DUSE_STORPORT=1 $(C_DEFINES) 30 | TARGETLIBS=$(SDK_LIB_PATH)\storport.lib ..\VirtIO\$(O)\virtiolib.lib 31 | !endif 32 | 33 | C_DEFINES = -DINDIRECT_SUPPORTED=1 $(C_DEFINES) 34 | 35 | 36 | INF_TARGET=$(OBJ_PATH)\$(O)\$(TARGETNAME).inf 37 | 38 | NTTARGETFILE1=$(INF_TARGET) 39 | PASS1_BINPLACE=$(NTTARGETFILE1) 40 | 41 | INCLUDES = $(INCLUDES);..\VirtIO; 42 | 43 | SOURCES= virtio_stor.c \ 44 | virtio_stor_utils.c \ 45 | virtio_stor_hw_helper.c \ 46 | virtio_stor.rc \ 47 | virtio_pci.c \ 48 | 49 | MAJORCOMP=ntos 50 | 51 | 52 | TARGETLIBS=$(TARGETLIBS) \ 53 | $(SDK_LIB_PATH)\ntoskrnl.lib\ 54 | $(SDK_LIB_PATH)\bufferoverflowk.lib\ 55 | $(SDK_LIB_PATH)\wdm.lib 56 | 57 | BUFFER_OVERFLOW_CHECKS=1 58 | MSC_WARNING_LEVEL=/W3 /WX 59 | 60 | #ENABLE_EVENT_TRACING=1 61 | # 62 | 63 | 64 | # select one or none of those 65 | #ENABLE_COM_DEBUG=1 66 | #ENABLE_PRINT_DEBUG=1 67 | 68 | !IFDEF ENABLE_COM_DEBUG 69 | C_DEFINES = $(C_DEFINES) -DCOM_DEBUG 70 | !ENDIF 71 | 72 | !IFDEF ENABLE_PRINT_DEBUG 73 | C_DEFINES = $(C_DEFINES) -DPRINT_DEBUG 74 | !ENDIF 75 | -------------------------------------------------------------------------------- /viostor/WinNET.inx: -------------------------------------------------------------------------------- 1 | ; Copyright (c) 2008-2015 Red Hat Inc. 2 | [Version] 3 | Signature="$Windows NT$" 4 | Class=SCSIAdapter 5 | ClassGUID={4D36E97B-E325-11CE-BFC1-08002BE10318} 6 | Provider=%RHEL% 7 | DriverVer=05/03/2010,6.0.6001.16640 8 | CatalogFile=viostor.cat 9 | DriverPackageType = PlugAndPlay 10 | DriverPackageDisplayName = %RHELScsi.DeviceDesc% 11 | 12 | ; 13 | ; Source file information 14 | ; 15 | 16 | [SourceDisksNames] 17 | 1 = %DiskId1%,,,"" 18 | 19 | [SourceDisksFiles] 20 | viostor.sys = 1,, 21 | 22 | [ControlFlags] 23 | ;ExcludeFromSelect = * 24 | 25 | [DestinationDirs] 26 | DefaultDestDir = 10 27 | viostor_Files_Driver = 12 28 | 29 | ; 30 | ; Driver information 31 | ; 32 | 33 | [Manufacturer] 34 | %RHEL% = RHEL,NT$ARCH$ 35 | 36 | [RHEL.NT$ARCH$] 37 | %RHELScsi.DeviceDesc% = rhelscsi_inst, PCI\VEN_1AF4&DEV_1001&SUBSYS_00021AF4&REV_00 38 | 39 | ; 40 | ; General installation section 41 | ; 42 | 43 | [viostor_Files_Driver] 44 | viostor.sys,,,2 45 | 46 | [rhelscsi_inst] 47 | CopyFiles=viostor_Files_Driver 48 | 49 | ; 50 | ; Service Installation 51 | ; 52 | 53 | [rhelscsi_inst.Services] 54 | AddService = viostor, 0x00000002 , rhelscsi_Service_Inst, rhelscsi_EventLog_Inst 55 | 56 | [rhelscsi_Service_Inst] 57 | ServiceType = %SERVICE_KERNEL_DRIVER% 58 | StartType = %SERVICE_BOOT_START% 59 | ErrorControl = %SERVICE_ERROR_NORMAL% 60 | ServiceBinary = %12%\viostor.sys 61 | LoadOrderGroup = SCSI miniport 62 | AddReg = pnpsafe_pci_addreg 63 | 64 | [rhelscsi_EventLog_Inst] 65 | AddReg = rhelscsi_EventLog_AddReg 66 | 67 | [rhelscsi_EventLog_AddReg] 68 | HKR,,EventMessageFile,%REG_EXPAND_SZ%,"%%SystemRoot%%\System32\IoLogMsg.dll" 69 | HKR,,TypesSupported,%REG_DWORD%,7 70 | 71 | [pnpsafe_pci_addreg] 72 | HKR, "Parameters\PnpInterface", "5", %REG_DWORD%, 0x00000001 73 | HKR, "Parameters", "BusType", %REG_DWORD%, 0x00000001 74 | 75 | [Strings] 76 | ; 77 | ; Localizable Strings 78 | ; 79 | diskId1 = "Red Hat VirtIO SCSI controller Installation Disk" 80 | RHELScsi.DeviceDesc = "Red Hat VirtIO SCSI controller" 81 | RHEL = "Red Hat, Inc." 82 | 83 | ; 84 | ; Non-Localizable Strings 85 | ; 86 | 87 | REG_EXPAND_SZ = 0x00020000 88 | REG_DWORD = 0x00010001 89 | SERVICE_KERNEL_DRIVER = 1 90 | SERVICE_BOOT_START = 0 91 | SERVICE_ERROR_NORMAL = 1 92 | -------------------------------------------------------------------------------- /viostor/WinXP.inx: -------------------------------------------------------------------------------- 1 | ; Copyright (c) 2008-2015 Red Hat Inc. 2 | [Version] 3 | Signature="$Windows NT$" 4 | Class=SCSIAdapter 5 | ClassGUID={4D36E97B-E325-11CE-BFC1-08002BE10318} 6 | Provider=%RHEL% 7 | DriverVer=05/03/2010,6.0.6001.16640 8 | CatalogFile=viostor.cat 9 | DriverPackageType = PlugAndPlay 10 | DriverPackageDisplayName = %RHELScsi.DeviceDesc% 11 | 12 | ; 13 | ; Source file information 14 | ; 15 | 16 | [SourceDisksNames] 17 | 1 = %DiskId1%,,,"" 18 | 19 | [SourceDisksFiles] 20 | viostor.sys = 1,, 21 | 22 | [ControlFlags] 23 | ;ExcludeFromSelect = * 24 | 25 | [DestinationDirs] 26 | DefaultDestDir = 10 27 | viostor_Files_Driver = 12 28 | 29 | ; 30 | ; Driver information 31 | ; 32 | 33 | [Manufacturer] 34 | %RHEL% = RHEL,NT$ARCH$ 35 | 36 | [RHEL.NT$ARCH$] 37 | %RHELScsi.DeviceDesc% = rhelscsi_inst, PCI\VEN_1AF4&DEV_1001&SUBSYS_00021AF4&REV_00 38 | 39 | ; 40 | ; General installation section 41 | ; 42 | 43 | [viostor_Files_Driver] 44 | viostor.sys,,,2 45 | 46 | [rhelscsi_inst] 47 | CopyFiles=viostor_Files_Driver 48 | 49 | ; 50 | ; Service Installation 51 | ; 52 | 53 | [rhelscsi_inst.Services] 54 | AddService = viostor, 0x00000002 , rhelscsi_Service_Inst, rhelscsi_EventLog_Inst 55 | 56 | [rhelscsi_Service_Inst] 57 | ServiceType = %SERVICE_KERNEL_DRIVER% 58 | StartType = %SERVICE_BOOT_START% 59 | ErrorControl = %SERVICE_ERROR_NORMAL% 60 | ServiceBinary = %12%\viostor.sys 61 | LoadOrderGroup = SCSI miniport 62 | AddReg = pnpsafe_pci_addreg 63 | 64 | [rhelscsi_EventLog_Inst] 65 | AddReg = rhelscsi_EventLog_AddReg 66 | 67 | [rhelscsi_EventLog_AddReg] 68 | HKR,,EventMessageFile,%REG_EXPAND_SZ%,"%%SystemRoot%%\System32\IoLogMsg.dll" 69 | HKR,,TypesSupported,%REG_DWORD%,7 70 | 71 | [pnpsafe_pci_addreg] 72 | HKR, "Parameters\PnpInterface", "5", %REG_DWORD%, 0x00000001 73 | HKR, "Parameters", "BusType", %REG_DWORD%, 0x00000001 74 | 75 | [Strings] 76 | ; 77 | ; Localizable Strings 78 | ; 79 | diskId1 = "Red Hat VirtIO SCSI controller Installation Disk" 80 | RHELScsi.DeviceDesc = "Red Hat VirtIO SCSI controller" 81 | RHEL = "Red Hat, Inc." 82 | 83 | ; 84 | ; Non-Localizable Strings 85 | ; 86 | 87 | REG_EXPAND_SZ = 0x00020000 88 | REG_DWORD = 0x00010001 89 | SERVICE_KERNEL_DRIVER = 1 90 | SERVICE_BOOT_START = 0 91 | SERVICE_ERROR_NORMAL = 1 92 | -------------------------------------------------------------------------------- /viostor/buildOne.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | if "%DDKVER%"=="" set DDKVER=7600.16385.1 4 | set BUILDROOT=C:\WINDDK\%DDKVER% 5 | 6 | if "%_BUILD_MAJOR_VERSION_%"=="" set _BUILD_MAJOR_VERSION_=101 7 | if "%_BUILD_MINOR_VERSION_%"=="" set _BUILD_MINOR_VERSION_=58000 8 | if "%_RHEL_RELEASE_VERSION_%"=="" set _RHEL_RELEASE_VERSION_=61 9 | 10 | set DDKBUILDENV= 11 | pushd %BUILDROOT% 12 | call %BUILDROOT%\bin\setenv.bat %BUILDROOT% %2 fre %1 no_oacr 13 | popd 14 | 15 | set /a _NT_TARGET_MAJ="(%_NT_TARGET_VERSION% >> 8) * 10 + (%_NT_TARGET_VERSION% & 255)" 16 | set STAMPINF_VERSION=%_NT_TARGET_MAJ%.%_RHEL_RELEASE_VERSION_%.%_BUILD_MAJOR_VERSION_%.%_BUILD_MINOR_VERSION_% 17 | 18 | build -cZg 19 | 20 | set DDKVER= 21 | set BUILDROOT= 22 | -------------------------------------------------------------------------------- /viostor/clean.bat: -------------------------------------------------------------------------------- 1 | @echo on 2 | 3 | rmdir /S /Q .\Install 4 | 5 | rmdir /S /Q objfre_wxp_x86 6 | rmdir /S /Q objfre_wnet_x86 7 | rmdir /S /Q objfre_wnet_amd64 8 | rmdir /S /Q objfre_wlh_x86 9 | rmdir /S /Q objfre_wlh_amd64 10 | rmdir /S /Q objfre_win7_x86 11 | rmdir /S /Q objfre_win7_amd64 12 | rmdir /S /Q objfre_win8_x86 13 | rmdir /S /Q objfre_win8_amd64 14 | rmdir /S /Q .\sdv 15 | rmdir /S /Q .\sdv.temp 16 | 17 | del /F *.log *.wrn *.err *.sdf 18 | del viostor-2012.h 19 | del viostor.dvl.xml 20 | del sdv-map.h 21 | 22 | -------------------------------------------------------------------------------- /viostor/disk1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vrozenfe/virtio-win/71667c799db2e53d3da301af1dd36dce6f6e20ef/viostor/disk1 -------------------------------------------------------------------------------- /viostor/makefile.inc: -------------------------------------------------------------------------------- 1 | _LNG=$(LANGUAGE) 2 | _INX=. 3 | STAMP=stampinf -f $@ -d * -a $(_BUILDARCH) 4 | 5 | 6 | $(INF_TARGET): $(_INX)\$(INF_NAME).inx 7 | copy $(_INX)\$(INF_NAME).inx $@ 8 | $(STAMP) 9 | 10 | 11 | -------------------------------------------------------------------------------- /viostor/txtsetup-amd64.oem: -------------------------------------------------------------------------------- 1 | [Disks] 2 | d1 = "OEM DISK (SCSI) Win2003/64-bit",\disk1,\amd64\Win2003 3 | 4 | [Defaults] 5 | SCSI = WNET64 6 | 7 | [scsi] 8 | WNET64 = "Red Hat VirtIO BLOCK Disk Device Win2003/64-bit" 9 | 10 | [Files.scsi.WNET64] 11 | driver = d1, viostor.sys, viostor 12 | inf = d1, viostor.inf 13 | catalog= d1, viostor.cat 14 | 15 | [HardwareIds.scsi.WNET64] 16 | id = "PCI\VEN_1AF4&DEV_1001&SUBSYS_00021AF4&REV_00", "viostor" 17 | 18 | [Config.WNET64] 19 | value = Parameters\PnpInterface,5,REG_DWORD,1 20 | 21 | -------------------------------------------------------------------------------- /viostor/txtsetup-i386.oem: -------------------------------------------------------------------------------- 1 | [Disks] 2 | d1 = "OEM DISK (SCSI) WinXP/32-bit",\disk1,\i386\WinXP 3 | d2 = "OEM DISK (SCSI) Win2003/32-bit",\disk1,\i386\Win2003 4 | 5 | [Defaults] 6 | SCSI = WXP32 7 | 8 | [scsi] 9 | WXP32 = "Red Hat VirtIO BLOCK Disk Device WinXP/32-bit" 10 | WNET32 = "Red Hat VirtIO BLOCK Disk Device Win2003/32-bit" 11 | [Files.scsi.WXP32] 12 | driver = d1, viostor.sys, viostor 13 | inf = d1, viostor.inf 14 | catalog= d1, viostor.cat 15 | 16 | [Files.scsi.WNET32] 17 | driver = d2, viostor.sys, viostor 18 | inf = d2, viostor.inf 19 | catalog= d2, viostor.cat 20 | 21 | [HardwareIds.scsi.WXP32] 22 | id = "PCI\VEN_1AF4&DEV_1001&SUBSYS_00021AF4&REV_00", "viostor" 23 | 24 | [HardwareIds.scsi.WNET32] 25 | id = "PCI\VEN_1AF4&DEV_1001&SUBSYS_00021AF4&REV_00", "viostor" 26 | 27 | [Config.WXP32] 28 | value = Parameters\PnpInterface,5,REG_DWORD,1 29 | 30 | [Config.WNET32] 31 | value = Parameters\PnpInterface,5,REG_DWORD,1 32 | 33 | -------------------------------------------------------------------------------- /viostor/txtsetup.oem: -------------------------------------------------------------------------------- 1 | [Disks] 2 | d1 = "OEM DISK (SCSI) WinXP/32-bit",\disk1,\i386\WinXP 3 | d2 = "OEM DISK (SCSI) Win2003/32-bit",\disk1,\i386\Win2003 4 | d3 = "OEM DISK (SCSI) Win2003/64-bit",\disk1,\amd64\Win2003 5 | d4 = "OEM DISK (SCSI) Win2003/32-bit",\disk1,\i386\Win2003 6 | d5 = "OEM DISK (SCSI) Win2003/64-bit",\disk1,\amd64\Win2003 7 | 8 | [Defaults] 9 | SCSI = WXP32 10 | 11 | [scsi] 12 | WXP32 = "Red Hat VirtIO BLOCK Disk Device WinXP/32-bit" 13 | WNET32 = "Red Hat VirtIO BLOCK Disk Device Win2003/32-bit" 14 | WNET64 = "Red Hat VirtIO BLOCK Disk Device Win2003/64-bit" 15 | WNET32_SCSI = "Red Hat VirtIO SCSI Disk Device Win2003/32-bit" 16 | WNET64_SCSI = "Red Hat VirtIO SCSI Disk Device Win2003/64-bit" 17 | [Files.scsi.WXP32] 18 | driver = d1, viostor.sys, viostor 19 | inf = d1, viostor.inf 20 | catalog= d1, viostor.cat 21 | 22 | [Files.scsi.WNET32] 23 | driver = d2, viostor.sys, viostor 24 | inf = d2, viostor.inf 25 | catalog= d2, viostor.cat 26 | 27 | [Files.scsi.WNET32_SCSI] 28 | driver = d4, vioscsi.sys, vioscsi 29 | inf = d4, vioscsi.inf 30 | catalog= d4, vioscsi.cat 31 | 32 | [Files.scsi.WNET64] 33 | driver = d3, viostor.sys, viostor 34 | inf = d3, viostor.inf 35 | catalog= d3, viostor.cat 36 | 37 | [Files.scsi.WNET64_SCSI] 38 | driver = d5, vioscsi.sys, vioscsi 39 | inf = d5, vioscsi.inf 40 | catalog= d5, vioscsi.cat 41 | 42 | [HardwareIds.scsi.WXP32] 43 | id = "PCI\VEN_1AF4&DEV_1001&SUBSYS_00021AF4&REV_00", "viostor" 44 | 45 | [HardwareIds.scsi.WNET32] 46 | id = "PCI\VEN_1AF4&DEV_1001&SUBSYS_00021AF4&REV_00", "viostor" 47 | 48 | 49 | [HardwareIds.scsi.WNET32_SCSI] 50 | id = "PCI\VEN_1AF4&DEV_1004&SUBSYS_00081AF4&REV_00", "vioscsi" 51 | 52 | [HardwareIds.scsi.WNET64] 53 | id = "PCI\VEN_1AF4&DEV_1001&SUBSYS_00021AF4&REV_00", "viostor" 54 | 55 | [HardwareIds.scsi.WNET64_SCSI] 56 | id = "PCI\VEN_1AF4&DEV_1004&SUBSYS_00081AF4&REV_00", "vioscsi" 57 | 58 | [Config.WXP32] 59 | value = Parameters\PnpInterface,5,REG_DWORD,1 60 | 61 | [Config.WNET32] 62 | value = Parameters\PnpInterface,5,REG_DWORD,1 63 | 64 | [Config.WNET64] 65 | value = Parameters\PnpInterface,5,REG_DWORD,1 66 | 67 | [Config.WNET32_SCSI] 68 | value = Parameters\PnpInterface,5,REG_DWORD,1 69 | 70 | [Config.WNET64_SCSI] 71 | value = Parameters\PnpInterface,5,REG_DWORD,1 72 | -------------------------------------------------------------------------------- /viostor/viostor.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | {8E41214B-6785-4CFE-B992-037D68949A14} 18 | inf;inv;inx;mof;mc; 19 | 20 | 21 | 22 | 23 | Driver Files 24 | 25 | 26 | 27 | 28 | Header Files 29 | 30 | 31 | Header Files 32 | 33 | 34 | Header Files 35 | 36 | 37 | 38 | 39 | Resource Files 40 | 41 | 42 | 43 | 44 | Source Files 45 | 46 | 47 | Source Files 48 | 49 | 50 | Source Files 51 | 52 | 53 | Source Files 54 | 55 | 56 | -------------------------------------------------------------------------------- /viostor/virtio_pci.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Virtio PCI driver 3 | * 4 | * This module allows virtio devices to be used over a virtual PCI device. 5 | * This can be used with QEMU based VMMs like KVM or Xen. 6 | * 7 | * Copyright IBM Corp. 2007 8 | * 9 | * Authors: 10 | * Anthony Liguori 11 | * Windows porting - Yan Vugenfirer 12 | * StorPort/ScsiPort code adjustment Vadim Rozenfeld 13 | * 14 | * This work is licensed under the terms of the GNU GPL, version 2. See 15 | * the COPYING file in the top-level directory. 16 | * 17 | */ 18 | /********************************************************************** 19 | * Copyright (c) 2008-2015 Red Hat, Inc. 20 | * 21 | * This work is licensed under the terms of the GNU GPL, version 2. See 22 | * the COPYING file in the top-level directory. 23 | * 24 | **********************************************************************/ 25 | #include "osdep.h" 26 | #include "VirtIO_PCI.h" 27 | #include "virtio_stor_utils.h" 28 | #include "virtio_stor.h" 29 | 30 | 31 | u32 ReadVirtIODeviceRegister(ULONG_PTR ulRegister) 32 | { 33 | return ScsiPortReadPortUlong((PULONG)(ulRegister)); 34 | } 35 | 36 | void WriteVirtIODeviceRegister(ULONG_PTR ulRegister, u32 ulValue) 37 | { 38 | ScsiPortWritePortUlong( (PULONG)(ulRegister),(ULONG)(ulValue) ); 39 | } 40 | 41 | u8 ReadVirtIODeviceByte(ULONG_PTR ulRegister) 42 | { 43 | return ScsiPortReadPortUchar((PUCHAR)(ulRegister)); 44 | } 45 | 46 | void WriteVirtIODeviceByte(ULONG_PTR ulRegister, u8 bValue) 47 | { 48 | ScsiPortWritePortUchar((PUCHAR)(ulRegister),(UCHAR)(bValue)); 49 | } 50 | 51 | u16 ReadVirtIODeviceWord(ULONG_PTR ulRegister) 52 | { 53 | return ScsiPortReadPortUshort((PUSHORT)(ulRegister)); 54 | } 55 | 56 | void WriteVirtIODeviceWord(ULONG_PTR ulRegister, u16 wValue) 57 | { 58 | ScsiPortWritePortUshort((PUSHORT)(ulRegister),(USHORT)(wValue)); 59 | } 60 | -------------------------------------------------------------------------------- /viostor/virtio_stor.rc: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * Copyright (c) 2008-2015 Red Hat, Inc. 3 | * 4 | * File: virtio_stor.rc 5 | * 6 | * This file contains resource (version) definitions for viostor driver. 7 | * 8 | * This work is licensed under the terms of the GNU GPL, version 2. See 9 | * the COPYING file in the top-level directory. 10 | * 11 | **********************************************************************/ 12 | #include 13 | #include 14 | 15 | #undef VER_PRODUCTBUILD 16 | #undef VER_PRODUCTBUILD_QFE 17 | #undef VER_PRODUCTMAJORVERSION 18 | #undef VER_PRODUCTMINORVERSION 19 | 20 | #undef VER_LEGALTRADEMARKS_STR 21 | #define VER_LEGALTRADEMARKS_STR "" 22 | 23 | #undef VER_LEGALCOPYRIGHT_STR 24 | #define VER_LEGALCOPYRIGHT_STR "Copyright (C) 2008-2015 Red Hat, Inc." 25 | 26 | #undef VER_COMPANYNAME_STR 27 | #define VER_COMPANYNAME_STR "Red Hat, Inc." 28 | 29 | #undef VER_PRODUCTNAME_STR 30 | #define VER_PRODUCTNAME_STR "Red Hat VirtIO SCSI controller" 31 | 32 | #ifndef _NT_TARGET_MAJ 33 | #include "viostor-2012.h" 34 | #endif 35 | 36 | #define VER_PRODUCTBUILD _MAJORVERSION_ 37 | #define VER_PRODUCTBUILD_QFE _MINORVERSION_ 38 | #define VER_PRODUCTMAJORVERSION _NT_TARGET_MAJ 39 | #define VER_PRODUCTMINORVERSION _NT_TARGET_MIN 40 | 41 | #define VER_LANGNEUTRAL 42 | 43 | #define VER_FILETYPE VFT_DRV 44 | #define VER_FILESUBTYPE VFT2_DRV_SYSTEM 45 | #define VER_FILEDESCRIPTION_STR "Red Hat VirtIO SCSI driver" 46 | #define VER_INTERNALNAME_STR "viostor.sys" 47 | #define VER_ORIGINALFILENAME_STR "viostor.sys" 48 | 49 | #include "common.ver" 50 | 51 | 52 | -------------------------------------------------------------------------------- /viostor/virtio_stor_hw_helper.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * Copyright (c) 2008-2015 Red Hat, Inc. 3 | * 4 | * File: virtio_stor_hw_helper.h 5 | * 6 | * Author(s): 7 | * Vadim Rozenfeld 8 | * 9 | * Virtio block device include module. 10 | * 11 | * This work is licensed under the terms of the GNU GPL, version 2. See 12 | * the COPYING file in the top-level directory. 13 | * 14 | **********************************************************************/ 15 | #ifndef ___VIOSTOR_HW_HELPER_H___ 16 | #define ___VIOSTOR_HW_HELPER_H___ 17 | 18 | 19 | #include 20 | 21 | #ifdef USE_STORPORT 22 | #define STOR_USE_SCSI_ALIASES 23 | #include 24 | #else 25 | #include 26 | #endif 27 | 28 | #include "osdep.h" 29 | #include "virtio_pci.h" 30 | #include "virtio_config.h" 31 | #include "virtio.h" 32 | #include "virtio_stor.h" 33 | 34 | 35 | BOOLEAN 36 | RhelDoReadWrite( 37 | IN PVOID DeviceExtension, 38 | PSCSI_REQUEST_BLOCK Srb 39 | ); 40 | 41 | BOOLEAN 42 | RhelDoFlush( 43 | IN PVOID DeviceExtension, 44 | PSCSI_REQUEST_BLOCK Srb, 45 | IN BOOLEAN sync 46 | ); 47 | 48 | VOID 49 | RhelShutDown( 50 | IN PVOID DeviceExtension 51 | ); 52 | 53 | ULONGLONG 54 | RhelGetLba( 55 | IN PVOID DeviceExtension, 56 | IN PCDB Cdb 57 | ); 58 | 59 | VOID 60 | RhelGetSerialNumber( 61 | IN PVOID DeviceExtension 62 | ); 63 | 64 | VOID 65 | RhelGetDiskGeometry( 66 | IN PVOID DeviceExtension 67 | ); 68 | 69 | #endif ___VIOSTOR_HW_HELPER_H___ 70 | -------------------------------------------------------------------------------- /viostor/virtio_stor_utils.h: -------------------------------------------------------------------------------- 1 | /********************************************************************** 2 | * Copyright (c) 2008-2015 Red Hat, Inc. 3 | * 4 | * File: virtio_stor_utils.h 5 | * 6 | * 7 | * This file contains debug print support routines and globals. 8 | * 9 | * This work is licensed under the terms of the GNU GPL, version 2. See 10 | * the COPYING file in the top-level directory. 11 | * 12 | **********************************************************************/ 13 | #ifndef ___VIOSTOR_UTILS_H___ 14 | #define ___VIOSTOR_UTILS_H___ 15 | 16 | 17 | #include 18 | #ifdef USE_STORPORT 19 | #define STOR_USE_SCSI_ALIASES 20 | #include 21 | #else 22 | #include 23 | #endif 24 | #include 25 | #include "kdebugprint.h" 26 | #include "evntrace.h" 27 | 28 | #define CHECKBIT(value, nbit) (((value) & (1 << (nbit))) != 0) 29 | 30 | int 31 | _cdecl 32 | _vsnprintf( 33 | char *buf, 34 | size_t size, 35 | const char *fmt, 36 | va_list args 37 | ); 38 | #define vsnprintf _vsnprintf 39 | 40 | void InitializeDebugPrints(IN PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath); 41 | 42 | extern int nViostorDebugLevel; 43 | 44 | #if DBG 45 | #define RhelDbgPrint(level, line) \ 46 | if ((!bDebugPrint) || level > nViostorDebugLevel) {} \ 47 | else VirtioDebugPrintProc line 48 | #else 49 | #define RhelDbgPrint(level, line) 50 | #endif 51 | 52 | #endif ___VIOSTOR_UTILS_H___ 53 | 54 | --------------------------------------------------------------------------------