summaryrefslogtreecommitdiff
path: root/gnss/gnssUmdf/Driver.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'gnss/gnssUmdf/Driver.cpp')
-rw-r--r--gnss/gnssUmdf/Driver.cpp111
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);
+}