Skip to content

Commit 6f90297

Browse files
sraman4malayaku
authored andcommitted
ZC v791 : Enabled ETL tracing and minor bug fixes
1 parent 9e8af81 commit 6f90297

24 files changed

+323
-239
lines changed

DVInstaller.ps1

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,17 @@ else {
4242
Write-Host "Start Zerocopy Driver installation..."
4343
pnputil.exe /add-driver .\DVServer\DVServerKMD.inf /install
4444

45-
Timeout /T 10
45+
Write-Host "Checking DVServer loaded successfully..."
46+
while($true){
47+
$count= (Get-Process WUDFHost | select -ExpandProperty modules | group -Property FileName | select name | Select-String -Pattern 'dvserver.dll' -AllMatches).matches.count
48+
if ($count -eq 1) {
49+
break
50+
}
51+
else{
52+
continue
53+
}
54+
}
55+
4656
Write-Host "Running DVEnabler..."
4757
& ".\DVEnabler.exe"
4858
if ($LASTEXITCODE -eq 0) {

DVServerKMD/DVServerKMD.vcxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<ClCompile Include="Device.cpp" />
2020
<ClCompile Include="Driver.cpp" />
2121
<ClCompile Include="Queue.cpp" />
22+
<ClCompile Include="Tracing.cpp" />
2223
<ClCompile Include="viogpulite.cpp" />
2324
<ClCompile Include="viogpu_idr.cpp" />
2425
<ClCompile Include="viogpu_pci.cpp" />
@@ -27,7 +28,6 @@
2728
<ItemGroup>
2829
<ClInclude Include="baseobj.h" />
2930
<ClInclude Include="bitops.h" />
30-
<ClInclude Include="debug.h" />
3131
<ClInclude Include="Device.h" />
3232
<ClInclude Include="Driver.h" />
3333
<ClInclude Include="edid.h" />
@@ -92,7 +92,7 @@
9292
<ClCompile>
9393
<WppEnabled>true</WppEnabled>
9494
<WppRecorderEnabled>true</WppRecorderEnabled>
95-
<WppScanConfigurationData Condition="'%(ClCompile.ScanConfigurationData)' == ''">trace.h</WppScanConfigurationData>
95+
<WppScanConfigurationData Condition="'%(ClCompile.ScanConfigurationData)' == ''">Trace.h</WppScanConfigurationData>
9696
<WppKernelMode>true</WppKernelMode>
9797
<AdditionalIncludeDirectories>C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.19041.0\um;C:\Program Files %28x86%29\Windows Kits\10\Include\10.0.19041.0\km;..\VirtIO;..\EDIDParser;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
9898
<PreprocessorDefinitions>_WIN64;_AMD64_;AMD64;%(PreprocessorDefinitions);__DEBUG</PreprocessorDefinitions>

DVServerKMD/DVServerKMD.vcxproj.filters

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,6 @@
7272
<ClInclude Include="edid.h">
7373
<Filter>Header Files</Filter>
7474
</ClInclude>
75-
<ClInclude Include="debug.h">
76-
<Filter>Header Files</Filter>
77-
</ClInclude>
7875
</ItemGroup>
7976
<ItemGroup>
8077
<ClCompile Include="baseobj.cpp">
@@ -104,6 +101,9 @@
104101
<ClCompile Include="viogpulite.cpp">
105102
<Filter>Source Files</Filter>
106103
</ClCompile>
104+
<ClCompile Include="Tracing.cpp">
105+
<Filter>Source Files</Filter>
106+
</ClCompile>
107107
</ItemGroup>
108108
<ItemGroup>
109109
<Text Include="DVServerKMD_Version.txt" />

DVServerKMD/DVServerKMD_Version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@
88
; This file will have the DVServerKMD version
99
;--------------------------------------------------------------------------*/
1010

11-
DVServerKMD_Version = 3.3.0
11+
DVServerKMD_Version = 3.4.0

DVServerKMD/Device.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ Module Name:
1515
--*/
1616

1717
#include "driver.h"
18-
#include "debug.h"
1918
#include "baseobj.h"
2019
#include "viogpulite.h"
20+
#include "Trace.h"
21+
#include <Device.tmh>
2122

2223
#ifdef ALLOC_PRAGMA
2324
#pragma alloc_text (PAGE, DVServerKMDCreateDevice)
@@ -234,10 +235,13 @@ Return Value:
234235
--*/
235236
{
236237
NTSTATUS status = STATUS_SUCCESS;
238+
PDEVICE_CONTEXT pDeviceContext;
237239
TRACING();
238240
UNREFERENCED_PARAMETER(Device);
239241
UNREFERENCED_PARAMETER(ResourcesTranslated);
240242

243+
pDeviceContext = DeviceGetContext(Device);
244+
delete (VioGpuAdapterLite*)pDeviceContext->pvDeviceExtension;
241245
return status;
242246
}
243247

DVServerKMD/Driver.cpp

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ Module Name:
1515
--*/
1616

1717
#include "driver.h"
18-
#include "debug.h"
18+
#include "Trace.h"
19+
#include <Driver.tmh>
1920
extern "C" {
2021
#include "kdebugprint.h"
2122
tDebugPrintFunc VirtioDebugPrintProc;
@@ -35,8 +36,11 @@ char module_name[80] = "KMD";
3536
#pragma alloc_text (PAGE, DVServerKMDEvtReleaseHardware)
3637
#pragma alloc_text (PAGE, DVServerKMDEvtD0Entry)
3738
#pragma alloc_text (PAGE, DVServerKMDEvtD0Exit)
39+
#pragma alloc_text (PAGE, DVServerKMDEvtDriverUnload)
3840
#endif
3941

42+
43+
4044
NTSTATUS
4145
DriverEntry(
4246
_In_ PDRIVER_OBJECT DriverObject,
@@ -71,7 +75,7 @@ Return Value:
7175
WDF_DRIVER_CONFIG config;
7276
NTSTATUS status;
7377
WDF_OBJECT_ATTRIBUTES attributes;
74-
TRACING();
78+
7579
//
7680
// Initialize WPP Tracing
7781
//
@@ -81,11 +85,14 @@ Return Value:
8185
//
8286
WDF_OBJECT_ATTRIBUTES_INIT(&attributes);
8387
attributes.EvtCleanupCallback = DVServerKMDEvtDriverContextCleanup;
88+
89+
WPP_INIT_TRACING(DriverObject, RegistryPath);
90+
TRACING();
8491

8592
WDF_DRIVER_CONFIG_INIT(&config,
8693
DVServerKMDEvtDeviceAdd
8794
);
88-
95+
config.EvtDriverUnload = DVServerKMDEvtDriverUnload;
8996
status = WdfDriverCreate(DriverObject,
9097
RegistryPath,
9198
&attributes,
@@ -94,12 +101,37 @@ Return Value:
94101
);
95102

96103
if (!NT_SUCCESS(status)) {
97-
return status;
104+
WPP_CLEANUP(DriverObject);
105+
return status;
98106
}
99-
107+
100108
return status;
101109
}
102110

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+
WPP_CLEANUP(WdfDriverWdmGetDriverObject(driver));
131+
132+
return;
133+
}
134+
103135
NTSTATUS
104136
DVServerKMDEvtDeviceAdd(
105137
_In_ WDFDRIVER Driver,
@@ -192,4 +224,4 @@ Return Value:
192224

193225
PAGED_CODE();
194226
TRACING();
195-
}
227+
}

DVServerKMD/Driver.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ EXTERN_C_START
3131
DRIVER_INITIALIZE DriverEntry;
3232
EVT_WDF_DRIVER_DEVICE_ADD DVServerKMDEvtDeviceAdd;
3333
EVT_WDF_OBJECT_CONTEXT_CLEANUP DVServerKMDEvtDriverContextCleanup;
34+
EVT_WDF_DRIVER_UNLOAD DVServerKMDEvtDriverUnload;
3435

3536
#define ENABLE_FRAME_TRACE
3637
#define ENABLE_CURSOR_TRACE

DVServerKMD/Queue.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ Module Name:
2222
#include "viogpulite.h"
2323
#include "Public.h"
2424
#include "edid.h"
25-
#include "debug.h"
26-
25+
#include "Trace.h"
26+
#include <Queue.tmh>
2727
extern "C" {
2828
#include "..\EDIDParser\edidshared.h"
2929
}

DVServerKMD/Trace.h

Lines changed: 34 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,50 @@
1-
/*++
1+
#pragma once
22

3-
Module Name:
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))
49

5-
Trace.h
6-
7-
Abstract:
8-
9-
Header file for the debug tracing related function defintions and macros.
10-
11-
Environment:
12-
13-
Kernel mode
14-
15-
--*/
16-
17-
//
18-
// Define the tracing flags.
19-
//
20-
// Tracing GUID - a2893be8-687f-4adc-9b03-46e5114d0a1e
21-
//
22-
23-
#define WPP_CONTROL_GUIDS \
24-
WPP_DEFINE_CONTROL_GUID( \
25-
DVServerKMDTraceGuid, (a2893be8,687f,4adc,9b03,46e5114d0a1e), \
26-
\
27-
WPP_DEFINE_BIT(MYDRIVER_ALL_INFO) \
28-
WPP_DEFINE_BIT(TRACE_DRIVER) \
29-
WPP_DEFINE_BIT(TRACE_DEVICE) \
30-
WPP_DEFINE_BIT(TRACE_QUEUE) \
31-
)
32-
33-
#define WPP_FLAG_LEVEL_LOGGER(flag, level) \
10+
#define WPP_FLAG_LEVEL_LOGGER(flag, level) \
3411
WPP_LEVEL_LOGGER(flag)
3512

36-
#define WPP_FLAG_LEVEL_ENABLED(flag, level) \
37-
(WPP_LEVEL_ENABLED(flag) && \
13+
#define WPP_FLAG_LEVEL_ENABLED(flag, level) \
14+
(WPP_LEVEL_ENABLED(flag) && \
3815
WPP_CONTROL(WPP_BIT_ ## flag).Level >= level)
3916

40-
#define WPP_LEVEL_FLAGS_LOGGER(lvl,flags) \
17+
#define WPP_LEVEL_FLAGS_LOGGER(lvl,flags) \
4118
WPP_LEVEL_LOGGER(flags)
42-
43-
#define WPP_LEVEL_FLAGS_ENABLED(lvl, flags) \
19+
20+
#define WPP_LEVEL_FLAGS_ENABLED(lvl, flags) \
4421
(WPP_LEVEL_ENABLED(flags) && WPP_CONTROL(WPP_BIT_ ## flags).Level >= lvl)
4522

46-
//
47-
// WPP orders static parameters before dynamic parameters. To support the Trace function
48-
// defined below which sets FLAGS=MYDRIVER_ALL_INFO, a custom macro must be defined to
49-
// reorder the arguments to what the .tpl configuration file expects.
50-
//
51-
#define WPP_RECORDER_FLAGS_LEVEL_ARGS(flags, lvl) WPP_RECORDER_LEVEL_FLAGS_ARGS(lvl, flags)
52-
#define WPP_RECORDER_FLAGS_LEVEL_FILTER(flags, lvl) WPP_RECORDER_LEVEL_FLAGS_FILTER(lvl, flags)
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__)
5332

5433
//
5534
// This comment block is scanned by the trace preprocessor to define our
5635
// Trace function.
5736
//
5837
// begin_wpp config
59-
// FUNC Trace{FLAGS=MYDRIVER_ALL_INFO}(LEVEL, MSG, ...);
60-
// FUNC TraceEvents(LEVEL, FLAGS, MSG, ...);
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");
6149
// end_wpp
62-
//
50+

DVServerKMD/Tracing.cpp

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*++
2+
*
3+
* Copyright (C) 2021 Intel Corporation
4+
* SPDX-License-Identifier: MS-PL
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+
}

0 commit comments

Comments
 (0)