Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions qcperf/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,30 @@ project(QcPerf
include(cmake/BuildConfig.cmake)


# ============================================================================
# Target Hardware Version
# ============================================================================
# Specify the hardware target version to select the appropriate thermal zone
# handling strategy at compile time:
# V1 - Targetted compilation for v1 hardware
# V2 - Targeted compilation for v2 hardware
# Default - Targeted compilation for v2 hardware
set(QCPERF_TARGET_VERSION "AUTO" CACHE STRING "Target hardware version (V1, V2)")
set_property(CACHE QCPERF_TARGET_VERSION PROPERTY STRINGS V1 V2)

if(WIN32 AND CMAKE_SYSTEM_PROCESSOR MATCHES "ARM64|aarch64")
if(QCPERF_TARGET_VERSION STREQUAL "HW_API_V1")
add_compile_definitions(QCPERF_TARGET_V1)
message(STATUS "Target version: V1 (generic thermal zone support)")
elseif(QCPERF_TARGET_VERSION STREQUAL "HW_API_V2")
add_compile_definitions(QCPERF_TARGET_V2)
message(STATUS "Target HW API version: V2")
else()
add_compile_definitions(QCPERF_TARGET_V2)
message(STATUS "Default Target HW API version: V2")
endif()
endif()

# ============================================================================
# Component subdirectories
# ============================================================================
Expand All @@ -61,4 +85,5 @@ message(STATUS " CXX Compiler: ${CMAKE_CXX_COMPILER}")
message(STATUS " System: ${CMAKE_SYSTEM_NAME}")
message(STATUS " Processor: ${CMAKE_SYSTEM_PROCESSOR}")
message(STATUS " Install prefix: ${CMAKE_INSTALL_PREFIX}")
message(STATUS " Target version: ${QCPERF_TARGET_VERSION}")
message(STATUS "")
2 changes: 1 addition & 1 deletion qcperf/backends/utils/wos/ioctl/src/wos_ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ enum IoctlCommonReturnCode ioctl_get_device_handle(GUID guid, HANDLE* device_han
return_code = ioctl_get_device_symbolic_link(symbolic_link_request);

if (RETURN_CODE_IOCTL_COMMON_SUCCESS == return_code) {
*device_handle = CreateFile((LPCSTR)symbolic_link_request->symbolic_link, GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
*device_handle = CreateFile((LPCSTR)symbolic_link_request->symbolic_link, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
error_number = GetLastError();
if (*device_handle == INVALID_HANDLE_VALUE) {
return_code = RETURN_CODE_IOCTL_COMMON_CREATE_FILE_FAILED;
Expand Down
85 changes: 85 additions & 0 deletions qcperf/backends/utils/wos/pep/inc/qcpep_power_ioctl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/*
Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
Redistribution and use in source and binary forms, with or without
modification, are permitted (subject to the limitations in the
disclaimer below) provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of Qualcomm Technologies, Inc. nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* @file qcpep_power_ioctl.h
* @brief IOCTL interface definitions for the qcpep8380 power driver (V1 hardware).
*
* Qualcomm Power Engine Plug-in Device (ACPI\VEN_QCOM&DEV_0C17, qcpep8380.sys)
* on Snapdragon 8380 (V1). The standard GUID_DEVICE_ENERGY_METER path returns
* GLE=1 on V1 firmware, so these proprietary IOCTLs are used instead.
*
* Protocol (all IOCTLs: FILE_DEVICE_UNKNOWN, METHOD_BUFFERED, FILE_READ_DATA):
* func=0x000 IOCTL_QCPEP_GET_VERSION -> uint16 driver API version (= 2)
* func=0x001 IOCTL_QCPEP_GET_CAPS_SIZE -> uint32 byte size of caps buffer
* func=0x002 IOCTL_QCPEP_GET_CAPABILITIES -> QcPepCapabilities (variable length)
* func=0x003 IOCTL_QCPEP_GET_MEASUREMENTS -> QcPepRailMeasurement[numRails]
*
* Power calculation (two consecutive GET_MEASUREMENTS calls):
* power_W = (energy2 - energy1) / (filetimeTick2 - filetimeTick1)
* (energy in 100 nJ units, FILETIME in 100 ns units, factors cancel to Watts)
*/

#ifndef QCPEP_POWER_IOCTL_H
#define QCPEP_POWER_IOCTL_H

#include <windows.h>
#include <initguid.h>
#include <stdint.h>

DEFINE_GUID(GUID_QCPEP_POWER_DEVICE_INTERFACE,
0x09195dae, 0x6bd7, 0x4a9c, 0x8f, 0x3b, 0xc8, 0x35, 0x87, 0x3d, 0x4d, 0xae);

#define IOCTL_QCPEP_GET_VERSION CTL_CODE(FILE_DEVICE_UNKNOWN, 0x000, METHOD_BUFFERED, FILE_READ_DATA)
#define IOCTL_QCPEP_GET_CAPS_SIZE CTL_CODE(FILE_DEVICE_UNKNOWN, 0x001, METHOD_BUFFERED, FILE_READ_DATA)
#define IOCTL_QCPEP_GET_CAPABILITIES CTL_CODE(FILE_DEVICE_UNKNOWN, 0x002, METHOD_BUFFERED, FILE_READ_DATA)
#define IOCTL_QCPEP_GET_MEASUREMENTS CTL_CODE(FILE_DEVICE_UNKNOWN, 0x003, METHOD_BUFFERED, FILE_READ_DATA)

#define QCPEP_CAPS_BUFFER_MAX 512
#define QCPEP_RAIL_INDEX_UNMATCHED 0xFF

/*
* Fixed header of IOCTL_QCPEP_GET_CAPABILITIES response.
* Followed by numRails variable-length entries:
* { uint16_t nameBytes; WCHAR name[nameBytes/2]; <padding> }
* Use IOCTL_QCPEP_GET_CAPS_SIZE to allocate the correct buffer size.
*/
struct QcPepCapabilities {
WCHAR vendor[16];
WCHAR model[16];
uint16_t version;
uint16_t numRails;
uint32_t reserved;
};

struct QcPepRailMeasurement {
uint64_t energy100nJ;
uint64_t filetimeTick;
};

#endif // QCPEP_POWER_IOCTL_H
Loading