From 4b870639a7cfc58a2884603690262c19ddc65da7 Mon Sep 17 00:00:00 2001 From: Daniel Schaefer Date: Wed, 12 Feb 2025 10:16:25 +0800 Subject: [PATCH 1/4] WPP: Change tracing GUID to newly generated one See: https://learn.microsoft.com/en-us/windows-hardware/drivers/gettingstarted/from-sample-code-to-production-driver Should not use the GUID from the sample. Signed-off-by: Daniel Schaefer --- FrameworkSensors/SensorsTrace.h | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/FrameworkSensors/SensorsTrace.h b/FrameworkSensors/SensorsTrace.h index 85a8b81..11b9159 100644 --- a/FrameworkSensors/SensorsTrace.h +++ b/FrameworkSensors/SensorsTrace.h @@ -1,4 +1,5 @@ //Copyright (C) Microsoft Corporation, All Rights Reserved +//Copyright (C) Framework Computer Inc, All Rights Reserved // //Abstract: // @@ -16,19 +17,20 @@ extern "C" { // Define the tracing flags. // -// Tracing GUID - 3C773167-F26D-4F72-A1DE-95F1FD795840 - -#define WPP_CONTROL_GUIDS \ - WPP_DEFINE_CONTROL_GUID( \ - SimpleDeviceOrientationSensorTraceGuid, (3C773167,F26D,4F72,A1DE,95F1FD795840), \ - WPP_DEFINE_BIT(EntryExit) \ - WPP_DEFINE_BIT(DataFlow) \ - WPP_DEFINE_BIT(Verbose) \ - WPP_DEFINE_BIT(Information) \ - WPP_DEFINE_BIT(Warning) \ - WPP_DEFINE_BIT(Error) \ - WPP_DEFINE_BIT(Fatal) \ - WPP_DEFINE_BIT(DriverStatus) \ +// Tracing GUID - B915AE22-198E-4CF7-BF4D-395FAD3F645A + + +#define WPP_CONTROL_GUIDS \ + WPP_DEFINE_CONTROL_GUID( \ + FrameworkSensorsTraceGuid, (B915AE22,198E,4CF7,BF4D,395FAD3F645A), \ + WPP_DEFINE_BIT(EntryExit) \ + WPP_DEFINE_BIT(DataFlow) \ + WPP_DEFINE_BIT(Verbose) \ + WPP_DEFINE_BIT(Information) \ + WPP_DEFINE_BIT(Warning) \ + WPP_DEFINE_BIT(Error) \ + WPP_DEFINE_BIT(Fatal) \ + WPP_DEFINE_BIT(DriverStatus) \ ) #define WPP_FLAG_LEVEL_LOGGER(flag, level) WPP_LEVEL_LOGGER(flag) From 8c55c9929b3ff5d3fe884349d8495380565c368e Mon Sep 17 00:00:00 2001 From: Daniel Schaefer Date: Wed, 12 Feb 2025 10:23:59 +0800 Subject: [PATCH 2/4] Change to custom Pool Tags See: https://learn.microsoft.com/en-us/windows-hardware/drivers/gettingstarted/from-sample-code-to-production-driver Should not keep using the same ones from the sample driver. Signed-off-by: Daniel Schaefer --- FrameworkSensors/AccelerometerClient.cpp | 14 +++++++------- FrameworkSensors/AlsClient.cpp | 14 +++++++------- FrameworkSensors/SimpleDeviceOrientationClient.cpp | 14 +++++++------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/FrameworkSensors/AccelerometerClient.cpp b/FrameworkSensors/AccelerometerClient.cpp index 47832a6..db50e31 100644 --- a/FrameworkSensors/AccelerometerClient.cpp +++ b/FrameworkSensors/AccelerometerClient.cpp @@ -13,7 +13,7 @@ #include "AccelerometerClient.tmh" -#define SENSORV2_POOL_TAG_ACCELEROMETER '2CaL' +#define FWK_SENSORS_POOL_TAG_ACCELEROMETER 'ccAF' #define AccelerometerDevice_Default_MinDataInterval (4) #define AccelerometerDevice_Default_Axis_Threshold (1.0f) @@ -111,7 +111,7 @@ AccelerometerDevice::Initialize( MemoryAttributes.ParentObject = SensorInstance; Status = WdfMemoryCreate(&MemoryAttributes, PagedPool, - SENSORV2_POOL_TAG_ACCELEROMETER, + FWK_SENSORS_POOL_TAG_ACCELEROMETER, Size, &MemoryHandle, (PVOID*)&m_pEnumerationProperties); @@ -163,7 +163,7 @@ AccelerometerDevice::Initialize( MemoryAttributes.ParentObject = SensorInstance; Status = WdfMemoryCreate(&MemoryAttributes, PagedPool, - SENSORV2_POOL_TAG_ACCELEROMETER, + FWK_SENSORS_POOL_TAG_ACCELEROMETER, Size, &MemoryHandle, (PVOID*)&m_pSupportedDataFields); @@ -197,7 +197,7 @@ AccelerometerDevice::Initialize( MemoryAttributes.ParentObject = SensorInstance; Status = WdfMemoryCreate(&MemoryAttributes, PagedPool, - SENSORV2_POOL_TAG_ACCELEROMETER, + FWK_SENSORS_POOL_TAG_ACCELEROMETER, Size, &MemoryHandle, (PVOID*)&m_pData); @@ -252,7 +252,7 @@ AccelerometerDevice::Initialize( MemoryAttributes.ParentObject = SensorInstance; Status = WdfMemoryCreate(&MemoryAttributes, PagedPool, - SENSORV2_POOL_TAG_ACCELEROMETER, + FWK_SENSORS_POOL_TAG_ACCELEROMETER, Size, &MemoryHandle, (PVOID*)&m_pProperties); @@ -295,7 +295,7 @@ AccelerometerDevice::Initialize( MemoryAttributes.ParentObject = SensorInstance; Status = WdfMemoryCreate(&MemoryAttributes, PagedPool, - SENSORV2_POOL_TAG_ACCELEROMETER, + FWK_SENSORS_POOL_TAG_ACCELEROMETER, Size, &MemoryHandle, (PVOID*)&m_pDataFieldProperties); @@ -335,7 +335,7 @@ AccelerometerDevice::Initialize( MemoryAttributes.ParentObject = SensorInstance; Status = WdfMemoryCreate(&MemoryAttributes, PagedPool, - SENSORV2_POOL_TAG_ACCELEROMETER, + FWK_SENSORS_POOL_TAG_ACCELEROMETER, Size, &MemoryHandle, (PVOID*)&m_pThresholds); diff --git a/FrameworkSensors/AlsClient.cpp b/FrameworkSensors/AlsClient.cpp index 753e873..4e451d7 100644 --- a/FrameworkSensors/AlsClient.cpp +++ b/FrameworkSensors/AlsClient.cpp @@ -13,7 +13,7 @@ #include "AlsClient.tmh" -#define SENSORV2_POOL_TAG_AMBIENT_LIGHT '2LmA' +#define FWK_SENSORS_POOL_TAG_AMBIENT_LIGHT 'SLAF' #define Als_Initial_MinDataInterval_Ms (10) // 100Hz #define Als_Initial_Lux_Threshold_Pct (1.0f) // Percent threshold: 100% @@ -148,7 +148,7 @@ AlsDevice::Initialize( MemoryAttributes.ParentObject = SensorInstance; Status = WdfMemoryCreate(&MemoryAttributes, PagedPool, - SENSORV2_POOL_TAG_AMBIENT_LIGHT, + FWK_SENSORS_POOL_TAG_AMBIENT_LIGHT, Size, &MemoryHandle, (PVOID*)&m_pEnumerationProperties); @@ -208,7 +208,7 @@ AlsDevice::Initialize( MemoryAttributes.ParentObject = SensorInstance; Status = WdfMemoryCreate(&MemoryAttributes, PagedPool, - SENSORV2_POOL_TAG_AMBIENT_LIGHT, + FWK_SENSORS_POOL_TAG_AMBIENT_LIGHT, Size, &MemoryHandle, (PVOID*)&m_pSupportedDataFields); @@ -243,7 +243,7 @@ AlsDevice::Initialize( MemoryAttributes.ParentObject = SensorInstance; Status = WdfMemoryCreate(&MemoryAttributes, PagedPool, - SENSORV2_POOL_TAG_AMBIENT_LIGHT, + FWK_SENSORS_POOL_TAG_AMBIENT_LIGHT, Size, &MemoryHandle, (PVOID*)&m_pData); @@ -305,7 +305,7 @@ AlsDevice::Initialize( MemoryAttributes.ParentObject = SensorInstance; Status = WdfMemoryCreate(&MemoryAttributes, PagedPool, - SENSORV2_POOL_TAG_AMBIENT_LIGHT, + FWK_SENSORS_POOL_TAG_AMBIENT_LIGHT, Size, &MemoryHandle, (PVOID*)&m_pProperties); @@ -373,7 +373,7 @@ AlsDevice::Initialize( MemoryAttributes.ParentObject = SensorInstance; Status = WdfMemoryCreate(&MemoryAttributes, PagedPool, - SENSORV2_POOL_TAG_AMBIENT_LIGHT, + FWK_SENSORS_POOL_TAG_AMBIENT_LIGHT, Size, &MemoryHandle, (PVOID*)&m_pDataFieldProperties); @@ -412,7 +412,7 @@ AlsDevice::Initialize( MemoryAttributes.ParentObject = SensorInstance; Status = WdfMemoryCreate(&MemoryAttributes, PagedPool, - SENSORV2_POOL_TAG_AMBIENT_LIGHT, + FWK_SENSORS_POOL_TAG_AMBIENT_LIGHT, Size, &MemoryHandle, (PVOID*)&m_pThresholds); diff --git a/FrameworkSensors/SimpleDeviceOrientationClient.cpp b/FrameworkSensors/SimpleDeviceOrientationClient.cpp index a92fd22..69aa500 100644 --- a/FrameworkSensors/SimpleDeviceOrientationClient.cpp +++ b/FrameworkSensors/SimpleDeviceOrientationClient.cpp @@ -12,7 +12,7 @@ #include "SimpleDeviceOrientationClient.tmh" -#define SENSORV2_POOL_TAG_LINEAR_ACCELEROMETER 'sodS' +#define FWK_SENSORS_POOL_TAG_ORIENTATION 'irOF' #define SimpleDeviceOrientationDevice_Default_MinDataInterval (4) #define SimpleDeviceOrientationDevice_Default_Axis_Threshold (1.0f) @@ -108,7 +108,7 @@ SimpleDeviceOrientationDevice::Initialize( MemoryAttributes.ParentObject = SensorInstance; Status = WdfMemoryCreate(&MemoryAttributes, PagedPool, - SENSORV2_POOL_TAG_LINEAR_ACCELEROMETER, + FWK_SENSORS_POOL_TAG_ORIENTATION, Size, &MemoryHandle, (PVOID*)&m_pEnumerationProperties); @@ -160,7 +160,7 @@ SimpleDeviceOrientationDevice::Initialize( MemoryAttributes.ParentObject = SensorInstance; Status = WdfMemoryCreate(&MemoryAttributes, PagedPool, - SENSORV2_POOL_TAG_LINEAR_ACCELEROMETER, + FWK_SENSORS_POOL_TAG_ORIENTATION, Size, &MemoryHandle, (PVOID*)&m_pSupportedDataFields); @@ -192,7 +192,7 @@ SimpleDeviceOrientationDevice::Initialize( MemoryAttributes.ParentObject = SensorInstance; Status = WdfMemoryCreate(&MemoryAttributes, PagedPool, - SENSORV2_POOL_TAG_LINEAR_ACCELEROMETER, + FWK_SENSORS_POOL_TAG_ORIENTATION, Size, &MemoryHandle, (PVOID*)&m_pData); @@ -237,7 +237,7 @@ SimpleDeviceOrientationDevice::Initialize( MemoryAttributes.ParentObject = SensorInstance; Status = WdfMemoryCreate(&MemoryAttributes, PagedPool, - SENSORV2_POOL_TAG_LINEAR_ACCELEROMETER, + FWK_SENSORS_POOL_TAG_ORIENTATION, Size, &MemoryHandle, (PVOID*)&m_pProperties); @@ -280,7 +280,7 @@ SimpleDeviceOrientationDevice::Initialize( MemoryAttributes.ParentObject = SensorInstance; Status = WdfMemoryCreate(&MemoryAttributes, PagedPool, - SENSORV2_POOL_TAG_LINEAR_ACCELEROMETER, + FWK_SENSORS_POOL_TAG_ORIENTATION, Size, &MemoryHandle, (PVOID*)&m_pDataFieldProperties); @@ -320,7 +320,7 @@ SimpleDeviceOrientationDevice::Initialize( MemoryAttributes.ParentObject = SensorInstance; Status = WdfMemoryCreate(&MemoryAttributes, PagedPool, - SENSORV2_POOL_TAG_LINEAR_ACCELEROMETER, + FWK_SENSORS_POOL_TAG_ORIENTATION, Size, &MemoryHandle, (PVOID*)&m_pThresholds); From 8e9e2d1334e65b634ea10356a2a2f6d1aa25be74 Mon Sep 17 00:00:00 2001 From: Daniel Schaefer Date: Wed, 12 Feb 2025 10:41:14 +0800 Subject: [PATCH 3/4] Generate new Sensor GUIDs See: https://learn.microsoft.com/en-us/windows-hardware/drivers/gettingstarted/from-sample-code-to-production-driver Signed-off-by: Daniel Schaefer --- FrameworkSensors/AccelerometerClient.cpp | 5 ++--- FrameworkSensors/AlsClient.cpp | 4 ++-- FrameworkSensors/SimpleDeviceOrientationClient.cpp | 5 ++--- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/FrameworkSensors/AccelerometerClient.cpp b/FrameworkSensors/AccelerometerClient.cpp index db50e31..db53f16 100644 --- a/FrameworkSensors/AccelerometerClient.cpp +++ b/FrameworkSensors/AccelerometerClient.cpp @@ -21,11 +21,10 @@ #define AccelerometerDevice_Axis_Minimum (-2.0f) // in g #define AccelerometerDevice_Axis_Maximum (2.0f) // in g -// TODO: New GUID for this? // Accelerometer Unique ID -// {2BAAA1A7-6795-42A0-B830-82526CFD28D1} +// {A931067B-D450-42A4-8B20-2647D4CA9D2D} DEFINE_GUID(GUID_AccelerometerDevice_UniqueID, - 0x2baaa1a7, 0x6795, 0x42a0, 0xb8, 0x30, 0x82, 0x52, 0x6c, 0xfd, 0x28, 0xd1); + 0xa931067b, 0xd450, 0x42a4, 0x8b, 0x20, 0x26, 0x47, 0xd4, 0xca, 0x9d, 0x2d); // Sensor data typedef enum diff --git a/FrameworkSensors/AlsClient.cpp b/FrameworkSensors/AlsClient.cpp index 4e451d7..3c2f123 100644 --- a/FrameworkSensors/AlsClient.cpp +++ b/FrameworkSensors/AlsClient.cpp @@ -29,9 +29,9 @@ #define AlsDevice_Resolution_Lux (AlsDevice_Range_Lux / AlsDevice_Precision) // Ambient Light Sensor Unique ID -// {2D2A4524-51E3-4E68-9B0F-5CAEDFB12C02} +// {506AC61B-C762-499E-A848-685FC45DF39F} DEFINE_GUID(GUID_AlsDevice_UniqueID, - 0x2d2a4524, 0x51e3, 0x4e68, 0x9b, 0xf, 0x5c, 0xae, 0xdf, 0xb1, 0x2c, 0x2); + 0x506ac61b, 0xc762, 0x499e, 0xa8, 0x48, 0x68, 0x5f, 0xc4, 0x5d, 0xf3, 0x9f); // Sensor data typedef enum diff --git a/FrameworkSensors/SimpleDeviceOrientationClient.cpp b/FrameworkSensors/SimpleDeviceOrientationClient.cpp index 69aa500..8f97b96 100644 --- a/FrameworkSensors/SimpleDeviceOrientationClient.cpp +++ b/FrameworkSensors/SimpleDeviceOrientationClient.cpp @@ -21,10 +21,9 @@ #define SimpleDeviceOrientationDevice_Axis_Maximum (2.0f) // in g // Simple Device Orientation ID -// {4A303B3E-332A-4044-A35A-282F3D6D56E5} +// {D1FCD247-5848-433A-9129-4C0B93979BE4} DEFINE_GUID(GUID_SimpleDeviceOrientationDevice_UniqueID, - 0x4a303b3e, 0x332a, 0x4044, 0xa3, 0x5a, 0x28, 0x2f, 0x3d, 0x6d, 0x56, - 0xe5); + 0xd1fcd247, 0x5848, 0x433a, 0x91, 0x29, 0x4c, 0xb, 0x93, 0x97, 0x9b, 0xe4); // Sensor data typedef enum From db272cc53eef457b232e972a977e1fb1a7ffe6fb Mon Sep 17 00:00:00 2001 From: Daniel Schaefer Date: Wed, 12 Feb 2025 10:44:41 +0800 Subject: [PATCH 4/4] Add some Framework Copyright notices To files that we changed or created. Signed-off-by: Daniel Schaefer --- FrameworkSensors/AccelerometerClient.cpp | 1 + FrameworkSensors/EcCommunication.cpp | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/FrameworkSensors/AccelerometerClient.cpp b/FrameworkSensors/AccelerometerClient.cpp index db53f16..84eed16 100644 --- a/FrameworkSensors/AccelerometerClient.cpp +++ b/FrameworkSensors/AccelerometerClient.cpp @@ -1,4 +1,5 @@ // Copyright (C) Microsoft Corporation, All Rights Reserved. +// Copyright (C) Framework Computer Inc, All Rights Reserved. // // Abstract: // diff --git a/FrameworkSensors/EcCommunication.cpp b/FrameworkSensors/EcCommunication.cpp index 9adac8d..72c3468 100644 --- a/FrameworkSensors/EcCommunication.cpp +++ b/FrameworkSensors/EcCommunication.cpp @@ -1,6 +1,16 @@ - -// Only need EC commands to use EC_CMD_MOTION_SENSE_CMD to determine which accel sensors there are and which position they are -// ALl the rest can be done using memory map reads +// Copyright (C) Framework Computer Inc, All Rights Reserved. +// +// Abstract: +// +// This module contains the implementation of communication with the embedded controller. +// +// Only need EC commands to use EC_CMD_MOTION_SENSE_CMD to determine which +// accel sensors there are and which position they are. ALl the rest can be +// done using memory map reads. +// +// Environment: +// +// Windows User-Mode Driver Framework (UMDF) #include "Clients.h" #include "EcCommunication.h"