├── DVInstaller.ps1 ├── DVServerKMD ├── DVServerKMD.inf ├── DVServerKMD.rc ├── DVServerKMD.sln ├── DVServerKMD.vcxproj ├── DVServerKMD.vcxproj.filters ├── DVServerKMD_Version.txt ├── Device.cpp ├── Device.h ├── Driver.cpp ├── Driver.h ├── LICENSE ├── Public.h ├── Queue.cpp ├── Queue.h ├── ReadMe.txt ├── Trace.h ├── Tracing.cpp ├── UpdateVersion.targets ├── baseobj.cpp ├── baseobj.h ├── bitops.cpp ├── bitops.h ├── edid.h ├── helper.h ├── qemu_edid.h ├── viogpu.h ├── viogpu_idr.cpp ├── viogpu_idr.h ├── viogpu_pci.cpp ├── viogpu_pci.h ├── viogpu_queue.cpp ├── viogpu_queue.h ├── viogpulite.cpp └── viogpulite.h ├── DVServerUMD ├── DVEnabler │ ├── DVEnabler.cpp │ ├── DVEnabler.rc │ ├── DVEnabler.vcxproj │ ├── DVEnabler.vcxproj.filters │ ├── DVEnabler_Version.txt │ ├── LICENSE │ ├── Trace.h │ ├── Tracing.cpp │ ├── UpdateVersion.targets │ ├── dllmain.cpp │ ├── framework.h │ ├── pch.cpp │ └── pch.h ├── DVServer.sln ├── DVServer │ ├── DVServer.inf │ ├── DVServer.rc │ ├── DVServer.vcxproj │ ├── DVServerUMD_Version.txt │ ├── DVServercommon.h │ ├── DVServeredid.cpp │ ├── DVServeredid.h │ ├── Driver.cpp │ ├── Driver.h │ ├── LICENSE │ ├── Trace.h │ ├── Tracing.cpp │ └── UpdateVersion.targets ├── LICENSE └── README.md ├── EDIDParser ├── LICENSE ├── edidparser.c ├── edidparser.h ├── edidparser.sln ├── edidparser.vcxproj ├── edidparser.vcxproj.filters └── edidshared.h ├── LICENSE ├── Readme.txt ├── SECURITY.md ├── Tools ├── Driver.Common.props ├── Driver.Common.targets ├── Driver.Initial.props ├── Driver.PackOne.targets ├── Driver.RHEL.props ├── Driver.VZ.props ├── Driver.Vendor.props ├── InstallCertificate.bat ├── LICENSE ├── RunSdv.js ├── SetVsEnv.bat ├── VirtIOTestCert.cer ├── VirtIOTestCert.pfx ├── build.bat ├── pushpdb.cmd ├── pushpdbREADME.txt ├── readme_msbuild.txt ├── rhel.ver ├── signAll.bat ├── vendor.ver └── vz.ver ├── VirtIO ├── LICENSE ├── VirtIO.h ├── VirtIOPCICommon.c ├── VirtIOPCILegacy.c ├── VirtIOPCIModern.c ├── VirtIORing-Packed.c ├── VirtIORing.c ├── VirtioLib.sln ├── VirtioLib.vcxproj ├── VirtioLib.vcxproj.filters ├── WDF │ ├── Callbacks.c │ ├── Dma.c │ ├── LICENSE │ ├── MemPortIO.c │ ├── PCI.c │ ├── VirtIOWdf.c │ ├── VirtIOWdf.h │ ├── VirtioLib-WDF.vcxproj │ ├── VirtioLib-WDF.vcxproj.filters │ ├── clean.bat │ └── private.h ├── buildAll.bat ├── clean.bat ├── kdebugprint.h ├── linux │ ├── types.h │ ├── virtio_config.h │ └── virtio_types.h ├── osdep.h ├── virtio_pci.h ├── virtio_pci_common.h ├── virtio_ring.h └── windows │ └── virtio_ring_allocation.h ├── WindowsDisplayVirtualization.sln └── ZeroCopyInstaller ├── DVInstaller.iss ├── DVInstaller ├── DVInstaller.cpp ├── DVInstaller.h ├── DVInstaller.ico ├── DVInstaller.rc ├── DVInstaller.vcxproj ├── DVInstaller.vcxproj.filters ├── DVInstaller_Version.txt ├── Resource.h ├── Trace.h ├── Tracing.cpp ├── UpdateVersion.targets ├── dventry.cpp ├── dvpostinit.cpp ├── dvutil.cpp └── small.ico ├── DVInstallerLib ├── DVInstallerLib.rc ├── DVInstallerLib.vcxproj ├── DVInstallerLib.vcxproj.filters ├── DVInstallerLib_Version.txt ├── DriverVersion.cpp ├── DriverVersion.h └── UpdateVersion.targets ├── LICENSE └── ZeroCopyInstaller.sln /DVInstaller.ps1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/Display-Virtualization-for-Windows-OS/6738cb0d71cd8e154a1543589de3300a087f2d58/DVInstaller.ps1 -------------------------------------------------------------------------------- /DVServerKMD/DVServerKMD.inf: -------------------------------------------------------------------------------- 1 | ; 2 | ; DVServerKMD.inf 3 | ; 4 | 5 | [Version] 6 | Signature="$WINDOWS NT$" 7 | Class=System 8 | ClassGuid={4d36e97d-e325-11ce-bfc1-08002be10318} 9 | Provider=%ManufacturerName% 10 | CatalogFile=DVServerKMD.cat 11 | DriverVer= 12 | PnpLockdown=1 13 | 14 | [DestinationDirs] 15 | DefaultDestDir = 12 16 | DVServerKMD_Device_CoInstaller_CopyFiles = 11 17 | 18 | ; ================= Class section ===================== 19 | 20 | #[ClassInstall32] 21 | Addreg=SystemClassReg 22 | 23 | [SystemClassReg] 24 | HKR,,,0,%ClassName% 25 | HKR,,Icon,,-5 26 | 27 | [SourceDisksNames] 28 | 1 = %DiskName%,,,"" 29 | 30 | [SourceDisksFiles] 31 | DVServerKMD.sys = 1,, 32 | WdfCoInstaller$KMDFCOINSTALLERVERSION$.dll=1 ; make sure the number matches with SourceDisksNames 33 | 34 | ;***************************************** 35 | ; Install Section 36 | ;***************************************** 37 | 38 | [Manufacturer] 39 | %ManufacturerName%=Standard,NTamd64.10.0...15063 40 | 41 | [Standard.NTamd64.10.0...15063] 42 | %DVServerKMD.DeviceDesc%=DVServerKMD_Device, PCI\VEN_1AF4&DEV_1050&CC_030000 43 | 44 | [DVServerKMD_Device.NT] 45 | CopyFiles=Drivers_Dir 46 | FeatureScore=01 47 | CopyINF = DVServer.inf 48 | 49 | [Drivers_Dir] 50 | DVServerKMD.sys 51 | 52 | ;-------------- Service installation 53 | [DVServerKMD_Device.NT.Services] 54 | AddService = DVServerKMD,%SPSVCINST_ASSOCSERVICE%, DVServerKMD_Service_Inst 55 | 56 | ; -------------- DVServerKMD driver install sections 57 | [DVServerKMD_Service_Inst] 58 | DisplayName = %DVServerKMD.SVCDESC% 59 | ServiceType = 1 ; SERVICE_KERNEL_DRIVER 60 | StartType = 3 ; SERVICE_DEMAND_START 61 | ErrorControl = 1 ; SERVICE_ERROR_NORMAL 62 | ServiceBinary = %12%\DVServerKMD.sys 63 | 64 | [DVServerKMD_Device.NT.HW] 65 | AddReg = Hw_AddReg 66 | 67 | [Hw_AddReg] 68 | HKR,,Security,,"D:P(A;;GA;;;BA)(A;;GA;;;SY)(A;;GA;;;UD)" 69 | 70 | ; 71 | ;--- DVServerKMD_Device Coinstaller installation ------ 72 | ; 73 | [DVServerKMD_Device.NT.Components] 74 | AddComponent=%ComponentName%,,component-install-section 75 | 76 | [component-install-section] 77 | ComponentIDs= %ComponentId% 78 | 79 | [DVServerKMD_Device.NT.CoInstallers] 80 | AddReg=DVServerKMD_Device_CoInstaller_AddReg 81 | CopyFiles=DVServerKMD_Device_CoInstaller_CopyFiles 82 | 83 | [DVServerKMD_Device_CoInstaller_AddReg] 84 | HKR,,CoInstallers32,0x00010000, "WdfCoInstaller$KMDFCOINSTALLERVERSION$.dll,WdfCoInstaller" 85 | 86 | [DVServerKMD_Device_CoInstaller_CopyFiles] 87 | WdfCoInstaller$KMDFCOINSTALLERVERSION$.dll 88 | 89 | [DVServerKMD_Device.NT.Wdf] 90 | KmdfService = DVServerKMD, DVServerKMD_wdfsect 91 | [DVServerKMD_wdfsect] 92 | KmdfLibraryVersion = $KMDFVERSION$ 93 | 94 | [Strings] 95 | SPSVCINST_ASSOCSERVICE= 0x00000002 96 | ManufacturerName="Intel" 97 | ClassName="System" 98 | DiskName = "DVServerKMD Installation Disk" 99 | DVServerKMD.DeviceDesc = "DVServerKMD Device" 100 | DVServerKMD.SVCDESC = "DVServerKMD Service" 101 | ComponentName = "DVServer" 102 | ComponentId = "DVServer" -------------------------------------------------------------------------------- /DVServerKMD/DVServerKMD.rc: -------------------------------------------------------------------------------- 1 | /*=========================================================================== 2 | ; DVServerKMD.rc 3 | ;---------------------------------------------------------------------------- 4 | ; Copyright (C) 2021 Intel Corporation 5 | ; SPDX-License-Identifier: BSD-3-Clause 6 | ; 7 | ; File Description: 8 | ; This file will have the DVServerKMD resources 9 | ;--------------------------------------------------------------------------*/ 10 | 11 | #include 12 | 13 | VS_VERSION_INFO VERSIONINFO 14 | FILEVERSION ${FileVersion} 15 | PRODUCTVERSION ${ProductVersion} 16 | BEGIN 17 | BLOCK "StringFileInfo" 18 | BEGIN 19 | BLOCK "040904B0" 20 | BEGIN 21 | VALUE "FileVersion", "${FileVersion}" 22 | VALUE "ProductVersion", "${ProductVersionString}" 23 | VALUE "ProductName", "DVServerKMD.dll" 24 | VALUE "LegalCopyright", "Copyright (C) 2021 Intel Corporation" 25 | VALUE "FileDescription", "Display Virtualization Kernel Mode Driver" 26 | END 27 | END 28 | BLOCK "VarFileInfo" 29 | BEGIN 30 | VALUE "Translation", 0x409, 1200 31 | END 32 | END 33 | -------------------------------------------------------------------------------- /DVServerKMD/DVServerKMD.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30204.135 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DVServerKMD", "DVServerKMD.vcxproj", "{306D5DF8-DE6B-4EE7-9383-5D1992FAF5EC}" 7 | ProjectSection(ProjectDependencies) = postProject 8 | {01D87C47-437A-4A16-8FD9-33FA5C99339E} = {01D87C47-437A-4A16-8FD9-33FA5C99339E} 9 | {F13DB17F-D1DC-4F34-9436-DA9C0E70A06A} = {F13DB17F-D1DC-4F34-9436-DA9C0E70A06A} 10 | EndProjectSection 11 | EndProject 12 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "VirtioLib", "..\VirtIO\VirtioLib.vcxproj", "{01D87C47-437A-4A16-8FD9-33FA5C99339E}" 13 | EndProject 14 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DVServerULT", "..\DVServerULT\DVServerULT.vcxproj", "{4C10F037-ACB7-4066-A07B-A7D730B7B45F}" 15 | EndProject 16 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "EdidParser", "..\EdidParser\EdidParser.vcxproj", "{F13DB17F-D1DC-4F34-9436-DA9C0E70A06A}" 17 | EndProject 18 | Global 19 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 20 | Debug|x64 = Debug|x64 21 | Debug|x86 = Debug|x86 22 | Release|x64 = Release|x64 23 | Release|x86 = Release|x86 24 | EndGlobalSection 25 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 26 | {306D5DF8-DE6B-4EE7-9383-5D1992FAF5EC}.Debug|x64.ActiveCfg = Debug|x64 27 | {306D5DF8-DE6B-4EE7-9383-5D1992FAF5EC}.Debug|x64.Build.0 = Debug|x64 28 | {306D5DF8-DE6B-4EE7-9383-5D1992FAF5EC}.Debug|x64.Deploy.0 = Debug|x64 29 | {306D5DF8-DE6B-4EE7-9383-5D1992FAF5EC}.Debug|x86.ActiveCfg = Debug|x64 30 | {306D5DF8-DE6B-4EE7-9383-5D1992FAF5EC}.Release|x64.ActiveCfg = Release|x64 31 | {306D5DF8-DE6B-4EE7-9383-5D1992FAF5EC}.Release|x64.Build.0 = Release|x64 32 | {306D5DF8-DE6B-4EE7-9383-5D1992FAF5EC}.Release|x64.Deploy.0 = Release|x64 33 | {306D5DF8-DE6B-4EE7-9383-5D1992FAF5EC}.Release|x86.ActiveCfg = Release|x64 34 | {01D87C47-437A-4A16-8FD9-33FA5C99339E}.Debug|x64.ActiveCfg = Debug|x64 35 | {01D87C47-437A-4A16-8FD9-33FA5C99339E}.Debug|x64.Build.0 = Debug|x64 36 | {01D87C47-437A-4A16-8FD9-33FA5C99339E}.Debug|x64.Deploy.0 = Debug|x64 37 | {01D87C47-437A-4A16-8FD9-33FA5C99339E}.Debug|x86.ActiveCfg = Debug|Win32 38 | {01D87C47-437A-4A16-8FD9-33FA5C99339E}.Debug|x86.Build.0 = Debug|Win32 39 | {01D87C47-437A-4A16-8FD9-33FA5C99339E}.Debug|x86.Deploy.0 = Debug|Win32 40 | {01D87C47-437A-4A16-8FD9-33FA5C99339E}.Release|x64.ActiveCfg = Release|x64 41 | {01D87C47-437A-4A16-8FD9-33FA5C99339E}.Release|x64.Build.0 = Release|x64 42 | {01D87C47-437A-4A16-8FD9-33FA5C99339E}.Release|x64.Deploy.0 = Release|x64 43 | {01D87C47-437A-4A16-8FD9-33FA5C99339E}.Release|x86.ActiveCfg = Release|Win32 44 | {01D87C47-437A-4A16-8FD9-33FA5C99339E}.Release|x86.Build.0 = Release|Win32 45 | {01D87C47-437A-4A16-8FD9-33FA5C99339E}.Release|x86.Deploy.0 = Release|Win32 46 | {4C10F037-ACB7-4066-A07B-A7D730B7B45F}.Debug|x64.ActiveCfg = Debug|x64 47 | {4C10F037-ACB7-4066-A07B-A7D730B7B45F}.Debug|x64.Build.0 = Debug|x64 48 | {4C10F037-ACB7-4066-A07B-A7D730B7B45F}.Debug|x86.ActiveCfg = Debug|Win32 49 | {4C10F037-ACB7-4066-A07B-A7D730B7B45F}.Debug|x86.Build.0 = Debug|Win32 50 | {4C10F037-ACB7-4066-A07B-A7D730B7B45F}.Release|x64.ActiveCfg = Release|x64 51 | {4C10F037-ACB7-4066-A07B-A7D730B7B45F}.Release|x64.Build.0 = Release|x64 52 | {4C10F037-ACB7-4066-A07B-A7D730B7B45F}.Release|x86.ActiveCfg = Release|Win32 53 | {4C10F037-ACB7-4066-A07B-A7D730B7B45F}.Release|x86.Build.0 = Release|Win32 54 | {F13DB17F-D1DC-4F34-9436-DA9C0E70A06A}.Debug|x64.ActiveCfg = Debug|x64 55 | {F13DB17F-D1DC-4F34-9436-DA9C0E70A06A}.Debug|x64.Build.0 = Debug|x64 56 | {F13DB17F-D1DC-4F34-9436-DA9C0E70A06A}.Debug|x86.ActiveCfg = Debug|Win32 57 | {F13DB17F-D1DC-4F34-9436-DA9C0E70A06A}.Debug|x86.Build.0 = Debug|Win32 58 | {F13DB17F-D1DC-4F34-9436-DA9C0E70A06A}.Release|x64.ActiveCfg = Release|x64 59 | {F13DB17F-D1DC-4F34-9436-DA9C0E70A06A}.Release|x64.Build.0 = Release|x64 60 | {F13DB17F-D1DC-4F34-9436-DA9C0E70A06A}.Release|x86.ActiveCfg = Release|Win32 61 | {F13DB17F-D1DC-4F34-9436-DA9C0E70A06A}.Release|x86.Build.0 = Release|Win32 62 | EndGlobalSection 63 | GlobalSection(SolutionProperties) = preSolution 64 | HideSolutionNode = FALSE 65 | EndGlobalSection 66 | GlobalSection(ExtensibilityGlobals) = postSolution 67 | SolutionGuid = {9D958D98-71B0-4549-B82D-3911444A92AE} 68 | EndGlobalSection 69 | EndGlobal 70 | -------------------------------------------------------------------------------- /DVServerKMD/DVServerKMD.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 | 24 | 25 | 26 | Driver Files 27 | 28 | 29 | 30 | 31 | Header Files 32 | 33 | 34 | Header Files 35 | 36 | 37 | Header Files 38 | 39 | 40 | Header Files 41 | 42 | 43 | Header Files 44 | 45 | 46 | Header Files 47 | 48 | 49 | Header Files 50 | 51 | 52 | Header Files 53 | 54 | 55 | Header Files 56 | 57 | 58 | Header Files 59 | 60 | 61 | Header Files 62 | 63 | 64 | Header Files 65 | 66 | 67 | Header Files 68 | 69 | 70 | Header Files 71 | 72 | 73 | Header Files 74 | 75 | 76 | 77 | 78 | Source Files 79 | 80 | 81 | Source Files 82 | 83 | 84 | Source Files 85 | 86 | 87 | Source Files 88 | 89 | 90 | Source Files 91 | 92 | 93 | Source Files 94 | 95 | 96 | Source Files 97 | 98 | 99 | Source Files 100 | 101 | 102 | Source Files 103 | 104 | 105 | Source Files 106 | 107 | 108 | 109 | 110 | 111 | -------------------------------------------------------------------------------- /DVServerKMD/DVServerKMD_Version.txt: -------------------------------------------------------------------------------- 1 | /*=========================================================================== 2 | ; DVServerKMD_Version.txt 3 | ;---------------------------------------------------------------------------- 4 | ; Copyright (C) 2021 Intel Corporation 5 | ; SPDX-License-Identifier: BSD-3-Clause 6 | ; 7 | ; File Description: 8 | ; This file will have the DVServerKMD version 9 | ;--------------------------------------------------------------------------*/ 10 | 11 | DVServerKMD_Version = 4.0.0 -------------------------------------------------------------------------------- /DVServerKMD/Device.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Module Name: 4 | 5 | device.h 6 | 7 | Abstract: 8 | 9 | This file contains the device definitions. 10 | 11 | Environment: 12 | 13 | Kernel-mode Driver Framework 14 | 15 | --*/ 16 | 17 | #include "public.h" 18 | 19 | EXTERN_C_START 20 | 21 | // 22 | // The device context performs the same job as 23 | // a WDM device extension in the driver frameworks 24 | // 25 | typedef struct _DEVICE_CONTEXT 26 | { 27 | ULONG PrivateDeviceData; // just a placeholder 28 | PVOID pvDeviceExtension; // for DVServerKMD 29 | WDFDEVICE WdfDevice; 30 | WDFINTERRUPT WdfInterrupt; 31 | WDFCMRESLIST ResourcesRaw; 32 | WDFCMRESLIST ResourcesTranslated; 33 | BUS_INTERFACE_STANDARD BusInterface; 34 | } DEVICE_CONTEXT, * PDEVICE_CONTEXT; 35 | 36 | // 37 | // This macro will generate an inline function called DeviceGetContext 38 | // which will be used to get a pointer to the device context memory 39 | // in a type safe manner. 40 | // 41 | WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(DEVICE_CONTEXT, DeviceGetContext) 42 | 43 | // 44 | // Function to initialize the device and its callbacks 45 | // 46 | NTSTATUS 47 | DVServerKMDCreateDevice( 48 | _Inout_ PWDFDEVICE_INIT DeviceInit 49 | ); 50 | 51 | EVT_WDF_DEVICE_PREPARE_HARDWARE DVServerKMDEvtPrepareHardware; 52 | EVT_WDF_DEVICE_RELEASE_HARDWARE DVServerKMDEvtReleaseHardware; 53 | EVT_WDF_DEVICE_D0_ENTRY DVServerKMDEvtD0Entry; 54 | EVT_WDF_DEVICE_D0_EXIT DVServerKMDEvtD0Exit; 55 | EVT_WDF_INTERRUPT_ISR DVServerKMDEvtInterruptISR; 56 | EVT_WDF_INTERRUPT_DPC DVServerKMDEvtInterruptDPC; 57 | EVT_WDF_DEVICE_D0_EXIT_PRE_INTERRUPTS_DISABLED DVServerKMDEvtDeviceD0ExitPreInterruptsDisabled; 58 | EVT_WDF_DEVICE_D0_ENTRY_POST_INTERRUPTS_ENABLED DVServerKMDEvtDeviceD0EntryPostInterruptsEnabled; 59 | EVT_WDF_INTERRUPT_ENABLE DVServerKMDEvtInterruptEnable; 60 | EVT_WDF_INTERRUPT_DISABLE DVServerKMDEvtInterruptDisable; 61 | EXTERN_C_END 62 | -------------------------------------------------------------------------------- /DVServerKMD/Driver.cpp: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Module Name: 4 | 5 | driver.c 6 | 7 | Abstract: 8 | 9 | This file contains the driver entry points and callbacks. 10 | 11 | Environment: 12 | 13 | Kernel-mode Driver Framework 14 | 15 | --*/ 16 | 17 | #include "driver.h" 18 | #include "Trace.h" 19 | #include 20 | extern "C" { 21 | #include "kdebugprint.h" 22 | tDebugPrintFunc VirtioDebugPrintProc; 23 | } 24 | 25 | int nDebugLevel; 26 | int virtioDebugLevel; 27 | int bDebugPrint; 28 | int bBreakAlways; 29 | char module_name[80] = "KMD"; 30 | 31 | #ifdef ALLOC_PRAGMA 32 | #pragma alloc_text (INIT, DriverEntry) 33 | #pragma alloc_text (PAGE, DVServerKMDEvtDeviceAdd) 34 | #pragma alloc_text (PAGE, DVServerKMDEvtDriverContextCleanup) 35 | #pragma alloc_text (PAGE, DVServerKMDEvtPrepareHardware) 36 | #pragma alloc_text (PAGE, DVServerKMDEvtReleaseHardware) 37 | #pragma alloc_text (PAGE, DVServerKMDEvtD0Entry) 38 | #pragma alloc_text (PAGE, DVServerKMDEvtD0Exit) 39 | #pragma alloc_text (PAGE, DVServerKMDEvtDriverUnload) 40 | #endif 41 | 42 | 43 | 44 | NTSTATUS 45 | DriverEntry( 46 | _In_ PDRIVER_OBJECT DriverObject, 47 | _In_ PUNICODE_STRING RegistryPath 48 | ) 49 | /*++ 50 | 51 | Routine Description: 52 | DriverEntry initializes the driver and is the first routine called by the 53 | system after the driver is loaded. DriverEntry specifies the other entry 54 | points in the function driver, such as EvtDevice and DriverUnload. 55 | 56 | Parameters Description: 57 | 58 | DriverObject - represents the instance of the function driver that is loaded 59 | into memory. DriverEntry must initialize members of DriverObject before it 60 | returns to the caller. DriverObject is allocated by the system before the 61 | driver is loaded, and it is released by the system after the system unloads 62 | the function driver from memory. 63 | 64 | RegistryPath - represents the driver specific path in the Registry. 65 | The function driver can use the path to store driver related data between 66 | reboots. The path does not store hardware instance specific data. 67 | 68 | Return Value: 69 | 70 | STATUS_SUCCESS if successful, 71 | STATUS_UNSUCCESSFUL otherwise. 72 | 73 | --*/ 74 | { 75 | WDF_DRIVER_CONFIG config; 76 | NTSTATUS status; 77 | WDF_OBJECT_ATTRIBUTES attributes; 78 | 79 | // 80 | // Initialize WPP Tracing 81 | // 82 | // 83 | // Register a cleanup callback so that we can call WPP_CLEANUP when 84 | // the framework driver object is deleted during driver unload. 85 | // 86 | WDF_OBJECT_ATTRIBUTES_INIT(&attributes); 87 | attributes.EvtCleanupCallback = DVServerKMDEvtDriverContextCleanup; 88 | 89 | WPP_INIT_TRACING(DriverObject, RegistryPath); 90 | TRACING(); 91 | 92 | WDF_DRIVER_CONFIG_INIT(&config, 93 | DVServerKMDEvtDeviceAdd 94 | ); 95 | config.EvtDriverUnload = DVServerKMDEvtDriverUnload; 96 | status = WdfDriverCreate(DriverObject, 97 | RegistryPath, 98 | &attributes, 99 | &config, 100 | WDF_NO_HANDLE 101 | ); 102 | 103 | if (!NT_SUCCESS(status)) { 104 | WPP_CLEANUP(DriverObject); 105 | return status; 106 | } 107 | 108 | return status; 109 | } 110 | 111 | VOID 112 | DVServerKMDEvtDriverUnload( 113 | _In_ WDFDRIVER driver 114 | ) 115 | /*++ 116 | Routine Description: 117 | 118 | OnDriverUnload is called by the framework when the driver unloads. 119 | 120 | Arguments: 121 | 122 | Driver - Handle to a framework driver object created in DriverEntry. 123 | 124 | Return Value: 125 | 126 | void 127 | 128 | --*/ 129 | { 130 | TRACING(); 131 | WPP_CLEANUP(WdfDriverWdmGetDriverObject(driver)); 132 | 133 | return; 134 | } 135 | 136 | NTSTATUS 137 | DVServerKMDEvtDeviceAdd( 138 | _In_ WDFDRIVER Driver, 139 | _Inout_ PWDFDEVICE_INIT DeviceInit 140 | ) 141 | /*++ 142 | Routine Description: 143 | 144 | EvtDeviceAdd is called by the framework in response to AddDevice 145 | call from the PnP manager. We create and initialize a device object to 146 | represent a new instance of the device. 147 | 148 | Arguments: 149 | 150 | Driver - Handle to a framework driver object created in DriverEntry 151 | 152 | DeviceInit - Pointer to a framework-allocated WDFDEVICE_INIT structure. 153 | 154 | Return Value: 155 | 156 | NTSTATUS 157 | 158 | --*/ 159 | { 160 | NTSTATUS status; 161 | WDF_PNPPOWER_EVENT_CALLBACKS pnpPowerCallbacks; 162 | 163 | UNREFERENCED_PARAMETER(Driver); 164 | TRACING(); 165 | 166 | PAGED_CODE(); 167 | 168 | 169 | WdfDeviceInitSetIoType(DeviceInit, WdfDeviceIoDirect); 170 | 171 | // 172 | // Zero out the PnpPowerCallbacks structure. 173 | // 174 | WDF_PNPPOWER_EVENT_CALLBACKS_INIT(&pnpPowerCallbacks); 175 | 176 | // 177 | // Set Callbacks for any of the functions we are interested in. 178 | // If no callback is set, Framework will take the default action 179 | // by itself. 180 | // 181 | pnpPowerCallbacks.EvtDevicePrepareHardware = DVServerKMDEvtPrepareHardware; 182 | pnpPowerCallbacks.EvtDeviceReleaseHardware = DVServerKMDEvtReleaseHardware; 183 | 184 | // 185 | // These two callbacks set up and tear down hardware state that must be 186 | // done every time the device moves in and out of the D0-working state. 187 | // 188 | pnpPowerCallbacks.EvtDeviceD0Entry = DVServerKMDEvtD0Entry; 189 | pnpPowerCallbacks.EvtDeviceD0Exit = DVServerKMDEvtD0Exit; 190 | 191 | pnpPowerCallbacks.EvtDeviceD0ExitPreInterruptsDisabled = DVServerKMDEvtDeviceD0ExitPreInterruptsDisabled; 192 | pnpPowerCallbacks.EvtDeviceD0EntryPostInterruptsEnabled = DVServerKMDEvtDeviceD0EntryPostInterruptsEnabled; 193 | 194 | // 195 | // Register the PnP Callbacks.. 196 | // 197 | WdfDeviceInitSetPnpPowerEventCallbacks(DeviceInit, &pnpPowerCallbacks); 198 | 199 | // 200 | // Create the device 201 | // 202 | status = DVServerKMDCreateDevice(DeviceInit); 203 | 204 | 205 | return status; 206 | } 207 | 208 | VOID 209 | DVServerKMDEvtDriverContextCleanup( 210 | _In_ WDFOBJECT DriverObject 211 | ) 212 | /*++ 213 | Routine Description: 214 | 215 | Free all the resources allocated in DriverEntry. 216 | 217 | Arguments: 218 | 219 | DriverObject - handle to a WDF Driver object. 220 | 221 | Return Value: 222 | 223 | VOID. 224 | 225 | --*/ 226 | { 227 | UNREFERENCED_PARAMETER(DriverObject); 228 | 229 | PAGED_CODE(); 230 | TRACING(); 231 | } 232 | -------------------------------------------------------------------------------- /DVServerKMD/Driver.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Module Name: 4 | 5 | driver.h 6 | 7 | Abstract: 8 | 9 | This file contains the driver definitions. 10 | 11 | Environment: 12 | 13 | Kernel-mode Driver Framework 14 | 15 | --*/ 16 | 17 | #include 18 | #include 19 | #include 20 | 21 | #include "device.h" 22 | #include "queue.h" 23 | #include "trace.h" 24 | 25 | EXTERN_C_START 26 | 27 | // 28 | // WDFDRIVER Events 29 | // 30 | 31 | DRIVER_INITIALIZE DriverEntry; 32 | EVT_WDF_DRIVER_DEVICE_ADD DVServerKMDEvtDeviceAdd; 33 | EVT_WDF_OBJECT_CONTEXT_CLEANUP DVServerKMDEvtDriverContextCleanup; 34 | EVT_WDF_DRIVER_UNLOAD DVServerKMDEvtDriverUnload; 35 | 36 | #define ENABLE_FRAME_TRACE 37 | #define ENABLE_CURSOR_TRACE 38 | #define ENABLE_IMAGE_DUMP 39 | #define NUMBEROFBYTES 10 40 | 41 | #define WPP_DEBUG(b) DbgPrint b 42 | 43 | #ifdef ENABLE_FRAME_TRACE 44 | #define PRINT_FRAME_DATA(b) WPP_DEBUG(b) 45 | #else 46 | #define PRINT_FRAME_DATA(b) 47 | #endif 48 | 49 | #ifdef ENABLE_CURSOR_TRACE 50 | #define PRINT_CURSOR_DATA(b) WPP_DEBUG(b) 51 | #else 52 | #define PRINT_CURSOR_DATA(b) 53 | #endif 54 | 55 | #ifdef ENABLE_IMAGE_DUMP 56 | #define PRINT_IMAGE_DATA(b) WPP_DEBUG(b) 57 | #else 58 | #define PRINT_IMAGE_DATA(b) 59 | #endif 60 | 61 | #define IMAGE_HEX_DUMP(n) for(int x = 0; x < n; x++) PRINT_IMAGE_DATA(("%x", addr[x])) 62 | 63 | #define DVSERVERKMD_SUCCESS 1 64 | #define DVSERVERKMD_FAILURE 0 65 | 66 | EXTERN_C_END 67 | -------------------------------------------------------------------------------- /DVServerKMD/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (C) 2021-2024 Intel Corporation 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are met: 5 | 6 | 1. Redistributions of source code must retain the above copyright notice, this 7 | list of conditions and the following disclaimer. 8 | 9 | 2. Redistributions in binary form must reproduce the above copyright notice, 10 | this list of conditions and the following disclaimer in the documentation and/ 11 | or other materials provided with the distribution. 12 | 13 | 3. Neither the name of the copyright holder nor the names of its contributors 14 | may be used to endorse or promote products derived from this software without 15 | specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 21 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 23 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 24 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 25 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | 28 | SPDX-License-Identifier: BSD-3-Clause 29 | -------------------------------------------------------------------------------- /DVServerKMD/Public.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Module Name: 4 | 5 | public.h 6 | 7 | Abstract: 8 | 9 | This module contains the common declarations shared by driver 10 | and user applications. 11 | 12 | Environment: 13 | 14 | user and kernel 15 | 16 | --*/ 17 | #ifndef __PUBLIC_H__ 18 | #define __PUBLIC_H__ 19 | // 20 | // Define an Interface Guid so that apps can find the device and talk to it. 21 | // 22 | 23 | DEFINE_GUID(GUID_DEVINTERFACE_DVServerKMD, 24 | 0x1c514918, 0xa855, 0x460a, 0x97, 0xda, 0xed, 0x69, 0x1d, 0xd5, 0x63, 0xcf); 25 | // {1c514918-a855-460a-97da-ed691dd563cf} 26 | 27 | #define MAX_SCAN_OUT 4 28 | #define IOCTL_DVSERVER_FRAME_DATA CTL_CODE(FILE_DEVICE_UNKNOWN, 0x807, METHOD_BUFFERED, FILE_ANY_ACCESS) 29 | #define IOCTL_DVSERVER_CURSOR_DATA CTL_CODE(FILE_DEVICE_UNKNOWN, 0x808, METHOD_BUFFERED, FILE_ANY_ACCESS) 30 | #define IOCTL_DVSERVER_GET_EDID_DATA CTL_CODE(FILE_DEVICE_UNKNOWN, 0x809, METHOD_BUFFERED, FILE_ANY_ACCESS) 31 | #define IOCTL_DVSERVER_SET_MODE CTL_CODE(FILE_DEVICE_UNKNOWN, 0x810, METHOD_BUFFERED, FILE_ANY_ACCESS) 32 | #define IOCTL_DVSERVER_TEST_IMAGE CTL_CODE(FILE_DEVICE_UNKNOWN, 0x812, METHOD_BUFFERED, FILE_ANY_ACCESS) 33 | #define IOCTL_DVSERVER_GET_TOTAL_SCREENS CTL_CODE(FILE_DEVICE_UNKNOWN, 0x813, METHOD_BUFFERED, FILE_ANY_ACCESS) 34 | #define IOCTL_DVSERVER_HP_EVENT CTL_CODE(FILE_DEVICE_UNKNOWN, 0x814, METHOD_BUFFERED, FILE_ANY_ACCESS) 35 | 36 | typedef struct FrameMetaData 37 | { 38 | unsigned int width; 39 | unsigned int height; 40 | unsigned int format; 41 | unsigned int pitch; 42 | unsigned int stride; 43 | UINT16 bitrate; 44 | void* addr; 45 | unsigned short refresh_rate; 46 | unsigned int screen_num; 47 | 48 | }FrameMetaData; 49 | 50 | typedef struct CursorData 51 | { 52 | INT cursor_x; 53 | INT cursor_y; 54 | UINT16 iscursorvisible; 55 | UINT32 cursor_version; 56 | UINT16 cursor_type; 57 | UINT32 width; 58 | UINT32 height; 59 | UINT32 pitch; 60 | void* data; 61 | }CursorData; 62 | 63 | struct mode_info 64 | { 65 | unsigned int width; 66 | unsigned int height; 67 | double refreshrate; 68 | }; 69 | 70 | struct edid_info 71 | { 72 | unsigned char edid_data[256]; 73 | unsigned int mode_size; 74 | unsigned int screen_num; 75 | mode_info* mode_list; 76 | }; 77 | 78 | struct screen_info 79 | { 80 | unsigned int total_screens; 81 | }; 82 | 83 | struct hp_info 84 | { 85 | HANDLE event; 86 | bool screen_present[MAX_SCAN_OUT]; 87 | }; 88 | 89 | struct KMDF_IOCTL_Response 90 | { 91 | UINT16 retval; 92 | }; 93 | 94 | #endif // __PUBLIC_H__ 95 | -------------------------------------------------------------------------------- /DVServerKMD/Queue.h: -------------------------------------------------------------------------------- 1 | /*++ 2 | 3 | Module Name: 4 | 5 | queue.h 6 | 7 | Abstract: 8 | 9 | This file contains the queue definitions. 10 | 11 | Environment: 12 | 13 | Kernel-mode Driver Framework 14 | 15 | --*/ 16 | 17 | EXTERN_C_START 18 | 19 | // 20 | // This is the context that can be placed per queue 21 | // and would contain per queue information. 22 | // 23 | typedef struct _QUEUE_CONTEXT { 24 | 25 | ULONG PrivateDeviceData; // just a placeholder 26 | 27 | } QUEUE_CONTEXT, * PQUEUE_CONTEXT; 28 | 29 | WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(QUEUE_CONTEXT, QueueGetContext) 30 | 31 | NTSTATUS 32 | DVServerKMDQueueInitialize( 33 | _In_ WDFDEVICE Device 34 | ); 35 | 36 | static NTSTATUS IoctlRequestSetMode( 37 | const PDEVICE_CONTEXT DeviceContext, 38 | const size_t InputBufferLength, 39 | const size_t OutputBufferLength, 40 | const WDFREQUEST Request, 41 | size_t* BytesReturned); 42 | 43 | static NTSTATUS IoctlRequestPresentFb( 44 | const PDEVICE_CONTEXT DeviceContext, 45 | const size_t InputBufferLength, 46 | const size_t OutputBufferLength, 47 | const WDFREQUEST Request, 48 | size_t* BytesReturned); 49 | 50 | static NTSTATUS IoctlRequestEdid( 51 | const PDEVICE_CONTEXT DeviceContext, 52 | const size_t InputBufferLength, 53 | const size_t OutputBufferLength, 54 | const WDFREQUEST Request, 55 | size_t* BytesReturned); 56 | 57 | static NTSTATUS IoctlRequestTotalScreens( 58 | const PDEVICE_CONTEXT DeviceContext, 59 | const size_t InputBufferLength, 60 | const size_t OutputBufferLength, 61 | const WDFREQUEST Request, 62 | size_t* BytesReturned); 63 | 64 | static NTSTATUS IoctlRequestHPEventInfo( 65 | const PDEVICE_CONTEXT DeviceContext, 66 | const size_t InputBufferLength, 67 | const size_t OutputBufferLength, 68 | const WDFREQUEST Request, 69 | size_t* BytesReturned); 70 | 71 | // 72 | // Events from the IoQueue object 73 | // 74 | EVT_WDF_IO_QUEUE_IO_DEVICE_CONTROL DVServerKMDEvtIoDeviceControl; 75 | EVT_WDF_IO_QUEUE_IO_STOP DVServerKMDEvtIoStop; 76 | 77 | EXTERN_C_END 78 | -------------------------------------------------------------------------------- /DVServerKMD/ReadMe.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | DVServerKMD Project Overview 3 | ======================================================================== 4 | 5 | This file contains a summary of what you will find in each of the files that make up your project. 6 | 7 | DVServerKMD.vcxproj 8 | This is the main project file for projects generated using an Application Wizard. 9 | It contains information about the version of the product that generated the file, and 10 | information about the platforms, configurations, and project features selected with the 11 | Application Wizard. 12 | 13 | DVServerKMD.vcxproj.filters 14 | This is the filters file for VC++ projects generated using an Application Wizard. 15 | It contains information about the association between the files in your project 16 | and the filters. This association is used in the IDE to show grouping of files with 17 | similar extensions under a specific node (for e.g. ".cpp" files are associated with the 18 | "Source Files" filter). 19 | 20 | Public.h 21 | Header file to be shared with applications. 22 | 23 | Driver.c & Driver.h 24 | DriverEntry and WDFDRIVER related functionality and callbacks. 25 | 26 | Device.c & Device.h 27 | WDFDEVICE related functionality and callbacks. 28 | 29 | Queue.c & Queue.h 30 | WDFQUEUE related functionality and callbacks. 31 | 32 | Trace.h 33 | Definitions for WPP tracing. 34 | 35 | ///////////////////////////////////////////////////////////////////////////// 36 | 37 | Learn more about Kernel Mode Driver Framework here: 38 | 39 | http://msdn.microsoft.com/en-us/library/ff544296(v=VS.85).aspx 40 | 41 | ///////////////////////////////////////////////////////////////////////////// 42 | -------------------------------------------------------------------------------- /DVServerKMD/Trace.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define WPP_CONTROL_GUIDS WPP_DEFINE_CONTROL_GUID(DVserverKMDGuid, (DB7C7BAE, 6D56, 4DF0, 8807, 48F2FB30E3D1), \ 4 | WPP_DEFINE_BIT(verbose) \ 5 | WPP_DEFINE_BIT(information) \ 6 | WPP_DEFINE_BIT(error) \ 7 | WPP_DEFINE_BIT(ftrace) \ 8 | WPP_DEFINE_BIT(warning)) 9 | 10 | #define WPP_FLAG_LEVEL_LOGGER(flag, level) \ 11 | WPP_LEVEL_LOGGER(flag) 12 | 13 | #define WPP_FLAG_LEVEL_ENABLED(flag, level) \ 14 | (WPP_LEVEL_ENABLED(flag) && \ 15 | WPP_CONTROL(WPP_BIT_ ## flag).Level >= level) 16 | 17 | #define WPP_LEVEL_FLAGS_LOGGER(lvl,flags) \ 18 | WPP_LEVEL_LOGGER(flags) 19 | 20 | #define WPP_LEVEL_FLAGS_ENABLED(lvl, flags) \ 21 | (WPP_LEVEL_ENABLED(flags) && WPP_CONTROL(WPP_BIT_ ## flags).Level >= lvl) 22 | 23 | 24 | class tracer { 25 | private: 26 | char* m_func_name; 27 | public: 28 | tracer(const char* func_name); 29 | ~tracer(); 30 | }; 31 | #define TRACING() tracer trace(__FUNCTION__) 32 | 33 | // 34 | // This comment block is scanned by the trace preprocessor to define our 35 | // Trace function. 36 | // 37 | // begin_wpp config 38 | // FUNC ERR{LEVEL=TRACE_LEVEL_ERROR,FLAGS=error}(MSG,...); 39 | // FUNC WARN{LEVEL=TRACE_LEVEL_WARNING,FLAGS=warning}(MSG,...); 40 | // FUNC WARNING{LEVEL=TRACE_LEVEL_WARNING,FLAGS=warning}(MSG,...); 41 | // FUNC INFO{LEVEL=TRACE_LEVEL_INFORMATION,FLAGS=information}(MSG,...); 42 | // FUNC DBGPRINT{LEVEL=TRACE_LEVEL_INFORMATION,FLAGS=verbose}(MSG,...); 43 | // FUNC FuncTrace{LEVEL=TRACE_LEVEL_INFORMATION,FLAGS=ftrace}(MSG, ...); 44 | // USEPREFIX(ERR, "%!STDPREFIX! [%!FUNC!:%!LINE!] [ERR] \t"); 45 | // USEPREFIX(WARN, "%!STDPREFIX! [%!FUNC!:%!LINE!] [WARN] \t"); 46 | // USEPREFIX(WARNING, "%!STDPREFIX! [%!FUNC!:%!LINE!] [WARN] \t"); 47 | // USEPREFIX(DBGPRINT, "%!STDPREFIX! [%!FUNC!:%!LINE!] [DBG] \t"); 48 | // USEPREFIX(INFO, "%!STDPREFIX! [%!FUNC!:%!LINE!] [INFO] \t"); 49 | // end_wpp 50 | 51 | -------------------------------------------------------------------------------- /DVServerKMD/Tracing.cpp: -------------------------------------------------------------------------------- 1 | /*++ 2 | * 3 | * Copyright (C) 2021 Intel Corporation 4 | * SPDX-License-Identifier: BSD-3-Clause 5 | 6 | Module Name: 7 | 8 | Tracing.cpp 9 | 10 | Abstract: 11 | 12 | This file contains the function tracing entry and exits. 13 | 14 | Environment: 15 | 16 | Kernel-mode Driver Framework 17 | 18 | --*/ 19 | #include "Driver.h" 20 | #include "Trace.h" 21 | #include "tracing.tmh" 22 | 23 | 24 | /******************************************************************************* 25 | * 26 | * Description 27 | * 28 | * tracer is a constructor member function of the class tracer called to mark the entry of the function. 29 | * 30 | * Parameters 31 | * func_name - Function name. 32 | * 33 | * 34 | ******************************************************************************/ 35 | tracer::tracer(const char* func_name) 36 | { 37 | FuncTrace(">>> %s\n", func_name); 38 | m_func_name = (char*)func_name; 39 | } 40 | /******************************************************************************* 41 | * 42 | * Description 43 | * 44 | * tracer is a destructor member function of the class tracer called to mark exit of the function. 45 | * 46 | * Parameters 47 | * func_name - Function name. 48 | * 49 | * 50 | ******************************************************************************/ 51 | tracer::~tracer() 52 | { 53 | FuncTrace("<<< %s\n", m_func_name); 54 | } -------------------------------------------------------------------------------- /DVServerKMD/UpdateVersion.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 1.0.0.0 5 | 1.0.0.0 6 | 7 | 8 | 9 | 10 | DVServerKMD.rc 11 | $([System.IO.File]::ReadAllText('$(VersionFile)')) 12 | 13 | 14 | $([System.String]::Copy($(FdvserverkmdVersion)).Split('.')[0]) 15 | $([System.String]::Copy($(FdvserverkmdVersion)).Split('.')[1]) 16 | $([System.String]::Copy($(FdvserverkmdVersion)).Split('.')[2]) 17 | $([System.String]::Copy($(FdvserverkmdVersion)).Split('.')[3]) 18 | 19 | $([System.String]::Copy($(PdvserverkmdVersion)).Split('.')[0]) 20 | $([System.String]::Copy($(PdvserverkmdVersion)).Split('.')[1]) 21 | $([System.String]::Copy($(PdvserverkmdVersion)).Split('.')[2]) 22 | $([System.String]::Copy($(PdvserverkmdVersion)).Split('.')[3]) 23 | 24 | 25 | $([System.Text.RegularExpressions.Regex]::Replace($(FileContent), '\$\{FileVersion\}', '$(FileVersionMajor),$(FileVersionMinor),$(FileVersionBuild),$(FileVersionRevision)')) 26 | $([System.Text.RegularExpressions.Regex]::Replace($(FileContent), '\$\{ProductVersion\}', '$(ProductVersionMajor),$(ProductVersionMinor),$(ProductVersionBuild),$(ProductVersionRevision)')) 27 | $([System.Text.RegularExpressions.Regex]::Replace($(FileContent), '\$\{ProductVersionString\}', '$(PdvserverkmdVersion)')) 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /DVServerKMD/baseobj.cpp: -------------------------------------------------------------------------------- 1 | #include "baseobj.h" 2 | 3 | _When_((PoolType& NonPagedPoolMustSucceed) != 0, 4 | __drv_reportError("Must succeed pool allocations are forbidden. " 5 | "Allocation failures cause a system crash")) 6 | void* __cdecl operator new(size_t Size, POOL_TYPE PoolType) 7 | { 8 | Size = (Size != 0) ? Size : 1; 9 | 10 | ULONG Flags = 0; 11 | switch (PoolType) { 12 | case NonPagedPool: 13 | Flags = POOL_FLAG_NON_PAGED; 14 | break; 15 | case PagedPool: 16 | Flags = POOL_FLAG_PAGED; 17 | break; 18 | case NonPagedPoolNx: 19 | Flags = POOL_FLAG_NON_PAGED | POOL_FLAG_CACHE_ALIGNED; 20 | break; 21 | default: 22 | // Handle other pool types or set a default flag 23 | Flags = POOL_FLAG_NON_PAGED; 24 | break; 25 | } 26 | 27 | void* pObject = ExAllocatePool2(Flags, Size, VIOGPUTAG); 28 | 29 | if (pObject != NULL) 30 | { 31 | #if DBG 32 | RtlFillMemory(pObject, Size, 0xCD); 33 | #else 34 | RtlZeroMemory(pObject, Size); 35 | #endif // DBG 36 | } 37 | return pObject; 38 | } 39 | 40 | _When_((PoolType& NonPagedPoolMustSucceed) != 0, 41 | __drv_reportError("Must succeed pool allocations are forbidden. " 42 | "Allocation failures cause a system crash")) 43 | void* __cdecl operator new[](size_t Size, POOL_TYPE PoolType) 44 | { 45 | 46 | Size = (Size != 0) ? Size : 1; 47 | 48 | ULONG Flags = 0; 49 | switch (PoolType) { 50 | case NonPagedPool: 51 | Flags = POOL_FLAG_NON_PAGED; 52 | break; 53 | case PagedPool: 54 | Flags = POOL_FLAG_PAGED; 55 | break; 56 | case NonPagedPoolNx: 57 | Flags = POOL_FLAG_NON_PAGED | POOL_FLAG_CACHE_ALIGNED; 58 | break; 59 | default: 60 | // Handle other pool types or set a default flag 61 | Flags = POOL_FLAG_NON_PAGED; 62 | break; 63 | } 64 | 65 | void* pObject = ExAllocatePool2(Flags, Size, VIOGPUTAG); 66 | 67 | if (pObject != NULL) 68 | { 69 | #if DBG 70 | RtlFillMemory(pObject, Size, 0xCD); 71 | #else 72 | RtlZeroMemory(pObject, Size); 73 | #endif 74 | } 75 | return pObject; 76 | } 77 | 78 | void __cdecl operator delete(void* pObject) 79 | { 80 | 81 | if (pObject != NULL) 82 | { 83 | ExFreePoolWithTag(pObject, VIOGPUTAG); 84 | } 85 | } 86 | 87 | void __cdecl operator delete[](void* pObject) 88 | { 89 | 90 | if (pObject != NULL) 91 | { 92 | ExFreePoolWithTag(pObject, VIOGPUTAG); 93 | } 94 | } 95 | 96 | void __cdecl operator delete(void* pObject, size_t Size) 97 | { 98 | 99 | UNREFERENCED_PARAMETER(Size); 100 | ::operator delete (pObject); 101 | } 102 | -------------------------------------------------------------------------------- /DVServerKMD/baseobj.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "helper.h" 3 | 4 | _When_((PoolType& NonPagedPoolMustSucceed) != 0, 5 | __drv_reportError("Must succeed pool allocations are forbidden. " 6 | "Allocation failures cause a system crash")) 7 | void* __cdecl operator new(size_t Size, POOL_TYPE PoolType = PagedPool); 8 | _When_((PoolType& NonPagedPoolMustSucceed) != 0, 9 | __drv_reportError("Must succeed pool allocations are forbidden. " 10 | "Allocation failures cause a system crash")) 11 | void* __cdecl operator new[](size_t Size, POOL_TYPE PoolType = PagedPool); 12 | void __cdecl operator delete(void* pObject); 13 | void __cdecl operator delete[](void* pObject); 14 | void __cdecl operator delete(void* pObject, size_t Size); 15 | -------------------------------------------------------------------------------- /DVServerKMD/bitops.cpp: -------------------------------------------------------------------------------- 1 | #include "bitops.h" 2 | #include "Trace.h" 3 | #include 4 | 5 | 6 | #pragma code_seg(push) 7 | #pragma code_seg() 8 | 9 | VOID 10 | GetPitches( 11 | _In_ CONST BLT_INFO* pBltInfo, 12 | _Out_ LONG* pPixelPitch, 13 | _Out_ LONG* pRowPitch 14 | ) 15 | { 16 | TRACING(); 17 | switch (pBltInfo->Rotation) { 18 | case D3DKMDT_VPPR_IDENTITY: 19 | *pPixelPitch = (pBltInfo->BitsPerPel / BITS_PER_BYTE); 20 | *pRowPitch = pBltInfo->Pitch; 21 | return; 22 | case D3DKMDT_VPPR_ROTATE90: 23 | *pPixelPitch = -((LONG)pBltInfo->Pitch); 24 | *pRowPitch = (pBltInfo->BitsPerPel / BITS_PER_BYTE); 25 | return; 26 | case D3DKMDT_VPPR_ROTATE180: 27 | *pPixelPitch = -((LONG)pBltInfo->BitsPerPel / BITS_PER_BYTE); 28 | *pRowPitch = -((LONG)pBltInfo->Pitch); 29 | return; 30 | case D3DKMDT_VPPR_ROTATE270: 31 | *pPixelPitch = pBltInfo->Pitch; 32 | *pRowPitch = -((LONG)pBltInfo->BitsPerPel / BITS_PER_BYTE); 33 | return; 34 | default: 35 | VioGpuDbgBreak(); 36 | VIOGPU_LOG_ASSERTION1("Invalid rotation (0x%I64x) specified", pBltInfo->Rotation); 37 | *pPixelPitch = 0; 38 | *pRowPitch = 0; 39 | return; 40 | } 41 | } 42 | 43 | BYTE* GetRowStart(_In_ CONST BLT_INFO* pBltInfo, CONST RECT* pRect) 44 | { 45 | TRACING(); 46 | BYTE* pRet = NULL; 47 | LONG OffLeft = pRect->left + pBltInfo->Offset.x; 48 | LONG OffTop = pRect->top + pBltInfo->Offset.y; 49 | LONG BytesPerPixel = (pBltInfo->BitsPerPel / BITS_PER_BYTE); 50 | 51 | switch (pBltInfo->Rotation) { 52 | case D3DKMDT_VPPR_IDENTITY: 53 | pRet = ((BYTE*)pBltInfo->pBits + 54 | OffTop * pBltInfo->Pitch + 55 | OffLeft * BytesPerPixel); 56 | break; 57 | case D3DKMDT_VPPR_ROTATE90: 58 | pRet = ((BYTE*)pBltInfo->pBits + 59 | (pBltInfo->Height - 1 - OffLeft) * pBltInfo->Pitch + 60 | OffTop * BytesPerPixel); 61 | break; 62 | case D3DKMDT_VPPR_ROTATE180: 63 | pRet = ((BYTE*)pBltInfo->pBits + 64 | (pBltInfo->Height - 1 - OffTop) * pBltInfo->Pitch + 65 | (pBltInfo->Width - 1 - OffLeft) * BytesPerPixel); 66 | break; 67 | case D3DKMDT_VPPR_ROTATE270: 68 | pRet = ((BYTE*)pBltInfo->pBits + 69 | OffLeft * pBltInfo->Pitch + 70 | (pBltInfo->Width - 1 - OffTop) * BytesPerPixel); 71 | break; 72 | default: 73 | { 74 | VIOGPU_LOG_ASSERTION1("Invalid rotation (0x%I64x) specified", pBltInfo->Rotation); 75 | } 76 | } 77 | 78 | return pRet; 79 | } 80 | 81 | VOID CopyBitsGeneric( 82 | BLT_INFO* pDst, 83 | CONST BLT_INFO* pSrc, 84 | UINT NumRects, 85 | _In_reads_(NumRects) CONST RECT* pRects) 86 | { 87 | TRACING(); 88 | LONG DstPixelPitch = 0; 89 | LONG DstRowPitch = 0; 90 | LONG SrcPixelPitch = 0; 91 | LONG SrcRowPitch = 0; 92 | 93 | DBGPRINT("NumRects = %d Dst = %p Src = %p\n", NumRects, pDst->pBits, pSrc->pBits); 94 | 95 | GetPitches(pDst, &DstPixelPitch, &DstRowPitch); 96 | GetPitches(pSrc, &SrcPixelPitch, &SrcRowPitch); 97 | 98 | for (UINT iRect = 0; iRect < NumRects; iRect++) { 99 | CONST RECT* pRect = &pRects[iRect]; 100 | 101 | VIOGPU_ASSERT(pRect->right >= pRect->left); 102 | VIOGPU_ASSERT(pRect->bottom >= pRect->top); 103 | 104 | UINT NumPixels = pRect->right - pRect->left; 105 | UINT NumRows = pRect->bottom - pRect->top; 106 | 107 | BYTE* pDstRow = GetRowStart(pDst, pRect); 108 | CONST BYTE* pSrcRow = GetRowStart(pSrc, pRect); 109 | 110 | for (UINT y = 0; y < NumRows; y++) { 111 | BYTE* pDstPixel = pDstRow; 112 | CONST BYTE* pSrcPixel = pSrcRow; 113 | 114 | for (UINT x = 0; x < NumPixels; x++) { 115 | if (pDst->BitsPerPel == 32 && pSrc->BitsPerPel == 32) { 116 | UINT32* pDstPixelAs32 = (UINT32*)pDstPixel; 117 | UINT32* pSrcPixelAs32 = (UINT32*)pSrcPixel; 118 | *pDstPixelAs32 = *pSrcPixelAs32; 119 | } 120 | else { 121 | VioGpuDbgBreak(); 122 | } 123 | pDstPixel += DstPixelPitch; 124 | pSrcPixel += SrcPixelPitch; 125 | } 126 | 127 | pDstRow += DstRowPitch; 128 | pSrcRow += SrcRowPitch; 129 | } 130 | } 131 | } 132 | 133 | 134 | VOID CopyBits32_32( 135 | BLT_INFO* pDst, 136 | CONST BLT_INFO* pSrc, 137 | UINT NumRects, 138 | _In_reads_(NumRects) CONST RECT* pRects) 139 | { 140 | VIOGPU_ASSERT((pDst->BitsPerPel == 32) && 141 | (pSrc->BitsPerPel == 32)); 142 | VIOGPU_ASSERT((pDst->Rotation == D3DKMDT_VPPR_IDENTITY) && 143 | (pSrc->Rotation == D3DKMDT_VPPR_IDENTITY)); 144 | 145 | TRACING(); 146 | 147 | for (UINT iRect = 0; iRect < NumRects; iRect++) { 148 | CONST RECT* pRect = &pRects[iRect]; 149 | 150 | VIOGPU_ASSERT(pRect->right >= pRect->left); 151 | VIOGPU_ASSERT(pRect->bottom >= pRect->top); 152 | 153 | UINT NumPixels = pRect->right - pRect->left; 154 | UINT NumRows = pRect->bottom - pRect->top; 155 | UINT BytesToCopy = NumPixels * 4; 156 | BYTE* pStartDst = ((BYTE*)pDst->pBits + 157 | (pRect->top + pDst->Offset.y) * pDst->Pitch + 158 | (pRect->left + pDst->Offset.x) * 4); 159 | CONST BYTE* pStartSrc = ((BYTE*)pSrc->pBits + 160 | (pRect->top + pSrc->Offset.y) * pSrc->Pitch + 161 | (pRect->left + pSrc->Offset.x) * 4); 162 | 163 | for (UINT i = 0; i < NumRows; ++i) { 164 | RtlCopyMemory(pStartDst, pStartSrc, BytesToCopy); 165 | pStartDst += pDst->Pitch; 166 | pStartSrc += pSrc->Pitch; 167 | } 168 | } 169 | } 170 | 171 | 172 | VOID BltBits( 173 | BLT_INFO* pDst, 174 | CONST BLT_INFO* pSrc, 175 | UINT NumRects, 176 | _In_reads_(NumRects) CONST RECT* pRects) 177 | { 178 | TRACING(); 179 | __try { 180 | if (pDst->Rotation == D3DKMDT_VPPR_IDENTITY && 181 | pSrc->Rotation == D3DKMDT_VPPR_IDENTITY) { 182 | CopyBits32_32(pDst, pSrc, NumRects, pRects); 183 | } 184 | else { 185 | CopyBitsGeneric(pDst, pSrc, NumRects, pRects); 186 | } 187 | } 188 | #pragma prefast(suppress: __WARNING_EXCEPTIONEXECUTEHANDLER, "try/except is only able to protect against user-mode errors and these are the only errors we try to catch here"); 189 | __except (EXCEPTION_EXECUTE_HANDLER) 190 | { 191 | ERR("Either dst (0x%p) or src (0x%p) bits encountered exception during access.\n", pDst->pBits, pSrc->pBits); 192 | } 193 | } 194 | 195 | UINT BPPFromPixelFormat(D3DDDIFORMAT Format) 196 | { 197 | TRACING(); 198 | switch (Format) 199 | { 200 | case D3DDDIFMT_UNKNOWN: return 0; 201 | case D3DDDIFMT_A1: return 1; 202 | case D3DDDIFMT_P8: return 8; 203 | case D3DDDIFMT_R5G6B5: return 16; 204 | case D3DDDIFMT_R8G8B8: return 24; 205 | case D3DDDIFMT_X8R8G8B8: 206 | case D3DDDIFMT_A8R8G8B8: return 32; 207 | default: VIOGPU_LOG_ASSERTION1("Unknown D3DDDIFORMAT 0x%I64x", Format); return 0; 208 | } 209 | } 210 | 211 | #pragma code_seg(pop) // End Non-Paged Code 212 | -------------------------------------------------------------------------------- /DVServerKMD/bitops.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "helper.h" 3 | 4 | typedef struct _BLT_INFO { 5 | PVOID pBits; 6 | UINT Pitch; 7 | UINT BitsPerPel; 8 | POINT Offset; 9 | D3DKMDT_VIDPN_PRESENT_PATH_ROTATION Rotation; 10 | UINT Width; 11 | UINT Height; 12 | } BLT_INFO; 13 | 14 | 15 | VOID GetPitches( 16 | _In_ CONST BLT_INFO* pBltInfo, 17 | _Out_ LONG* pPixelPitch, 18 | _Out_ LONG* pRowPitch); 19 | 20 | BYTE* GetRowStart( 21 | _In_ CONST BLT_INFO* pBltInfo, 22 | _In_ CONST RECT* pRect); 23 | 24 | VOID CopyBitsGeneric( 25 | _Out_ BLT_INFO* pDst, 26 | _In_ CONST BLT_INFO* pSrc, 27 | _In_ UINT NumRects, 28 | _In_reads_(NumRects) CONST RECT* pRects); 29 | 30 | VOID CopyBits32_32( 31 | _Out_ BLT_INFO* pDst, 32 | _In_ CONST BLT_INFO* pSrc, 33 | _In_ UINT NumRects, 34 | _In_reads_(NumRects) CONST RECT* pRects); 35 | 36 | VOID BltBits( 37 | _Out_ BLT_INFO* pDst, 38 | _In_ CONST BLT_INFO* pSrc, 39 | _In_ UINT NumRects, 40 | _In_reads_(NumRects) CONST RECT* pRects); 41 | 42 | 43 | UINT BPPFromPixelFormat(D3DDDIFORMAT Format); 44 | -------------------------------------------------------------------------------- /DVServerKMD/edid.h: -------------------------------------------------------------------------------- 1 | /*=========================================================================== 2 | ; edid.h 3 | ;---------------------------------------------------------------------------- 4 | ; Copyright (C) 2021 Intel Corporation 5 | ; SPDX-License-Identifier: BSD-3-Clause 6 | ;--------------------------------------------------------------------------*/ 7 | 8 | #ifndef __EDID_H__ 9 | #define __EDID_H__ 10 | 11 | //This header file is a Placeholder for generic edid parser 12 | 13 | #define QEMU_MODELIST_SIZE 23 //already we know the supported resolution in qemu 14 | #define MAX_MODELIST_SIZE 128 15 | 16 | #endif // __EDID_H__ 17 | #pragma once 18 | -------------------------------------------------------------------------------- /DVServerKMD/helper.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019-2020 Red Hat, Inc. 3 | * 4 | * Written By: Vadim Rozenfeld 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met : 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and / or other materials provided with the distribution. 14 | * 3. Neither the names of the copyright holders nor the names of their contributors 15 | * may be used to endorse or promote products derived from this software 16 | * without specific prior written permission. 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | */ 29 | 30 | #pragma once 31 | 32 | extern "C" { 33 | 34 | #define __CPLUSPLUS 35 | 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | 42 | #include 43 | 44 | #include 45 | 46 | #ifndef FAR 47 | #define FAR 48 | #endif 49 | 50 | #include 51 | #include 52 | 53 | #include 54 | #include 55 | 56 | #include 57 | #include 58 | 59 | #include 60 | #include 61 | 62 | #include 63 | #include 64 | 65 | #include 66 | 67 | #include 68 | 69 | #include "trace.h" 70 | #include "osdep.h" 71 | #include "virtio_pci.h" 72 | #include "virtio.h" 73 | #include "virtio_ring.h" 74 | #include "kdebugprint.h" 75 | #include "viogpu_pci.h" 76 | #include "viogpu.h" 77 | #include "viogpu_queue.h" 78 | #include "viogpu_idr.h" 79 | 80 | #include 81 | } 82 | 83 | #define MAX_VIEWS 1 84 | #define BITS_PER_BYTE 8 85 | 86 | #define POINTER_SIZE 64 87 | #define MIN_WIDTH_SIZE 640 88 | #define MIN_HEIGHT_SIZE 480 89 | #define NOM_WIDTH_SIZE 1024 90 | #define NOM_HEIGHT_SIZE 768 91 | #define VGPU_BPP 32 92 | 93 | #define VIOGPUTAG 'OIVg' 94 | 95 | extern VirtIOSystemOps VioGpuSystemOps; 96 | 97 | #define VIOGPU_LOG_ASSERTION0(Msg) NT_ASSERT(FALSE) 98 | #define VIOGPU_LOG_ASSERTION1(Msg,Param1) NT_ASSERT(FALSE) 99 | #define VIOGPU_ASSERT(exp) {if (!(exp)) {VIOGPU_LOG_ASSERTION0(#exp);}} 100 | 101 | 102 | #if DBG 103 | #define VIOGPU_ASSERT_CHK(exp) VIOGPU_ASSERT(exp) 104 | #else 105 | #define VIOGPU_ASSERT_CHK(exp) {} 106 | #endif 107 | 108 | #define PAGED_CODE_SEG __declspec(code_seg("PAGE")) 109 | #define PAGED_CODE_SEG_BEGIN \ 110 | __pragma(code_seg(push)) \ 111 | __pragma(code_seg("PAGE")) 112 | 113 | #define PAGED_CODE_SEG_END \ 114 | __pragma(code_seg(pop)) 115 | 116 | #define VioGpuDbgBreak() {} 117 | 118 | -------------------------------------------------------------------------------- /DVServerKMD/qemu_edid.h: -------------------------------------------------------------------------------- 1 | /*=========================================================================== 2 | ; qemu_edid.h 3 | ;---------------------------------------------------------------------------- 4 | ; Copyright (C) 2021 Intel Corporation 5 | ; SPDX-License-Identifier: BSD-3-Clause 6 | ;--------------------------------------------------------------------------*/ 7 | 8 | 9 | #ifndef __QEMU_EDID_H__ 10 | #define __QEMU_EDID_H__ 11 | 12 | #include "edid.h" 13 | 14 | struct edid_predefined_qemu_modes { 15 | unsigned int x; 16 | unsigned int y; 17 | double rr; 18 | }; 19 | 20 | edid_predefined_qemu_modes qemu_modelist[QEMU_MODELIST_SIZE] = { 21 | {640, 480, 60.000000}, 22 | {800, 600, 60.000000}, 23 | {1024, 768, 60.000000}, 24 | {2048, 1152, 60.000000}, 25 | {1920, 1080, 60.000000}, 26 | {1920, 1200, 60.000000}, 27 | {1600, 1200, 60.000000}, 28 | {1680, 1050, 60.000000}, 29 | {1440, 900, 60.000000}, 30 | {1280, 1024, 60.000000}, 31 | {1280, 960, 60.000000}, 32 | {1280, 768, 59.870228}, 33 | {1360, 768, 60.015162}, 34 | {1440, 1050, 59.978442}, 35 | {1792, 1344, 59.999789}, 36 | {1856, 1392, 59.995184}, 37 | {1920, 1440, 60.000000}, 38 | {5120, 2160, 50.000000}, 39 | {4096, 2160, 50.000000}, 40 | {3840, 2160, 50.000000}, 41 | {2560, 1080, 50.000000}, 42 | {1920, 1080, 50.000000}, 43 | {3840, 2160, 60.000000} 44 | }; 45 | 46 | 47 | #endif // __QEMU_EDID_H__ 48 | -------------------------------------------------------------------------------- /DVServerKMD/viogpu_idr.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019-2020 Red Hat, Inc. 3 | * 4 | * Written By: Vadim Rozenfeld 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met : 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and / or other materials provided with the distribution. 14 | * 3. Neither the names of the copyright holders nor the names of their contributors 15 | * may be used to endorse or promote products derived from this software 16 | * without specific prior written permission. 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | */ 29 | 30 | #include "helper.h" 31 | #include "baseobj.h" 32 | #include "Trace.h" 33 | #include 34 | #if !DBG 35 | #include "viogpu_idr.tmh" 36 | #endif 37 | 38 | VioGpuIdr::VioGpuIdr() 39 | { 40 | m_uStartIndex = 0; 41 | m_IdBitMap.SizeOfBitMap = 0; 42 | m_IdBitMap.Buffer = NULL; 43 | } 44 | 45 | VioGpuIdr::~VioGpuIdr() 46 | { 47 | Close(); 48 | } 49 | 50 | BOOLEAN VioGpuIdr::Init( 51 | _In_ ULONG start) 52 | { 53 | PUCHAR buf = NULL; 54 | BOOLEAN ret = FALSE; 55 | m_uStartIndex = start; 56 | ExInitializeFastMutex(&m_IdBitMapMutex); 57 | 58 | VIOGPU_ASSERT(m_IdBitMap.Buffer == NULL); 59 | Lock(); 60 | buf = new (NonPagedPoolNx) UCHAR[PAGE_SIZE]; 61 | if (buf) { 62 | RtlInitializeBitMap(&m_IdBitMap, 63 | (PULONG)buf, 64 | CHAR_BIT * PAGE_SIZE); 65 | RtlClearAllBits(&m_IdBitMap); 66 | RtlSetBits(&m_IdBitMap, 0, m_uStartIndex); 67 | ret = TRUE; 68 | } 69 | Unlock(); 70 | return ret; 71 | } 72 | 73 | #pragma warning( disable: 28167 ) 74 | //_IRQL_raises_(APC_LEVEL) 75 | //_IRQL_saves_global_(OldIrql, m_IdBitMapMutex) 76 | VOID VioGpuIdr::Lock(VOID) 77 | { 78 | ExAcquireFastMutex(&m_IdBitMapMutex); 79 | } 80 | 81 | #pragma warning( disable: 28167 ) 82 | //_IRQL_requires_(APC_LEVEL) 83 | //_IRQL_restores_global_(OldIrql, m_IdBitMapMutex) 84 | VOID VioGpuIdr::Unlock(VOID) 85 | { 86 | ExReleaseFastMutex(&m_IdBitMapMutex); 87 | } 88 | 89 | ULONG VioGpuIdr::GetId(VOID) 90 | { 91 | ULONG id = 0; 92 | Lock(); 93 | if (m_IdBitMap.Buffer != NULL) 94 | { 95 | id = RtlFindClearBitsAndSet(&m_IdBitMap, 1, 0); 96 | } 97 | Unlock(); 98 | DBGPRINT("id = %d\n", id); 99 | ASSERT(id < USHORT_MAX); 100 | return id; 101 | } 102 | 103 | VOID VioGpuIdr::PutId(ULONG id) 104 | { 105 | ASSERT(id >= m_uStartIndex); 106 | ASSERT(id <= (CHAR_BIT * PAGE_SIZE)); 107 | DBGPRINT("bit %d\n", id); 108 | Lock(); 109 | if (m_IdBitMap.Buffer != NULL) 110 | { 111 | if (!RtlAreBitsSet(&m_IdBitMap, id, 1)) 112 | { 113 | ERR("bit %d is not set\n", id - m_uStartIndex); 114 | } 115 | RtlClearBits(&m_IdBitMap, id, 1); 116 | } 117 | Unlock(); 118 | } 119 | 120 | VOID VioGpuIdr::Close(VOID) 121 | { 122 | Lock(); 123 | if (m_IdBitMap.Buffer != NULL) 124 | { 125 | delete[] m_IdBitMap.Buffer; 126 | m_IdBitMap.Buffer = NULL; 127 | } 128 | m_uStartIndex = 0; 129 | Unlock(); 130 | } 131 | -------------------------------------------------------------------------------- /DVServerKMD/viogpu_idr.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019-2020 Red Hat, Inc. 3 | * 4 | * Written By: Vadim Rozenfeld 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met : 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and / or other materials provided with the distribution. 14 | * 3. Neither the names of the copyright holders nor the names of their contributors 15 | * may be used to endorse or promote products derived from this software 16 | * without specific prior written permission. 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | */ 29 | #pragma once 30 | #include "helper.h" 31 | 32 | class VioGpuIdr 33 | { 34 | public: 35 | VioGpuIdr(); 36 | ~VioGpuIdr(); 37 | BOOLEAN Init(_In_ ULONG start); 38 | ULONG GetId(VOID); 39 | VOID PutId(_In_ ULONG id); 40 | private: 41 | VOID Close(VOID); 42 | VOID Lock(VOID); 43 | VOID Unlock(VOID); 44 | private: 45 | ULONG m_uStartIndex; 46 | RTL_BITMAP m_IdBitMap; 47 | FAST_MUTEX m_IdBitMapMutex; 48 | }; 49 | -------------------------------------------------------------------------------- /DVServerKMD/viogpu_pci.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "helper.h" 3 | 4 | #define REDHAT_PCI_VENDOR_ID 0x1AF4 5 | 6 | #define PORT_MASK 0xFFFF 7 | #define VIRTIO_GPU_MSIX_CONFIG_VECTOR 0 8 | 9 | class CPciBar 10 | { 11 | public: 12 | CPciBar(PHYSICAL_ADDRESS BasePA, ULONG uSize, bool bPortSpace, bool bIoMapped) 13 | : m_BasePA(BasePA) 14 | , m_uSize(uSize) 15 | , m_BaseVA(nullptr) 16 | , m_bPortSpace(bPortSpace) 17 | , m_bIoMapped(bIoMapped) 18 | { 19 | ASSERT(!m_bPortSpace || m_BasePA.HighPart == 0); 20 | } 21 | 22 | CPciBar() : CPciBar(PHYSICAL_ADDRESS(), 0, false, true) 23 | { } 24 | 25 | ~CPciBar() 26 | { 27 | ASSERT(m_BaseVA == nullptr); 28 | } 29 | 30 | ULONG GetSize() 31 | { 32 | return m_uSize; 33 | } 34 | 35 | bool IsPortSpace() 36 | { 37 | return m_bPortSpace; 38 | } 39 | 40 | PHYSICAL_ADDRESS GetPA() 41 | { 42 | return m_BasePA; 43 | } 44 | 45 | // Maps BAR into virtual memory if not already mapped 46 | PVOID GetVA(PDXGKRNL_INTERFACE pDxgkInterface); 47 | 48 | // Undoes the effect of GetVA 49 | void Unmap(); 50 | 51 | private: 52 | PHYSICAL_ADDRESS m_BasePA; 53 | ULONG m_uSize; 54 | PVOID m_BaseVA; 55 | bool m_bPortSpace; 56 | bool m_bIoMapped; 57 | }; 58 | 59 | class CPciResources 60 | { 61 | public: 62 | CPciResources() 63 | : m_pDxgkInterface(nullptr), 64 | m_InterruptFlags(0) 65 | { } 66 | 67 | ~CPciResources() 68 | { 69 | for (UINT bar = 0; bar < PCI_TYPE0_ADDRESSES; bar++) 70 | { 71 | m_Bars[bar].Unmap(); 72 | } 73 | } 74 | 75 | bool Init(PVOID pvDeviceContext, PVOID pResList); 76 | 77 | ULONG GetBarSize(UINT bar) 78 | { 79 | ASSERT(bar < PCI_TYPE0_ADDRESSES); 80 | return m_Bars[bar].GetSize(); 81 | } 82 | 83 | USHORT GetInterruptFlags() 84 | { 85 | return m_InterruptFlags; 86 | } 87 | 88 | BOOLEAN IsMSIEnabled() 89 | { 90 | return (m_InterruptFlags & CM_RESOURCE_INTERRUPT_MESSAGE); 91 | } 92 | 93 | CPciBar* GetPciBar(UINT bar) 94 | { 95 | ASSERT(bar < PCI_TYPE0_ADDRESSES); 96 | if (bar < PCI_TYPE0_ADDRESSES) 97 | { 98 | return &m_Bars[bar]; 99 | } 100 | return NULL; 101 | } 102 | 103 | PVOID GetMappedAddress(UINT bar, ULONG uOffset); 104 | 105 | private: 106 | PDXGKRNL_INTERFACE m_pDxgkInterface; 107 | USHORT m_InterruptFlags; 108 | CPciBar m_Bars[PCI_TYPE0_ADDRESSES]; 109 | PVOID m_pvDeviceContext; 110 | }; 111 | 112 | NTSTATUS 113 | MapFrameBuffer( 114 | _In_ PHYSICAL_ADDRESS PhysicalAddress, 115 | _In_ ULONG Length, 116 | _Outptr_result_bytebuffer_(Length) VOID** VirtualAddress); 117 | 118 | NTSTATUS 119 | UnmapFrameBuffer( 120 | _In_reads_bytes_(Length) VOID* VirtualAddress, 121 | _In_ ULONG Length); 122 | 123 | -------------------------------------------------------------------------------- /DVServerUMD/DVEnabler/DVEnabler.rc: -------------------------------------------------------------------------------- 1 | /*=========================================================================== 2 | ; DVEnabler.rc 3 | ;---------------------------------------------------------------------------- 4 | ; Copyright (C) 2021 Intel Corporation 5 | ; SPDX-License-Identifier: MIT 6 | ; 7 | ; File Description: 8 | ; This file will have the DVEnabler resources 9 | ;--------------------------------------------------------------------------*/ 10 | 11 | #include 12 | 13 | VS_VERSION_INFO VERSIONINFO 14 | FILEVERSION ${FileVersion} 15 | PRODUCTVERSION ${ProductVersion} 16 | BEGIN 17 | BLOCK "StringFileInfo" 18 | BEGIN 19 | BLOCK "040904B0" 20 | BEGIN 21 | VALUE "FileVersion", "${FileVersion}" 22 | VALUE "ProductVersion", "${ProductVersionString}" 23 | VALUE "ProductName", "DVEnabler.dll" 24 | VALUE "LegalCopyright", "Copyright (C) 2021 Intel Corporation" 25 | VALUE "FileDescription", "Display Virtualization Monitor Switching Service" 26 | END 27 | END 28 | BLOCK "VarFileInfo" 29 | BEGIN 30 | VALUE "Translation", 0x409, 1200 31 | END 32 | END 33 | -------------------------------------------------------------------------------- /DVServerUMD/DVEnabler/DVEnabler.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;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 | 29 | 30 | Source Files 31 | 32 | 33 | Source Files 34 | 35 | 36 | Source Files 37 | 38 | 39 | Source Files 40 | 41 | 42 | -------------------------------------------------------------------------------- /DVServerUMD/DVEnabler/DVEnabler_Version.txt: -------------------------------------------------------------------------------- 1 | /*=========================================================================== 2 | ; DVEnabler_Version.txt 3 | ;---------------------------------------------------------------------------- 4 | ; Copyright (C) 2021 Intel Corporation 5 | ; SPDX-License-Identifier: MIT 6 | ; 7 | ; File Description: 8 | ; This file will have the DVEnabler version 9 | ;--------------------------------------------------------------------------*/ 10 | 11 | DVEnabler_Version = 4.0.0 -------------------------------------------------------------------------------- /DVServerUMD/DVEnabler/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright © 2021-2024 Intel Corporation 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 7 | of the Software, and to permit persons to whom the Software is furnished to do 8 | so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | 21 | SPDX-License-Identifier: MIT 22 | -------------------------------------------------------------------------------- /DVServerUMD/DVEnabler/Trace.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define WPP_CONTROL_GUIDS WPP_DEFINE_CONTROL_GUID(DVEnablerGuid, (5E6BE9AC, 16AC, 40C9, BBC1, A7D39E3F463F), \ 4 | WPP_DEFINE_BIT(verbose) \ 5 | WPP_DEFINE_BIT(information) \ 6 | WPP_DEFINE_BIT(error) \ 7 | WPP_DEFINE_BIT(ftrace) \ 8 | WPP_DEFINE_BIT(warning)) 9 | 10 | #define WPP_FLAG_LEVEL_LOGGER(flag, level) \ 11 | WPP_LEVEL_LOGGER(flag) 12 | 13 | #define WPP_FLAG_LEVEL_ENABLED(flag, level) \ 14 | (WPP_LEVEL_ENABLED(flag) && \ 15 | WPP_CONTROL(WPP_BIT_ ## flag).Level >= level) 16 | 17 | #define WPP_LEVEL_FLAGS_LOGGER(lvl,flags) \ 18 | WPP_LEVEL_LOGGER(flags) 19 | 20 | #define WPP_LEVEL_FLAGS_ENABLED(lvl, flags) \ 21 | (WPP_LEVEL_ENABLED(flags) && WPP_CONTROL(WPP_BIT_ ## flags).Level >= lvl) 22 | 23 | 24 | class tracer { 25 | private: 26 | char* m_func_name; 27 | public: 28 | tracer(const char* func_name); 29 | ~tracer(); 30 | }; 31 | #define TRACING() tracer trace(__FUNCTION__) 32 | 33 | // 34 | // This comment block is scanned by the trace preprocessor to define our 35 | // Trace function. 36 | // 37 | // begin_wpp config 38 | // FUNC ERR{LEVEL=TRACE_LEVEL_ERROR,FLAGS=error}(MSG,...); 39 | // FUNC WARN{LEVEL=TRACE_LEVEL_WARNING,FLAGS=warning}(MSG,...); 40 | // FUNC WARNING{LEVEL=TRACE_LEVEL_WARNING,FLAGS=warning}(MSG,...); 41 | // FUNC INFO{LEVEL=TRACE_LEVEL_INFORMATION,FLAGS=information}(MSG,...); 42 | // FUNC DBGPRINT{LEVEL=TRACE_LEVEL_INFORMATION,FLAGS=verbose}(MSG,...); 43 | // FUNC FuncTrace{LEVEL=TRACE_LEVEL_INFORMATION,FLAGS=ftrace}(MSG, ...); 44 | // USEPREFIX(ERR, "%!STDPREFIX! [%!FUNC!:%!LINE!] [ERR] \t"); 45 | // USEPREFIX(WARN, "%!STDPREFIX! [%!FUNC!:%!LINE!] [WARN] \t"); 46 | // USEPREFIX(WARNING, "%!STDPREFIX! [%!FUNC!:%!LINE!] [WARN] \t"); 47 | // USEPREFIX(DBGPRINT, "%!STDPREFIX! [%!FUNC!:%!LINE!] [DBG] \t"); 48 | // USEPREFIX(INFO, "%!STDPREFIX! [%!FUNC!:%!LINE!] [INFO] \t"); 49 | // end_wpp 50 | 51 | -------------------------------------------------------------------------------- /DVServerUMD/DVEnabler/Tracing.cpp: -------------------------------------------------------------------------------- 1 | /*=========================================================================== 2 | ; Tracing.cpp 3 | ;---------------------------------------------------------------------------- 4 | ; Copyright (C) 2021 Intel Corporation 5 | ; SPDX-License-Identifier: MIT 6 | ; 7 | ; File Description: 8 | ; This file contains function tracing entry and exits calls. 9 | ;--------------------------------------------------------------------------*/ 10 | 11 | 12 | #include "pch.h" 13 | #include "Trace.h" 14 | #include "Tracing.tmh" 15 | 16 | 17 | /******************************************************************************* 18 | * 19 | * Description 20 | * 21 | * tracer is a constructor member function of the class tracer called to mark the entry of the function. 22 | * 23 | * Parameters 24 | * func_name - Function name. 25 | * 26 | * 27 | ******************************************************************************/ 28 | tracer::tracer(const char* func_name) 29 | { 30 | FuncTrace(">>> %s\n", func_name); 31 | m_func_name = (char*)func_name; 32 | } 33 | /******************************************************************************* 34 | * 35 | * Description 36 | * 37 | * tracer is a destructor member function of the class tracer called to mark exit of the function. 38 | * 39 | * Parameters 40 | * func_name - Function name. 41 | * 42 | * 43 | ******************************************************************************/ 44 | tracer::~tracer() 45 | { 46 | FuncTrace("<<< %s\n", m_func_name); 47 | } -------------------------------------------------------------------------------- /DVServerUMD/DVEnabler/UpdateVersion.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 1.0.0.0 5 | 1.0.0.0 6 | 7 | 8 | 9 | 10 | DVEnabler.rc 11 | $([System.IO.File]::ReadAllText('$(VersionFile)')) 12 | 13 | 14 | $([System.String]::Copy($(FdvenablerVersion)).Split('.')[0]) 15 | $([System.String]::Copy($(FdvenablerVersion)).Split('.')[1]) 16 | $([System.String]::Copy($(FdvenablerVersion)).Split('.')[2]) 17 | $([System.String]::Copy($(FdvenablerVersion)).Split('.')[3]) 18 | 19 | $([System.String]::Copy($(PdvsenablerVersion)).Split('.')[0]) 20 | $([System.String]::Copy($(PdvsenablerVersion)).Split('.')[1]) 21 | $([System.String]::Copy($(PdvsenablerVersion)).Split('.')[2]) 22 | $([System.String]::Copy($(PdvsenablerVersion)).Split('.')[3]) 23 | 24 | 25 | $([System.Text.RegularExpressions.Regex]::Replace($(FileContent), '\$\{FileVersion\}', '$(FileVersionMajor),$(FileVersionMinor),$(FileVersionBuild),$(FileVersionRevision)')) 26 | $([System.Text.RegularExpressions.Regex]::Replace($(FileContent), '\$\{ProductVersion\}', '$(ProductVersionMajor),$(ProductVersionMinor),$(ProductVersionBuild),$(ProductVersionRevision)')) 27 | $([System.Text.RegularExpressions.Regex]::Replace($(FileContent), '\$\{ProductVersionString\}', '$(PdvsenablerVersion)')) 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /DVServerUMD/DVEnabler/dllmain.cpp: -------------------------------------------------------------------------------- 1 | // dllmain.cpp : Defines the entry point for the DLL application. 2 | #include "pch.h" 3 | 4 | BOOL APIENTRY DllMain(HMODULE hModule, 5 | DWORD ul_reason_for_call, 6 | LPVOID lpReserved 7 | ) 8 | { 9 | UNREFERENCED_PARAMETER(lpReserved); 10 | UNREFERENCED_PARAMETER(hModule); 11 | dvenabler_init(); 12 | switch (ul_reason_for_call) 13 | { 14 | case DLL_PROCESS_ATTACH: 15 | case DLL_THREAD_ATTACH: 16 | case DLL_THREAD_DETACH: 17 | case DLL_PROCESS_DETACH: 18 | break; 19 | } 20 | return TRUE; 21 | } 22 | 23 | -------------------------------------------------------------------------------- /DVServerUMD/DVEnabler/framework.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef WIN32_LEAN_AND_MEAN 4 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 5 | #endif 6 | // Windows Header Files 7 | #include 8 | -------------------------------------------------------------------------------- /DVServerUMD/DVEnabler/pch.cpp: -------------------------------------------------------------------------------- 1 | // pch.cpp: source file corresponding to the pre-compiled header 2 | 3 | #include "pch.h" 4 | 5 | // When you are using pre-compiled headers, this source file is necessary for compilation to succeed. 6 | -------------------------------------------------------------------------------- /DVServerUMD/DVEnabler/pch.h: -------------------------------------------------------------------------------- 1 | // pch.h: This is a precompiled header file. 2 | // Files listed below are compiled only once, improving build performance for future builds. 3 | // This also affects IntelliSense performance, including code completion and many code browsing features. 4 | // However, files listed here are ALL re-compiled if any one of them is updated between builds. 5 | // Do not add files here that you will be updating frequently as this negates the performance advantage. 6 | 7 | #ifndef PCH_H 8 | #define PCH_H 9 | 10 | // add headers that you want to pre-compile here 11 | #include "framework.h" 12 | #include 13 | 14 | /* DVENABLER Error Codes */ 15 | #define DVENABLER_SUCCESS 0 16 | #define DVENABLER_FAILURE -1 17 | 18 | #define HOTPLUG_EVENT L"Global\\HOTPLUG_EVENT" 19 | #define DVE_EVENT L"Global\\DVE_EVENT" 20 | #define DISP_INFO L"Global\\DISP_INFO" 21 | #define DELAY_TIME 50 22 | int dvenabler_init(); 23 | struct disp_info { 24 | int disp_count; 25 | HANDLE mutex; 26 | }; 27 | int GetDisplayCount(disp_info* pdinfo); 28 | int IsSystemLocked(); 29 | #endif //PCH_H 30 | -------------------------------------------------------------------------------- /DVServerUMD/DVServer.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.29728.190 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DVServer", "DVServer\DVServer.vcxproj", "{2D54CB75-8B17-4F11-97DC-847B0244CD46}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|ARM = Debug|ARM 11 | Debug|ARM64 = Debug|ARM64 12 | Debug|x64 = Debug|x64 13 | Debug|x86 = Debug|x86 14 | Release|ARM = Release|ARM 15 | Release|ARM64 = Release|ARM64 16 | Release|x64 = Release|x64 17 | Release|x86 = Release|x86 18 | EndGlobalSection 19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 20 | {2D54CB75-8B17-4F11-97DC-847B0244CD46}.Debug|ARM.ActiveCfg = Debug|ARM 21 | {2D54CB75-8B17-4F11-97DC-847B0244CD46}.Debug|ARM.Build.0 = Debug|ARM 22 | {2D54CB75-8B17-4F11-97DC-847B0244CD46}.Debug|ARM.Deploy.0 = Debug|ARM 23 | {2D54CB75-8B17-4F11-97DC-847B0244CD46}.Debug|ARM64.ActiveCfg = Debug|ARM64 24 | {2D54CB75-8B17-4F11-97DC-847B0244CD46}.Debug|ARM64.Build.0 = Debug|ARM64 25 | {2D54CB75-8B17-4F11-97DC-847B0244CD46}.Debug|ARM64.Deploy.0 = Debug|ARM64 26 | {2D54CB75-8B17-4F11-97DC-847B0244CD46}.Debug|x64.ActiveCfg = Debug|x64 27 | {2D54CB75-8B17-4F11-97DC-847B0244CD46}.Debug|x64.Build.0 = Debug|x64 28 | {2D54CB75-8B17-4F11-97DC-847B0244CD46}.Debug|x64.Deploy.0 = Debug|x64 29 | {2D54CB75-8B17-4F11-97DC-847B0244CD46}.Debug|x86.ActiveCfg = Debug|Win32 30 | {2D54CB75-8B17-4F11-97DC-847B0244CD46}.Debug|x86.Build.0 = Debug|Win32 31 | {2D54CB75-8B17-4F11-97DC-847B0244CD46}.Debug|x86.Deploy.0 = Debug|Win32 32 | {2D54CB75-8B17-4F11-97DC-847B0244CD46}.Release|ARM.ActiveCfg = Release|ARM 33 | {2D54CB75-8B17-4F11-97DC-847B0244CD46}.Release|ARM.Build.0 = Release|ARM 34 | {2D54CB75-8B17-4F11-97DC-847B0244CD46}.Release|ARM.Deploy.0 = Release|ARM 35 | {2D54CB75-8B17-4F11-97DC-847B0244CD46}.Release|ARM64.ActiveCfg = Release|ARM64 36 | {2D54CB75-8B17-4F11-97DC-847B0244CD46}.Release|ARM64.Build.0 = Release|ARM64 37 | {2D54CB75-8B17-4F11-97DC-847B0244CD46}.Release|ARM64.Deploy.0 = Release|ARM64 38 | {2D54CB75-8B17-4F11-97DC-847B0244CD46}.Release|x64.ActiveCfg = Release|x64 39 | {2D54CB75-8B17-4F11-97DC-847B0244CD46}.Release|x64.Build.0 = Release|x64 40 | {2D54CB75-8B17-4F11-97DC-847B0244CD46}.Release|x64.Deploy.0 = Release|x64 41 | {2D54CB75-8B17-4F11-97DC-847B0244CD46}.Release|x86.ActiveCfg = Release|Win32 42 | {2D54CB75-8B17-4F11-97DC-847B0244CD46}.Release|x86.Build.0 = Release|Win32 43 | {2D54CB75-8B17-4F11-97DC-847B0244CD46}.Release|x86.Deploy.0 = Release|Win32 44 | EndGlobalSection 45 | GlobalSection(SolutionProperties) = preSolution 46 | HideSolutionNode = FALSE 47 | EndGlobalSection 48 | GlobalSection(ExtensibilityGlobals) = postSolution 49 | SolutionGuid = {1C92CFF5-AC99-48BC-949B-7E7DD3AA4AD7} 50 | EndGlobalSection 51 | EndGlobal 52 | -------------------------------------------------------------------------------- /DVServerUMD/DVServer/DVServer.inf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/Display-Virtualization-for-Windows-OS/6738cb0d71cd8e154a1543589de3300a087f2d58/DVServerUMD/DVServer/DVServer.inf -------------------------------------------------------------------------------- /DVServerUMD/DVServer/DVServer.rc: -------------------------------------------------------------------------------- 1 | /*=========================================================================== 2 | ; DVServer.rc 3 | ;---------------------------------------------------------------------------- 4 | ; Copyright (C) 2021 Intel Corporation 5 | ; SPDX-License-Identifier: MS-PL 6 | ; 7 | ; File Description: 8 | ; This file will have the DVServer resources 9 | ;--------------------------------------------------------------------------*/ 10 | #include 11 | 12 | VS_VERSION_INFO VERSIONINFO 13 | FILEVERSION ${FileVersion} 14 | PRODUCTVERSION ${ProductVersion} 15 | BEGIN 16 | BLOCK "StringFileInfo" 17 | BEGIN 18 | BLOCK "040904B0" 19 | BEGIN 20 | VALUE "FileVersion", "${FileVersion}" 21 | VALUE "ProductVersion", "${ProductVersionString}" 22 | VALUE "ProductName", "DVServer.dll" 23 | VALUE "LegalCopyright", "Copyright (C) 2021 Intel Corporation" 24 | VALUE "FileDescription", "Display Virtualization User Mode Driver " 25 | END 26 | END 27 | BLOCK "VarFileInfo" 28 | BEGIN 29 | VALUE "Translation", 0x409, 1200 30 | END 31 | END 32 | -------------------------------------------------------------------------------- /DVServerUMD/DVServer/DVServerUMD_Version.txt: -------------------------------------------------------------------------------- 1 | /*=========================================================================== 2 | ; DVServerUMD_Version.txt 3 | ;---------------------------------------------------------------------------- 4 | ; Copyright (C) 2021 Intel Corporation 5 | ; SPDX-License-Identifier: MS-PL 6 | ; 7 | ; File Description: 8 | ; This file will have the DVServerUMD version 9 | ;--------------------------------------------------------------------------*/ 10 | 11 | DVServerUMD_Version = 4.0.0 -------------------------------------------------------------------------------- /DVServerUMD/DVServer/DVServercommon.h: -------------------------------------------------------------------------------- 1 | /*=========================================================================== 2 | ; DVServercommon.h 3 | ;---------------------------------------------------------------------------- 4 | ; Copyright (C) 2021 Intel Corporation 5 | ; SPDX-License-Identifier: MS-PL 6 | ; 7 | ; File Description: 8 | ; This file declares the common variables used & related functionalities 9 | ;--------------------------------------------------------------------------*/ 10 | #ifndef __DVSERVER_COMMON_H__ 11 | #define __DVSERVER_COMMON_H__ 12 | 13 | #include "Driver.h" 14 | 15 | /* DVServerUMD Error Codes */ 16 | #define DVSERVERUMD_SUCCESS 0 17 | #define DVSERVERUMD_FAILURE -1 18 | #define MODE_LIST_MAX_SIZE 32 19 | #define MAX_MONITOR_SUPPORTED 4 20 | #define HOTPLUG_EVENT L"Global\\HOTPLUG_EVENT" 21 | #define DVE_EVENT L"Global\\DVE_EVENT" 22 | #define HOTPLUG_TERMINATE_EVENT L"Global\\HOTPLUG_TERMINATE_EVENT" 23 | #define DISP_INFO L"Global\\DISP_INFO" 24 | #define PRIMARY_IDD_INDEX 0 25 | 26 | #endif /* __DVSERVER_COMMON_H__ */ 27 | -------------------------------------------------------------------------------- /DVServerUMD/DVServer/DVServeredid.h: -------------------------------------------------------------------------------- 1 | /*=========================================================================== 2 | ; DVServeredid.h 3 | ;---------------------------------------------------------------------------- 4 | ; Copyright (C) 2021 Intel Corporation 5 | ; SPDX-License-Identifier: MS-PL 6 | ; 7 | ; File Description: 8 | ; This file declares the IOTG IDD edid parser function releted definitions 9 | ;--------------------------------------------------------------------------*/ 10 | #ifndef __DVSERVER_EDID_H__ 11 | #define __DVSERVER_EDID_H__ 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include "Driver.h" 22 | #include "DVServercommon.h" 23 | 24 | 25 | #define WIDTH_UPPER_CAP 3840 //3840x2160 26 | #define WIDTH_LOWER_CAP 1024 //1024x768 27 | #define REFRESH_RATE_59 59 //59Hz 28 | #define REFRESH_RATE_60 60 //60Hz 29 | #define ARRAY_SIZE(x) (sizeof(x)/sizeof((x)[0])) 30 | 31 | int get_total_screens(HANDLE devHandle); 32 | int get_edid_data(HANDLE devHandle, void *m, DWORD id, BOOL d_edid); 33 | int is_blacklist(unsigned int width, unsigned int height); 34 | 35 | #endif /* __DVSERVER_EDID_H__ */ 36 | -------------------------------------------------------------------------------- /DVServerUMD/DVServer/Driver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define NOMINMAX 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #include 16 | #include 17 | 18 | #include "Trace.h" 19 | #include "DVServeredid.h" 20 | #include "..\..\DVServerKMD\Public.h" 21 | 22 | DEFINE_GUID(GUID_DEVINTERFACE_DVSERVERKMD, 23 | 0x1c514918, 0xa855, 0x460a, 0x97, 0xda, 0xed, 0x69, 0x1d, 0xd5, 0x63, 0xcf); 24 | 25 | //#define DVSERVER_HWDCURSOR 26 | 27 | #define DVSERVERUMD_COLORFORMAT 21 // D3DDDIFMT_A8R8G8B8 28 | #define DVSERVER_BBP 4 // 4 Bytes per pixel 29 | #define DEVINFO_FLAGS DIGCF_PRESENT | DIGCF_ALLCLASSES | DIGCF_DEVICEINTERFACE 30 | #define REPORT_FRAME_STATS 60 // we need to report frame stats to OS for every 60 frames 31 | #define PRINT_FREQ 3600 32 | 33 | typedef enum FrameType 34 | { 35 | FRAME_TYPE_INVALID, 36 | FRAME_TYPE_BGRA, // BGRA interleaved: B,G,R,A 32bpp 37 | FRAME_TYPE_RGBA, // RGBA interleaved: R,G,B,A 32bpp 38 | FRAME_TYPE_RGBA10, // RGBA interleaved: R,G,B,A 10,10,10,2 bpp 39 | FRAME_TYPE_YUV420, // YUV420 40 | FRAME_TYPE_MAX, // sentinel value 41 | } 42 | FrameType; 43 | 44 | #ifdef DVSERVER_HWDCURSOR 45 | typedef struct CursorData 46 | { 47 | INT cursor_x; 48 | INT cursor_y; 49 | UINT16 iscursorvisible; 50 | UINT32 cursor_version; 51 | UINT16 cursor_type; 52 | UINT32 width; 53 | UINT32 height; 54 | UINT32 pitch; 55 | void* data; 56 | }CursorData; 57 | #endif //end of DVSERVER_HWDCURSOR 58 | 59 | 60 | namespace Microsoft 61 | { 62 | namespace WRL 63 | { 64 | namespace Wrappers 65 | { 66 | // Adds a wrapper for thread handles to the existing set of WRL handle wrapper classes 67 | typedef HandleT Thread; 68 | } 69 | } 70 | } 71 | 72 | namespace Microsoft 73 | { 74 | namespace IndirectDisp 75 | { 76 | /// 77 | /// Manages the creation and lifetime of a Direct3D render device. 78 | /// 79 | struct IndirectSampleMonitor 80 | { 81 | static constexpr size_t szEdidBlock = 256; 82 | static constexpr size_t szModeList = 32; 83 | 84 | BYTE pEdidBlock[szEdidBlock]; 85 | struct SampleMonitorMode { 86 | DWORD Width; 87 | DWORD Height; 88 | DWORD VSync; 89 | } pModeList[szModeList]; 90 | DWORD ulPreferredModeIdx; 91 | }; 92 | 93 | /// 94 | /// Manages the creation and lifetime of a Direct3D render device. 95 | /// 96 | struct Direct3DDevice 97 | { 98 | Direct3DDevice(LUID AdapterLuid); 99 | Direct3DDevice(); 100 | HRESULT Init(); 101 | 102 | LUID AdapterLuid; 103 | Microsoft::WRL::ComPtr DxgiFactory; 104 | Microsoft::WRL::ComPtr Adapter; 105 | Microsoft::WRL::ComPtr Device; 106 | Microsoft::WRL::ComPtr DeviceContext; 107 | }; 108 | 109 | class DeviceInfo { 110 | private: 111 | PSP_DEVICE_INTERFACE_DETAIL_DATA device_iface_data; 112 | HDEVINFO devinfo_handle; 113 | HANDLE devHandle_frame; 114 | public: 115 | DeviceInfo(); 116 | ~DeviceInfo(); 117 | int get_dvserver_kmdf_device(); 118 | HANDLE get_Handle() { return devHandle_frame; } 119 | }; 120 | 121 | /// 122 | /// Manages a thread that consumes buffers from an indirect display swap-chain object. 123 | /// 124 | class SwapChainProcessor 125 | { 126 | public: 127 | SwapChainProcessor(IDDCX_SWAPCHAIN hSwapChain, std::shared_ptr Device, HANDLE NewFrameEvent, UINT MonitorIndex); 128 | ~SwapChainProcessor(); 129 | int GetFrameData(std::shared_ptr idd_device, ID3D11Texture2D* desktopimage); 130 | void cleanup_resources(); 131 | void report_frame_statistics(IDARG_OUT_RELEASEANDACQUIREBUFFER Buffer); 132 | void init(); 133 | 134 | private: 135 | static DWORD CALLBACK RunThread(LPVOID Argument); 136 | void Run(); 137 | void RunCore(); 138 | 139 | IDDCX_SWAPCHAIN m_hSwapChain; 140 | std::shared_ptr m_Device; 141 | HANDLE m_hAvailableBufferEvent; 142 | Microsoft::WRL::Wrappers::Thread m_hThread; 143 | Microsoft::WRL::Wrappers::Event m_hTerminateEvent; 144 | int m_screen_num, print_counter; 145 | 146 | //FrameMetaData related 147 | ID3D11Texture2D* m_destimage; 148 | ID3D11Texture2D* m_IAcquiredDesktopImage; 149 | D3D11_MAPPED_SUBRESOURCE m_staging_buffer; 150 | D3D11_TEXTURE2D_DESC m_input_desc, m_staging_desc; 151 | uint32_t m_width, m_height, m_pitch, m_stride; 152 | FrameType m_format; 153 | HANDLE m_GPUResourceMutex; 154 | uint32_t m_frame_statistics_counter; 155 | BOOL m_resolution_changed; 156 | 157 | //IOCTL related buffers 158 | ULONG m_ioctlresp_size; 159 | struct FrameMetaData* m_framedata; 160 | struct KMDF_IOCTL_Response* m_ioctlresp_frame; 161 | 162 | #ifdef DVSERVER_HWDCURSOR 163 | //Cursor related 164 | struct CursorData* m_cursordata; 165 | struct KMDF_IOCTL_Response* m_ioctlresp_cursor; 166 | IDARG_OUT_QUERY_HWCURSOR m_outputargs; 167 | HANDLE cursorthread_handle; 168 | 169 | void GetCursorData(); 170 | static DWORD CALLBACK CursorThread(LPVOID Argument); 171 | 172 | #endif //end of DVSERVER_HWDCURSOR 173 | }; 174 | 175 | /// 176 | /// Provides a sample implementation of an indirect display driver. 177 | /// 178 | class IndirectDeviceContext 179 | { 180 | public: 181 | IndirectDeviceContext(_In_ WDFDEVICE WdfDevice); 182 | virtual ~IndirectDeviceContext(); 183 | 184 | void InitAdapter(WDF_POWER_DEVICE_STATE PreviousState); 185 | void FinishInit(UINT ConnectorIndex); 186 | static DWORD CALLBACK HPDThread(LPVOID Argument); 187 | 188 | protected: 189 | WDFDEVICE m_WdfDevice; 190 | IDDCX_ADAPTER m_Adapter; 191 | }; 192 | 193 | class IndirectMonitorContext 194 | { 195 | public: 196 | IndirectMonitorContext(_In_ IDDCX_MONITOR Monitor, _In_ UINT ConnectorIndex); 197 | virtual ~IndirectMonitorContext(); 198 | 199 | void AssignSwapChain(IDDCX_SWAPCHAIN SwapChain, LUID RenderAdapter, HANDLE NewFrameEvent); 200 | void UnassignSwapChain(); 201 | 202 | #ifdef DVSERVER_HWDCURSOR 203 | void SetupIDDCursor(IDDCX_PATH* pPath); 204 | #endif //end of DVSERVER_HWDCURSOR 205 | 206 | private: 207 | IDDCX_MONITOR m_Monitor; 208 | UINT m_MonitorIndex; 209 | std::unique_ptr m_ProcessingThread; 210 | }; 211 | } 212 | } 213 | int hpd_event_create(IDDCX_ADAPTER AdapterObject); 214 | int get_hpd_data(HANDLE devHandle, struct hp_info* data); 215 | struct disp_info { 216 | int disp_count; 217 | HANDLE mutex; 218 | }; 219 | 220 | struct monitor_info { 221 | bool status; 222 | static constexpr size_t szEdidBlock = 256; 223 | BYTE pEdidBlock[szEdidBlock]; 224 | }; 225 | -------------------------------------------------------------------------------- /DVServerUMD/DVServer/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (C) 2021-2024 Intel Corporation 2 | 3 | This license governs use of the accompanying software. If you use the software, 4 | you accept this license. If you do not accept the license, do not use the 5 | software. 6 | 7 | 1. Definitions 8 | The terms “reproduce,” “reproduction,” “derivative works,” and “distribution” 9 | have the same meaning here as under U.S. copyright law. 10 | 11 | A “contribution” is the original software, or any additions or changes to the 12 | software. 13 | 14 | A “contributor” is any person that distributes its contribution under this 15 | license. 16 | 17 | “Licensed patents” are a contributor’s patent claims that read directly on its 18 | contribution. 19 | 20 | 2. Grant of Rights 21 | 22 | (A) Copyright Grant- Subject to the terms of this license, including the 23 | license conditions and limitations in section 3, each contributor grants you a 24 | non-exclusive, worldwide, royalty-free copyright license to reproduce its 25 | contribution, prepare derivative works of its contribution, and distribute its 26 | contribution or any derivative works that you create. 27 | 28 | (B) Patent Grant- Subject to the terms of this license, including the license 29 | conditions and limitations in section 3, each contributor grants you a 30 | non-exclusive, worldwide, royalty-free license under its licensed patents to 31 | make, have made, use, sell, offer for sale, import, and/or otherwise dispose of 32 | its contribution in the software or derivative works of the contribution in the 33 | software. 34 | 35 | 3. Conditions and Limitations 36 | 37 | (A) No Trademark License- This license does not grant you rights to use any 38 | contributors’ name, logo, or trademarks. 39 | 40 | (B) If you bring a patent claim against any contributor over patents that you 41 | claim are infringed by the software, your patent license from such contributor 42 | to the software ends automatically. 43 | 44 | (C) If you distribute any portion of the software, you must retain all 45 | copyright, patent, trademark, and attribution notices that are present in the 46 | software. 47 | 48 | (D) If you distribute any portion of the software in source code form, you may 49 | do so only under this license by including a complete copy of this license with 50 | your distribution. If you distribute any portion of the software in compiled or 51 | object code form, you may only do so under a license that complies with this 52 | license. 53 | 54 | (E) The software is licensed “as-is.” You bear the risk of using it. The 55 | contributors give no express warranties, guarantees or conditions. You may have 56 | additional consumer rights under your local laws which this license cannot 57 | change. To the extent permitted under your local laws, the contributors exclude 58 | the implied warranties of merchantability, fitness for a particular purpose and 59 | non-infringement. 60 | 61 | SPDX-License-Identifier: MS-PL 62 | -------------------------------------------------------------------------------- /DVServerUMD/DVServer/Trace.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define WPP_CONTROL_GUIDS WPP_DEFINE_CONTROL_GUID(DVserverUMDGuid, (351BC0B2, 53AB, 4C14, 8851, 3B80F878BADC), \ 4 | WPP_DEFINE_BIT(verbose) \ 5 | WPP_DEFINE_BIT(information) \ 6 | WPP_DEFINE_BIT(error) \ 7 | WPP_DEFINE_BIT(ftrace) \ 8 | WPP_DEFINE_BIT(warning)) 9 | 10 | #define WPP_FLAG_LEVEL_LOGGER(flag, level) \ 11 | WPP_LEVEL_LOGGER(flag) 12 | 13 | #define WPP_FLAG_LEVEL_ENABLED(flag, level) \ 14 | (WPP_LEVEL_ENABLED(flag) && \ 15 | WPP_CONTROL(WPP_BIT_ ## flag).Level >= level) 16 | 17 | #define WPP_LEVEL_FLAGS_LOGGER(lvl,flags) \ 18 | WPP_LEVEL_LOGGER(flags) 19 | 20 | #define WPP_LEVEL_FLAGS_ENABLED(lvl, flags) \ 21 | (WPP_LEVEL_ENABLED(flags) && WPP_CONTROL(WPP_BIT_ ## flags).Level >= lvl) 22 | 23 | class tracer { 24 | private: 25 | char* m_func_name; 26 | public: 27 | tracer(const char* func_name); 28 | ~tracer(); 29 | }; 30 | 31 | #define TRACING() tracer trace(__FUNCTION__) 32 | // 33 | // This comment block is scanned by the trace preprocessor to define our 34 | // Trace function. 35 | // 36 | // begin_wpp config 37 | // FUNC ERR{LEVEL=TRACE_LEVEL_ERROR,FLAGS=error}(MSG,...); 38 | // FUNC WARN{LEVEL=TRACE_LEVEL_WARNING,FLAGS=warning}(MSG,...); 39 | // FUNC INFO{LEVEL=TRACE_LEVEL_INFORMATION,FLAGS=information}(MSG,...); 40 | // FUNC DBGPRINT{LEVEL=TRACE_LEVEL_INFORMATION,FLAGS=verbose}(MSG,...); 41 | // FUNC FuncTrace{LEVEL=TRACE_LEVEL_INFORMATION,FLAGS=ftrace}(MSG, ...); 42 | // USEPREFIX(ERR, "%!STDPREFIX! [%!FUNC!:%!LINE!] [ERR] \t"); 43 | // USEPREFIX(WARN, "%!STDPREFIX! [%!FUNC!:%!LINE!] [WARN] \t"); 44 | // USEPREFIX(DBGPRINT, "%!STDPREFIX! [%!FUNC!:%!LINE!] [DBG] \t"); 45 | // USEPREFIX(INFO, "%!STDPREFIX! [%!FUNC!:%!LINE!] [INFO] \t"); 46 | // end_wpp 47 | 48 | -------------------------------------------------------------------------------- /DVServerUMD/DVServer/Tracing.cpp: -------------------------------------------------------------------------------- 1 | /*=========================================================================== 2 | ; Tracing.cpp 3 | ;---------------------------------------------------------------------------- 4 | ; Copyright (C) 2021 Intel Corporation 5 | ; SPDX-License-Identifier: MS-PL 6 | ; 7 | ; File Description: 8 | ; This file defines tracing definitions. 9 | ;--------------------------------------------------------------------------*/ 10 | 11 | #include "Driver.h" 12 | #include "Trace.h" 13 | #include "tracing.tmh" 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | /******************************************************************************* 20 | * 21 | * Description 22 | * 23 | * tracer is a constructor member function of the class tracer invoked to mark the entry of the function. 24 | * 25 | * Parameters 26 | * func_name - Function name. 27 | * 28 | * 29 | ******************************************************************************/ 30 | tracer::tracer(const char* func_name) 31 | { 32 | FuncTrace(">>> %s\n", func_name); 33 | m_func_name = (char*)func_name; 34 | } 35 | /******************************************************************************* 36 | * 37 | * Description 38 | * 39 | * ~tracer is a destructor member function of the class tracer invoked to mark the exit of the function. 40 | * 41 | * Parameters 42 | * func_name - Function name. 43 | * 44 | * 45 | ******************************************************************************/ 46 | tracer::~tracer() 47 | { 48 | FuncTrace("<<< %s\n", m_func_name); 49 | } -------------------------------------------------------------------------------- /DVServerUMD/DVServer/UpdateVersion.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 1.0.0.0 5 | 1.0.0.0 6 | 7 | 8 | 9 | 10 | DVServer.rc 11 | $([System.IO.File]::ReadAllText('$(VersionFile)')) 12 | 13 | 14 | $([System.String]::Copy($(FdvserverumdVersion)).Split('.')[0]) 15 | $([System.String]::Copy($(FdvserverumdVersion)).Split('.')[1]) 16 | $([System.String]::Copy($(FdvserverumdVersion)).Split('.')[2]) 17 | $([System.String]::Copy($(FdvserverumdVersion)).Split('.')[3]) 18 | 19 | $([System.String]::Copy($(PdvserverumdVersion)).Split('.')[0]) 20 | $([System.String]::Copy($(PdvserverumdVersion)).Split('.')[1]) 21 | $([System.String]::Copy($(PdvserverumdVersion)).Split('.')[2]) 22 | $([System.String]::Copy($(PdvserverumdVersion)).Split('.')[3]) 23 | 24 | 25 | $([System.Text.RegularExpressions.Regex]::Replace($(FileContent), '\$\{FileVersion\}', '$(FileVersionMajor),$(FileVersionMinor),$(FileVersionBuild),$(FileVersionRevision)')) 26 | $([System.Text.RegularExpressions.Regex]::Replace($(FileContent), '\$\{ProductVersion\}', '$(ProductVersionMajor),$(ProductVersionMinor),$(ProductVersionBuild),$(ProductVersionRevision)')) 27 | $([System.Text.RegularExpressions.Regex]::Replace($(FileContent), '\$\{ProductVersionString\}', '$(PdvserverumdVersion)')) 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /DVServerUMD/LICENSE: -------------------------------------------------------------------------------- 1 | This folder contains various sub-folders and files, each of which may be 2 | subject to different copyright and licensing terms. For relevant licensing 3 | information, please refer to the LICENSE or COPYING file located within each 4 | specific folder, or check the notations within each individual file. 5 | -------------------------------------------------------------------------------- /DVServerUMD/README.md: -------------------------------------------------------------------------------- 1 | --- 2 | topic: sample 3 | page_type: sample 4 | languages: 5 | - cpp 6 | products: 7 | - windows 8 | - windows-wdk 9 | name: 'IddSample' 10 | description: "Implements a sample IddCx 1.4 driver and a sample application that instantiates a software device using it." 11 | statusNotificationTargets: 12 | - dspkdev@microsoft.com 13 | --- 14 | 15 | # Indirect Display Driver Sample # 16 | 17 | This is a sample driver that shows how to create a Windows Indirect Display Driver using IddCx (Indirect Display Driver Class eXtension). 18 | 19 | ## Background reading ## 20 | 21 | Start at the [Indirect Display Driver Model Overview](https://msdn.microsoft.com/en-us/library/windows/hardware/mt761968(v=vs.85).aspx) on MSDN. 22 | 23 | ## Customizing the sample ## 24 | 25 | The sample driver code is very simplistic and does nothing more than enumerate a single monitor when its device enters the D0/started power state. Throughout the code, there are `TODO` blocks with important information on implementing functionality in a production driver. 26 | 27 | ### Code structure ### 28 | 29 | * `Direct3DDevice` class 30 | * Contains logic for enumerating the correct render GPU from DXGI and creating a D3D device. 31 | * Manages the lifetime of a DXGI factory and a D3D device created for the render GPU the system is using to render frames for your indirect display device's swap-chain. 32 | * `SwapChainProcessor` class 33 | * Processes frames for a swap-chain assigned to the monitor object on a dedicated thread. 34 | * The sample code does nothing with the frames, but demonstrates a correct processing loop with error handling and notifying the OS of frame completion. 35 | * `IndirectDeviceContext` class 36 | * Processes device callbacks from IddCx. 37 | * Manages the creation and arrival of the sample monitor. 38 | * Handles swap-chain arrival and departure by creating a `Direct3DDevice` and handing it off to a `SwapChainProcessor`. 39 | 40 | ### First steps ### 41 | 42 | Consider the capabilities of your device. If the device supports multiple monitors being hotplugged and removed at runtime, you may want to abstract the monitors further from the `IndirectDeviceContext` class. 43 | 44 | The INF file included in the sample needs updating for production use. One field, `DeviceGroupId`, controls how the UMDF driver gets pooled with other UMDF drivers in the same process. Since indirect display drivers tend to be more complicated than other driver classes, it's highly recommended that you pick a unique string for this field which will cause instances of your device driver to pool in a dedicated process. This will improve system reliability in case your driver encounters a problem since other drivers will not be affected. 45 | 46 | Ensure the device information reported to `IddCxAdapterInitAsync` is accurate. This information determines how the device is reported to the OS and what static features (like support for gamma tables) the device will have available. If some information cannot be known immediately in the `EvtDeviceD0Entry` callback, IddCx allows the driver to call `IddCxAdapterInitAsync` at any point after D0 entry, before D0 exit. 47 | 48 | Careful attention should be paid to the frame processing loop. This will directly impact the performance of the user's system, so making use of the [Multimedia Class Scheduler Service](https://msdn.microsoft.com/en-us/library/windows/desktop/ms684247(v=vs.85).aspx) and DXGI's support for [GPU prioritization](https://msdn.microsoft.com/en-us/library/windows/desktop/bb174534(v=vs.85).aspx) should be considered. Any significant work should be performed outside the main processing loop, such as by queuing work in a thread pool. See `SwapChainProcessor::RunCore` for more information. -------------------------------------------------------------------------------- /EDIDParser/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright © 2021-2024 Intel Corporation 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 7 | of the Software, and to permit persons to whom the Software is furnished to do 8 | so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | 21 | SPDX-License-Identifier: MIT 22 | -------------------------------------------------------------------------------- /EDIDParser/edidparser.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.32002.261 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "edidparser", "edidparser.vcxproj", "{7F9F9DEC-8689-4D05-9DC8-FC0125C5254A}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {7F9F9DEC-8689-4D05-9DC8-FC0125C5254A}.Debug|x64.ActiveCfg = Debug|x64 17 | {7F9F9DEC-8689-4D05-9DC8-FC0125C5254A}.Debug|x64.Build.0 = Debug|x64 18 | {7F9F9DEC-8689-4D05-9DC8-FC0125C5254A}.Debug|x86.ActiveCfg = Debug|Win32 19 | {7F9F9DEC-8689-4D05-9DC8-FC0125C5254A}.Debug|x86.Build.0 = Debug|Win32 20 | {7F9F9DEC-8689-4D05-9DC8-FC0125C5254A}.Release|x64.ActiveCfg = Release|x64 21 | {7F9F9DEC-8689-4D05-9DC8-FC0125C5254A}.Release|x64.Build.0 = Release|x64 22 | {7F9F9DEC-8689-4D05-9DC8-FC0125C5254A}.Release|x86.ActiveCfg = Release|Win32 23 | {7F9F9DEC-8689-4D05-9DC8-FC0125C5254A}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {2CAF2ACB-C7C1-4EFB-87DB-8F69844D9CB3} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /EDIDParser/edidparser.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;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 | Source Files 20 | 21 | 22 | 23 | 24 | Header Files 25 | 26 | 27 | Header Files 28 | 29 | 30 | -------------------------------------------------------------------------------- /EDIDParser/edidshared.h: -------------------------------------------------------------------------------- 1 | /*=========================================================================== 2 | ; edidshared.h 3 | ;---------------------------------------------------------------------------- 4 | ; Copyright (C) 2021 Intel Corporation 5 | ; SPDX-License-Identifier: MIT 6 | ;--------------------------------------------------------------------------*/ 7 | 8 | #ifndef __EDID_SHARED_H__ 9 | #define __EDID_SHARED_H__ 10 | 11 | #define OUTPUT_MODELIST_SIZE 32 12 | 13 | struct edid_qemu_modes { 14 | unsigned int width; 15 | unsigned int height; 16 | double refresh_rate; 17 | }; 18 | 19 | struct output_modelist { 20 | struct edid_qemu_modes modelist[OUTPUT_MODELIST_SIZE]; 21 | unsigned int modelist_size; 22 | }; 23 | 24 | int parse_edid_data(unsigned char*, struct output_modelist*); 25 | 26 | #endif //__EDID_SHARED_H__ 27 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | NOTICE 2 | 3 | This package contains various components, each of which are subject to 4 | different copyright and licensing terms. 5 | 6 | -------------------------------------------------------------------------- 7 | MS-PL License 8 | Applicable components: 9 | DVServerUMD 10 | 11 | Copyright (C) 2021-2024 Intel Corporation 12 | 13 | This license governs use of the accompanying software. If you use the software, 14 | you accept this license. If you do not accept the license, do not use the 15 | software. 16 | 17 | 1. Definitions 18 | The terms “reproduce,” “reproduction,” “derivative works,” and “distribution” 19 | have the same meaning here as under U.S. copyright law. 20 | 21 | A “contribution” is the original software, or any additions or changes to the 22 | software. 23 | 24 | A “contributor” is any person that distributes its contribution under this 25 | license. 26 | 27 | “Licensed patents” are a contributor’s patent claims that read directly on its 28 | contribution. 29 | 30 | 2. Grant of Rights 31 | 32 | (A) Copyright Grant- Subject to the terms of this license, including the 33 | license conditions and limitations in section 3, each contributor grants you a 34 | non-exclusive, worldwide, royalty-free copyright license to reproduce its 35 | contribution, prepare derivative works of its contribution, and distribute its 36 | contribution or any derivative works that you create. 37 | 38 | (B) Patent Grant- Subject to the terms of this license, including the license 39 | conditions and limitations in section 3, each contributor grants you a 40 | non-exclusive, worldwide, royalty-free license under its licensed patents to 41 | make, have made, use, sell, offer for sale, import, and/or otherwise dispose of 42 | its contribution in the software or derivative works of the contribution in the 43 | software. 44 | 45 | 3. Conditions and Limitations 46 | 47 | (A) No Trademark License- This license does not grant you rights to use any 48 | contributors’ name, logo, or trademarks. 49 | 50 | (B) If you bring a patent claim against any contributor over patents that you 51 | claim are infringed by the software, your patent license from such contributor 52 | to the software ends automatically. 53 | 54 | (C) If you distribute any portion of the software, you must retain all 55 | copyright, patent, trademark, and attribution notices that are present in the 56 | software. 57 | 58 | (D) If you distribute any portion of the software in source code form, you may 59 | do so only under this license by including a complete copy of this license with 60 | your distribution. If you distribute any portion of the software in compiled or 61 | object code form, you may only do so under a license that complies with this 62 | license. 63 | 64 | (E) The software is licensed “as-is.” You bear the risk of using it. The 65 | contributors give no express warranties, guarantees or conditions. You may have 66 | additional consumer rights under your local laws which this license cannot 67 | change. To the extent permitted under your local laws, the contributors exclude 68 | the implied warranties of merchantability, fitness for a particular purpose and 69 | non-infringement. 70 | 71 | SPDX-License-Identifier: MS-PL 72 | 73 | -------------------------------------------------------------------------- 74 | BSD-3-Clause License 75 | Applicable components: 76 | DVServerKMD 77 | 78 | Copyright (C) 2021-2024 Intel Corporation 79 | 80 | Redistribution and use in source and binary forms, with or without 81 | modification, are permitted provided that the following conditions are met: 82 | 83 | 1. Redistributions of source code must retain the above copyright notice, this 84 | list of conditions and the following disclaimer. 85 | 86 | 2. Redistributions in binary form must reproduce the above copyright notice, 87 | this list of conditions and the following disclaimer in the documentation and/ 88 | or other materials provided with the distribution. 89 | 90 | 3. Neither the name of the copyright holder nor the names of its contributors 91 | may be used to endorse or promote products derived from this software without 92 | specific prior written permission. 93 | 94 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND 95 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 96 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 97 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 98 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 99 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 100 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 101 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 102 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 103 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 104 | 105 | SPDX-License-Identifier: BSD-3-Clause 106 | 107 | -------------------------------------------------------------------------- 108 | MIT License 109 | Applicable components: 110 | EDID Parser Lib 111 | DVEnabler 112 | Scripts 113 | DVInstaller (GUI) 114 | 115 | Copyright © 2021-2024 Intel Corporation 116 | 117 | Permission is hereby granted, free of charge, to any person obtaining a copy of 118 | this software and associated documentation files (the "Software"), to deal in 119 | the Software without restriction, including without limitation the rights to 120 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 121 | of the Software, and to permit persons to whom the Software is furnished to do 122 | so, subject to the following conditions: 123 | 124 | The above copyright notice and this permission notice shall be included in all 125 | copies or substantial portions of the Software. 126 | 127 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 128 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 129 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 130 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 131 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 132 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 133 | SOFTWARE. 134 | 135 | SPDX-License-Identifier: MIT -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | Intel is committed to rapidly addressing security vulnerabilities affecting our customers and providing clear guidance on the solution, impact, severity and mitigation. 3 | 4 | ## Reporting a Vulnerability 5 | Please report any security vulnerabilities in this project utilizing the guidelines [here](https://www.intel.com/content/www/us/en/security-center/vulnerability-handling-guidelines.html). 6 | -------------------------------------------------------------------------------- /Tools/Driver.Initial.props: -------------------------------------------------------------------------------- 1 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | <_NT_TARGET_VERSION>0x0A00 20 | 21 | 22 | <_NT_TARGET_VERSION>0x0603 23 | 24 | 25 | <_NT_TARGET_VERSION>0x0602 26 | 27 | 28 | <_NT_TARGET_VERSION>0x0601 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /Tools/Driver.RHEL.props: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 10 | 11 | <_RHEL_RELEASE_VERSION_ Condition="'$(_RHEL_RELEASE_VERSION_)' == ''">6 12 | 13 | <_BUILD_MAJOR_VERSION_ Condition="'$(_BUILD_MAJOR_VERSION_)' == ''">101 14 | 15 | <_BUILD_MINOR_VERSION_ Condition="'$(_BUILD_MINOR_VERSION_)' == ''">58000 16 | 17 | 18 | 19 | $(_NT_TARGET_MAJ).$(_RHEL_RELEASE_VERSION_).$(_BUILD_MAJOR_VERSION_).$(_BUILD_MINOR_VERSION_) 20 | 21 | 2009 22 | 2015 23 | 2016 24 | 2014 25 | 2018 26 | 2012 27 | 2010 28 | 2008 29 | 2017 30 | 2008 31 | 2018 32 | 2019 33 | 20?? 34 | 35 | 36 | 1 37 | 38 | 1 39 | 40 | 41 | 42 | $(RHEL_COPYRIGHT_STARTING_YEAR)-$(COPYRIGHT_CURRENT_YEAR) 43 | $(COPYRIGHT_CURRENT_YEAR) 44 | 45 | 46 | 47 | 48 | 49 | _BUILD_MAJOR_VERSION_=$(_BUILD_MAJOR_VERSION_);_BUILD_MINOR_VERSION_=$(_BUILD_MINOR_VERSION_);_NT_TARGET_MAJ=$(_NT_TARGET_MAJ);_RHEL_RELEASE_VERSION_=$(_RHEL_RELEASE_VERSION_);%(PreprocessorDefinitions) 50 | RHEL_COPYRIGHT_STARTING_YEAR=$(RHEL_COPYRIGHT_STARTING_YEAR);%(PreprocessorDefinitions) 51 | 52 | 53 | _BUILD_MAJOR_VERSION_=$(_BUILD_MAJOR_VERSION_);_BUILD_MINOR_VERSION_=$(_BUILD_MINOR_VERSION_);_NT_TARGET_MAJ=$(_NT_TARGET_MAJ);_RHEL_RELEASE_VERSION_=$(_RHEL_RELEASE_VERSION_);%(PreprocessorDefinitions) 54 | RHEL_COPYRIGHT_YEARS="$(RHEL_COPYRIGHT_YEARS)";%(PreprocessorDefinitions) 55 | 56 | 57 | 58 | 59 | 60 | Copyright (c) $(RHEL_COPYRIGHT_YEARS) Red Hat Inc. 61 | 62 | 63 | 64 | 65 | 66 | Red Hat, Inc. 67 | 68 | 69 | Red Hat 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /Tools/Driver.VZ.props: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 10 | 11 | 1 12 | 1 13 | 0 14 | 15 | 16 | 17 | 1 18 | 2 19 | $(VZ_RELEASE_N) 20 | 21 | 22 | 23 | 1 24 | 3 25 | 0 26 | 27 | 28 | 29 | $(VZ_RELEASE_A).$(VZ_RELEASE_B).$(VZ_RELEASE_C).$(_NT_TARGET_MAJ) 30 | 31 | 2009 32 | 2015 33 | 2016 34 | 2014 35 | 2018 36 | 2012 37 | 2010 38 | 2008 39 | 2017 40 | 2008 41 | 20?? 42 | 43 | 2016 44 | 2017 45 | 2018 46 | 2019 47 | 48 | 49 | 50 | 51 | $(RHEL_COPYRIGHT_STARTING_YEAR)-$(COPYRIGHT_CURRENT_YEAR) 52 | $(COPYRIGHT_CURRENT_YEAR) 53 | 54 | $(VZ_COPYRIGHT_STARTING_YEAR)-$(COPYRIGHT_CURRENT_YEAR) 55 | $(COPYRIGHT_CURRENT_YEAR) 56 | 57 | 58 | 59 | 60 | Virtuozzo International GmbH 61 | Virtuozzo 62 | Copyright (c) $(VZ_COPYRIGHT_YEARS) $(VZ_VENDOR_NAME) 63 | 1DF0 64 | 65 | 66 | 67 | 68 | 69 | VZ_RELEASE_N=$(VZ_RELEASE_N);%(PreprocessorDefinitions) 70 | VZ_RELEASE_A=$(VZ_RELEASE_A);VZ_RELEASE_B=$(VZ_RELEASE_B);VZ_RELEASE_C=$(VZ_RELEASE_C);_NT_TARGET_MAJ=$(_NT_TARGET_MAJ);%(PreprocessorDefinitions) 71 | RHEL_COPYRIGHT_STARTING_YEAR=$(RHEL_COPYRIGHT_STARTING_YEAR);VZ_COPYRIGHT_STARTING_YEAR=$(VZ_COPYRIGHT_STARTING_YEAR);%(PreprocessorDefinitions) 72 | VZ_VENDOR_NAME=$(VZ_VENDOR_NAME);VZ_VENDOR_PREFIX=$(VZ_VENDOR_PREFIX);VZ_VENDOR_COPYRIGHT=$(VZ_VENDOR_COPYRIGHT);%(PreprocessorDefinitions) 73 | 74 | 75 | VZ_RELEASE_N=$(VZ_RELEASE_N);%(PreprocessorDefinitions) 76 | VZ_RELEASE_A=$(VZ_RELEASE_A);VZ_RELEASE_B=$(VZ_RELEASE_B);VZ_RELEASE_C=$(VZ_RELEASE_C);_NT_TARGET_MAJ=$(_NT_TARGET_MAJ);%(PreprocessorDefinitions) 77 | RHEL_COPYRIGHT_STARTING_YEAR=$(RHEL_COPYRIGHT_STARTING_YEAR);VZ_COPYRIGHT_STARTING_YEAR=$(VZ_COPYRIGHT_STARTING_YEAR);%(PreprocessorDefinitions) 78 | VZ_VENDOR_NAME=$(VZ_VENDOR_NAME);VZ_VENDOR_PREFIX=$(VZ_VENDOR_PREFIX);VZ_VENDOR_COPYRIGHT=$(VZ_VENDOR_COPYRIGHT);%(PreprocessorDefinitions) 79 | 80 | 81 | 82 | 83 | 84 | Copyright (c) $(RHEL_COPYRIGHT_YEARS) Red Hat Inc. 85 | 86 | 87 | $(VZ_VENDOR_COPYRIGHT) 88 | 89 | 90 | $(VZ_VENDOR_NAME) 91 | 92 | 93 | $(VZ_VENDOR_PREFIX) 94 | 95 | 96 | $(VZ_VENDOR_PREFIX) 97 | 98 | 99 | $(VZ_VENDOR_PREFIX) 100 | 101 | 102 | 103 | -------------------------------------------------------------------------------- /Tools/Driver.Vendor.props: -------------------------------------------------------------------------------- 1 | 16 | 17 | 18 | 19 | <_VENDOR_ Condition="'$(_VENDOR_)'=='' OR '$(Feature_AlwaysDefaultVendor)'!='false'">RHEL 20 | 2020 21 | 22 | 23 | 24 | x86 25 | 26 | 27 | x64 28 | 29 | 30 | ARM64 31 | 32 | 33 | 34 | 35 | 36 | 37 | 1AF4 38 | 39 | 40 | 41 | $(SUBSYSTEM_VENDOR_ID) 42 | 43 | 44 | 45 | 46 | 47 | 48 | VENDOR_VER=$(_VENDOR_).ver;VER_OS=$(TargetOS);VER_ARCH=$(VerArch);%(PreprocessorDefinitions) 49 | COPYRIGHT_CURRENT_YEAR=$(COPYRIGHT_CURRENT_YEAR);%(PreprocessorDefinitions) 50 | 51 | 52 | VENDOR_VER=$(_VENDOR_).ver;VER_OS=$(TargetOS);VER_ARCH=$(VerArch);%(PreprocessorDefinitions) 53 | COPYRIGHT_CURRENT_YEAR=$(COPYRIGHT_CURRENT_YEAR);%(PreprocessorDefinitions) 54 | 55 | 56 | $(STAMPINF_VERSION) 57 | 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /Tools/InstallCertificate.bat: -------------------------------------------------------------------------------- 1 | certmgr.exe -add VirtIOTestCert.cer -s -r localMachine root 2 | certmgr.exe -add VirtIOTestCert.cer -s -r localMachine trustedpublisher 3 | -------------------------------------------------------------------------------- /Tools/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2009-2017 Red Hat, Inc. and/or its affiliates. 2 | Copyright 2016 Virtuozzo, Inc. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | 8 | Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 11 | Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | 15 | Neither the name of the copyright holder nor the names of its 16 | contributors may be used to endorse or promote products derived from 17 | this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /Tools/SetVsEnv.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | if not "%VSFLAVOR%"=="" goto :knownVS 3 | call :checkvs 4 | echo USING %VSFLAVOR% Visual Studio 5 | 6 | :knownVS 7 | echo %0: Setting NATIVE ENV for %1 (VS %VSFLAVOR%)... 8 | call "C:\Program Files (x86)\Microsoft Visual Studio\2017\%VSFLAVOR%\VC\Auxiliary\Build\vcvarsall.bat" %1 9 | goto :eof 10 | 11 | :checkvs 12 | set VSFLAVOR=Professional 13 | if exist "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" set VSFLAVOR=Community 14 | goto :eof 15 | -------------------------------------------------------------------------------- /Tools/VirtIOTestCert.cer: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/Display-Virtualization-for-Windows-OS/6738cb0d71cd8e154a1543589de3300a087f2d58/Tools/VirtIOTestCert.cer -------------------------------------------------------------------------------- /Tools/VirtIOTestCert.pfx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/Display-Virtualization-for-Windows-OS/6738cb0d71cd8e154a1543589de3300a087f2d58/Tools/VirtIOTestCert.pfx -------------------------------------------------------------------------------- /Tools/pushpdbREADME.txt: -------------------------------------------------------------------------------- 1 | This script adds a pdb file to the specified symbol store. 2 | 3 | Usage: 4 | 5 | %~0 [-u] [Path] 6 | 7 | 8 | -u [Path] Download a remote file (zip or rpm) and push pdbs. 9 | NOTE: Path MUST BE a URL. 10 | [Path] Push pdbs, Path can be pdb, zip or rpm or a folder. 11 | NOTE: If one pdb is chosen, make sure .inf file is 12 | in the same directory. 13 | 14 | USED ENVIRONMENT VARIABLES: 15 | 16 | %%DSTORE_LOCATION%% - The symbol store path, that pdb files 17 | will be pushed to. 18 | 19 | %%DSTORE_BUILD_TAG%% - Will serve as a tag for future versions, 20 | pushed with the pdb as a message.(Optional) 21 | if not configured, the default is "eng". 22 | 23 | NOTE: 1. 7zip should be installed and the path to 7z.exe should be 24 | configured in the push.cmd file. 25 | 2. Path to symstore.exe, comes with (WDK), should be configured 26 | in the push.cmd file. 27 | 28 | Edit the pushpdb.cmd with any text editor and configure the values. 29 | -------------------------------------------------------------------------------- /Tools/readme_msbuild.txt: -------------------------------------------------------------------------------- 1 | https://blogs.msdn.microsoft.com/visualstudio/2010/05/14/a-guide-to-vcxproj-and-props-file-structure/ 2 | 3 | https://msdn.microsoft.com/en-us/library/cyhcc7zc.aspx - how to detail output window (MSBuild project build output/log verbosity) 4 | https://msdn.microsoft.com/en-us/library/ms171458.aspx - properties $ 5 | https://msdn.microsoft.com/en-us/library/ms171453.aspx - elements @ aka ItemGroup 6 | https://msdn.microsoft.com/en-us/library/ms171462.aspx - targets 7 | https://msdn.microsoft.com/en-us/library/ms171466.aspx - tasks 8 | https://msdn.microsoft.com/en-us/library/ms164307.aspx - element Choose 9 | https://msdn.microsoft.com/en-us/library/ms164313.aspx - well known item metadata 10 | https://msdn.microsoft.com/en-us/library/ms171473.aspx - % batching 11 | https://msdn.microsoft.com/en-us/library/ms171474.aspx - % batching 12 | https://msdn.microsoft.com/en-us/library/ms228229.aspx - % batching 13 | https://msdn.microsoft.com/en-us/library/ms171476.aspx - -> transforms 14 | https://msdn.microsoft.com/en-us/library/bb383819.aspx - special characters @,%,$ 15 | https://msdn.microsoft.com/en-us/library/dd997067.aspx - comparing propetires and items 16 | -------------------------------------------------------------------------------- /Tools/rhel.ver: -------------------------------------------------------------------------------- 1 | /* 2 | * This file contains rhel vendor specific 3 | * resource (version) definitions for all drivers 4 | * 5 | * Copyright (c) 2017 Parallels IP Holdings GmbH 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met : 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and / or other materials provided with the distribution. 15 | * 3. Neither the names of the copyright holders nor the names of their contributors 16 | * may be used to endorse or promote products derived from this software 17 | * without specific prior written permission. 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND 19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 | * ARE DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE 22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 | * SUCH DAMAGE. 29 | */ 30 | 31 | /* 32 | * These defines are only for Visual Studio built-in rc editor 33 | */ 34 | #ifndef _NT_TARGET_MAJ 35 | #define _NT_TARGET_MAJ 1 36 | #define _RHEL_RELEASE_VERSION_ 20 37 | #define _BUILD_MAJOR_VERSION_ 300 38 | #define _BUILD_MINOR_VERSION_ 5800 39 | #endif 40 | 41 | /* 42 | * rhel versioning 43 | */ 44 | #define VENDOR_VIRTIO_1 _NT_TARGET_MAJ 45 | #define VENDOR_VIRTIO_2 _RHEL_RELEASE_VERSION_ 46 | #define VENDOR_VIRTIO_3 _BUILD_MAJOR_VERSION_ 47 | #define VENDOR_VIRTIO_4 _BUILD_MINOR_VERSION_ 48 | 49 | /* 50 | * rhel strings 51 | */ 52 | #define VENDOR_VIRTIO_COPYRIGHT "Copyright (C) " STRINGIFY(RHEL_COPYRIGHT_YEARS) " Red Hat, Inc." 53 | #define VENDOR_VIRTIO_COMPANY "Red Hat,\040Inc." 54 | #define VENDOR_PREFIX "Red Hat\040" 55 | #define VENDOR_PRODUCT_PREFIX VENDOR_PREFIX 56 | #define QEMU_PRODUCT_PREFIX "QEMU\040" 57 | #define VENDOR_DESC_PREFIX VENDOR_PREFIX 58 | #define VENDOR_DESC_POSTFIX "" 59 | 60 | /* 61 | * remaining macro should be defined in project .rc file 62 | * 63 | * VENDOR_VIRTIO_PRODUCT, VER_FILEDESCRIPTION_STR, VER_INTERNALNAME_STR 64 | */ 65 | -------------------------------------------------------------------------------- /Tools/signAll.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | SET "SignToolDir=C:\Program Files (x86)\Windows Kits\8.1\bin\x64" 3 | for /r "%~dp0\..\" %%i in (*.sys) do "%SignToolDir%\signtool.exe" sign /f "%~dp0\VirtIOTestCert.pfx" "%%i" 4 | for /r "%~dp0\..\" %%i in (*.cat) do "%SignToolDir%\signtool.exe" sign /f "%~dp0\VirtIOTestCert.pfx" "%%i" 5 | 6 | -------------------------------------------------------------------------------- /Tools/vendor.ver: -------------------------------------------------------------------------------- 1 | /* 2 | * This file contains resource (version) definitions for all drivers 3 | * that are independent from vendor. 4 | * 5 | * Copyright (c) 2017 Parallels IP Holdings GmbH 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met : 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and / or other materials provided with the distribution. 15 | * 3. Neither the names of the copyright holders nor the names of their contributors 16 | * may be used to endorse or promote products derived from this software 17 | * without specific prior written permission. 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND 19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 | * ARE DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE 22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 | * SUCH DAMAGE. 29 | */ 30 | 31 | /* 32 | * These defines are only for Visual Studio built-in rc editor 33 | * 34 | * VER_OS <= $(TargetOS) for description postfix 35 | * VER_ARCH <= $(VerArch) for description postfix 36 | * VENDOR_VER <= $(_VENDOR_).ver (rhel by default) 37 | */ 38 | #ifndef VER_OS 39 | #define VER_OS Win?? 40 | #endif 41 | #ifndef VER_ARCH 42 | #define VER_ARCH x?? 43 | #endif 44 | #ifndef VENDOR_VER 45 | #define VENDOR_VER rhel.ver 46 | //#define VENDOR_VER vz.ver 47 | #endif 48 | 49 | /* 50 | * AUTO: these defines are defined in common.ver 51 | * VER_PRODUCTVERSION <= VER_PRODUCTMAJORVERSION,VER_PRODUCTMINORVERSION,VER_PRODUCTBUILD,VER_PRODUCTBUILD_QFE 52 | * VER_FILEVERSION <= VER_PRODUCTVERSION 53 | * VER_FILEVERSION_STR <= VER_PRODUCTVERSION_STR 54 | * VER_ORIGINALFILENAME_STR <= VER_INTERNALNAME_STR 55 | */ 56 | 57 | /* 58 | * COMMON: these defines are strictly required 59 | */ 60 | #define VER_LANGNEUTRAL 61 | #define VER_FILETYPE VFT_DRV 62 | #define VER_FILESUBTYPE VFT2_DRV_SYSTEM 63 | #define VER_FILEDESCRIPTION_STR "File Description required" 64 | #define VER_INTERNALNAME_STR "File Name required" 65 | 66 | /* 67 | * STRINGIFY 68 | */ 69 | #define STRINGIFY_AUX(X) #X 70 | #define STRINGIFY(X) STRINGIFY_AUX(X) 71 | 72 | /* 73 | * VENDOR SPECIFIC 74 | */ 75 | #include STRINGIFY(VENDOR_VER) 76 | 77 | /* 78 | * Applying vendor specific 79 | */ 80 | #undef VER_PRODUCTBUILD 81 | #undef VER_PRODUCTBUILD_QFE 82 | #undef VER_PRODUCTMAJORVERSION 83 | #undef VER_PRODUCTMINORVERSION 84 | 85 | #define VER_PRODUCTMAJORVERSION VENDOR_VIRTIO_1 86 | #define VER_PRODUCTMINORVERSION VENDOR_VIRTIO_2 87 | #define VER_PRODUCTBUILD VENDOR_VIRTIO_3 88 | #define VER_PRODUCTBUILD_QFE VENDOR_VIRTIO_4 89 | 90 | #undef VER_LEGALTRADEMARKS_STR 91 | #undef VER_LEGALCOPYRIGHT_STR 92 | #undef VER_COMPANYNAME_STR 93 | #undef VER_PRODUCTNAME_STR 94 | 95 | #define VER_LEGALTRADEMARKS_STR "" 96 | #define VER_LEGALCOPYRIGHT_STR VENDOR_VIRTIO_COPYRIGHT 97 | #define VER_COMPANYNAME_STR VENDOR_VIRTIO_COMPANY 98 | #define VER_PRODUCTNAME_STR VENDOR_VIRTIO_PRODUCT 99 | -------------------------------------------------------------------------------- /Tools/vz.ver: -------------------------------------------------------------------------------- 1 | /* 2 | * This file contains vz vendor specific 3 | * resource (version) definitions for all drivers 4 | * 5 | * Copyright (c) 2017 Parallels IP Holdings GmbH 6 | * 7 | * Redistribution and use in source and binary forms, with or without 8 | * modification, are permitted provided that the following conditions 9 | * are met : 10 | * 1. Redistributions of source code must retain the above copyright 11 | * notice, this list of conditions and the following disclaimer. 12 | * 2. Redistributions in binary form must reproduce the above copyright 13 | * notice, this list of conditions and the following disclaimer in the 14 | * documentation and / or other materials provided with the distribution. 15 | * 3. Neither the names of the copyright holders nor the names of their contributors 16 | * may be used to endorse or promote products derived from this software 17 | * without specific prior written permission. 18 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND 19 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 | * ARE DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE 22 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 | * SUCH DAMAGE. 29 | */ 30 | 31 | /* 32 | * These defines are only for Visual Studio built-in rc editor 33 | */ 34 | #ifndef _NT_TARGET_MAJ 35 | #define VZ_RELEASE_A 1 36 | #define VZ_RELEASE_B 20 37 | #define VZ_RELEASE_C 300 38 | #define _NT_TARGET_MAJ 4000 39 | #endif 40 | 41 | /* 42 | * vz build variants 43 | */ 44 | #ifndef VZ_RELEASE_N 45 | //custom 46 | #define VENDOR_DESC_PREFIX "Custom\040" 47 | #define VENDOR_DESC_POSTFIX "\040" STRINGIFY(VER_OS) "\040for\040" STRINGIFY(VER_ARCH) 48 | #elif (VZ_RELEASE_N != 0) 49 | //experimental 50 | #define VENDOR_DESC_PREFIX "Experimental\040" 51 | #define VENDOR_DESC_POSTFIX "\040" STRINGIFY(VER_OS) "\040for\040" STRINGIFY(VER_ARCH) 52 | #elif (VZ_RELEASE_N == 0) 53 | //build 54 | #define VENDOR_DESC_PREFIX VENDOR_PREFIX 55 | #define VENDOR_DESC_POSTFIX "\040(" STRINGIFY(VER_ARCH) ")" 56 | #endif 57 | 58 | /* 59 | * vz versioning 60 | */ 61 | #define VENDOR_VIRTIO_1 VZ_RELEASE_A 62 | #define VENDOR_VIRTIO_2 VZ_RELEASE_B 63 | #define VENDOR_VIRTIO_3 VZ_RELEASE_C 64 | #define VENDOR_VIRTIO_4 _NT_TARGET_MAJ 65 | 66 | /* 67 | * vz strings 68 | */ 69 | #define VENDOR_VIRTIO_COPYRIGHT STRINGIFY(VZ_VENDOR_COPYRIGHT) 70 | #define VENDOR_VIRTIO_COMPANY STRINGIFY(VZ_VENDOR_NAME) 71 | #define VENDOR_PREFIX STRINGIFY(VZ_VENDOR_PREFIX) "\040" 72 | #define VENDOR_PRODUCT_PREFIX VENDOR_PREFIX 73 | #define QEMU_PRODUCT_PREFIX VENDOR_PREFIX "QEMU\040" 74 | 75 | /* 76 | * remaining macro should be defined in project .rc file 77 | * 78 | * VENDOR_VIRTIO_PRODUCT, VER_FILEDESCRIPTION_STR, VER_INTERNALNAME_STR 79 | */ 80 | -------------------------------------------------------------------------------- /VirtIO/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2009-2017 Red Hat, Inc. and/or its affiliates. 2 | Copyright 2016 Google, Inc. 3 | Copyright 2007 IBM Corporation 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions 7 | are met: 8 | 9 | Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | 12 | Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in the 14 | documentation and/or other materials provided with the distribution. 15 | 16 | Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | -------------------------------------------------------------------------------- /VirtIO/VirtIO.h: -------------------------------------------------------------------------------- 1 | #ifndef _LINUX_VIRTIO_H 2 | #define _LINUX_VIRTIO_H 3 | 4 | #include "virtio_ring.h" 5 | 6 | #define scatterlist VirtIOBufferDescriptor 7 | 8 | struct VirtIOBufferDescriptor { 9 | PHYSICAL_ADDRESS physAddr; 10 | ULONG length; 11 | }; 12 | 13 | typedef int (*proc_virtqueue_add_buf)( 14 | struct virtqueue *vq, 15 | struct scatterlist sg[], 16 | unsigned int out_num, 17 | unsigned int in_num, 18 | void *opaque, 19 | void *va_indirect, 20 | ULONGLONG phys_indirect); 21 | 22 | typedef bool(*proc_virtqueue_kick_prepare)(struct virtqueue *vq); 23 | 24 | typedef void(*proc_virtqueue_kick_always)(struct virtqueue *vq); 25 | 26 | typedef void * (*proc_virtqueue_get_buf)(struct virtqueue *vq, unsigned int *len); 27 | 28 | typedef void(*proc_virtqueue_disable_cb)(struct virtqueue *vq); 29 | 30 | typedef bool(*proc_virtqueue_enable_cb)(struct virtqueue *vq); 31 | 32 | typedef bool(*proc_virtqueue_enable_cb_delayed)(struct virtqueue *vq); 33 | 34 | typedef void * (*proc_virtqueue_detach_unused_buf)(struct virtqueue *vq); 35 | 36 | typedef BOOLEAN(*proc_virtqueue_is_interrupt_enabled)(struct virtqueue *vq); 37 | 38 | typedef BOOLEAN(*proc_virtqueue_has_buf)(struct virtqueue *vq); 39 | 40 | typedef void(*proc_virtqueue_shutdown)(struct virtqueue *vq); 41 | 42 | /* Represents one virtqueue; only data pointed to by the vring structure is exposed to the host */ 43 | struct virtqueue { 44 | VirtIODevice *vdev; 45 | unsigned int index; 46 | void (*notification_cb)(struct virtqueue *vq); 47 | void *notification_addr; 48 | void *avail_va; 49 | void *used_va; 50 | proc_virtqueue_add_buf add_buf; 51 | proc_virtqueue_kick_prepare kick_prepare; 52 | proc_virtqueue_kick_always kick_always; 53 | proc_virtqueue_get_buf get_buf; 54 | proc_virtqueue_disable_cb disable_cb; 55 | proc_virtqueue_enable_cb enable_cb; 56 | proc_virtqueue_enable_cb_delayed enable_cb_delayed; 57 | proc_virtqueue_detach_unused_buf detach_unused_buf; 58 | proc_virtqueue_is_interrupt_enabled is_interrupt_enabled; 59 | proc_virtqueue_has_buf has_buf; 60 | proc_virtqueue_shutdown shutdown; 61 | }; 62 | 63 | static inline int virtqueue_add_buf( 64 | struct virtqueue *vq, 65 | struct scatterlist sg[], 66 | unsigned int out_num, 67 | unsigned int in_num, 68 | void *opaque, 69 | void *va_indirect, 70 | ULONGLONG phys_indirect) 71 | { 72 | return vq->add_buf(vq, sg, out_num, in_num, opaque, va_indirect, phys_indirect); 73 | } 74 | 75 | static inline bool virtqueue_kick_prepare(struct virtqueue *vq) 76 | { 77 | return vq->kick_prepare(vq); 78 | } 79 | 80 | static inline void virtqueue_kick_always(struct virtqueue *vq) 81 | { 82 | vq->kick_always(vq); 83 | } 84 | 85 | static inline void *virtqueue_get_buf(struct virtqueue *vq, unsigned int *len) 86 | { 87 | return vq->get_buf(vq, len); 88 | } 89 | 90 | static inline void virtqueue_disable_cb(struct virtqueue *vq) 91 | { 92 | vq->disable_cb(vq); 93 | } 94 | 95 | static inline bool virtqueue_enable_cb(struct virtqueue *vq) 96 | { 97 | return vq->enable_cb(vq); 98 | } 99 | 100 | static inline bool virtqueue_enable_cb_delayed(struct virtqueue *vq) 101 | { 102 | return vq->enable_cb_delayed(vq); 103 | } 104 | 105 | static inline void *virtqueue_detach_unused_buf(struct virtqueue *vq) 106 | { 107 | return vq->detach_unused_buf(vq); 108 | } 109 | 110 | static inline BOOLEAN virtqueue_is_interrupt_enabled(struct virtqueue *vq) 111 | { 112 | return vq->is_interrupt_enabled(vq); 113 | } 114 | 115 | static inline BOOLEAN virtqueue_has_buf(struct virtqueue *vq) 116 | { 117 | return vq->has_buf(vq); 118 | } 119 | 120 | static inline void virtqueue_shutdown(struct virtqueue *vq) 121 | { 122 | vq->shutdown(vq); 123 | } 124 | 125 | void virtqueue_notify(struct virtqueue *vq); 126 | void virtqueue_kick(struct virtqueue *vq); 127 | 128 | #endif /* _LINUX_VIRTIO_H */ 129 | -------------------------------------------------------------------------------- /VirtIO/VirtioLib.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Debug 10 | x64 11 | 12 | 13 | Release 14 | Win32 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | {01D87C47-437A-4A16-8FD9-33FA5C99339E} 42 | {0a049372-4c4d-4ea0-a64e-dc6ad88ceca1} 43 | v4.5.2 44 | 11.0 45 | Win8 Release 46 | Win32 47 | 48 | 49 | VirtioLib_win8 50 | $(VCTargetsPath11) 51 | 10.0.22621.0 52 | 53 | 54 | StaticLibrary 55 | virtiolib 56 | 57 | 58 | WDM 59 | 60 | 61 | true 62 | 63 | 64 | Windows10 65 | WindowsKernelModeDriver10.0 66 | 67 | 68 | Windows10 69 | WindowsKernelModeDriver10.0 70 | 71 | 72 | Windows10 73 | WindowsKernelModeDriver10.0 74 | 75 | 76 | Windows10 77 | WindowsKernelModeDriver10.0 78 | 79 | 80 | true 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | objfre_win10_x86\i386\ 91 | objfre_win10_x86\i386\ 92 | 93 | 94 | objfre_win10_x86\i386\ 95 | objfre_win10_x86\i386\ 96 | 97 | 98 | objfre_win10_amd64\amd64\ 99 | objfre_win10_amd64\amd64\ 100 | 101 | 102 | objchk_win10_amd64\amd64\ 103 | objchk_win10_amd64\amd64\ 104 | 105 | 106 | 107 | /kernel %(AdditionalOptions) 108 | Level3 109 | false 110 | 111 | 112 | 113 | 114 | $(ProjectDir);%(AdditionalIncludeDirectories) 115 | Full 116 | Disabled 117 | Default 118 | 119 | 120 | 121 | 122 | 123 | -------------------------------------------------------------------------------- /VirtIO/VirtioLib.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Source Files 6 | 7 | 8 | Source Files 9 | 10 | 11 | Source Files 12 | 13 | 14 | Source Files 15 | 16 | 17 | Source Files 18 | 19 | 20 | 21 | 22 | Header Files\linux 23 | 24 | 25 | Header Files\linux 26 | 27 | 28 | Header Files\windows 29 | 30 | 31 | Header Files 32 | 33 | 34 | Header Files 35 | 36 | 37 | Header Files 38 | 39 | 40 | Header Files\linux 41 | 42 | 43 | Header Files 44 | 45 | 46 | Header Files 47 | 48 | 49 | Header Files 50 | 51 | 52 | 53 | 54 | {0663b857-c5cf-46d8-87cf-6a063853d175} 55 | 56 | 57 | {0c19f7ef-49c4-418f-95c1-fd17620f7fc2} 58 | 59 | 60 | {6ce4f0db-0521-42df-8916-d5a42631de01} 61 | 62 | 63 | {240d1e8d-7dc9-4917-8188-1f35599bd440} 64 | 65 | 66 | -------------------------------------------------------------------------------- /VirtIO/WDF/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2009-2017 Red Hat, Inc. and/or its affiliates. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions 5 | are met: 6 | 7 | Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | 10 | Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | 14 | Neither the name of the copyright holder nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /VirtIO/WDF/MemPortIO.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Implementation of memory & port access routines required by VirtioLib 3 | * 4 | * Copyright (c) 2016-2017 Red Hat, Inc. 5 | * 6 | * Author(s): 7 | * Ladi Prosek 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met : 12 | * 1. Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in the 16 | * documentation and / or other materials provided with the distribution. 17 | * 3. Neither the names of the copyright holders nor the names of their contributors 18 | * may be used to endorse or promote products derived from this software 19 | * without specific prior written permission. 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND 21 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE 24 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 | * SUCH DAMAGE. 31 | */ 32 | #include "osdep.h" 33 | #include "virtio_pci.h" 34 | 35 | /* The lower 64k of memory is never mapped so we can use the same routines 36 | * for both port I/O and memory access and use the address alone to decide 37 | * which space to use. 38 | */ 39 | #define PORT_MASK 0xFFFF 40 | 41 | /* READ_REGISTER_* and WRITE_REGISTER_* take volatile ptr in newer DDKs */ 42 | #if NTDDI_VERSION >= NTDDI_WIN7 43 | #define _VOLATILE volatile 44 | #else 45 | #define _VOLATILE 46 | #endif 47 | 48 | #define READ_PORT_OR_REGISTER(address, width) \ 49 | (address & ~PORT_MASK) ? \ 50 | READ_REGISTER_##width((_VOLATILE width *)address) : \ 51 | READ_PORT_##width((width *)address) 52 | 53 | #define WRITE_PORT_OR_REGISTER(address, width, value) \ 54 | (address & ~PORT_MASK) ? \ 55 | WRITE_REGISTER_##width((_VOLATILE width *)address, value) : \ 56 | WRITE_PORT_##width((width *)address, value) 57 | 58 | u8 ReadVirtIODeviceByte(ULONG_PTR ulRegister) 59 | { 60 | return READ_PORT_OR_REGISTER(ulRegister, UCHAR); 61 | } 62 | 63 | void WriteVirtIODeviceByte(ULONG_PTR ulRegister, u8 bValue) 64 | { 65 | WRITE_PORT_OR_REGISTER(ulRegister, UCHAR, bValue); 66 | } 67 | 68 | u16 ReadVirtIODeviceWord(ULONG_PTR ulRegister) 69 | { 70 | return READ_PORT_OR_REGISTER(ulRegister, USHORT); 71 | } 72 | 73 | void WriteVirtIODeviceWord(ULONG_PTR ulRegister, u16 wValue) 74 | { 75 | WRITE_PORT_OR_REGISTER(ulRegister, USHORT, wValue); 76 | } 77 | 78 | u32 ReadVirtIODeviceRegister(ULONG_PTR ulRegister) 79 | { 80 | return READ_PORT_OR_REGISTER(ulRegister, ULONG); 81 | } 82 | 83 | void WriteVirtIODeviceRegister(ULONG_PTR ulRegister, u32 ulValue) 84 | { 85 | WRITE_PORT_OR_REGISTER(ulRegister, ULONG, ulValue); 86 | } 87 | -------------------------------------------------------------------------------- /VirtIO/WDF/VirtioLib-WDF.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;hh;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 | Source Files 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | Source Files 29 | 30 | 31 | Source Files 32 | 33 | 34 | 35 | 36 | Header Files 37 | 38 | 39 | Header Files 40 | 41 | 42 | -------------------------------------------------------------------------------- /VirtIO/WDF/clean.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | for /d %%x in (objfre_*) do rmdir /S /Q %%x 4 | for /d %%x in (objchk_*) do rmdir /S /Q %%x 5 | 6 | del /F *.log *.wrn *.err 7 | -------------------------------------------------------------------------------- /VirtIO/WDF/private.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Private VirtioLib-WDF prototypes 3 | * 4 | * Copyright (c) 2016-2017 Red Hat, Inc. 5 | * 6 | * Author(s): 7 | * Ladi Prosek 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met : 12 | * 1. Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * 2. Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in the 16 | * documentation and / or other materials provided with the distribution. 17 | * 3. Neither the names of the copyright holders nor the names of their contributors 18 | * may be used to endorse or promote products derived from this software 19 | * without specific prior written permission. 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND 21 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 | * ARE DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE 24 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 | * SUCH DAMAGE. 31 | */ 32 | #pragma once 33 | 34 | #include 35 | #include 36 | #include "kdebugprint.h" 37 | 38 | typedef struct virtio_wdf_bar { 39 | SINGLE_LIST_ENTRY ListEntry; 40 | 41 | int iBar; 42 | PHYSICAL_ADDRESS BasePA; 43 | ULONG uLength; 44 | PVOID pBase; 45 | bool bPortSpace; 46 | } VIRTIO_WDF_BAR, *PVIRTIO_WDF_BAR; 47 | 48 | typedef struct virtio_wdf_interrupt_context { 49 | /* This is a workaround for a WDF bug where on resource rebalance 50 | * it does not preserve the MessageNumber field of its internal 51 | * data structures describing interrupts. As a result, we fail to 52 | * report the right MSI message number to the virtio device when 53 | * re-initializing it and it may stop working. 54 | */ 55 | USHORT uMessageNumber; 56 | bool bMessageNumberSet; 57 | } VIRTIO_WDF_INTERRUPT_CONTEXT, *PVIRTIO_WDF_INTERRUPT_CONTEXT; 58 | 59 | WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(VIRTIO_WDF_INTERRUPT_CONTEXT, GetInterruptContext) 60 | 61 | NTSTATUS PCIAllocBars(WDFCMRESLIST ResourcesTranslated, 62 | PVIRTIO_WDF_DRIVER pWdfDriver); 63 | 64 | void PCIFreeBars(PVIRTIO_WDF_DRIVER pWdfDriver); 65 | 66 | int PCIReadConfig(PVIRTIO_WDF_DRIVER pWdfDriver, 67 | int where, 68 | void *buffer, 69 | size_t length); 70 | 71 | NTSTATUS PCIRegisterInterrupt(WDFINTERRUPT Interrupt); 72 | 73 | u16 PCIGetMSIInterruptVector(WDFINTERRUPT Interrupt); 74 | 75 | typedef struct virtio_wdf_memory_block_context { 76 | PVOID pVirtualAddress; 77 | PHYSICAL_ADDRESS PhysicalAddress; 78 | WDFCOMMONBUFFER WdfBuffer; 79 | size_t Length; 80 | ULONG groupTag; 81 | BOOLEAN bToBeDeleted; 82 | } VIRTIO_WDF_MEMORY_BLOCK_CONTEXT, *PVIRTIO_WDF_MEMORY_BLOCK_CONTEXT; 83 | 84 | WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(VIRTIO_WDF_MEMORY_BLOCK_CONTEXT, GetMemoryBlockContext) 85 | 86 | typedef struct virtio_wdf_dma_transaction_context { 87 | VIRTIO_DMA_TRANSACTION_PARAMS parameters; 88 | VirtIOWdfDmaTransactionCallback callback; 89 | PMDL mdl; 90 | PVOID buffer; 91 | LONG refCount; 92 | } VIRTIO_WDF_DMA_TRANSACTION_CONTEXT, *PVIRTIO_WDF_DMA_TRANSACTION_CONTEXT; 93 | 94 | WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(VIRTIO_WDF_DMA_TRANSACTION_CONTEXT, GetDmaTransactionContext) 95 | -------------------------------------------------------------------------------- /VirtIO/buildAll.bat: -------------------------------------------------------------------------------- 1 | @call ..\tools\build.bat VirtioLib.sln "Wxp Wnet Wlh Win7 Win8 Win10" %* 2 | -------------------------------------------------------------------------------- /VirtIO/clean.bat: -------------------------------------------------------------------------------- 1 | for /d %%x in (objfre_*) do rmdir /S /Q %%x 2 | for /d %%x in (objchk_*) do rmdir /S /Q %%x 3 | rmdir /S /Q Win8Release 4 | rmdir /S /Q Win8Debug 5 | rmdir /S /Q x64 6 | 7 | del /F *.log *.wrn *.err 8 | 9 | cd WDF 10 | call clean.bat 11 | cd .. 12 | -------------------------------------------------------------------------------- /VirtIO/kdebugprint.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | extern int virtioDebugLevel; 4 | extern int bDebugPrint; 5 | typedef void (*tDebugPrintFunc)(const char *format, ...); 6 | extern tDebugPrintFunc VirtioDebugPrintProc; 7 | 8 | #define DPrintf(Level, MSG, ...) if ((!bDebugPrint) || Level > virtioDebugLevel) {} else VirtioDebugPrintProc(MSG, __VA_ARGS__) 9 | 10 | #define DEBUG_ENTRY(level) DPrintf(level, "[%s]=>\n", __FUNCTION__) 11 | #define DEBUG_EXIT_STATUS(level, status) DPrintf((status == NDIS_STATUS_SUCCESS ? level : 0), "[%s]<=0x%X\n", __FUNCTION__, (status)) 12 | -------------------------------------------------------------------------------- /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_config.h: -------------------------------------------------------------------------------- 1 | #ifndef _UAPI_LINUX_VIRTIO_CONFIG_H 2 | #define _UAPI_LINUX_VIRTIO_CONFIG_H 3 | /* This header, excluding the #ifdef __KERNEL__ part, is BSD licensed so 4 | * anyone can use the definitions to implement compatible drivers/servers. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions 8 | * are met: 9 | * 1. Redistributions of source code must retain the above copyright 10 | * notice, this list of conditions and the following disclaimer. 11 | * 2. Redistributions in binary form must reproduce the above copyright 12 | * notice, this list of conditions and the following disclaimer in the 13 | * documentation and/or other materials provided with the distribution. 14 | * 3. Neither the name of IBM nor the names of its contributors 15 | * may be used to endorse or promote products derived from this software 16 | * without specific prior written permission. 17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. */ 28 | 29 | /* Virtio devices use a standardized configuration space to define their 30 | * features and pass configuration information, but each implementation can 31 | * store and access that space differently. */ 32 | 33 | /* Status byte for guest to report progress, and synchronize features. */ 34 | /* We have seen device and processed generic fields (VIRTIO_CONFIG_F_VIRTIO) */ 35 | #define VIRTIO_CONFIG_S_ACKNOWLEDGE 1 36 | /* We have found a driver for the device. */ 37 | #define VIRTIO_CONFIG_S_DRIVER 2 38 | /* Driver has used its parts of the config, and is happy */ 39 | #define VIRTIO_CONFIG_S_DRIVER_OK 4 40 | /* Driver has finished configuring features */ 41 | #define VIRTIO_CONFIG_S_FEATURES_OK 8 42 | /* Device entered invalid state, driver SHOULD reset it */ 43 | #define VIRTIO_CONFIG_S_NEEDS_RESET 0x40 44 | /* We've given up on this device. */ 45 | #define VIRTIO_CONFIG_S_FAILED 0x80 46 | /* virtio library features bits */ 47 | 48 | 49 | /* Some virtio feature bits (currently bits 28 through 31) are reserved for the 50 | * transport being used (eg. virtio_ring), the rest are per-device feature 51 | * bits. */ 52 | #define VIRTIO_TRANSPORT_F_START 28 53 | #define VIRTIO_TRANSPORT_F_END 32 54 | 55 | /* Do we get callbacks when the ring is completely used, even if we've 56 | * suppressed them? */ 57 | #define VIRTIO_F_NOTIFY_ON_EMPTY 24 58 | 59 | /* Can the device handle any descriptor layout? */ 60 | #define VIRTIO_F_ANY_LAYOUT 27 61 | 62 | /* v1.0 compliant. */ 63 | #define VIRTIO_F_VERSION_1 32 64 | 65 | #define VIRTIO_F_ACCESS_PLATFORM 33 66 | 67 | /* This feature indicates support for the packed virtqueue layout. */ 68 | #define VIRTIO_F_RING_PACKED 34 69 | 70 | // if this number is not equal to desc size, queue creation fails 71 | #define SIZE_OF_SINGLE_INDIRECT_DESC 16 72 | 73 | #endif /* _UAPI_LINUX_VIRTIO_CONFIG_H */ 74 | -------------------------------------------------------------------------------- /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 | 35 | #include "linux/types.h" 36 | 37 | /* 38 | * __virtio{16,32,64} have the following meaning: 39 | * - __u{16,32,64} for virtio devices in legacy mode, accessed in native endian 40 | * - __le{16,32,64} for standard-compliant virtio devices 41 | */ 42 | 43 | typedef __u16 __bitwise__ __virtio16; 44 | typedef __u32 __bitwise__ __virtio32; 45 | typedef __u64 __bitwise__ __virtio64; 46 | 47 | #endif /* _UAPI_LINUX_VIRTIO_TYPES_H */ 48 | -------------------------------------------------------------------------------- /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 | #pragma once 16 | 17 | #include 18 | 19 | #define ENOSPC 1 20 | 21 | #if !defined(__cplusplus) && !defined(bool) 22 | // Important note: in MSFT C++ bool length is 1 bytes 23 | // C++ does not define length of bool 24 | // inconsistent definition of 'bool' may create compatibility problems 25 | #define bool u8 26 | #define false FALSE 27 | #define true TRUE 28 | #endif 29 | 30 | #define inline __forceinline 31 | #define SMP_CACHE_BYTES 64 32 | -------------------------------------------------------------------------------- /VirtIO/virtio_pci_common.h: -------------------------------------------------------------------------------- 1 | #ifndef _DRIVERS_VIRTIO_VIRTIO_PCI_COMMON_H 2 | #define _DRIVERS_VIRTIO_VIRTIO_PCI_COMMON_H 3 | /* 4 | * Virtio PCI driver - APIs for common functionality for all device versions 5 | * 6 | * Copyright IBM Corp. 2007 7 | * Copyright Red Hat, Inc. 2014 8 | * 9 | * Authors: 10 | * Anthony Liguori 11 | * Rusty Russell 12 | * Michael S. Tsirkin 13 | * 14 | * Redistribution and use in source and binary forms, with or without 15 | * modification, are permitted provided that the following conditions 16 | * are met : 17 | * 1. Redistributions of source code must retain the above copyright 18 | * notice, this list of conditions and the following disclaimer. 19 | * 2. Redistributions in binary form must reproduce the above copyright 20 | * notice, this list of conditions and the following disclaimer in the 21 | * documentation and / or other materials provided with the distribution. 22 | * 3. Neither the names of the copyright holders nor the names of their contributors 23 | * may be used to endorse or promote products derived from this software 24 | * without specific prior written permission. 25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND 26 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28 | * ARE DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE 29 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 30 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 31 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 32 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 34 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 35 | * SUCH DAMAGE. 36 | */ 37 | 38 | #define ioread8(vdev, addr) \ 39 | vdev->system->vdev_read_byte((ULONG_PTR)(addr)) 40 | #define ioread16(vdev, addr) \ 41 | vdev->system->vdev_read_word((ULONG_PTR)(addr)) 42 | #define ioread32(vdev, addr) \ 43 | vdev->system->vdev_read_dword((ULONG_PTR)(addr)) 44 | #define iowrite8(vdev, val, addr) \ 45 | vdev->system->vdev_write_byte((ULONG_PTR)(addr), val) 46 | #define iowrite16(vdev, val, addr) \ 47 | vdev->system->vdev_write_word((ULONG_PTR)(addr), val) 48 | #define iowrite32(vdev, val, addr) \ 49 | vdev->system->vdev_write_dword((ULONG_PTR)(addr), val) 50 | #define iowrite64_twopart(vdev, val, lo_addr, hi_addr) \ 51 | vdev->system->vdev_write_dword((ULONG_PTR)(lo_addr), (u32)(val)); \ 52 | vdev->system->vdev_write_dword((ULONG_PTR)(hi_addr), (val) >> 32) 53 | 54 | #define mem_alloc_contiguous_pages(vdev, size) \ 55 | vdev->system->mem_alloc_contiguous_pages(vdev->DeviceContext, size) 56 | #define mem_free_contiguous_pages(vdev, virt) \ 57 | vdev->system->mem_free_contiguous_pages(vdev->DeviceContext, virt) 58 | #define mem_get_physical_address(vdev, virt) \ 59 | vdev->system->mem_get_physical_address(vdev->DeviceContext, virt) 60 | #define mem_alloc_nonpaged_block(vdev, size) \ 61 | vdev->system->mem_alloc_nonpaged_block(vdev->DeviceContext, size) 62 | #define mem_free_nonpaged_block(vdev, addr) \ 63 | vdev->system->mem_free_nonpaged_block(vdev->DeviceContext, addr) 64 | 65 | #define pci_read_config_byte(vdev, where, bVal) \ 66 | vdev->system->pci_read_config_byte(vdev->DeviceContext, where, bVal) 67 | #define pci_read_config_word(vdev, where, wVal) \ 68 | vdev->system->pci_read_config_word(vdev->DeviceContext, where, wVal) 69 | #define pci_read_config_dword(vdev, where, dwVal) \ 70 | vdev->system->pci_read_config_dword(vdev->DeviceContext, where, dwVal) 71 | 72 | #define pci_get_resource_len(vdev, bar) \ 73 | vdev->system->pci_get_resource_len(vdev->DeviceContext, bar) 74 | #define pci_map_address_range(vdev, bar, offset, maxlen) \ 75 | vdev->system->pci_map_address_range(vdev->DeviceContext, bar, offset, maxlen) 76 | 77 | #define vdev_get_msix_vector(vdev, queue) \ 78 | vdev->system->vdev_get_msix_vector(vdev->DeviceContext, queue) 79 | #define vdev_sleep(vdev, msecs) \ 80 | vdev->system->vdev_sleep(vdev->DeviceContext, msecs) 81 | 82 | /* the notify function used when creating a virt queue */ 83 | bool vp_notify(struct virtqueue *vq); 84 | 85 | NTSTATUS vio_legacy_initialize(VirtIODevice *vdev); 86 | NTSTATUS vio_modern_initialize(VirtIODevice *vdev); 87 | 88 | #endif -------------------------------------------------------------------------------- /VirtIO/virtio_ring.h: -------------------------------------------------------------------------------- 1 | #ifndef _UAPI_LINUX_VIRTIO_RING_H 2 | #define _UAPI_LINUX_VIRTIO_RING_H 3 | /* An interface for efficient virtio implementation, currently for use by KVM 4 | * and lguest, but hopefully others soon. Do NOT change this since it will 5 | * break existing servers and clients. 6 | * 7 | * This header is BSD licensed so anyone can use the definitions to implement 8 | * compatible drivers/servers. 9 | * 10 | * Redistribution and use in source and binary forms, with or without 11 | * modification, are permitted provided that the following conditions 12 | * are met: 13 | * 1. Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in the 17 | * documentation and/or other materials provided with the distribution. 18 | * 3. Neither the name of IBM nor the names of its contributors 19 | * may be used to endorse or promote products derived from this software 20 | * without specific prior written permission. 21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND 22 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 | * ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE 25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 | * SUCH DAMAGE. 32 | * 33 | * Copyright Rusty Russell IBM Corporation 2007. */ 34 | 35 | #include "linux/types.h" 36 | #include "linux/virtio_types.h" 37 | 38 | /* We support indirect buffer descriptors */ 39 | #define VIRTIO_RING_F_INDIRECT_DESC 28 40 | 41 | /* The Guest publishes the used index for which it expects an interrupt 42 | * at the end of the avail ring. Host should ignore the avail->flags field. */ 43 | /* The Host publishes the avail index for which it expects a kick 44 | * at the end of the used ring. Guest should ignore the used->flags field. */ 45 | #define VIRTIO_RING_F_EVENT_IDX 29 46 | 47 | void vring_transport_features(VirtIODevice *vdev, u64 *features); 48 | unsigned long vring_size(unsigned int num, unsigned long align, bool packed); 49 | 50 | #endif /* _UAPI_LINUX_VIRTIO_RING_H */ 51 | -------------------------------------------------------------------------------- /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_split(unsigned int index, 5 | unsigned int num, 6 | unsigned int vring_align, 7 | VirtIODevice *vdev, 8 | void *pages, 9 | void (*notify)(struct virtqueue *), 10 | void *control); 11 | 12 | struct virtqueue *vring_new_virtqueue_packed(unsigned int index, 13 | unsigned int num, 14 | unsigned int vring_align, 15 | VirtIODevice *vdev, 16 | void *pages, 17 | void (*notify)(struct virtqueue *), 18 | void *control); 19 | 20 | unsigned int vring_control_block_size(u16 qsize, bool packed); 21 | unsigned int vring_control_block_size_packed(u16 qsize); 22 | unsigned long vring_size_packed(unsigned int num, unsigned long align); 23 | 24 | #endif /* _VIRTIO_RING_ALLOCATION_H */ 25 | -------------------------------------------------------------------------------- /ZeroCopyInstaller/DVInstaller/DVInstaller.h: -------------------------------------------------------------------------------- 1 | /*============================================================================== 2 | ; DVInstaller.h 3 | ;------------------------------------------------------------------------------- 4 | ; Copyright (C) 2023 Intel Corporation 5 | ; SPDX-License-Identifier: MIT 6 | ; 7 | ; File Description: 8 | ; This file declares Variables and API's used in GUI installer functionality 9 | ;-----------------------------------------------------------------------------*/ 10 | #pragma once 11 | 12 | #include "resource.h" 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | 40 | #define TEXT(quote) __TEXT(quote) 41 | 42 | #ifdef _UNICODE 43 | #define UPDATEDRIVERFORPLUGANDPLAYDEVICES "UpdateDriverForPlugAndPlayDevicesW" 44 | #define SETUPUNINSTALLOEMINF "SetupUninstallOEMInfW" 45 | #define DIINSTALLDRIVER "DiInstallDriverW" 46 | #define DIUNINSTALLDRIVER "DiUninstallDriverW" 47 | #else 48 | #define UPDATEDRIVERFORPLUGANDPLAYDEVICES "UpdateDriverForPlugAndPlayDevicesA" 49 | #define SETUPUNINSTALLOEMINF "SetupUninstallOEMInfA" 50 | #define DINSTALLDRIVER "DiInstallDriverA" 51 | #define DIUNINSTALLDRIVER "DiUninstallDriverA" 52 | #endif 53 | 54 | enum InstallModes { 55 | INSTALL = 1, 56 | UNINSTALL, 57 | UPDATE, 58 | UNINSTALLANDUPDATE, 59 | MAXMODES 60 | }; 61 | 62 | #define EXIT_OK (0) 63 | #define EXIT_FAIL (1) 64 | #define EXIT_REBOOT (2) 65 | #define EXIT_USAGE (3) 66 | #define EXIT_UMD_INF_REMOVAL_FAILED (4) 67 | #define EXIT_KMD_INF_REMOVAL_FAILED (5) 68 | 69 | #define SUCCESS 1 70 | #define FAIL 0 71 | 72 | #define DLL_LOADED_MAX_RETRY 10 73 | #define DV_HWID TEXT("PCI\\VEN_1AF4&DEV_1050&CC_030000") 74 | #define DVSERVERKMD_INF TEXT("DVServerKMD.inf") 75 | #define DVSERVERKMD_DESC L"DVServerKMD Device" 76 | #define DVSERVERUMD_DESC L"DVServerUMD Device" 77 | #define DVINSTALLER_RUNDLL_EXE L"rundll32.exe" 78 | #define DVINSTALLER_RUNDLL_ARGUMENT L"DVEnabler.dll,dvenabler_init" 79 | #define DVINSTALLER_DLL_NAME L"DVEnabler.dll" 80 | #define DVINSTALLER_REG_RUN_PATH TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Run") 81 | #define DVINSTALLER_REG_DLL_KEYNAME TEXT("dvServerDll") 82 | #define DVINSTALLER_REG_EXE_KEYNAME TEXT("dvServerExe") 83 | #define DVINSTALLER_WIN_APP TEXT("DV") 84 | #define DVINSTALLER_DVSERVERDLL_NAME "dvserver.dll" 85 | #define DVINSTALLER_DLL_FUNCTION L"dvenabler_init" 86 | 87 | DEFINE_GUID(ClassGuid, 0x4d36e97d, 0xe325, 0x11ce, 0xbf, 0xc1, 0x08, 0x00, 0x2b, 0xe1, 0x03, 0x18); 88 | 89 | int dvPostInstall(void); 90 | int dvInstall(InstallModes code, BOOL dvInstallUmd); 91 | int dvGetInstalledOemInfFile(WCHAR*); 92 | int dvUninstall(WCHAR*); 93 | int dvGetInfPath(TCHAR* infFile, TCHAR* infPath); 94 | int dvLoadUnloadNewdevLib(HMODULE* newdevMod, BOOL isLoad); 95 | void dvKillDll(std::wstring moduleName); 96 | int dvUpdateCertifcates(void); 97 | BOOL dvDeviceScan(void); 98 | BOOL dvGetInstalledOemInfFileName(const wchar_t* deviceDesc, WCHAR* infFileName); 99 | BOOL dvUninstallKmdAndUmd(BOOL unInstallUmd); 100 | 101 | typedef BOOL(WINAPI* UpdateDriverForPlugAndPlayDevicesProto)(_In_opt_ HWND hwndParent, 102 | _In_ LPCTSTR HardwareId, 103 | _In_ LPCTSTR FullInfPath, 104 | _In_ DWORD InstallFlags, 105 | _Out_opt_ PBOOL bRebootRequired 106 | ); 107 | typedef BOOL(WINAPI* DINSTALLDRIVERProto)(_In_opt_ HWND hwndParent, 108 | _In_ LPCTSTR FullInfPath, 109 | _In_ DWORD InstallFlags, 110 | _Out_opt_ PBOOL bRebootRequired 111 | ); 112 | 113 | typedef BOOL(WINAPI* DIUNINSTALLDRIVERProto)(_In_opt_ HWND hwndParent, 114 | _In_ LPCTSTR InfFileName, 115 | _In_ DWORD Flags, 116 | PBOOL NeedReboot 117 | ); 118 | -------------------------------------------------------------------------------- /ZeroCopyInstaller/DVInstaller/DVInstaller.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/Display-Virtualization-for-Windows-OS/6738cb0d71cd8e154a1543589de3300a087f2d58/ZeroCopyInstaller/DVInstaller/DVInstaller.ico -------------------------------------------------------------------------------- /ZeroCopyInstaller/DVInstaller/DVInstaller.rc: -------------------------------------------------------------------------------- 1 | /*=========================================================================== 2 | ; DVInstaller.rc 3 | ;---------------------------------------------------------------------------- 4 | ; Copyright (C) 2021 Intel Corporation 5 | ; SPDX-License-Identifier: MIT 6 | ; 7 | ; File Description: 8 | ; This file will have the DVInstaller resources 9 | ;--------------------------------------------------------------------------*/ 10 | #include 11 | 12 | VS_VERSION_INFO VERSIONINFO 13 | FILEVERSION ${FileVersion} 14 | PRODUCTVERSION ${ProductVersion} 15 | BEGIN 16 | BLOCK "StringFileInfo" 17 | BEGIN 18 | BLOCK "040904B0" 19 | BEGIN 20 | VALUE "FileVersion", "${FileVersion}" 21 | VALUE "ProductVersion", "${ProductVersionString}" 22 | VALUE "ProductName", "DVInstaller.dll" 23 | VALUE "LegalCopyright", "Copyright (C) 2021 Intel Corporation" 24 | VALUE "FileDescription", "Display Virtualization Installer " 25 | END 26 | END 27 | BLOCK "VarFileInfo" 28 | BEGIN 29 | VALUE "Translation", 0x409, 1200 30 | END 31 | END 32 | -------------------------------------------------------------------------------- /ZeroCopyInstaller/DVInstaller/DVInstaller.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;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 | 26 | 27 | Source Files 28 | 29 | 30 | Source Files 31 | 32 | 33 | Source Files 34 | 35 | 36 | Source Files 37 | 38 | 39 | Source Files 40 | 41 | 42 | -------------------------------------------------------------------------------- /ZeroCopyInstaller/DVInstaller/DVInstaller_Version.txt: -------------------------------------------------------------------------------- 1 | /*=========================================================================== 2 | ; DVInstaller_Version.txt 3 | ;---------------------------------------------------------------------------- 4 | ; Copyright (C) 2021 Intel Corporation 5 | ; SPDX-License-Identifier: MIT 6 | ; 7 | ; File Description: 8 | ; This file will have the DVInstaller version 9 | ;--------------------------------------------------------------------------*/ 10 | 11 | DVInstaller_Version = 1.0.0 -------------------------------------------------------------------------------- /ZeroCopyInstaller/DVInstaller/Resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by DVInstaller.rc 4 | 5 | #define IDS_APP_TITLE 103 6 | 7 | #define IDR_MAINFRAME 128 8 | #define IDD_DVINSTALLER_DIALOG 102 9 | #define IDD_ABOUTBOX 103 10 | #define IDM_ABOUT 104 11 | #define IDM_EXIT 105 12 | #define IDI_DVINSTALLER 107 13 | #define IDI_SMALL 108 14 | #define IDC_DVINSTALLER 109 15 | #define IDC_MYICON 2 16 | #ifndef IDC_STATIC 17 | #define IDC_STATIC -1 18 | #endif 19 | // Next default values for new objects 20 | // 21 | #ifdef APSTUDIO_INVOKED 22 | #ifndef APSTUDIO_READONLY_SYMBOLS 23 | 24 | #define _APS_NO_MFC 130 25 | #define _APS_NEXT_RESOURCE_VALUE 129 26 | #define _APS_NEXT_COMMAND_VALUE 32771 27 | #define _APS_NEXT_CONTROL_VALUE 1000 28 | #define _APS_NEXT_SYMED_VALUE 110 29 | #endif 30 | #endif 31 | -------------------------------------------------------------------------------- /ZeroCopyInstaller/DVInstaller/Trace.h: -------------------------------------------------------------------------------- 1 | /*============================================================================== 2 | ; Trace.h 3 | ;------------------------------------------------------------------------------- 4 | ; Copyright (C) 2023 Intel Corporation 5 | ; SPDX-License-Identifier: MIT 6 | ; 7 | ; File Description: 8 | ; This file declares definations for the ETL pre processor 9 | ;-----------------------------------------------------------------------------*/ 10 | #pragma once 11 | 12 | #define WPP_CONTROL_GUIDS WPP_DEFINE_CONTROL_GUID(DVEnablerGuid, (3ABD0A19, 3767, 47FA, A2C0, EAB7977BAC78), \ 13 | WPP_DEFINE_BIT(verbose) \ 14 | WPP_DEFINE_BIT(information) \ 15 | WPP_DEFINE_BIT(error) \ 16 | WPP_DEFINE_BIT(ftrace) \ 17 | WPP_DEFINE_BIT(warning)) 18 | 19 | #define WPP_FLAG_LEVEL_LOGGER(flag, level) \ 20 | WPP_LEVEL_LOGGER(flag) 21 | 22 | #define WPP_FLAG_LEVEL_ENABLED(flag, level) \ 23 | (WPP_LEVEL_ENABLED(flag) && \ 24 | WPP_CONTROL(WPP_BIT_ ## flag).Level >= level) 25 | 26 | #define WPP_LEVEL_FLAGS_LOGGER(lvl,flags) \ 27 | WPP_LEVEL_LOGGER(flags) 28 | 29 | #define WPP_LEVEL_FLAGS_ENABLED(lvl, flags) \ 30 | (WPP_LEVEL_ENABLED(flags) && WPP_CONTROL(WPP_BIT_ ## flags).Level >= lvl) 31 | 32 | 33 | class tracer { 34 | private: 35 | char* m_func_name; 36 | public: 37 | tracer(const char* func_name); 38 | ~tracer(); 39 | }; 40 | #define TRACING() tracer trace(__FUNCTION__) 41 | 42 | // 43 | // This comment block is scanned by the trace preprocessor to define our 44 | // Trace function. 45 | // 46 | // begin_wpp config 47 | // FUNC ERR{LEVEL=TRACE_LEVEL_ERROR,FLAGS=error}(MSG,...); 48 | // FUNC WARN{LEVEL=TRACE_LEVEL_WARNING,FLAGS=warning}(MSG,...); 49 | // FUNC WARNING{LEVEL=TRACE_LEVEL_WARNING,FLAGS=warning}(MSG,...); 50 | // FUNC INFO{LEVEL=TRACE_LEVEL_INFORMATION,FLAGS=information}(MSG,...); 51 | // FUNC DBGPRINT{LEVEL=TRACE_LEVEL_INFORMATION,FLAGS=verbose}(MSG,...); 52 | // FUNC FuncTrace{LEVEL=TRACE_LEVEL_INFORMATION,FLAGS=ftrace}(MSG, ...); 53 | // USEPREFIX(ERR, "%!STDPREFIX! [%!FUNC!:%!LINE!] [ERR] \t"); 54 | // USEPREFIX(WARN, "%!STDPREFIX! [%!FUNC!:%!LINE!] [WARN] \t"); 55 | // USEPREFIX(WARNING, "%!STDPREFIX! [%!FUNC!:%!LINE!] [WARN] \t"); 56 | // USEPREFIX(DBGPRINT, "%!STDPREFIX! [%!FUNC!:%!LINE!] [DBG] \t"); 57 | // USEPREFIX(INFO, "%!STDPREFIX! [%!FUNC!:%!LINE!] [INFO] \t"); 58 | // end_wpp 59 | 60 | -------------------------------------------------------------------------------- /ZeroCopyInstaller/DVInstaller/Tracing.cpp: -------------------------------------------------------------------------------- 1 | /*=========================================================================== 2 | ; Tracing.cpp 3 | ;---------------------------------------------------------------------------- 4 | ; Copyright (C) 2023 Intel Corporation 5 | ; SPDX-License-Identifier: MIT 6 | ; 7 | ; File Description: 8 | ; This file contains function entry and exits calls trace. 9 | ;--------------------------------------------------------------------------*/ 10 | 11 | 12 | //#include "pch.h" 13 | #include "Trace.h" 14 | #include "Tracing.tmh" 15 | 16 | 17 | /******************************************************************************* 18 | * 19 | * Description 20 | * 21 | * tracer is a constructor member function of the class tracer called to mark the 22 | * entry of the function. 23 | * 24 | * Parameters 25 | * func_name - Function name. 26 | * 27 | * 28 | ******************************************************************************/ 29 | tracer::tracer(const char* func_name) 30 | { 31 | FuncTrace(">>> %s\n", func_name); 32 | m_func_name = (char*)func_name; 33 | } 34 | /******************************************************************************* 35 | * 36 | * Description 37 | * 38 | * tracer is a destructor member function of the class tracer called to mark 39 | * exit of the function. 40 | * 41 | * Parameters 42 | * func_name - Function name. 43 | * 44 | * 45 | ******************************************************************************/ 46 | tracer::~tracer() 47 | { 48 | FuncTrace("<<< %s\n", m_func_name); 49 | } -------------------------------------------------------------------------------- /ZeroCopyInstaller/DVInstaller/UpdateVersion.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 1.0.0.0 5 | 1.0.0.0 6 | 7 | 8 | 9 | 10 | DVInstaller.rc 11 | $([System.IO.File]::ReadAllText('$(VersionFile)')) 12 | 13 | 14 | $([System.String]::Copy($(FdvInstaller)).Split('.')[0]) 15 | $([System.String]::Copy($(FdvInstaller)).Split('.')[1]) 16 | $([System.String]::Copy($(FdvInstaller)).Split('.')[2]) 17 | $([System.String]::Copy($(FdvInstaller)).Split('.')[3]) 18 | 19 | $([System.String]::Copy($(PdvInstaller)).Split('.')[0]) 20 | $([System.String]::Copy($(PdvInstaller)).Split('.')[1]) 21 | $([System.String]::Copy($(PdvInstaller)).Split('.')[2]) 22 | $([System.String]::Copy($(PdvInstaller)).Split('.')[3]) 23 | 24 | 25 | $([System.Text.RegularExpressions.Regex]::Replace($(FileContent), '\$\{FileVersion\}', '$(FileVersionMajor),$(FileVersionMinor),$(FileVersionBuild),$(FileVersionRevision)')) 26 | $([System.Text.RegularExpressions.Regex]::Replace($(FileContent), '\$\{ProductVersion\}', '$(ProductVersionMajor),$(ProductVersionMinor),$(ProductVersionBuild),$(ProductVersionRevision)')) 27 | $([System.Text.RegularExpressions.Regex]::Replace($(FileContent), '\$\{ProductVersionString\}', '$(PdvInstaller)')) 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /ZeroCopyInstaller/DVInstaller/dventry.cpp: -------------------------------------------------------------------------------- 1 | /*=========================================================================== 2 | ; dventry.cpp 3 | ;---------------------------------------------------------------------------- 4 | ; Copyright (C) 2023 Intel Corporation 5 | ; SPDX-License-Identifier: MIT 6 | ; 7 | ; File Description: 8 | ; This file is the entry point for SRIOV DV installer implementation code 9 | ;--------------------------------------------------------------------------*/ 10 | 11 | #include "DVInstaller.h" 12 | #include "Trace.h" 13 | #include "dventry.tmh" 14 | 15 | /******************************************************************************* 16 | * 17 | * Description 18 | * 19 | * wWinMain - Entry into the dvinstaller, basically control transfer from 20 | * inno setup process. 21 | * 22 | * Parameters 23 | * 24 | * 25 | * Return val 26 | * int - 0 = EXIT_OK, 1 = EXIT_FAIL 27 | * 28 | ******************************************************************************/ 29 | int APIENTRY wWinMain(_In_ HINSTANCE hInstance, 30 | _In_opt_ HINSTANCE hPrevInstance, 31 | _In_ LPWSTR lpCmdLine, 32 | _In_ int nCmdShow) 33 | { 34 | UNREFERENCED_PARAMETER(hPrevInstance); 35 | UNREFERENCED_PARAMETER(lpCmdLine); 36 | WCHAR infFullPath[MAX_PATH]; 37 | InstallModes RequestedMode; 38 | int result = EXIT_OK, argc, unInstallLoop = 10;; 39 | LPWSTR commandline = GetCommandLine(); 40 | LPWSTR* argv; 41 | 42 | WPP_INIT_TRACING(NULL); 43 | TRACING(); 44 | DBGPRINT("DV installation begins\n"); 45 | 46 | argv = CommandLineToArgvW(commandline, &argc); 47 | if (argc < 2) { 48 | ERR("no arguments passed\n"); 49 | WPP_CLEANUP(); 50 | return EXIT_FAIL; 51 | } 52 | 53 | RequestedMode = (InstallModes)_wtoi(argv[1]); 54 | switch (RequestedMode) { 55 | case INSTALL: 56 | case UPDATE: 57 | DBGPRINT("RequestedMode is %d\n", RequestedMode); 58 | if (dvUpdateCertifcates()) { 59 | ERR("Failed to add certificates\n"); 60 | return EXIT_FAIL; 61 | } 62 | if (dvInstall(RequestedMode, FALSE)) { 63 | ERR("dvInstall: Failed to %d\n", RequestedMode); 64 | } 65 | else { 66 | DBGPRINT("dvInstall: succeeded to %d\n", RequestedMode); 67 | result = EXIT_FAIL; 68 | } 69 | break; 70 | case UNINSTALL: 71 | DBGPRINT("RequestedMode is UNINSTALL\n"); 72 | while (unInstallLoop--) { 73 | if (dvUninstallKmdAndUmd(TRUE)) { 74 | DBGPRINT("dvUninstallKmdAndUmd succeeded to uninstall in interation = %d\n", unInstallLoop); 75 | break; 76 | } 77 | else { 78 | ERR("dvUninstallKmdAndUmd Failed to uninstall in iteration = %d\n", unInstallLoop); 79 | Sleep(1000); 80 | } 81 | } 82 | break; 83 | case UNINSTALLANDUPDATE: 84 | DBGPRINT("RequestedMode is UNINSTALLANDUPDATE\n"); 85 | 86 | if (dvUninstallKmdAndUmd(TRUE)) { 87 | if (dvUpdateCertifcates()) { 88 | ERR("Failed to add certificates\n"); 89 | return EXIT_FAIL; 90 | } 91 | if (dvInstall(INSTALL, FALSE)) { 92 | ERR("UNINSTALLANDUPDATE Failed to update\n"); 93 | } 94 | else { 95 | DBGPRINT("UNINSTALLANDUPDATE Succeded to update\n"); 96 | result = EXIT_OK; 97 | } 98 | } 99 | else { 100 | ERR("dvUninstallKmdAndUmd Failed to uninstall before update\n"); 101 | } 102 | break; 103 | default: 104 | break; 105 | } 106 | WPP_CLEANUP(); 107 | return result; 108 | } 109 | -------------------------------------------------------------------------------- /ZeroCopyInstaller/DVInstaller/small.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/intel/Display-Virtualization-for-Windows-OS/6738cb0d71cd8e154a1543589de3300a087f2d58/ZeroCopyInstaller/DVInstaller/small.ico -------------------------------------------------------------------------------- /ZeroCopyInstaller/DVInstallerLib/DVInstallerLib.rc: -------------------------------------------------------------------------------- 1 | /*=========================================================================== 2 | ; DVInstallerLib.rc 3 | ;---------------------------------------------------------------------------- 4 | ; Copyright (C) 2021 Intel Corporation 5 | ; SPDX-License-Identifier: MIT 6 | ; 7 | ; File Description: 8 | ; This file will have the DVInstallerLib resources 9 | ;--------------------------------------------------------------------------*/ 10 | #include 11 | 12 | VS_VERSION_INFO VERSIONINFO 13 | FILEVERSION ${FileVersion} 14 | PRODUCTVERSION ${ProductVersion} 15 | BEGIN 16 | BLOCK "StringFileInfo" 17 | BEGIN 18 | BLOCK "040904B0" 19 | BEGIN 20 | VALUE "FileVersion", "${FileVersion}" 21 | VALUE "ProductVersion", "${ProductVersionString}" 22 | VALUE "ProductName", "DVInstallerLib.dll" 23 | VALUE "LegalCopyright", "Copyright (C) 2021 Intel Corporation" 24 | VALUE "FileDescription", "Display Virtualization InstallerLib " 25 | END 26 | END 27 | BLOCK "VarFileInfo" 28 | BEGIN 29 | VALUE "Translation", 0x409, 1200 30 | END 31 | END 32 | -------------------------------------------------------------------------------- /ZeroCopyInstaller/DVInstallerLib/DVInstallerLib.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;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 | Source Files 20 | 21 | 22 | 23 | 24 | Header Files 25 | 26 | 27 | -------------------------------------------------------------------------------- /ZeroCopyInstaller/DVInstallerLib/DVInstallerLib_Version.txt: -------------------------------------------------------------------------------- 1 | /*=========================================================================== 2 | ; DVInstallerLib_Version.txt 3 | ;---------------------------------------------------------------------------- 4 | ; Copyright (C) 2021 Intel Corporation 5 | ; SPDX-License-Identifier: MIT 6 | ; 7 | ; File Description: 8 | ; This file will have the DVInstallerLib version 9 | ;--------------------------------------------------------------------------*/ 10 | 11 | DVInstallerLib_Version = 1.0.0 -------------------------------------------------------------------------------- /ZeroCopyInstaller/DVInstallerLib/DriverVersion.cpp: -------------------------------------------------------------------------------- 1 | /*=========================================================================== 2 | ; DriverVersion.cpp 3 | ;---------------------------------------------------------------------------- 4 | ; Copyright (C) 2023 Intel Corporation 5 | ; SPDX-License-Identifier: MIT 6 | ; 7 | ; File Description: 8 | ; Implements the Driver version retrieval functionality 9 | ;--------------------------------------------------------------------------*/ 10 | #include "DriverVersion.h" 11 | 12 | EXPORT int cdecl GetStringfromRegister(int* major, int* minor, int* patch, int* build) { 13 | const wchar_t* partialDriverkeyPath = DRIVERINSTALLER_REGPATH; 14 | wchar_t filterDeviceDesc[] = DVSERVERKMD_DESC; 15 | int result = 0; 16 | DWORD index = 0, size = 0; 17 | SP_DEVINFO_DATA devInfo; 18 | wchar_t deviceName[MAX_PATH]; 19 | wchar_t driverVersion[MAX_PATH]; 20 | wchar_t versionBuffer[MAX_PATH]; 21 | wchar_t regkey[MAX_PATH]; 22 | HKEY hkey; 23 | DWORD versionBufferSize = sizeof(versionBuffer); 24 | HDEVINFO devInfoSet; 25 | 26 | devInfoSet = SetupDiGetClassDevs(&ClassGuid, nullptr, nullptr, DIGCF_PRESENT); 27 | if (devInfoSet == INVALID_HANDLE_VALUE) { 28 | return result; 29 | } 30 | // Get the device info for this device 31 | devInfo.cbSize = sizeof(SP_DEVINFO_DATA); 32 | for (index = 0; SetupDiEnumDeviceInfo(devInfoSet, index, &devInfo); index++) { 33 | 34 | // Build a list of driver info items that we will retrieve below 35 | if (!SetupDiGetDeviceRegistryProperty(devInfoSet, &devInfo, SPDRP_DEVICEDESC, NULL, 36 | (PBYTE)deviceName, sizeof(deviceName), &size)) { 37 | continue; 38 | } 39 | // compare any driver matches with "DVServerKMD Device" 40 | if (wcsstr(deviceName, filterDeviceDesc) == NULL) { 41 | continue; 42 | } 43 | // retrieve Driver key matching with "DVServerKMD Device" 44 | if (!SetupDiGetDeviceRegistryProperty(devInfoSet, &devInfo, SPDRP_DRIVER, nullptr, 45 | reinterpret_cast(driverVersion), sizeof(driverVersion), &size)) { 46 | continue; 47 | } 48 | //get the Registry path of the DVServerKMD Device file 49 | _snwprintf_s(regkey, MAX_PATH, _TRUNCATE, L"%s\\%s", partialDriverkeyPath, driverVersion); 50 | 51 | if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, regkey, 0, KEY_READ, &hkey) != ERROR_SUCCESS) { 52 | continue; 53 | } 54 | if (RegQueryValueEx(hkey, L"DriverVersion", NULL, NULL, (LPBYTE)versionBuffer, &versionBufferSize) == ERROR_SUCCESS) { 55 | result = 1; 56 | if (!swscanf_s(versionBuffer, L"%d.%d.%d.%d", &(*major), &(*minor), &(*patch), &(*build))) { 57 | result = 0; 58 | } 59 | } 60 | RegCloseKey(hkey); 61 | break; 62 | } 63 | SetupDiDestroyDeviceInfoList(devInfoSet); 64 | return result; 65 | } 66 | 67 | BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) 68 | { 69 | switch (ul_reason_for_call) { 70 | case DLL_PROCESS_ATTACH: 71 | break; 72 | case DLL_THREAD_ATTACH: 73 | break; 74 | case DLL_THREAD_DETACH: 75 | break; 76 | case DLL_PROCESS_DETACH: 77 | break; 78 | } 79 | return TRUE; 80 | } 81 | -------------------------------------------------------------------------------- /ZeroCopyInstaller/DVInstallerLib/DriverVersion.h: -------------------------------------------------------------------------------- 1 | /*============================================================================== 2 | ; DriverVersion.h 3 | ;------------------------------------------------------------------------------- 4 | ; Copyright (C) 2023 Intel Corporation 5 | ; SPDX-License-Identifier: MIT 6 | ; 7 | ; File Description: 8 | ; This file declares variables used in driver version retrieval functionality 9 | ;-----------------------------------------------------------------------------*/ 10 | #pragma once 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | #define EXPORT extern "C" __declspec(dllexport) 17 | #define DVSERVERKMD_DESC L"DVServerKMD Device" 18 | #define DRIVERINSTALLER_REGPATH L"SYSTEM\\CurrentControlSet\\Control\\Class" 19 | 20 | DEFINE_GUID(ClassGuid, 0x4d36e97d, 0xe325, 0x11ce, 0xbf, 0xc1, 0x08, 0x00, 0x2b, 0xe1, 0x03, 0x18); 21 | -------------------------------------------------------------------------------- /ZeroCopyInstaller/DVInstallerLib/UpdateVersion.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 1.0.0.0 5 | 1.0.0.0 6 | 7 | 8 | 9 | 10 | DVInstallerLib.rc 11 | $([System.IO.File]::ReadAllText('$(VersionFile)')) 12 | 13 | 14 | $([System.String]::Copy($(FdvInstallerLib)).Split('.')[0]) 15 | $([System.String]::Copy($(FdvInstallerLib)).Split('.')[1]) 16 | $([System.String]::Copy($(FdvInstallerLib)).Split('.')[2]) 17 | $([System.String]::Copy($(FdvInstallerLib)).Split('.')[3]) 18 | 19 | $([System.String]::Copy($(PdvInstallerLib)).Split('.')[0]) 20 | $([System.String]::Copy($(PdvInstallerLib)).Split('.')[1]) 21 | $([System.String]::Copy($(PdvInstallerLib)).Split('.')[2]) 22 | $([System.String]::Copy($(PdvInstallerLib)).Split('.')[3]) 23 | 24 | 25 | $([System.Text.RegularExpressions.Regex]::Replace($(FileContent), '\$\{FileVersion\}', '$(FileVersionMajor),$(FileVersionMinor),$(FileVersionBuild),$(FileVersionRevision)')) 26 | $([System.Text.RegularExpressions.Regex]::Replace($(FileContent), '\$\{ProductVersion\}', '$(ProductVersionMajor),$(ProductVersionMinor),$(ProductVersionBuild),$(ProductVersionRevision)')) 27 | $([System.Text.RegularExpressions.Regex]::Replace($(FileContent), '\$\{ProductVersionString\}', '$(PdvInstallerLib)')) 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /ZeroCopyInstaller/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright © 2021-2024 Intel Corporation 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 7 | of the Software, and to permit persons to whom the Software is furnished to do 8 | so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | 21 | SPDX-License-Identifier: MIT 22 | -------------------------------------------------------------------------------- /ZeroCopyInstaller/ZeroCopyInstaller.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30503.244 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DVInstaller", "DVInstaller\DVInstaller.vcxproj", "{FACB0E6C-2731-467E-8927-CF06FFA82011}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DVInstallerLib", "DVInstallerLib\DVInstallerLib.vcxproj", "{2F21F298-5702-412A-8D0F-6A70051B6DF0}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|ARM = Debug|ARM 13 | Debug|ARM64 = Debug|ARM64 14 | Debug|x64 = Debug|x64 15 | Debug|x86 = Debug|x86 16 | Release|ARM = Release|ARM 17 | Release|ARM64 = Release|ARM64 18 | Release|x64 = Release|x64 19 | Release|x86 = Release|x86 20 | EndGlobalSection 21 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 22 | {FACB0E6C-2731-467E-8927-CF06FFA82011}.Debug|ARM.ActiveCfg = Debug|Win32 23 | {FACB0E6C-2731-467E-8927-CF06FFA82011}.Debug|ARM64.ActiveCfg = Debug|Win32 24 | {FACB0E6C-2731-467E-8927-CF06FFA82011}.Debug|x64.ActiveCfg = Debug|x64 25 | {FACB0E6C-2731-467E-8927-CF06FFA82011}.Debug|x64.Build.0 = Debug|x64 26 | {FACB0E6C-2731-467E-8927-CF06FFA82011}.Debug|x86.ActiveCfg = Debug|Win32 27 | {FACB0E6C-2731-467E-8927-CF06FFA82011}.Debug|x86.Build.0 = Debug|Win32 28 | {FACB0E6C-2731-467E-8927-CF06FFA82011}.Release|ARM.ActiveCfg = Release|Win32 29 | {FACB0E6C-2731-467E-8927-CF06FFA82011}.Release|ARM64.ActiveCfg = Release|Win32 30 | {FACB0E6C-2731-467E-8927-CF06FFA82011}.Release|x64.ActiveCfg = Release|x64 31 | {FACB0E6C-2731-467E-8927-CF06FFA82011}.Release|x64.Build.0 = Release|x64 32 | {FACB0E6C-2731-467E-8927-CF06FFA82011}.Release|x86.ActiveCfg = Release|Win32 33 | {FACB0E6C-2731-467E-8927-CF06FFA82011}.Release|x86.Build.0 = Release|Win32 34 | {2F21F298-5702-412A-8D0F-6A70051B6DF0}.Debug|ARM.ActiveCfg = Debug|Win32 35 | {2F21F298-5702-412A-8D0F-6A70051B6DF0}.Debug|ARM64.ActiveCfg = Debug|Win32 36 | {2F21F298-5702-412A-8D0F-6A70051B6DF0}.Debug|x64.ActiveCfg = Debug|Win32 37 | {2F21F298-5702-412A-8D0F-6A70051B6DF0}.Debug|x64.Build.0 = Debug|Win32 38 | {2F21F298-5702-412A-8D0F-6A70051B6DF0}.Debug|x86.ActiveCfg = Debug|Win32 39 | {2F21F298-5702-412A-8D0F-6A70051B6DF0}.Debug|x86.Build.0 = Debug|Win32 40 | {2F21F298-5702-412A-8D0F-6A70051B6DF0}.Release|ARM.ActiveCfg = Release|Win32 41 | {2F21F298-5702-412A-8D0F-6A70051B6DF0}.Release|ARM64.ActiveCfg = Release|Win32 42 | {2F21F298-5702-412A-8D0F-6A70051B6DF0}.Release|x64.ActiveCfg = Release|Win32 43 | {2F21F298-5702-412A-8D0F-6A70051B6DF0}.Release|x64.Build.0 = Release|Win32 44 | {2F21F298-5702-412A-8D0F-6A70051B6DF0}.Release|x86.ActiveCfg = Release|Win32 45 | {2F21F298-5702-412A-8D0F-6A70051B6DF0}.Release|x86.Build.0 = Release|Win32 46 | EndGlobalSection 47 | GlobalSection(SolutionProperties) = preSolution 48 | HideSolutionNode = FALSE 49 | EndGlobalSection 50 | GlobalSection(ExtensibilityGlobals) = postSolution 51 | SolutionGuid = {9D304C05-837B-4375-923E-DAB2AD6B0486} 52 | EndGlobalSection 53 | EndGlobal 54 | --------------------------------------------------------------------------------