diff options
| author | Cheoljin Lee <[email protected]> | 2018-11-28 11:08:27 -0800 |
|---|---|---|
| committer | Cheoljin Lee <[email protected]> | 2018-11-28 11:08:27 -0800 |
| commit | 964d0d1e461e7a9af0f9045a7f192acd74999843 (patch) | |
| tree | b8169004db5fc67fd4f45b2f7999ea6e70865ab4 /gnss/gnssUmdf/Driver.cpp | |
| parent | 0990b0cbbd460336036dc6ec71cb8e2a8403e287 (diff) | |
Initial version of GPS/GNSS UMDF Sample Driver (UMDF Version 2)
Diffstat (limited to 'gnss/gnssUmdf/Driver.cpp')
| -rw-r--r-- | gnss/gnssUmdf/Driver.cpp | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/gnss/gnssUmdf/Driver.cpp b/gnss/gnssUmdf/Driver.cpp new file mode 100644 index 00000000..6e4a2289 --- /dev/null +++ b/gnss/gnssUmdf/Driver.cpp @@ -0,0 +1,111 @@ +/*++ + +Copyright (c) Microsoft Corporation. All rights reserved. + +Module Name: + + driver.cpp + +Abstract: + + This file contains the driver entry points and callbacks. + +Environment: + + Windows User-Mode Driver Framework + +--*/ + +#include "precomp.h" +#include "Trace.h" +#include "Defaults.h" +#include "Driver.h" +#include "Device.h" +#include "NmeaProcessor.h" +#include "FixSession.h" +#include "FixHandler.h" +#include "Queue.h" + +#include "Driver.tmh" + + +extern "C" +NTSTATUS +DriverEntry( + _In_ PDRIVER_OBJECT DriverObject, + _In_ PUNICODE_STRING RegistryPath +) +{ + NTSTATUS status = STATUS_SUCCESS; + + // Initialize WPP Tracing + WPP_INIT_TRACING(DriverObject, RegistryPath); + + TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_DRIVER, "%!FUNC! Entry"); + + // Register a cleanup callback so that we can call WPP_CLEANUP when + // the framework driver object is deleted during driver unload. + WDF_OBJECT_ATTRIBUTES attributes; + WDF_OBJECT_ATTRIBUTES_INIT(&attributes); + attributes.EvtCleanupCallback = GnssUmdfEvtDriverContextCleanup; + + WDF_DRIVER_CONFIG config; + WDF_DRIVER_CONFIG_INIT(&config, + CDevice::OnDeviceAdd); + + config.EvtDriverUnload = OnDriverUnload; + + status = WdfDriverCreate(DriverObject, + RegistryPath, + &attributes, + &config, + WDF_NO_HANDLE); + + if (!NT_SUCCESS(status)) + { + TraceEvents(TRACE_LEVEL_ERROR, TRACE_DRIVER, "WdfDriverCreate failed %!STATUS!", status); + + WPP_CLEANUP(DriverObject); + + return status; + } + + TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_DRIVER, "%!FUNC! Exit"); + + return status; +} + +void +GnssUmdfEvtDriverContextCleanup( + _In_ WDFOBJECT DriverObject +) +/*++ +Routine Description: + + Free all the resources allocated in DriverEntry. + +Arguments: + + DriverObject - handle to a WDF Driver object. + +Return Value: + + void. + +--*/ +{ + UNREFERENCED_PARAMETER(DriverObject); + + TraceEvents(TRACE_LEVEL_INFORMATION, TRACE_DRIVER, "%!FUNC! Entry"); + + // Stop WPP Tracing + WPP_CLEANUP(WdfDriverWdmGetDriverObject((WDFDRIVER)DriverObject)); +} + +void +OnDriverUnload( + _In_ WDFDRIVER /* Driver */ +) +{ + WPP_CLEANUP(Driver); +} |
