diff --git a/.gitignore b/.gitignore index ab950ebb..1b2a7423 100644 --- a/.gitignore +++ b/.gitignore @@ -28,11 +28,6 @@ public *.tmp_proj *.aps *.vssettings -*.tlog -*.recipe -*.log -*.idb -*.pdb .vs x64 Win32 @@ -81,5 +76,4 @@ ppm_compiler /ESIF/Products/ESIF_UI/Sources/solution/esif_ui_solution/bin/esif_ui_solution.dll /ESIF/Products/IPF_UI/Sources/solution/ipf_ui_solution/bin /ESIF/Products/IPF_UI/index.html -/IPF/Linux -/DPTF/Windows/Solution/.klocwork/ \ No newline at end of file +/IPF/Linux \ No newline at end of file diff --git a/Android.mk b/Android.mk index bcda0e75..f5e3c6aa 100644 --- a/Android.mk +++ b/Android.mk @@ -23,5 +23,7 @@ INTEL_DPTF_ROOT_PATH:= $(call my-dir) include $(INTEL_DPTF_ROOT_PATH)/ESIF/Products/ESIF_UF/Androidx86/jni/Android.mk include $(INTEL_DPTF_ROOT_PATH)/ESIF/Products/ESIF_CMP/Android/Android.mk include $(INTEL_DPTF_ROOT_PATH)/ESIF/Products/ESIF_WS/Android/Android.mk -include $(INTEL_DPTF_ROOT_PATH)/ESIF/Products/UPE_IOC/Android/Android.mk +#include $(INTEL_DPTF_ROOT_PATH)/ESIF/Products/UPE_IOC/Android/Android.mk +#include $(INTEL_DPTF_ROOT_PATH)/ESIF/Products/UPE_JAVA/Android/Android.mk +#include $(INTEL_DPTF_ROOT_PATH)/ESIF/Products/JHS/Android.mk include $(INTEL_DPTF_ROOT_PATH)/DPTF/Androidx86/jni/Android.mk diff --git a/Common/Ver.h b/Common/Ver.h index 58d74cf7..6666ce91 100644 --- a/Common/Ver.h +++ b/Common/Ver.h @@ -20,5 +20,5 @@ #define VER_MAJOR 1 #define VER_MINOR 0 -#define VER_HOTFIX 11100 -#define VER_BUILD 29358 +#define VER_HOTFIX 11001 +#define VER_BUILD 28546 diff --git a/Common/esif_ccb.h b/Common/esif_ccb.h index 2bcdf628..a6d16162 100644 --- a/Common/esif_ccb.h +++ b/Common/esif_ccb.h @@ -53,13 +53,33 @@ #pragma once +#if !defined(ESIF_ATTR_KERNEL) && !defined(ESIF_ATTR_USER) +/* User Mode Build */ +#define ESIF_ATTR_USER +#endif +#if defined(_WIN32) +#if !defined(ESIF_ATTR_OS_WINDOWS) +/* Windows OS */ +#define ESIF_ATTR_OS_WINDOWS +#endif +#else +#if !defined(ESIF_ATTR_OS_LINUX) && !defined(ESIF_ATTR_OS_CHROME) && !defined(ESIF_ATTR_OS_ANDROID) +/* Linux Derived OS */ +#define ESIF_ATTR_OS_LINUX +#endif +#endif #ifdef ESIF_ATTR_OS_CHROME /* Linux Derived OS */ #define ESIF_ATTR_OS_LINUX #define ESIF_ATTR_OS "Chrome" /* OS Is Chromium */ #endif +#ifdef ESIF_ATTR_OS_ANDROID +/* Linux Derived OS */ +#define ESIF_ATTR_OS_LINUX +#define ESIF_ATTR_OS "Android" /* OS Is Android */ +#endif #if defined(ESIF_ATTR_OS_LINUX) && !defined(_GNU_SOURCE) /* -std=gnu99 support */ #define _GNU_SOURCE @@ -70,13 +90,110 @@ #endif /* OS Agnostic */ +#ifdef ESIF_ATTR_USER #include #include +#else +#include +#endif + +#ifdef ESIF_ATTR_OS_WINDOWS + +/* Windows OS */ +#pragma strict_gs_check(on) + +#ifdef ESIF_ATTR_USER +#define _WINSOCKAPI_ /* Override for Winsock */ +#include + +/* Avoids Serialization Warnings*/ +#define ESIF_SERIAL_FENCE() _mm_lfence() + +#else +#include +#define INVALID_HANDLE_VALUE ((HANDLE)(LONG_PTR)-1) /* Invalid ESIF Handle */ +#endif + +/* Add Linux Base Types for Windows */ +typedef unsigned char u8; /* A BYTE */ +typedef unsigned short u16; /* A WORD */ +typedef unsigned int u32; /* A DWORD */ +typedef unsigned long long u64; /* A QWORD */ + +typedef char *esif_string; /* NULL-teriminated ANSI string */ +typedef HANDLE esif_os_handle_t;/* opaque OS Handle (not a pointer) */ +typedef u64 esif_handle_t; /* opaque ESIF 64-bit handle (may NOT be a pointer) */ +typedef u64 esif_context_t; /* opaque ESIF 64-bit context (may be a pointer) */ + +#define ESIF_ATTR_OS "Windows" /* OS Is Windows */ +#define ESIF_INLINE __inline /* Inline Function Directive */ +#define ESIF_FUNC __FUNCTION__ /* Current Function Name */ +#define ESIF_CALLCONV __cdecl /* SDK Calling Convention */ +#define ESIF_PATH_SEP "\\" /* Path Separator String */ +#define ESIF_EXPORT __declspec(dllexport) /* Used for Exported Symbols */ +#define ESIF_INVALID_HANDLE ((esif_handle_t)(-1)) /* Invalid ESIF Handle */ +#define ESIF_HANDLE_DEFAULT ((esif_handle_t)(0)) /* Reserved ESIF handle */ +#define ESIF_HANDLE_PRIMARY_PARTICIPANT ((esif_handle_t)(1)) /* Reserved ESIF primary participant handle */ +#define ESIF_HANDLE_MATCH_ANY_EVENT ((esif_handle_t)(-2)) /* Reserved ESIF handle */ + +#define ESIF_WS_LIBRARY_NAME "ipf_ws" /* Legacy Library/App Name for deprecated in-process web server*/ +#define esif_ccb_isfullpath(fname) (fname[0] == '\\' || (isalpha(fname[0]) && fname[1] == ':')) + +#ifdef __cplusplus +#define ESIF_ELEMENT(x) /* C99 Designated Initializers unsupported in C++ */ +#else +#define ESIF_ELEMENT(x) x = /* Support C99 Designated Initializers */ +#endif + +/* Avoids "conditional constant is an expression" warnings for do...while(0) loops */ +#define ESIF_CONSTEXPR(expr) __pragma(warning(push)) __pragma(warning(disable:4127)) (expr) __pragma(warning(pop)) + +/* Sleep Interface */ +#define esif_ccb_sleep(sec) Sleep(sec * 1000) +#define esif_ccb_sleep_msec(msec) Sleep(msec) + +/* Deduce Platform based on predefined compiler flags */ +#ifdef _WIN64 +#define ESIF_ATTR_64BIT +#endif + +/* Deduce Debug Build for Windows. Non-Windows can define this in Makefile */ +#ifdef _DEBUG +#define ESIF_ATTR_DEBUG +#endif + +#ifdef ESIF_ATTR_DEBUG +#ifdef ESIF_ATTR_USER +#define ESIF_ASSERT(x) \ + do { \ + if ESIF_CONSTEXPR(!(x)) \ + DebugBreak(); \ + } while ESIF_CONSTEXPR(0) + +#else /* !ESIF_ATTR_USER */ +#define ESIF_ASSERT(x) ASSERT(x) +#endif /* !ESIF_ATTR_USER */ +#else /* !ESIF_ATTR_DEBUG */ +#define ESIF_ASSERT(x) (0) +#endif /* !ESIF_ATTR_DEBUG */ + + +#ifdef ESIF_ATTR_USER +/* Byte Ordering Utilities (Winsock2.h) */ +#define esif_ccb_htons(val) htons(val) +#define esif_ccb_htonl(val) htonl(val) +#define esif_ccb_htonll(val) htonll(val) +#endif + +#endif /* WINDOWS */ + +#ifdef ESIF_ATTR_OS_LINUX /* All Linux Derived OS */ +#ifdef ESIF_ATTR_USER #include /* POSIX API */ /* Common Windows Symbols */ @@ -89,6 +206,7 @@ #include #define ESIF_SERIAL_FENCE() _mm_lfence() +#endif /* Add Linux Base Types */ typedef unsigned char u8; @@ -120,8 +238,18 @@ typedef u64 esif_handle_t; /* opaque ESIF 64-bit handle (may not be a pointer) * typedef u64 esif_context_t; /* opaque ESIF 64-bit context (may be a pointer) */ #ifdef ESIF_ATTR_DEBUG +# ifdef ESIF_ATTR_USER # include # define ESIF_ASSERT(x) assert(x) +# else +# define ESIF_ASSERT(x) \ + do { \ + if (x) \ + break; \ + printk(KERN_EMERG "!ESIF_ASSERT! [%s@%s#%d]: %s\n", ESIF_FUNC, __FILE__, __LINE__, #x); \ + BUG(); \ + } while (0) +# endif #else # define ESIF_ASSERT(x) #endif @@ -146,6 +274,7 @@ typedef u64 esif_context_t; /* opaque ESIF 64-bit context (may be a pointer) */ /* Used for constant expressions, such as do...while(0) loops */ #define ESIF_CONSTEXPR(expr) (expr) +#ifdef ESIF_ATTR_USER /* Byte Ordering Utilities */ #include /* htonl */ #define esif_ccb_htons(val) htons(val) @@ -157,7 +286,9 @@ static ESIF_INLINE u64 esif_ccb_htonll(u64 value) u32 lo = htonl((u32)value); return (((u64)lo) << 32) | hi; } +#endif +#endif /* LINUX */ /* * OS Agnostic diff --git a/Common/esif_ccb_atomic.h b/Common/esif_ccb_atomic.h index d2d95ddf..1fc3e529 100644 --- a/Common/esif_ccb_atomic.h +++ b/Common/esif_ccb_atomic.h @@ -53,16 +53,27 @@ #pragma once -#include "esif_ccb.h" - /* * C/C++ OS-Agnostic Universal Implementation of atomic integer operations. * Interface is based on native Linux atomic_t kernel type (atomic.h) * Note: atomic_t is 32 or 64 bit, depending on OS/Platform so treat as opaque */ +#if defined(ESIF_ATTR_KERNEL) + +#if defined(ESIF_ATTR_OS_WINDOWS) +#include "esif_ccb_atomic_win_kern.h" +#elif defined(ESIF_ATTR_OS_LINUX) +#include "esif_ccb_atomic_lin_kern.h" +#endif +#elif defined(ESIF_ATTR_USER) + +#if defined(ESIF_ATTR_OS_WINDOWS) +#include "esif_ccb_atomic_win_user.h" +#elif defined(ESIF_ATTR_OS_LINUX) #include "esif_ccb_atomic_lin_user.h" +#endif /* Disable User-Mode Atomic operations. Use at your own risk */ #if defined(ATOMIC_LIB_DISABLE) @@ -75,3 +86,4 @@ # define atomic_sub(i, v) (*(v) -= (i)) #endif +#endif /* USER */ diff --git a/Common/esif_ccb_atomic_lin_user.h b/Common/esif_ccb_atomic_lin_user.h index f58537d8..680fb675 100644 --- a/Common/esif_ccb_atomic_lin_user.h +++ b/Common/esif_ccb_atomic_lin_user.h @@ -18,6 +18,7 @@ #pragma once +#if defined(ESIF_ATTR_OS_LINUX) && defined(ESIF_ATTR_USER) /* Linux User: Use native x86/x64 type and __atomic builtin functions [gcc 4.7.0 or higher] */ @@ -68,3 +69,4 @@ typedef volatile atomic_basetype atomic_t; #define atomic_sub(i, v) __atomic_fetch_sub(v, i, __ATOMIC_SEQ_CST) #endif /* !DISABLE */ +#endif /* LINUX USER */ diff --git a/Common/esif_ccb_cpuid.h b/Common/esif_ccb_cpuid.h index ed14ab32..4ac41b0e 100644 --- a/Common/esif_ccb_cpuid.h +++ b/Common/esif_ccb_cpuid.h @@ -53,8 +53,6 @@ #pragma once -#include "esif_ccb.h" - /* * C/C++ OS-Agnostic Universal Implementation of the cpuid intrinsic. */ @@ -125,5 +123,17 @@ typedef struct esif_ccb_cpuid_s { #pragma pack(pop) +#if defined(ESIF_ATTR_KERNEL) +#if defined(ESIF_ATTR_OS_WINDOWS) +#include "esif_ccb_cpuid_win_kern.h" +#elif defined(ESIF_ATTR_OS_LINUX) +#include "esif_ccb_cpuid_lin_kern.h" +#endif +#elif defined(ESIF_ATTR_USER) +#if defined(ESIF_ATTR_OS_WINDOWS) +#include "esif_ccb_cpuid_win_user.h" +#elif defined(ESIF_ATTR_OS_LINUX) #include "esif_ccb_cpuid_lin_user.h" +#endif +#endif /* USER */ diff --git a/Common/esif_ccb_cpuid_lin_user.h b/Common/esif_ccb_cpuid_lin_user.h index b8f7f932..144e1e14 100644 --- a/Common/esif_ccb_cpuid_lin_user.h +++ b/Common/esif_ccb_cpuid_lin_user.h @@ -18,6 +18,7 @@ #pragma once +#if defined(ESIF_ATTR_OS_LINUX) && defined(ESIF_ATTR_USER) #include @@ -30,3 +31,4 @@ static ESIF_INLINE void esif_ccb_cpuid(esif_ccb_cpuid_t *cpuidPtr) &cpuidPtr->edx); } +#endif /* LINUX USER */ diff --git a/Common/esif_ccb_env.h b/Common/esif_ccb_env.h index 33a740e0..9d6650b8 100644 --- a/Common/esif_ccb_env.h +++ b/Common/esif_ccb_env.h @@ -18,9 +18,32 @@ #pragma once +#if defined(ESIF_ATTR_USER) + #include "esif_ccb.h" +#if defined(ESIF_ATTR_OS_WINDOWS) + +// Get Environment variable +static ESIF_INLINE char *esif_ccb_getenv(const char *name) +{ + char *path = NULL; + size_t len = 0; + + if (_dupenv_s(&path, &len, name) != 0) + path = NULL; + return path; +} + +static ESIF_INLINE void esif_ccb_envfree(char *name) +{ + if (name) { + free(name); + } +} + +#elif defined(ESIF_ATTR_OS_LINUX) #include @@ -29,4 +52,6 @@ #define esif_ccb_envfree(arg) ((void)(0)) +#endif /* LINUX */ +#endif /* USER */ \ No newline at end of file diff --git a/Common/esif_ccb_file.h b/Common/esif_ccb_file.h index d9666cc7..7a5cb2d5 100644 --- a/Common/esif_ccb_file.h +++ b/Common/esif_ccb_file.h @@ -18,8 +18,14 @@ #pragma once -#include "esif_ccb.h" +#if defined(ESIF_ATTR_USER) +#include "esif_ccb.h" +#if defined(ESIF_ATTR_OS_WINDOWS) +#include "esif_ccb_file_win_user.h" +#elif defined(ESIF_ATTR_OS_LINUX) #include "esif_ccb_file_lin_user.h" +#endif +#endif /* USER */ \ No newline at end of file diff --git a/Common/esif_ccb_file_lin_user.h b/Common/esif_ccb_file_lin_user.h index 2e148050..b2f54a4a 100644 --- a/Common/esif_ccb_file_lin_user.h +++ b/Common/esif_ccb_file_lin_user.h @@ -18,6 +18,7 @@ #pragma once +#if defined(ESIF_ATTR_OS_LINUX) && defined(ESIF_ATTR_USER) #include #include @@ -290,3 +291,4 @@ static ESIF_INLINE void esif_ccb_file_enum_close(esif_ccb_file_enum_t find_handl esif_ccb_free(find_handle); } +#endif /* LINUX USER */ \ No newline at end of file diff --git a/Common/esif_ccb_kpe.h b/Common/esif_ccb_kpe.h index 47359310..9f6b470f 100644 --- a/Common/esif_ccb_kpe.h +++ b/Common/esif_ccb_kpe.h @@ -62,6 +62,43 @@ * MACRO DEFINITIONS */ +#ifdef ESIF_ATTR_OS_WINDOWS +#include +#include + +#ifdef ESIF_ATTR_DEBUG +#define KPE_TRACE_MSG(fmt, ...) DbgPrint("[%s@%s#%d]: " fmt, \ + ESIF_FUNC, __FILE__, __LINE__, ##__VA_ARGS__) +#else +#define KPE_TRACE_MSG(fmt, ...) (0) +#endif + +#define PNP_INTERFACE_VERSION_KPE 2 + +/* + * The following GUID is used to register for PnP notification for when the + * DPTF driver arrives/leaves: + * {EE27098E-1B22-472A-89D8-5CCCE16B1356} + */ +DEFINE_GUID(GUID_PNP_INTERFACE_ESIF_LF, +0xee27098e, 0x1b22, 0x472a, 0x89, 0xd8, 0x5c, 0xcc, 0xe1, 0x6b, 0x13, 0x56); + +/* + * The following GUID is used to query for the KPE interface once the DPTF + * driver is present: + * {286F08C0-C9BE-4C6E-A0A3-152D3F167D78} + */ +DEFINE_GUID(GUID_PNP_INTERFACE_KPE, +0x286f08c0, 0xc9be, 0x4c6e, 0xa0, 0xa3, 0x15, 0x2d, 0x3f, 0x16, 0x7d, 0x78); + +typedef struct _PNP_INTERFACE_KPE { + INTERFACE InterfaceHeader; + enum esif_rc (*esif_lf_register_driver)(struct esif_driver_iface *diPtr); + enum esif_rc (*esif_lf_unregister_driver)(struct esif_driver_iface *diPtr); +} PNP_INTERFACE_KPE, *PPNP_INTERFACE_KPE; + + +#else /* NOT ESIF_ATTR_OS_WINDOWS */ #ifdef ESIF_ATTR_DEBUG #define KPE_TRACE_MSG(fmt, ...) printk("[%s@%s#%d]: " fmt, \ ESIF_FUNC, __FILE__, __LINE__, ##__VA_ARGS__) @@ -72,5 +109,6 @@ enum esif_rc esif_lf_register_driver(struct esif_driver_iface *diPtr); enum esif_rc esif_lf_unregister_driver(struct esif_driver_iface *diPtr); +#endif /* NOT ESIF_ATTR_OS_WINDOWS */ diff --git a/Common/esif_ccb_library.h b/Common/esif_ccb_library.h index 256bce07..79742383 100644 --- a/Common/esif_ccb_library.h +++ b/Common/esif_ccb_library.h @@ -18,8 +18,14 @@ #pragma once -#include "esif_ccb.h" +#if defined(ESIF_ATTR_USER) +#include "esif_ccb.h" +#if defined(ESIF_ATTR_OS_WINDOWS) +#include "esif_ccb_library_win_user.h" +#elif defined(ESIF_ATTR_OS_LINUX) #include "esif_ccb_library_lin_user.h" +#endif +#endif /* USER */ diff --git a/Common/esif_ccb_library_lin_user.h b/Common/esif_ccb_library_lin_user.h index ffd85c79..6a58feef 100644 --- a/Common/esif_ccb_library_lin_user.h +++ b/Common/esif_ccb_library_lin_user.h @@ -18,6 +18,7 @@ #pragma once +#if defined(ESIF_ATTR_OS_LINUX) && defined(ESIF_ATTR_USER) #include #include @@ -247,3 +248,4 @@ static ESIF_INLINE Bool esif_ccb_library_isloaded(esif_lib_t lib) return (NULL != lib && NULL != lib->handle); } +#endif /* LINUX USER */ diff --git a/Common/esif_ccb_lock.h b/Common/esif_ccb_lock.h index b9240e97..812850f2 100644 --- a/Common/esif_ccb_lock.h +++ b/Common/esif_ccb_lock.h @@ -55,6 +55,15 @@ #include "esif_ccb.h" +#if defined(ESIF_ATTR_KERNEL) + +#if defined(ESIF_ATTR_OS_WINDOWS) +#include "esif_ccb_lock_win_kern.h" +#elif defined(ESIF_ATTR_OS_LINUX) +#include "esif_ccb_lock_lin_kern.h" +#endif + +#elif defined(ESIF_ATTR_USER) #include "esif_ccb_atomic.h" @@ -65,5 +74,10 @@ typedef atomic_t esif_ccb_spinlock_t; #define esif_ccb_spinlock_lock(lockPtr) while (atomic_set(lockPtr, 1) == 1) {;} #define esif_ccb_spinlock_unlock(lockPtr) atomic_set(lockPtr, 0) +#if defined(ESIF_ATTR_OS_WINDOWS) +#include "esif_ccb_lock_win_user.h" +#elif defined(ESIF_ATTR_OS_LINUX) #include "esif_ccb_lock_lin_user.h" +#endif +#endif /* USER */ diff --git a/Common/esif_ccb_lock_lin_user.h b/Common/esif_ccb_lock_lin_user.h index e5543fd8..7359deb4 100644 --- a/Common/esif_ccb_lock_lin_user.h +++ b/Common/esif_ccb_lock_lin_user.h @@ -18,6 +18,7 @@ #pragma once +#if defined(ESIF_ATTR_OS_LINUX) && defined(ESIF_ATTR_USER) #include #include @@ -119,3 +120,4 @@ static ESIF_INLINE void esif_ccb_read_unlock(esif_ccb_lock_t *lockPtr) if (pthread_rwlock_unlock(lockPtr) != 0) {} } +#endif /* LINUX */ diff --git a/Common/esif_ccb_memory.h b/Common/esif_ccb_memory.h index 778dae03..e35d5464 100644 --- a/Common/esif_ccb_memory.h +++ b/Common/esif_ccb_memory.h @@ -55,8 +55,21 @@ #include "esif_ccb.h" +#if defined(ESIF_ATTR_KERNEL) +#if defined(ESIF_ATTR_OS_WINDOWS) +#include "esif_ccb_memory_win_kern.h" +#elif defined(ESIF_ATTR_OS_LINUX) +#include "esif_ccb_memory_lin_kern.h" +#endif + +#elif defined(ESIF_ATTR_USER) + +#if defined(ESIF_ATTR_OS_WINDOWS) +#include "esif_ccb_memory_win_user.h" +#elif defined(ESIF_ATTR_OS_LINUX) #include "esif_ccb_memory_lin_user.h" +#endif // Find a substring in a non-NULL terminated string buffer static ESIF_INLINE char *esif_ccb_memstr( @@ -77,3 +90,4 @@ static ESIF_INLINE char *esif_ccb_memstr( return NULL; } +#endif /* USER */ diff --git a/Common/esif_ccb_memory_lin_user.h b/Common/esif_ccb_memory_lin_user.h index ba945f3f..a951ec53 100644 --- a/Common/esif_ccb_memory_lin_user.h +++ b/Common/esif_ccb_memory_lin_user.h @@ -18,6 +18,7 @@ #pragma once +#if defined(ESIF_ATTR_OS_LINUX) && defined(ESIF_ATTR_USER) #include #include @@ -96,6 +97,7 @@ static ESIF_INLINE void *esif_ccb_realloc( } #endif /* ESIF_ATTR_MEMTRACE */ +#endif /* _ESIF_CCB_MEMORY_H_ */ /*****************************************************************************/ /*****************************************************************************/ diff --git a/Common/esif_ccb_memstat.h b/Common/esif_ccb_memstat.h index a1a7fe76..0b342794 100644 --- a/Common/esif_ccb_memstat.h +++ b/Common/esif_ccb_memstat.h @@ -53,8 +53,6 @@ #pragma once -#include "esif_ccb.h" - /* * Kernel Memory Statistics */ @@ -69,3 +67,58 @@ struct esif_memory_stats { }; #pragma pack(pop) +#if defined(ESIF_ATTR_KERNEL) + +/* Enable Memory Statistics for ESIF_LF Kernel Driver? */ +#ifdef ESIF_FEAT_OPT_USE_VIRT_DRVRS + +/* Placeholder macros for memstats when not building ESIF_LF */ +#define memstat_inc(ptr) +#define memstat_read(ptr) (0) +#define memstat_set(ptr) + +#else + +/* Kernel Memory Stats */ +#include "esif_ccb_lock.h" + +#ifdef __cplusplus +extern "C" { +#endif + +extern struct esif_memory_stats g_memstat; +extern esif_ccb_lock_t g_memstat_lock; + +#ifdef __cplusplus +} +#endif + +/* WARNING: This function may not be called from paged code in kernel */ +static ESIF_INLINE void memstat_inc(u32 *intptr) +{ + esif_ccb_write_lock(&g_memstat_lock); + (*(intptr))++; + esif_ccb_write_unlock(&g_memstat_lock); +} + +/* WARNING: This function may not be called from paged code in kernel */ +static ESIF_INLINE u32 memstat_read(u32 *intptr) +{ + u32 rc; + esif_ccb_read_lock(&g_memstat_lock); + rc = *(intptr); + esif_ccb_read_unlock(&g_memstat_lock); + return rc; +} + +/* WARNING: This function may not be called from paged code in kernel */ +static ESIF_INLINE void memstat_set(u32 *intptr, u32 val) +{ + esif_ccb_write_lock(&g_memstat_lock); + *(intptr) = val; + esif_ccb_write_unlock(&g_memstat_lock); +} + +#endif /* not ESIF_FEAT_OPT_USE_VIRT_DRVRS */ + +#endif /* KERNEL */ diff --git a/Common/esif_ccb_memtrace.h b/Common/esif_ccb_memtrace.h index dd62972b..0d7074db 100644 --- a/Common/esif_ccb_memtrace.h +++ b/Common/esif_ccb_memtrace.h @@ -18,8 +18,6 @@ #pragma once -#include "esif_ccb.h" - #if defined(ESIF_ATTR_USER) && defined(ESIF_ATTR_MEMTRACE) #include "esif_ccb_rc.h" diff --git a/Common/esif_ccb_random.h b/Common/esif_ccb_random.h index 5e10fa9d..3d17f135 100644 --- a/Common/esif_ccb_random.h +++ b/Common/esif_ccb_random.h @@ -18,9 +18,14 @@ #pragma once -#include "esif_ccb.h" - +#if defined(ESIF_ATTR_USER) +#include "esif_ccb.h" #include "esif_ccb_rc.h" +#if defined(ESIF_ATTR_OS_WINDOWS) +#include "esif_ccb_random_win_user.h" +#elif defined(ESIF_ATTR_OS_LINUX) #include "esif_ccb_random_lin_user.h" +#endif +#endif /* USER */ \ No newline at end of file diff --git a/Common/esif_ccb_random_lin_user.h b/Common/esif_ccb_random_lin_user.h index e0240d51..640e9be9 100644 --- a/Common/esif_ccb_random_lin_user.h +++ b/Common/esif_ccb_random_lin_user.h @@ -18,6 +18,7 @@ #pragma once +#if defined(ESIF_ATTR_OS_LINUX) && defined(ESIF_ATTR_USER) // Use getrandom() for GLIBC 2.25 and higher (Ubuntu 18.04) #if defined(__GLIBC__) && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 25)) // getrandom @@ -73,3 +74,4 @@ static ESIF_INLINE esif_error_t esif_ccb_random(void *buffer, size_t buf_len) } +#endif /* LINUX USER */ diff --git a/Common/esif_ccb_rc.h b/Common/esif_ccb_rc.h index c7f7fd73..5f837e0a 100644 --- a/Common/esif_ccb_rc.h +++ b/Common/esif_ccb_rc.h @@ -396,4 +396,6 @@ static ESIF_INLINE char *esif_error_str(esif_error_t type) #define esif_rc_str(type) esif_error_str(type) +#ifdef ESIF_ATTR_USER typedef enum esif_rc eEsifError; +#endif diff --git a/Common/esif_ccb_sem.h b/Common/esif_ccb_sem.h index 7a0ee0e7..ac9565f4 100644 --- a/Common/esif_ccb_sem.h +++ b/Common/esif_ccb_sem.h @@ -56,8 +56,22 @@ #include "esif_ccb.h" #include "esif_ccb_rc.h" +#if defined(ESIF_ATTR_KERNEL) +#if defined(ESIF_ATTR_OS_WINDOWS) +#include "esif_ccb_sem_win_kern.h" +#elif defined(ESIF_ATTR_OS_LINUX) +#include "esif_ccb_sem_lin_kern.h" +#endif /* KERNEL */ + +#elif defined(ESIF_ATTR_USER) + +#if defined(ESIF_ATTR_OS_WINDOWS) +#include "esif_ccb_sem_win_user.h" +#elif defined(ESIF_ATTR_OS_LINUX) #include "esif_ccb_sem_lin_user.h" +#endif +#endif /* USER */ #include "esif_ccb_lock.h" @@ -80,6 +94,9 @@ static ESIF_INLINE void esif_ccb_event_init(esif_ccb_event_t *event_ptr) } +#if defined(ESIF_ATTR_OS_WINDOWS) +#pragma warning(suppress: 28167) +#endif /* * Suppresses SCA false positive where IRQL level is not properly tracked. */ @@ -105,6 +122,9 @@ static ESIF_INLINE void esif_ccb_event_uninit(esif_ccb_event_t *event_ptr) } +#if defined(ESIF_ATTR_OS_WINDOWS) +#pragma warning(suppress: 28167) +#endif /* * Suppresses SCA false positive where IRQL level is not properly tracked. */ @@ -127,6 +147,9 @@ static ESIF_INLINE void esif_ccb_event_wait(esif_ccb_event_t *event_ptr) } +#if defined(ESIF_ATTR_OS_WINDOWS) +#pragma warning(suppress: 28167) +#endif /* * Suppresses SCA false positive where IRQL level is not properly tracked. */ @@ -159,6 +182,9 @@ static ESIF_INLINE void esif_ccb_event_reset(esif_ccb_event_t *event_ptr) * Special use case function which allows all waiters to proceed, but does not * change the signaled state. */ +#if defined(ESIF_ATTR_OS_WINDOWS) +#pragma warning(suppress: 28167) +#endif /* * Suppresses SCA false positive where IRQL level is not properly tracked. */ diff --git a/Common/esif_ccb_sem_lin_user.h b/Common/esif_ccb_sem_lin_user.h index 165a657c..d7629635 100644 --- a/Common/esif_ccb_sem_lin_user.h +++ b/Common/esif_ccb_sem_lin_user.h @@ -18,6 +18,7 @@ #pragma once +#if defined(ESIF_ATTR_OS_LINUX) && defined(ESIF_ATTR_USER) #include #include @@ -71,3 +72,4 @@ typedef pthread_cond_t esif_ccb_cond_t; #define esif_ccb_cond_signal pthread_cond_signal #define esif_ccb_cond_broadcast pthread_cond_broadcast +#endif /* LINUX */ diff --git a/Common/esif_ccb_socket.h b/Common/esif_ccb_socket.h index 56a256dc..72bf35d6 100644 --- a/Common/esif_ccb_socket.h +++ b/Common/esif_ccb_socket.h @@ -18,7 +18,13 @@ #pragma once -#include "esif_ccb.h" +#if defined(ESIF_ATTR_USER) +#include "esif_ccb.h" +#if defined(ESIF_ATTR_OS_WINDOWS) +#include "esif_ccb_socket_win_user.h" +#elif defined(ESIF_ATTR_OS_LINUX) #include "esif_ccb_socket_lin_user.h" +#endif +#endif /* USER */ \ No newline at end of file diff --git a/Common/esif_ccb_socket_lin_user.h b/Common/esif_ccb_socket_lin_user.h index 383c110c..13218c26 100644 --- a/Common/esif_ccb_socket_lin_user.h +++ b/Common/esif_ccb_socket_lin_user.h @@ -18,6 +18,7 @@ #pragma once +#if defined(ESIF_ATTR_OS_LINUX) && defined(ESIF_ATTR_USER) #include #include @@ -74,3 +75,4 @@ static int ESIF_INLINE esif_ccb_socket_shutdown(esif_ccb_socket_t socket, int ho #define esif_ccb_socketpair(af, typ, prot, sock) socketpair(af, typ, prot, sock) +#endif /* LINUX USER */ diff --git a/Common/esif_ccb_sort.h b/Common/esif_ccb_sort.h index d30d009d..dfa02af9 100644 --- a/Common/esif_ccb_sort.h +++ b/Common/esif_ccb_sort.h @@ -18,9 +18,14 @@ #pragma once -#include "esif_ccb.h" - +#if defined(ESIF_ATTR_USER) +#include "esif_ccb.h" #include "esif_ccb_string.h" +#if defined(ESIF_ATTR_OS_WINDOWS) +#include "esif_ccb_sort_win_user.h" +#elif defined(ESIF_ATTR_OS_LINUX) #include "esif_ccb_sort_lin_user.h" +#endif +#endif /* USER */ \ No newline at end of file diff --git a/Common/esif_ccb_sort_lin_user.h b/Common/esif_ccb_sort_lin_user.h index 6ec05d0d..d4e4155a 100644 --- a/Common/esif_ccb_sort_lin_user.h +++ b/Common/esif_ccb_sort_lin_user.h @@ -18,9 +18,46 @@ #pragma once +#if defined(ESIF_ATTR_OS_LINUX) && defined(ESIF_ATTR_USER) #include +#if defined (ESIF_ATTR_OS_ANDROID) + +// qsort_r unavailable Android Bionic library so use standard qsort +static ESIF_INLINE void esif_ccb_qsort( + void *base, + size_t num, + size_t size, + int(*compar)(const void *, const void *), + void *ctx + ) +{ + UNREFERENCED_PARAMETER(ctx); + if (base && num > 0) { + qsort(base, num, size, compar); + } +} + +// qsort() callback to case-insenstive sort an array of null-terminated ANSI strings +static ESIF_INLINE int ESIF_CALLCONV esif_ccb_qsort_stricmp( + const void *arg1, + const void *arg2 + ) +{ + return esif_ccb_stricmp(*(char **)arg1, *(char **)arg2); +} + +// qsort() callback to case-senstive sort an array of null-terminated ANSI strings +static ESIF_INLINE int ESIF_CALLCONV esif_ccb_qsort_strcmp( + const void *arg1, + const void *arg2 + ) +{ + return esif_ccb_strcmp(*(char **)arg1, *(char **)arg2); +} + +#else /* Chrome and all other Linux-derived OS */ static ESIF_INLINE void esif_ccb_qsort( void *base, @@ -56,4 +93,6 @@ static ESIF_INLINE int ESIF_CALLCONV esif_ccb_qsort_strcmp( UNREFERENCED_PARAMETER(ctx); return esif_ccb_strcmp(*(char **)arg1, *(char **)arg2); } +#endif /* ANDROID */ +#endif /* LINUX USER */ diff --git a/Common/esif_ccb_string.h b/Common/esif_ccb_string.h index 240948d9..fc8f4322 100644 --- a/Common/esif_ccb_string.h +++ b/Common/esif_ccb_string.h @@ -56,9 +56,23 @@ #include "esif_ccb.h" #include "esif_ccb_memory.h" +#if defined(ESIF_ATTR_KERNEL) +#if defined(ESIF_ATTR_OS_WINDOWS) +#include "esif_ccb_string_win_kern.h" +#elif defined(ESIF_ATTR_OS_LINUX) +#include "esif_ccb_string_lin_kern.h" +#endif + +#elif defined(ESIF_ATTR_USER) + +#if defined(ESIF_ATTR_OS_WINDOWS) +#include "esif_ccb_string_win_user.h" +#elif defined(ESIF_ATTR_OS_LINUX) #include "esif_ccb_string_lin_user.h" +#endif +#endif /* USER */ /* OS/Kernel Agnostic */ diff --git a/Common/esif_ccb_string_lin_user.h b/Common/esif_ccb_string_lin_user.h index ac3b0fd5..3a48f401 100644 --- a/Common/esif_ccb_string_lin_user.h +++ b/Common/esif_ccb_string_lin_user.h @@ -18,6 +18,7 @@ #pragma once +#if defined(ESIF_ATTR_OS_LINUX) && defined(ESIF_ATTR_USER) #include "esif_ccb_memory.h" #include @@ -236,3 +237,4 @@ static ESIF_INLINE char *esif_ccb_strncpy( return dst; } +#endif /* LINUX USER */ diff --git a/Common/esif_ccb_thread.h b/Common/esif_ccb_thread.h index 8026c2a3..a0257bbe 100644 --- a/Common/esif_ccb_thread.h +++ b/Common/esif_ccb_thread.h @@ -18,16 +18,20 @@ #pragma once -#include "esif_ccb.h" - +#if defined(ESIF_ATTR_USER) +#include "esif_ccb.h" #include "esif_ccb_rc.h" #define THREAD_DEBUG(fmt, ...) /* NOOP */ typedef void *(ESIF_CALLCONV * work_func_t)(void *); /* Worker Function */ +#if defined(ESIF_ATTR_OS_WINDOWS) +#include "esif_ccb_thread_win_user.h" +#elif defined(ESIF_ATTR_OS_LINUX) #include "esif_ccb_thread_lin_user.h" +#endif /* ** esif_wthread_t - A Waitable Thread object that encapsulates esif_thread_t into a new object that can have more than @@ -111,3 +115,4 @@ static ESIF_INLINE esif_thread_id_t esif_ccb_wthread_id(esif_wthread_t *self) return id; } +#endif /* USER */ \ No newline at end of file diff --git a/Common/esif_ccb_thread_lin_user.h b/Common/esif_ccb_thread_lin_user.h index 4235a3d2..6393f29a 100644 --- a/Common/esif_ccb_thread_lin_user.h +++ b/Common/esif_ccb_thread_lin_user.h @@ -18,6 +18,7 @@ #pragma once +#if defined(ESIF_ATTR_OS_LINUX) && defined(ESIF_ATTR_USER) #include typedef pthread_t esif_thread_t; /* Non-Unique Thread Handle */ @@ -115,3 +116,4 @@ static ESIF_INLINE enum esif_rc esif_ccb_thread_close(esif_thread_t* thread_ptr) return rc; } +#endif /* LINUX USER */ diff --git a/Common/esif_ccb_time.h b/Common/esif_ccb_time.h index fef95c76..ad1b02a7 100644 --- a/Common/esif_ccb_time.h +++ b/Common/esif_ccb_time.h @@ -57,6 +57,15 @@ typedef u64 esif_ccb_time_t; /* Agnostic */ +#if defined(ESIF_ATTR_KERNEL) + +#if defined(ESIF_ATTR_OS_WINDOWS) +#include "esif_ccb_time_win_kern.h" +#elif defined(ESIF_ATTR_OS_LINUX) +#include "esif_ccb_time_lin_kern.h" +#endif /* KERNEL */ + +#elif defined(ESIF_ATTR_USER) #define MAX_CTIME_LEN 30 /* max length of ctime string */ @@ -66,5 +75,10 @@ typedef struct esif_ccb_realtime_s { u64 clocktime; /* standard local time_t seconds since 01/01/1970 */ } esif_ccb_realtime_t; +#if defined(ESIF_ATTR_OS_WINDOWS) +#include "esif_ccb_time_win_user.h" +#elif defined(ESIF_ATTR_OS_LINUX) #include "esif_ccb_time_lin_user.h" +#endif +#endif /* USER */ diff --git a/Common/esif_ccb_time_lin_user.h b/Common/esif_ccb_time_lin_user.h index 84fe4395..2115636e 100644 --- a/Common/esif_ccb_time_lin_user.h +++ b/Common/esif_ccb_time_lin_user.h @@ -18,6 +18,7 @@ #pragma once +#if defined(ESIF_ATTR_OS_LINUX) && defined(ESIF_ATTR_USER) #include #include @@ -106,3 +107,4 @@ static ESIF_INLINE esif_ccb_realtime_t esif_ccb_realtime_null() return result; } +#endif /* LINUX USER */ \ No newline at end of file diff --git a/Common/esif_ccb_timer.c b/Common/esif_ccb_timer.c index 03daf9e3..2ea4e6a5 100644 --- a/Common/esif_ccb_timer.c +++ b/Common/esif_ccb_timer.c @@ -435,8 +435,10 @@ void esif_ccb_tmrm_exit(void) esif_ccb_timer_kill_w_wait(&cur_timer); } +#ifdef ESIF_ATTR_USER /* Wait for any possible callbacks to be processed before exiting */ esif_ccb_sleep_msec(ESIF_TIMER_DISABLE_DELAY); +#endif g_tmrm.enabled = ESIF_FALSE; esif_ccb_lock_uninit(&g_tmrm.mgr_lock); diff --git a/Common/esif_ccb_timer.h b/Common/esif_ccb_timer.h index a6db5199..79d14d76 100644 --- a/Common/esif_ccb_timer.h +++ b/Common/esif_ccb_timer.h @@ -185,12 +185,47 @@ void esif_ccb_tmrm_callback( * Normally, these options should be specified in the project settings in * order to allow different options depending on need for a given binary. */ +#if defined(ESIF_ATTR_OS_WINDOWS) + + /* + * Build option to enable use of the WDF timers in Windows + * If not enabled, legacy kernel timers are used in kernel mode and + * and the specified user timer type is used in user mode. + * (See user section below.) + */ + /* #define ESIF_FEAT_OPT_WDFTIMER - Enable in project settings */ + +#if defined(ESIF_ATTR_USER) + +/* Build option to enable use of the "waitable" timers in Windows */ +/* #define ESIF_FEAT_OPT_WAITABLE_TIMERS - Enable in project settings */ + +#if defined(ESIF_FEAT_OPT_WAITABLE_TIMERS) +#undef ESIF_FEAT_OPT_WDFTIMER +#endif + +#endif /* ESIF_ATTR_USER */ +#endif /* ESIF_ATTR_OS_WINDOWS */ /* * Bring in OS-specific implementation code */ +#if defined(ESIF_ATTR_KERNEL) +#if defined(ESIF_ATTR_OS_WINDOWS) +#include "esif_ccb_timer_win_kern.h" +#elif defined(ESIF_ATTR_OS_LINUX) +#include "esif_ccb_timer_lin_kern.h" +#endif + +#elif defined(ESIF_ATTR_USER) + +#if defined(ESIF_ATTR_OS_WINDOWS) +#include "esif_ccb_timer_win_user.h" +#elif defined(ESIF_ATTR_OS_LINUX) #include "esif_ccb_timer_lin_user.h" +#endif +#endif /* * IMPORTANT!!!!!!!!! @@ -205,4 +240,4 @@ void esif_ccb_tmrm_callback( #include "esif_ccb_timer.c" -#endif +#endif \ No newline at end of file diff --git a/Common/esif_ccb_timer_lin_user.h b/Common/esif_ccb_timer_lin_user.h index cf885139..2049d3f8 100644 --- a/Common/esif_ccb_timer_lin_user.h +++ b/Common/esif_ccb_timer_lin_user.h @@ -23,6 +23,7 @@ * This file contains OS-specific implementation code and NOT interface code. */ +#if defined(ESIF_ATTR_OS_LINUX) && defined(ESIF_ATTR_USER) #include @@ -135,3 +136,4 @@ static ESIF_INLINE void esif_ccb_timer_obj_disable_timer( } } +#endif /* LINUX USER */ diff --git a/Common/esif_link_list.h b/Common/esif_link_list.h index 35e0dd1a..e224dbe4 100644 --- a/Common/esif_link_list.h +++ b/Common/esif_link_list.h @@ -129,8 +129,10 @@ struct esif_link_list { #pragma pack(pop) +#ifdef ESIF_ATTR_USER typedef struct esif_link_list EsifLinkList, *EsifLinkListPtr; typedef struct esif_link_list_node EsifLinkListNode, *EsifLinkListNodePtr; +#endif typedef void (*link_list_data_destroy_func)(void *data_ptr); diff --git a/Common/esif_queue.h b/Common/esif_queue.h index 2e0056dd..5c7fa749 100644 --- a/Common/esif_queue.h +++ b/Common/esif_queue.h @@ -51,7 +51,8 @@ ** *******************************************************************************/ -#pragma once +#ifndef _ESIF_QUEUE_H_ +#define _ESIF_QUEUE_H_ #include "esif_ccb.h" #include "esif_link_list.h" @@ -72,7 +73,9 @@ struct esif_queue_instance { char queue_name[ESIF_QUEUE_NAME_LEN]; /* Queue Name */ }; +#ifdef ESIF_ATTR_USER typedef struct esif_queue_instance EsifQueue, *EsifQueuePtr; +#endif typedef void (*queue_item_destroy_func) (void *item_ptr); @@ -117,3 +120,9 @@ void esif_queue_exit(void); #ifdef __cplusplus } #endif + +#endif /* _ESIF_QUEUE_H_ */ + +/*****************************************************************************/ +/*****************************************************************************/ +/*****************************************************************************/ diff --git a/Common/esif_sdk.h b/Common/esif_sdk.h index 375a4f2b..c3ae5fc5 100644 --- a/Common/esif_sdk.h +++ b/Common/esif_sdk.h @@ -99,6 +99,7 @@ typedef u8 esif_ver_t; /* Version */ /* Primitive Instance */ #define ESIF_INSTANCE_NO_PERSIST 254 +#ifdef ESIF_ATTR_USER #pragma pack(push, 1) @@ -118,3 +119,4 @@ typedef struct esif_app_broadcast_header_s { #pragma pack(pop) +#endif /* USER */ \ No newline at end of file diff --git a/Common/esif_sdk_action_type.h b/Common/esif_sdk_action_type.h index 136e568b..6f17d0a7 100644 --- a/Common/esif_sdk_action_type.h +++ b/Common/esif_sdk_action_type.h @@ -79,7 +79,6 @@ typedef enum esif_action_type { ESIF_ACTION_IOC = 74, ESIF_ACTION_IOSF = 34, ESIF_ACTION_JAVA = 62, - ESIF_ACTION_KACACHE = 85, ESIF_ACTION_KDELEGATE = 52, ESIF_ACTION_KHID = 73, ESIF_ACTION_KIOCTL = 64, @@ -111,7 +110,7 @@ typedef enum esif_action_type { } esif_action_type_t; /* Max Enum Value for Iteration purposes */ -#define MAX_ESIF_ACTION_ENUM_VALUE ESIF_ACTION_KACACHE +#define MAX_ESIF_ACTION_ENUM_VALUE ESIF_ACTION_VPU static ESIF_INLINE esif_string esif_action_type_str(esif_action_type_t type) { @@ -135,7 +134,6 @@ static ESIF_INLINE esif_string esif_action_type_str(esif_action_type_t type) ESIF_CASE_ENUM(ESIF_ACTION_IOC); ESIF_CASE_ENUM(ESIF_ACTION_IOSF); ESIF_CASE_ENUM(ESIF_ACTION_JAVA); - ESIF_CASE_ENUM(ESIF_ACTION_KACACHE); ESIF_CASE_ENUM(ESIF_ACTION_KDELEGATE); ESIF_CASE_ENUM(ESIF_ACTION_KHID); ESIF_CASE_ENUM(ESIF_ACTION_KIOCTL); @@ -169,6 +167,7 @@ static ESIF_INLINE esif_string esif_action_type_str(esif_action_type_t type) } +#ifdef ESIF_ATTR_USER #ifdef esif_ccb_stricmp static ESIF_INLINE esif_action_type_t esif_action_type_str2enum(esif_string name) { @@ -196,7 +195,6 @@ static ESIF_INLINE esif_action_type_t esif_action_type_str2enum(esif_string name ESIF_MAP_ENUM(ESIF_ACTION_IOC), ESIF_MAP_ENUM(ESIF_ACTION_IOSF), ESIF_MAP_ENUM(ESIF_ACTION_JAVA), - ESIF_MAP_ENUM(ESIF_ACTION_KACACHE), ESIF_MAP_ENUM(ESIF_ACTION_KDELEGATE), ESIF_MAP_ENUM(ESIF_ACTION_KHID), ESIF_MAP_ENUM(ESIF_ACTION_KIOCTL), @@ -246,6 +244,7 @@ static ESIF_INLINE esif_action_type_t esif_action_type_str2enum(esif_string name return (esif_action_type_t)0; } #endif +#endif /* diff --git a/Common/esif_sdk_class_guid.h b/Common/esif_sdk_class_guid.h index 0954141a..80a9b1d1 100644 --- a/Common/esif_sdk_class_guid.h +++ b/Common/esif_sdk_class_guid.h @@ -53,8 +53,6 @@ #pragma once -#include "esif_sdk.h" - /* * Class GUIDs */ diff --git a/Common/esif_sdk_data.h b/Common/esif_sdk_data.h index f0fda245..c53b13a0 100644 --- a/Common/esif_sdk_data.h +++ b/Common/esif_sdk_data.h @@ -100,6 +100,8 @@ union esif_data_variant { #pragma pack(pop) +#ifdef ESIF_ATTR_USER typedef struct esif_data EsifData, *EsifDataPtr, *EsifDataArray, **EsifDataPtrLocation; +#endif /* USER */ diff --git a/Common/esif_sdk_data_misc.h b/Common/esif_sdk_data_misc.h index 69ab2d27..513902c7 100644 --- a/Common/esif_sdk_data_misc.h +++ b/Common/esif_sdk_data_misc.h @@ -73,7 +73,7 @@ typedef struct EsifPpmParamValues_s typedef struct EsifPpmParamValuesHeader_s { - u32 revision; // 1,2, ... + u32 revision; // 1,2, … u32 numberElement; EsifPpmParamValues ppmParamValuesArray[DEFAULT_PARAM_COUNT]; // Additional items may be present following this } EsifPpmParamValuesHeader; @@ -143,7 +143,7 @@ struct loadable_action_devices { #define OCMB_REQUEST_VERSION OCMB_REQUEST_VERSION_1 struct ocmb_affinity_data { - u16 group; + u16 group; u64 affinity_mask; /* 0 indicates no affinity required */ u32 data; /* Only used for SETs. GET data returned in response */ /* @@ -177,6 +177,7 @@ struct ocmb_request { #define OFFSET_PTR(ptr, offset, type) ((type)(((char *)(ptr)) + (offset))) +#ifdef ESIF_ATTR_USER /* * ESIF Data is used to marshall most data between ESIF and the @@ -264,3 +265,4 @@ struct esif_data_rfprofile #define SOCWC_NUMBER_WORKLOAD_CLASSIFICATIONS 5 +#endif /* ESIF_ATTR_USER */ \ No newline at end of file diff --git a/Common/esif_sdk_data_type.h b/Common/esif_sdk_data_type.h index e54cbdaa..e5a4c310 100644 --- a/Common/esif_sdk_data_type.h +++ b/Common/esif_sdk_data_type.h @@ -173,6 +173,7 @@ static ESIF_INLINE size_t esif_data_type_sizeof(esif_data_type_t type) } } +#ifdef ESIF_ATTR_USER #ifdef esif_ccb_stricmp static ESIF_INLINE esif_data_type_t esif_data_type_str2enum(const esif_string name) { @@ -237,4 +238,5 @@ static ESIF_INLINE esif_data_type_t esif_data_type_str2enum(const esif_string na return ESIF_DATA_VOID; } #endif +#endif diff --git a/Common/esif_sdk_event_guid.h b/Common/esif_sdk_event_guid.h index a1185215..b9af903e 100644 --- a/Common/esif_sdk_event_guid.h +++ b/Common/esif_sdk_event_guid.h @@ -53,8 +53,6 @@ #pragma once -#include "esif_sdk.h" - /* * Event Name: DTT_ACTIVE_RELATIONSHIP_TABLE_CHANGED * Event GUID: C7C5FC88-8AAC-42C2-8B51-21777033E75D diff --git a/Common/esif_sdk_event_type.h b/Common/esif_sdk_event_type.h index 3e96e35a..730e950e 100644 --- a/Common/esif_sdk_event_type.h +++ b/Common/esif_sdk_event_type.h @@ -335,6 +335,7 @@ static ESIF_INLINE char *esif_event_type_str(esif_event_type_t type) return ESIF_NOT_AVAILABLE; } +#ifdef ESIF_ATTR_USER #ifdef esif_ccb_stricmp static ESIF_INLINE esif_event_type_t esif_event_type_str2enum(const esif_string name) { @@ -483,3 +484,4 @@ static ESIF_INLINE esif_event_type_t esif_event_type_str2enum(const esif_string return ESIF_EVENT_NONE; } #endif +#endif diff --git a/Common/esif_sdk_guid.h b/Common/esif_sdk_guid.h index ddc81527..bbd04548 100644 --- a/Common/esif_sdk_guid.h +++ b/Common/esif_sdk_guid.h @@ -55,6 +55,7 @@ #include "esif_ccb_string.h" #include "esif_sdk.h" +#include "esif_sdk_guid.h" #define ESIF_GUIDSTR_LEN ((ESIF_GUID_LEN * 2) + 4 + 1) /* xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx + NUL */ diff --git a/Common/esif_sdk_iface.h b/Common/esif_sdk_iface.h index e7fd544c..b46db190 100644 --- a/Common/esif_sdk_iface.h +++ b/Common/esif_sdk_iface.h @@ -53,9 +53,9 @@ #pragma once -#include "esif_sdk.h" - +#ifdef ESIF_ATTR_USER +#include "esif_sdk.h" #include "esif_sdk_data.h" #include "esif_sdk_domain_type.h" #include "esif_sdk_participant_enum.h" @@ -108,3 +108,4 @@ typedef enum esif_participant_enum eParticipantBus; typedef enum esif_domain_type eDomainType; typedef esif_flags_t EsifFlags; +#endif /* USER */ \ No newline at end of file diff --git a/Common/esif_sdk_iface_app.h b/Common/esif_sdk_iface_app.h index afaf18e6..2127f717 100644 --- a/Common/esif_sdk_iface_app.h +++ b/Common/esif_sdk_iface_app.h @@ -53,8 +53,7 @@ #pragma once -#include "esif_sdk.h" - +#ifdef ESIF_ATTR_USER #include "esif_sdk_iface.h" #include "esif_sdk_data.h" @@ -360,3 +359,4 @@ ESIF_EXPORT eEsifError GetApplicationInterfaceV2(AppInterfaceSetPtr theIface); #define GET_APPLICATION_INTERFACE_FUNCTION "GetApplicationInterfaceV2" +#endif /* USER */ diff --git a/Common/esif_sdk_iface_compress.h b/Common/esif_sdk_iface_compress.h index 0185a76d..5f062662 100644 --- a/Common/esif_sdk_iface_compress.h +++ b/Common/esif_sdk_iface_compress.h @@ -20,7 +20,11 @@ #include "esif_ccb.h" +#ifdef ESIF_ATTR_OS_WINDOWS +#define ESIFCMP_LIBRARY "ipf_cmp" // Name of Loadable .dll or .so Library +#else #define ESIFCMP_LIBRARY "esif_cmp" // Name of Loadable .dll or .so Library +#endif #define ESIFCMP_COMPRESSOR "IpfCompress" // Name of Exported Symbol in Library to Compress data #define ESIFCMP_DECOMPRESSOR "IpfDecompress" // Name of Exported Symbol in Library to Decompress data #define ESIFCMP_ERROR_OUTPUT_EOF 7 // Output Buffer too small return code (SZ_ERROR_OUTPUT_EOF) diff --git a/Common/esif_sdk_iface_conjure.h b/Common/esif_sdk_iface_conjure.h index 5f17b019..5645d681 100644 --- a/Common/esif_sdk_iface_conjure.h +++ b/Common/esif_sdk_iface_conjure.h @@ -53,8 +53,7 @@ #pragma once -#include "esif_sdk.h" - +#ifdef ESIF_ATTR_USER #include "esif_sdk_data.h" #include "esif_sdk_iface.h" @@ -154,3 +153,4 @@ typedef struct _t_EsifConjureInterface { #pragma pack(pop) +#endif /* USER */ \ No newline at end of file diff --git a/Common/esif_sdk_iface_esif.h b/Common/esif_sdk_iface_esif.h index dba05787..4861e63a 100644 --- a/Common/esif_sdk_iface_esif.h +++ b/Common/esif_sdk_iface_esif.h @@ -53,8 +53,7 @@ #pragma once -#include "esif_sdk.h" - +#ifdef ESIF_ATTR_USER #include "esif_sdk_iface.h" @@ -179,3 +178,4 @@ struct _t_EsifInterface { #pragma pack(pop) +#endif /* USER */ \ No newline at end of file diff --git a/Common/esif_sdk_iface_participant.h b/Common/esif_sdk_iface_participant.h index e0f3b35b..1377e69d 100644 --- a/Common/esif_sdk_iface_participant.h +++ b/Common/esif_sdk_iface_participant.h @@ -71,6 +71,104 @@ #define ESIF_FLAG_EXTERN_DPTFZ 0x2 /* Participant Is Actually A DPTF Zone exposed by an external driver */ #define ESIF_FLAG_ACCESS_ACPI_VIA_HAL 0x4 /* Participant is using the ACPI HAL target with absolute paths */ +#ifdef ESIF_ATTR_KERNEL + +#ifdef ESIF_ATTR_OS_WINDOWS +#include /* ACPI */ +typedef WDFIOTARGET acpi_handle; +#endif + +#define MSR_WHITELIST_TERMINATOR 0 +#define MMIO_WHITELIST_TERMINATOR 0 +#define OCMB_ALLOWLIST_TERMINATOR 0 + +/* The order is such that access rights are increased with value */ +enum whitelist_access { + WHITELIST_ACCESS_NONE = 0, + WHITELIST_ACCESS_READ = 1, + WHITELIST_ACCESS_WRITE = 2, + WHITELIST_ACCESS_BOTH = 3 +}; + +static ESIF_INLINE esif_string whitelist_access_str(enum whitelist_access type) +{ + switch (type) { + ESIF_CASE_ENUM(WHITELIST_ACCESS_NONE); + ESIF_CASE_ENUM(WHITELIST_ACCESS_READ); + ESIF_CASE_ENUM(WHITELIST_ACCESS_WRITE); + ESIF_CASE_ENUM(WHITELIST_ACCESS_BOTH); + } + return ESIF_NOT_AVAILABLE; +} + +struct msr_whitelist_entry { + u32 msr; + enum whitelist_access access; +}; + +struct mmio_whitelist_entry { + u32 start; + u32 end; + enum whitelist_access access; +}; + +struct ocmb_allowlist_entry { + u32 cmd; + enum whitelist_access access; +}; + +/* Participant INTERFACE */ +struct esif_participant_iface { + esif_ver_t version; /* Version */ + esif_guid_t class_guid; /* Class GUID */ + enum esif_participant_enum enumerator; /* Device Enumerator If Any */ + esif_flags_t flags; /* Flags If Any + * */ + char name[ESIF_NAME_LEN]; /* Friendly Name */ + char desc[ESIF_DESC_LEN]; /* Description */ + char driver_name[ESIF_NAME_LEN]; /* Driver Name */ + char device_name[ESIF_NAME_LEN]; /* Device Name */ + char device_path[ESIF_PATH_LEN]; + + /* EVENT Send Event From Driver To Framework */ + enum esif_rc (*send_event)(struct esif_participant_iface *pi, + enum esif_event_type type, u16 domain, + struct esif_data *data); + /* EVENT Receive Event From Framework To Driver */ + enum esif_rc (*recv_event)(enum esif_event_type type, u16 domain, + struct esif_data *data); + + /* ACPI */ + char acpi_device[ESIF_SCOPE_LEN];/* Device INT340X */ + char acpi_scope[ESIF_SCOPE_LEN]; /* Scope/REGEX e.g. \_SB.PCI0.TPCH */ + char acpi_uid[ESIF_ACPI_UID_LEN]; /* Unique ID If Any */ + u32 acpi_type; /* Participant Type If Any */ + + /* PCI */ + u32 pci_vendor; /* PCI Vendor e.g. 0x8086 For Intel */ + u32 pci_device; /* Device ID Unique To Vendor */ + u8 pci_bus; /* Bus This Device Resides On */ + u8 pci_bus_device; /* Device Number On Bus */ + u8 pci_function; /* Function Of Device */ + u8 pci_revision; /* Revision Of PCI Hardware Device */ + u8 pci_class; /* Class 3 bytes: (base class,sub sclass, prog-if) */ + u8 pci_sub_class; /* Sub Class */ + u8 pci_prog_if; /* Program Interface */ + + esif_device_t device; /* Os Agnostic Driver Context */ + void __iomem *mem_base; /* MMIO/MCHBAR Address */ + u32 mem_size; /* MMIO/MCHBAR Size */ + acpi_handle acpi_handle; /* ACPI Handle */ + + struct msr_whitelist_entry *msr_wlist_ptr; + struct mmio_whitelist_entry *mmio_wlist_ptr; + struct ocmb_allowlist_entry *ocmb_alist_ptr; + + void *context; /* Reserved */ +}; + +#endif /* ESIF ATTR_KERNEL */ +#ifdef ESIF_ATTR_USER #pragma pack(push,1) @@ -97,3 +195,4 @@ typedef struct _t_EsifParticipantIface { #pragma pack(pop) +#endif /* ESIF_ATTR_USER */ diff --git a/Common/esif_sdk_iface_upe.h b/Common/esif_sdk_iface_upe.h index d3792006..55653ac8 100644 --- a/Common/esif_sdk_iface_upe.h +++ b/Common/esif_sdk_iface_upe.h @@ -17,9 +17,9 @@ ******************************************************************************/ #pragma once +#include "esif_sdk.h" #include "esif_ccb.h" #include "esif_ccb_rc.h" -#include "esif_sdk.h" #include "esif_sdk_data.h" #include "esif_sdk_event_type.h" #include "esif_sdk_action_type.h" diff --git a/Common/esif_sdk_logging_data.h b/Common/esif_sdk_logging_data.h index d1aa60be..b5ee495b 100644 --- a/Common/esif_sdk_logging_data.h +++ b/Common/esif_sdk_logging_data.h @@ -56,6 +56,7 @@ #include "esif_sdk_data.h" #include "esif_sdk_data_misc.h" +#ifdef ESIF_ATTR_USER #pragma pack(push, 1) @@ -258,6 +259,7 @@ typedef struct _t_EsifManagerStatusData { UInt32 mixedRealityMode; UInt32 platformUserPresence; UInt32 foregroundBackgroundRatio; + UInt32 ppmPackage; UInt32 collaboration; EsifPpmParamValues ppmParamValues; } EsifManagerStatusData, * EsifManagerStatusDataPtr; @@ -307,3 +309,4 @@ typedef struct _t_EsifCapabilityData { #pragma pack(pop) +#endif /* ESIF_ATTR_USER */ diff --git a/Common/esif_sdk_participant_enum.h b/Common/esif_sdk_participant_enum.h index 2945dc81..76d15ae4 100644 --- a/Common/esif_sdk_participant_enum.h +++ b/Common/esif_sdk_participant_enum.h @@ -88,6 +88,7 @@ static ESIF_INLINE esif_string esif_participant_enum_str( return ESIF_NOT_AVAILABLE; } +#ifdef ESIF_ATTR_USER #ifdef esif_ccb_stricmp static ESIF_INLINE esif_participant_enum_t esif_participant_enum_str2enum(const esif_string name) { @@ -124,3 +125,4 @@ static ESIF_INLINE esif_participant_enum_t esif_participant_enum_str2enum(const return (esif_participant_enum_t)(-1); } #endif +#endif diff --git a/Common/esif_sdk_primitive_type.h b/Common/esif_sdk_primitive_type.h index c1e6872e..f20943d7 100644 --- a/Common/esif_sdk_primitive_type.h +++ b/Common/esif_sdk_primitive_type.h @@ -100,9 +100,6 @@ typedef enum esif_primitive_type { GET_CORE_ACTIVITY_COUNTER = 442, GET_DC_PEAK_POWER = 451, GET_DDR_DVFS_DATA_RATE = 789, - GET_DDR_DVFS_DATA_RATE_REG_HI = 836, - GET_DDR_DVFS_DATA_RATE_REG_LO = 837, - GET_DDR_DVFS_RFI_RESTRICTION_REG = 838, GET_DDR_RFI_TABLE = 770, GET_DEVICE_UNIQUE_ID = 67, GET_DISENGAGED_STABILITY_WINDOW = 737, @@ -130,15 +127,11 @@ typedef enum esif_primitive_type { GET_FAN_STATUS = 86, GET_FAST_POLL_TIME = 462, GET_FIVR_VERSION = 652, - GET_FIVR_VERSION_PLATFORM_SUR = 672, GET_FIVR_VERSION_SUR = 653, + GET_FIVR_VERSION_SUR_PLATFORM = 672, GET_GT_CLIP_REASONS = 610, GET_HID_ACCESS_INFO = 491, GET_HWP_EPP_VALUE = 825, - GET_HWP_GUARANTEED_PERFORMANCE_LEVEL = 844, - GET_HWP_HIGHEST_PERFORMANCE_LEVEL = 842, - GET_HWP_LOWEST_PERFORMANCE_LEVEL = 845, - GET_HWP_MOST_EFFICIENT_PERFORMANCE_LEVEL = 843, GET_HWPF_STATE = 606, GET_IA_CLIP_REASONS = 609, GET_INFO = 439, @@ -220,7 +213,6 @@ typedef enum esif_primitive_type { GET_PROC_PERF_SUPPORT_STATES = 95, GET_PROC_PERF_THROTTLE_PRESENT_CAPABILITY = 62, GET_PROC_PERF_TSTATE_DEPTH_LIMIT = 61, - GET_PROC_PHYSICAL_CORE_COUNT = 841, GET_PROC_PKG_CSTATE_RESIDENCY = 315, GET_PROC_RF_TUNING_AVAILABLE = 268, GET_PROC_RP_STATE_CAPABILITY = 277, @@ -231,8 +223,6 @@ typedef enum esif_primitive_type { GET_PROC_TSC = 312, GET_RAPL_ENERGY = 128, GET_RAPL_ENERGY_COUNTER_WIDTH = 475, - GET_RAPL_ENERGY_CPU_SUR = 846, - GET_RAPL_ENERGY_GPU_SUR = 847, GET_RAPL_ENERGY_UNIT = 123, GET_RAPL_FLOOR_STATE = 537, GET_RAPL_POWER = 35, @@ -295,15 +285,13 @@ typedef enum esif_primitive_type { GET_STORAGE_SAMPLE_PERIOD = 572, GET_SUPPORT_EPP_HINT = 556, GET_SUPPORTED_POLICIES = 92, - GET_TCC_LOCK_STATUS = 848, GET_TCC_OFFSET = 477, GET_TEMPERATURE = 14, - GET_TEMPERATURE_ACPI_SUR = 320, GET_TEMPERATURE_APPROX_TABLE = 164, GET_TEMPERATURE_SUR = 290, + GET_TEMPERATURE_SURACPI = 320, GET_TEMPERATURE_THRESHOLD_HYSTERESIS = 15, GET_TEMPERATURE_THRESHOLDS = 143, - GET_TEMPERATURE_VRAM_SUR = 840, GET_THERMAL_MBOX_CMD_DATA = 548, GET_THERMAL_MBOX_CMD_REG = 541, GET_THERMAL_MBOX_DATA_REG = 538, @@ -357,7 +345,6 @@ typedef enum esif_primitive_type { SET_CONFIG_RESET = 392, SET_DC_PEAK_POWER = 452, SET_DDR_DVFS_RFI_RESTRICTION = 790, - SET_DDR_DVFS_RFI_RESTRICTION_REG = 839, SET_DDR_RFI_TABLE = 771, SET_DEVICE_TEMPERATURE_INDICATION = 51, SET_DISENGAGED_STABILITY_WINDOW = 738, @@ -516,8 +503,6 @@ typedef enum esif_primitive_type { SET_TSTATE_CURRENT = 147, SET_UNDER_VOLTAGE_THRESHOLD = 519, SET_USER_BASED_REFRESH_RATE = 819, - SET_USER_BASED_REFRESH_RATE_RESET = 849, - SET_USER_BASED_REFRESH_RATE_RESET_SUR = 850, SET_USER_BASED_REFRESH_RATE_SUR = 820, SET_UVTH = 670, SET_VIRTUAL_SENSOR_CALIB_TABLE = 350, @@ -530,7 +515,7 @@ typedef enum esif_primitive_type { } esif_primitive_type_t; /* Max Enum Value for Iteration purposes */ -#define MAX_PRIMITIVE_ENUM_VALUE SET_USER_BASED_REFRESH_RATE_RESET_SUR +#define MAX_PRIMITIVE_ENUM_VALUE SET_FAN_OPERATING_MODE static ESIF_INLINE esif_string esif_primitive_str(esif_primitive_type_t type) { @@ -575,9 +560,6 @@ static ESIF_INLINE esif_string esif_primitive_str(esif_primitive_type_t type) ESIF_CASE_ENUM(GET_CORE_ACTIVITY_COUNTER); ESIF_CASE_ENUM(GET_DC_PEAK_POWER); ESIF_CASE_ENUM(GET_DDR_DVFS_DATA_RATE); - ESIF_CASE_ENUM(GET_DDR_DVFS_DATA_RATE_REG_HI); - ESIF_CASE_ENUM(GET_DDR_DVFS_DATA_RATE_REG_LO); - ESIF_CASE_ENUM(GET_DDR_DVFS_RFI_RESTRICTION_REG); ESIF_CASE_ENUM(GET_DDR_RFI_TABLE); ESIF_CASE_ENUM(GET_DEVICE_UNIQUE_ID); ESIF_CASE_ENUM(GET_DISENGAGED_STABILITY_WINDOW); @@ -605,15 +587,11 @@ static ESIF_INLINE esif_string esif_primitive_str(esif_primitive_type_t type) ESIF_CASE_ENUM(GET_FAN_STATUS); ESIF_CASE_ENUM(GET_FAST_POLL_TIME); ESIF_CASE_ENUM(GET_FIVR_VERSION); - ESIF_CASE_ENUM(GET_FIVR_VERSION_PLATFORM_SUR); ESIF_CASE_ENUM(GET_FIVR_VERSION_SUR); + ESIF_CASE_ENUM(GET_FIVR_VERSION_SUR_PLATFORM); ESIF_CASE_ENUM(GET_GT_CLIP_REASONS); ESIF_CASE_ENUM(GET_HID_ACCESS_INFO); ESIF_CASE_ENUM(GET_HWP_EPP_VALUE); - ESIF_CASE_ENUM(GET_HWP_GUARANTEED_PERFORMANCE_LEVEL); - ESIF_CASE_ENUM(GET_HWP_HIGHEST_PERFORMANCE_LEVEL); - ESIF_CASE_ENUM(GET_HWP_LOWEST_PERFORMANCE_LEVEL); - ESIF_CASE_ENUM(GET_HWP_MOST_EFFICIENT_PERFORMANCE_LEVEL); ESIF_CASE_ENUM(GET_HWPF_STATE); ESIF_CASE_ENUM(GET_IA_CLIP_REASONS); ESIF_CASE_ENUM(GET_INFO); @@ -695,7 +673,6 @@ static ESIF_INLINE esif_string esif_primitive_str(esif_primitive_type_t type) ESIF_CASE_ENUM(GET_PROC_PERF_SUPPORT_STATES); ESIF_CASE_ENUM(GET_PROC_PERF_THROTTLE_PRESENT_CAPABILITY); ESIF_CASE_ENUM(GET_PROC_PERF_TSTATE_DEPTH_LIMIT); - ESIF_CASE_ENUM(GET_PROC_PHYSICAL_CORE_COUNT); ESIF_CASE_ENUM(GET_PROC_PKG_CSTATE_RESIDENCY); ESIF_CASE_ENUM(GET_PROC_RF_TUNING_AVAILABLE); ESIF_CASE_ENUM(GET_PROC_RP_STATE_CAPABILITY); @@ -706,8 +683,6 @@ static ESIF_INLINE esif_string esif_primitive_str(esif_primitive_type_t type) ESIF_CASE_ENUM(GET_PROC_TSC); ESIF_CASE_ENUM(GET_RAPL_ENERGY); ESIF_CASE_ENUM(GET_RAPL_ENERGY_COUNTER_WIDTH); - ESIF_CASE_ENUM(GET_RAPL_ENERGY_CPU_SUR); - ESIF_CASE_ENUM(GET_RAPL_ENERGY_GPU_SUR); ESIF_CASE_ENUM(GET_RAPL_ENERGY_UNIT); ESIF_CASE_ENUM(GET_RAPL_FLOOR_STATE); ESIF_CASE_ENUM(GET_RAPL_POWER); @@ -770,15 +745,13 @@ static ESIF_INLINE esif_string esif_primitive_str(esif_primitive_type_t type) ESIF_CASE_ENUM(GET_STORAGE_SAMPLE_PERIOD); ESIF_CASE_ENUM(GET_SUPPORT_EPP_HINT); ESIF_CASE_ENUM(GET_SUPPORTED_POLICIES); - ESIF_CASE_ENUM(GET_TCC_LOCK_STATUS); ESIF_CASE_ENUM(GET_TCC_OFFSET); ESIF_CASE_ENUM(GET_TEMPERATURE); - ESIF_CASE_ENUM(GET_TEMPERATURE_ACPI_SUR); ESIF_CASE_ENUM(GET_TEMPERATURE_APPROX_TABLE); ESIF_CASE_ENUM(GET_TEMPERATURE_SUR); + ESIF_CASE_ENUM(GET_TEMPERATURE_SURACPI); ESIF_CASE_ENUM(GET_TEMPERATURE_THRESHOLD_HYSTERESIS); ESIF_CASE_ENUM(GET_TEMPERATURE_THRESHOLDS); - ESIF_CASE_ENUM(GET_TEMPERATURE_VRAM_SUR); ESIF_CASE_ENUM(GET_THERMAL_MBOX_CMD_DATA); ESIF_CASE_ENUM(GET_THERMAL_MBOX_CMD_REG); ESIF_CASE_ENUM(GET_THERMAL_MBOX_DATA_REG); @@ -832,7 +805,6 @@ static ESIF_INLINE esif_string esif_primitive_str(esif_primitive_type_t type) ESIF_CASE_ENUM(SET_CONFIG_RESET); ESIF_CASE_ENUM(SET_DC_PEAK_POWER); ESIF_CASE_ENUM(SET_DDR_DVFS_RFI_RESTRICTION); - ESIF_CASE_ENUM(SET_DDR_DVFS_RFI_RESTRICTION_REG); ESIF_CASE_ENUM(SET_DDR_RFI_TABLE); ESIF_CASE_ENUM(SET_DEVICE_TEMPERATURE_INDICATION); ESIF_CASE_ENUM(SET_DISENGAGED_STABILITY_WINDOW); @@ -991,8 +963,6 @@ static ESIF_INLINE esif_string esif_primitive_str(esif_primitive_type_t type) ESIF_CASE_ENUM(SET_TSTATE_CURRENT); ESIF_CASE_ENUM(SET_UNDER_VOLTAGE_THRESHOLD); ESIF_CASE_ENUM(SET_USER_BASED_REFRESH_RATE); - ESIF_CASE_ENUM(SET_USER_BASED_REFRESH_RATE_RESET); - ESIF_CASE_ENUM(SET_USER_BASED_REFRESH_RATE_RESET_SUR); ESIF_CASE_ENUM(SET_USER_BASED_REFRESH_RATE_SUR); ESIF_CASE_ENUM(SET_UVTH); ESIF_CASE_ENUM(SET_VIRTUAL_SENSOR_CALIB_TABLE); @@ -1006,6 +976,7 @@ static ESIF_INLINE esif_string esif_primitive_str(esif_primitive_type_t type) return ESIF_NOT_AVAILABLE; } +#ifdef ESIF_ATTR_USER #ifdef esif_ccb_stricmp static ESIF_INLINE esif_primitive_type_t esif_primitive_type_str2enum(const esif_string name) { @@ -1054,9 +1025,6 @@ static ESIF_INLINE esif_primitive_type_t esif_primitive_type_str2enum(const esif ESIF_MAP_ENUM(GET_CORE_ACTIVITY_COUNTER), ESIF_MAP_ENUM(GET_DC_PEAK_POWER), ESIF_MAP_ENUM(GET_DDR_DVFS_DATA_RATE), - ESIF_MAP_ENUM(GET_DDR_DVFS_DATA_RATE_REG_HI), - ESIF_MAP_ENUM(GET_DDR_DVFS_DATA_RATE_REG_LO), - ESIF_MAP_ENUM(GET_DDR_DVFS_RFI_RESTRICTION_REG), ESIF_MAP_ENUM(GET_DDR_RFI_TABLE), ESIF_MAP_ENUM(GET_DEVICE_UNIQUE_ID), ESIF_MAP_ENUM(GET_DISENGAGED_STABILITY_WINDOW), @@ -1084,15 +1052,11 @@ static ESIF_INLINE esif_primitive_type_t esif_primitive_type_str2enum(const esif ESIF_MAP_ENUM(GET_FAN_STATUS), ESIF_MAP_ENUM(GET_FAST_POLL_TIME), ESIF_MAP_ENUM(GET_FIVR_VERSION), - ESIF_MAP_ENUM(GET_FIVR_VERSION_PLATFORM_SUR), ESIF_MAP_ENUM(GET_FIVR_VERSION_SUR), + ESIF_MAP_ENUM(GET_FIVR_VERSION_SUR_PLATFORM), ESIF_MAP_ENUM(GET_GT_CLIP_REASONS), ESIF_MAP_ENUM(GET_HID_ACCESS_INFO), ESIF_MAP_ENUM(GET_HWP_EPP_VALUE), - ESIF_MAP_ENUM(GET_HWP_GUARANTEED_PERFORMANCE_LEVEL), - ESIF_MAP_ENUM(GET_HWP_HIGHEST_PERFORMANCE_LEVEL), - ESIF_MAP_ENUM(GET_HWP_LOWEST_PERFORMANCE_LEVEL), - ESIF_MAP_ENUM(GET_HWP_MOST_EFFICIENT_PERFORMANCE_LEVEL), ESIF_MAP_ENUM(GET_HWPF_STATE), ESIF_MAP_ENUM(GET_IA_CLIP_REASONS), ESIF_MAP_ENUM(GET_INFO), @@ -1174,7 +1138,6 @@ static ESIF_INLINE esif_primitive_type_t esif_primitive_type_str2enum(const esif ESIF_MAP_ENUM(GET_PROC_PERF_SUPPORT_STATES), ESIF_MAP_ENUM(GET_PROC_PERF_THROTTLE_PRESENT_CAPABILITY), ESIF_MAP_ENUM(GET_PROC_PERF_TSTATE_DEPTH_LIMIT), - ESIF_MAP_ENUM(GET_PROC_PHYSICAL_CORE_COUNT), ESIF_MAP_ENUM(GET_PROC_PKG_CSTATE_RESIDENCY), ESIF_MAP_ENUM(GET_PROC_RF_TUNING_AVAILABLE), ESIF_MAP_ENUM(GET_PROC_RP_STATE_CAPABILITY), @@ -1185,8 +1148,6 @@ static ESIF_INLINE esif_primitive_type_t esif_primitive_type_str2enum(const esif ESIF_MAP_ENUM(GET_PROC_TSC), ESIF_MAP_ENUM(GET_RAPL_ENERGY), ESIF_MAP_ENUM(GET_RAPL_ENERGY_COUNTER_WIDTH), - ESIF_MAP_ENUM(GET_RAPL_ENERGY_CPU_SUR), - ESIF_MAP_ENUM(GET_RAPL_ENERGY_GPU_SUR), ESIF_MAP_ENUM(GET_RAPL_ENERGY_UNIT), ESIF_MAP_ENUM(GET_RAPL_FLOOR_STATE), ESIF_MAP_ENUM(GET_RAPL_POWER), @@ -1249,15 +1210,13 @@ static ESIF_INLINE esif_primitive_type_t esif_primitive_type_str2enum(const esif ESIF_MAP_ENUM(GET_STORAGE_SAMPLE_PERIOD), ESIF_MAP_ENUM(GET_SUPPORT_EPP_HINT), ESIF_MAP_ENUM(GET_SUPPORTED_POLICIES), - ESIF_MAP_ENUM(GET_TCC_LOCK_STATUS), ESIF_MAP_ENUM(GET_TCC_OFFSET), ESIF_MAP_ENUM(GET_TEMPERATURE), - ESIF_MAP_ENUM(GET_TEMPERATURE_ACPI_SUR), ESIF_MAP_ENUM(GET_TEMPERATURE_APPROX_TABLE), ESIF_MAP_ENUM(GET_TEMPERATURE_SUR), + ESIF_MAP_ENUM(GET_TEMPERATURE_SURACPI), ESIF_MAP_ENUM(GET_TEMPERATURE_THRESHOLD_HYSTERESIS), ESIF_MAP_ENUM(GET_TEMPERATURE_THRESHOLDS), - ESIF_MAP_ENUM(GET_TEMPERATURE_VRAM_SUR), ESIF_MAP_ENUM(GET_THERMAL_MBOX_CMD_DATA), ESIF_MAP_ENUM(GET_THERMAL_MBOX_CMD_REG), ESIF_MAP_ENUM(GET_THERMAL_MBOX_DATA_REG), @@ -1311,7 +1270,6 @@ static ESIF_INLINE esif_primitive_type_t esif_primitive_type_str2enum(const esif ESIF_MAP_ENUM(SET_CONFIG_RESET), ESIF_MAP_ENUM(SET_DC_PEAK_POWER), ESIF_MAP_ENUM(SET_DDR_DVFS_RFI_RESTRICTION), - ESIF_MAP_ENUM(SET_DDR_DVFS_RFI_RESTRICTION_REG), ESIF_MAP_ENUM(SET_DDR_RFI_TABLE), ESIF_MAP_ENUM(SET_DEVICE_TEMPERATURE_INDICATION), ESIF_MAP_ENUM(SET_DISENGAGED_STABILITY_WINDOW), @@ -1499,3 +1457,4 @@ static ESIF_INLINE esif_primitive_type_t esif_primitive_type_str2enum(const esif return (esif_primitive_type_t)0; } #endif +#endif diff --git a/Common/esif_sdk_sha.c b/Common/esif_sdk_sha.c index 7d3299a3..ff68ca01 100644 --- a/Common/esif_sdk_sha.c +++ b/Common/esif_sdk_sha.c @@ -513,6 +513,7 @@ void esif_sha_finish(esif_sha_t *self) } } +#ifdef ESIF_ATTR_USER // Convert a completed SHA1 or SHA256 Hash into a string const char *esif_sha_tostring(esif_sha_t *self, char *buffer, size_t buf_len) @@ -542,3 +543,4 @@ const char *esif_hash_tostring(u8 hash_bytes[], size_t hash_len, char *buffer, s return NULL; } +#endif \ No newline at end of file diff --git a/Common/ipf_sdk_version.h b/Common/ipf_sdk_version.h index cc966e49..4be330dc 100644 --- a/Common/ipf_sdk_version.h +++ b/Common/ipf_sdk_version.h @@ -24,7 +24,7 @@ #include // Current IPF SDK Version: Major.Minor.Revision where same Major.Minor compatible with other Revisions, but not newer Major.Minor -#define IPF_SDK_VERSION "1.0.11100" +#define IPF_SDK_VERSION "1.0.10999" typedef u64 ipfsdk_version_t; // IPF SDK Encoded Version Number diff --git a/DPTF/Androidx86/jni/Android.mk b/DPTF/Androidx86/jni/Android.mk index 732e69a7..580fce17 100644 --- a/DPTF/Androidx86/jni/Android.mk +++ b/DPTF/Androidx86/jni/Android.mk @@ -51,11 +51,11 @@ include $(TOP_PATH)/SharedLib/ResourceLib/Android.mk include $(TOP_PATH)/PolicyLib/Android.mk include $(TOP_PATH)/UnifiedParticipant/Android.mk include $(TOP_PATH)/Policies/ActivePolicy/Android.mk -include $(TOP_PATH)/Policies/ConditionalLogicLib/Android.mk -include $(TOP_PATH)/Policies/AdaptivePerformancePolicy/Android.mk +#include $(TOP_PATH)/Policies/ConditionalLogicLib/Android.mk +#include $(TOP_PATH)/Policies/AdaptivePerformancePolicy/Android.mk include $(TOP_PATH)/Policies/CriticalPolicy/Android.mk -include $(TOP_PATH)/Policies/EmergencyCallModePolicy/Android.mk -include $(TOP_PATH)/Policies/PassivePolicy2/Android.mk -include $(TOP_PATH)/Policies/VirtualSensorPolicy/Android.mk +#include $(TOP_PATH)/Policies/EmergencyCallModePolicy/Android.mk +#include $(TOP_PATH)/Policies/PassivePolicy2/Android.mk +#include $(TOP_PATH)/Policies/VirtualSensorPolicy/Android.mk include $(TOP_PATH)/Manager/Android.mk include $(TOP_PATH)/Resources/Android.mk diff --git a/DPTF/Androidx86/jni/SharedLib/x86 b/DPTF/Androidx86/jni/SharedLib/x86 new file mode 120000 index 00000000..baa205c3 --- /dev/null +++ b/DPTF/Androidx86/jni/SharedLib/x86 @@ -0,0 +1 @@ +../../../../../../../prebuilts/ndk/current/sources/cxx-stl/llvm-libc++/libs/x86 \ No newline at end of file diff --git a/DPTF/Androidx86/jni/SharedLib/x86_64 b/DPTF/Androidx86/jni/SharedLib/x86_64 new file mode 120000 index 00000000..5dea93eb --- /dev/null +++ b/DPTF/Androidx86/jni/SharedLib/x86_64 @@ -0,0 +1 @@ +../../../../../../../prebuilts/ndk/current/sources/cxx-stl/llvm-libc++/libs/x86_64 \ No newline at end of file diff --git a/DPTF/Linux/CMakeLists.txt b/DPTF/Linux/CMakeLists.txt index d52d0e8b..ad822853 100644 --- a/DPTF/Linux/CMakeLists.txt +++ b/DPTF/Linux/CMakeLists.txt @@ -5,7 +5,7 @@ cmake_minimum_required(VERSION 2.8.6) message ("CXX Flags (initial) : " ${CMAKE_CXX_FLAGS}) set(CMAKE_POSITION_INDEPENDENT_CODE ON) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -Wall -Werror -Wno-unused-value -fPIC -Wformat -Wformat-security -O2 -D_FORTIFY_SOURCE=2 -fno-strict-overflow -fno-delete-null-pointer-checks -fwrapv -DDPTF_REMOVE_UNIT_TESTS -fvisibility=hidden") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Werror -Wno-unused-value -fPIC -Wformat -Wformat-security -O2 -D_FORTIFY_SOURCE=2 -fno-strict-overflow -fno-delete-null-pointer-checks -fwrapv -DDPTF_REMOVE_UNIT_TESTS -fvisibility=hidden") if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.9.0") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector") else() @@ -14,24 +14,22 @@ endif() set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -z noexecstack -z relro -z now") -# Enable Debug Symbols for all builds and strip it in post build process -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g") if (CHROMIUM_BUILD MATCHES YES) message("Building for Chromium OS...") add_definitions(-DESIF_ATTR_OS_CHROME -DESIF_ATTR_USER) if (BUILD_ARCH MATCHES 32bit) - message("Building 32-bit...") + message("Building 32-bit...") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32") - set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/x32) - set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/x32) - set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/x32) + set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/x32) + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/x32) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/x32) else() - message("Building 64-bit...") + message("Building 64-bit...") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64") - set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/x64) - set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/x64) - set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/x64) + set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/x64) + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/x64) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/x64) endif() else() @@ -41,32 +39,34 @@ else() set(CMAKE_CXX_FLAGS_RELEASE "-Os") if (BUILD_ARCH MATCHES 32bit AND CMAKE_BUILD_TYPE MATCHES Release) - message("Building 32-bit release...") + message("Building 32-bit release...") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32") - set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/x32/release) - set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/x32/release) - set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/x32/release) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s") + set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/x32/release) + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/x32/release) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/x32/release) elseif (BUILD_ARCH MATCHES 64bit AND CMAKE_BUILD_TYPE MATCHES Debug) - message("Building 64-bit debug...") + message("Building 64-bit debug...") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64") - set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/x64/debug) - set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/x64/debug) - set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/x64/debug) + set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/x64/debug) + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/x64/debug) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/x64/debug) elseif (BUILD_ARCH MATCHES 32bit AND CMAKE_BUILD_TYPE MATCHES Debug) - message("Building 32-bit debug...") + message("Building 32-bit debug...") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32") - set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/x32/debug) - set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/x32/debug) - set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/x32/debug) + set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/x32/debug) + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/x32/debug) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/x32/debug) else () - message("Building 64-bit release...") + message("Building 64-bit release...") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64") - set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/x64/release) - set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/x64/release) - set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/x64/release) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s") + set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/x64/release) + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/x64/release) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/x64/release) endif() endif() diff --git a/DPTF/Linux/Manager/CMakeLists.txt b/DPTF/Linux/Manager/CMakeLists.txt index 9ca0da9c..fdb17e7e 100644 --- a/DPTF/Linux/Manager/CMakeLists.txt +++ b/DPTF/Linux/Manager/CMakeLists.txt @@ -39,11 +39,3 @@ add_library(${MANAGER} MODULE ${manager_SOURCES}) set_target_properties(${MANAGER} PROPERTIES PREFIX "") target_link_libraries(${MANAGER} ${SHARED_LIB} ${BASIC_TYPES_LIB} ${ESIF_TYPES_LIB} ${DPTF_TYPES_LIB} ${DPTF_OBJECTS_LIB} ${PARTICIPANT_CONTROLS_LIB} ${PARTICIPANT_LIB} ${EVENTS_LIB} ${XML_LIB} ${MESSAGE_LOGGING_LIB} ${RESOURCE_LIB} ${UNIFIED_PARTICIPANT} rt ${CMAKE_DL_LIBS} ${CMAKE_THREAD_LIBS_INIT}) -if (CMAKE_BUILD_TYPE MATCHES Release AND NOT CHROMIUM_BUILD MATCHES YES) - add_custom_command(TARGET ${MANAGER} - POST_BUILD - COMMAND cp ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${MANAGER}.so ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${MANAGER}.so.debug - COMMAND ${CMAKE_STRIP} --strip-unneeded ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${MANAGER}.so - COMMAND ${CMAKE_OBJCOPY} --add-gnu-debuglink=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${MANAGER}.so.debug ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${MANAGER}.so - ) -endif() diff --git a/DPTF/Linux/Policies/ActivePolicy/CMakeLists.txt b/DPTF/Linux/Policies/ActivePolicy/CMakeLists.txt index 18b5f41f..7f39255e 100644 --- a/DPTF/Linux/Policies/ActivePolicy/CMakeLists.txt +++ b/DPTF/Linux/Policies/ActivePolicy/CMakeLists.txt @@ -11,12 +11,3 @@ add_library(${ACTIVE_POLICY} MODULE ${ACTIVE_POLICY_SOURCES}) set_target_properties(${ACTIVE_POLICY} PROPERTIES PREFIX "") target_link_libraries(${ACTIVE_POLICY} ${POLICY_LIB} ${SHARED_LIB} ${BASIC_TYPES_LIB} ${ESIF_TYPES_LIB} ${DPTF_TYPES_LIB} ${DPTF_OBJECTS_LIB} ${PARTICIPANT_CONTROLS_LIB} ${MESSAGE_LOGGING_LIB} ${PARTICIPANT_LIB} ${EVENTS_LIB} ${XML_LIB}) -if (CMAKE_BUILD_TYPE MATCHES Release AND NOT CHROMIUM_BUILD MATCHES YES) - add_custom_command(TARGET ${ACTIVE_POLICY} - POST_BUILD - COMMAND cp ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${ACTIVE_POLICY}.so ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${ACTIVE_POLICY}.so.debug - COMMAND ${CMAKE_STRIP} --strip-unneeded ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${ACTIVE_POLICY}.so - COMMAND ${CMAKE_OBJCOPY} --add-gnu-debuglink=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${ACTIVE_POLICY}.so.debug ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${ACTIVE_POLICY}.so - BYPRODUCTS ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${ACTIVE_POLICY}.so.debug - ) -endif() \ No newline at end of file diff --git a/DPTF/Linux/Policies/CriticalPolicy/CMakeLists.txt b/DPTF/Linux/Policies/CriticalPolicy/CMakeLists.txt index 9d9f1175..172c990f 100644 --- a/DPTF/Linux/Policies/CriticalPolicy/CMakeLists.txt +++ b/DPTF/Linux/Policies/CriticalPolicy/CMakeLists.txt @@ -11,12 +11,3 @@ add_library(${CRITICAL_POLICY} MODULE ${CRITICAL_POLICY_SOURCES}) set_target_properties(${CRITICAL_POLICY} PROPERTIES PREFIX "") target_link_libraries(${CRITICAL_POLICY} ${POLICY_LIB} ${SHARED_LIB} ${BASIC_TYPES_LIB} ${ESIF_TYPES_LIB} ${DPTF_TYPES_LIB} ${DPTF_OBJECTS_LIB} ${PARTICIPANT_CONTROLS_LIB} ${MESSAGE_LOGGING_LIB} ${PARTICIPANT_LIB} ${EVENTS_LIB} ${XML_LIB}) -if (CMAKE_BUILD_TYPE MATCHES Release AND NOT CHROMIUM_BUILD MATCHES YES) - add_custom_command(TARGET ${CRITICAL_POLICY} - POST_BUILD - COMMAND cp ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CRITICAL_POLICY}.so ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CRITICAL_POLICY}.so.debug - COMMAND ${CMAKE_STRIP} --strip-unneeded ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CRITICAL_POLICY}.so - COMMAND ${CMAKE_OBJCOPY} --add-gnu-debuglink=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CRITICAL_POLICY}.so.debug ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CRITICAL_POLICY}.so - BYPRODUCTS ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CRITICAL_POLICY}.so.debug - ) -endif() \ No newline at end of file diff --git a/DPTF/Linux/Policies/PassivePolicy/CMakeLists.txt b/DPTF/Linux/Policies/PassivePolicy/CMakeLists.txt index 56c2a1ec..138611bd 100644 --- a/DPTF/Linux/Policies/PassivePolicy/CMakeLists.txt +++ b/DPTF/Linux/Policies/PassivePolicy/CMakeLists.txt @@ -11,12 +11,3 @@ add_library(${PASSIVE_POLICY} MODULE ${PASSIVE_POLICY_SOURCES}) set_target_properties(${PASSIVE_POLICY} PROPERTIES PREFIX "") target_link_libraries(${PASSIVE_POLICY} ${POLICY_LIB} ${SHARED_LIB} ${BASIC_TYPES_LIB} ${ESIF_TYPES_LIB} ${DPTF_TYPES_LIB} ${DPTF_OBJECTS_LIB} ${PARTICIPANT_CONTROLS_LIB} ${MESSAGE_LOGGING_LIB} ${PARTICIPANT_LIB} ${EVENTS_LIB} ${XML_LIB}) -if (CMAKE_BUILD_TYPE MATCHES Release AND NOT CHROMIUM_BUILD MATCHES YES) - add_custom_command(TARGET ${PASSIVE_POLICY} - POST_BUILD - COMMAND cp ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${PASSIVE_POLICY}.so ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${PASSIVE_POLICY}.so.debug - COMMAND ${CMAKE_STRIP} --strip-unneeded ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${PASSIVE_POLICY}.so - COMMAND ${CMAKE_OBJCOPY} --add-gnu-debuglink=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${PASSIVE_POLICY}.so.debug ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${PASSIVE_POLICY}.so - BYPRODUCTS ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${PASSIVE_POLICY}.so.debug - ) -endif() \ No newline at end of file diff --git a/DPTF/Linux/Policies/PolicyLib/CMakeLists.txt b/DPTF/Linux/Policies/PolicyLib/CMakeLists.txt index 83247f1f..53bca76e 100644 --- a/DPTF/Linux/Policies/PolicyLib/CMakeLists.txt +++ b/DPTF/Linux/Policies/PolicyLib/CMakeLists.txt @@ -7,12 +7,3 @@ endif() add_library(${POLICY_LIB} STATIC ${POLICY_LIB_SOURCES}) set_target_properties(${POLICY_LIB} PROPERTIES PREFIX "") -if (CMAKE_BUILD_TYPE MATCHES Release AND NOT CHROMIUM_BUILD MATCHES YES) - add_custom_command(TARGET ${POLICY_LIB} - POST_BUILD - COMMAND cp ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${POLICY_LIB}.a ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${POLICY_LIB}.a.debug - COMMAND ${CMAKE_STRIP} --strip-debug ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${POLICY_LIB}.a - COMMAND ${CMAKE_OBJCOPY} --add-gnu-debuglink=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${POLICY_LIB}.a.debug ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${POLICY_LIB}.a - BYPRODUCTS ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${POLICY_LIB}.a.debug - ) -endif() \ No newline at end of file diff --git a/DPTF/Linux/SharedLib/BasicTypesLib/CMakeLists.txt b/DPTF/Linux/SharedLib/BasicTypesLib/CMakeLists.txt index 7a91bab5..fd0be8b4 100644 --- a/DPTF/Linux/SharedLib/BasicTypesLib/CMakeLists.txt +++ b/DPTF/Linux/SharedLib/BasicTypesLib/CMakeLists.txt @@ -13,12 +13,3 @@ endif() add_library(${BASIC_TYPES_LIB} STATIC ${basic_types_lib_SOURCES}) set_target_properties(${BASIC_TYPES_LIB} PROPERTIES PREFIX "") -if (CMAKE_BUILD_TYPE MATCHES Release AND NOT CHROMIUM_BUILD MATCHES YES) - add_custom_command(TARGET ${BASIC_TYPES_LIB} - POST_BUILD - COMMAND cp ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${BASIC_TYPES_LIB}.a ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${BASIC_TYPES_LIB}.a.debug - COMMAND ${CMAKE_STRIP} --strip-debug ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${BASIC_TYPES_LIB}.a - COMMAND ${CMAKE_OBJCOPY} --add-gnu-debuglink=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${BASIC_TYPES_LIB}.a.debug ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${BASIC_TYPES_LIB}.a - BYPRODUCTS ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${BASIC_TYPES_LIB}.a.debug - ) -endif() \ No newline at end of file diff --git a/DPTF/Linux/SharedLib/DptfObjectsLib/CMakeLists.txt b/DPTF/Linux/SharedLib/DptfObjectsLib/CMakeLists.txt index 35f066c4..b0a5e977 100644 --- a/DPTF/Linux/SharedLib/DptfObjectsLib/CMakeLists.txt +++ b/DPTF/Linux/SharedLib/DptfObjectsLib/CMakeLists.txt @@ -25,12 +25,3 @@ endif() add_library(${DPTF_OBJECTS_LIB} STATIC ${dptf_objects_lib_SOURCES}) set_target_properties(${DPTF_OBJECTS_LIB} PROPERTIES PREFIX "") -if (CMAKE_BUILD_TYPE MATCHES Release AND NOT CHROMIUM_BUILD MATCHES YES) - add_custom_command(TARGET ${DPTF_OBJECTS_LIB} - POST_BUILD - COMMAND cp ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DPTF_OBJECTS_LIB}.a ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DPTF_OBJECTS_LIB}.a.debug - COMMAND ${CMAKE_STRIP} --strip-debug ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DPTF_OBJECTS_LIB}.a - COMMAND ${CMAKE_OBJCOPY} --add-gnu-debuglink=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DPTF_OBJECTS_LIB}.a.debug ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DPTF_OBJECTS_LIB}.a - BYPRODUCTS ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DPTF_OBJECTS_LIB}.a.debug - ) -endif() diff --git a/DPTF/Linux/SharedLib/DptfTypesLib/CMakeLists.txt b/DPTF/Linux/SharedLib/DptfTypesLib/CMakeLists.txt index d1c359ab..7a57b100 100644 --- a/DPTF/Linux/SharedLib/DptfTypesLib/CMakeLists.txt +++ b/DPTF/Linux/SharedLib/DptfTypesLib/CMakeLists.txt @@ -15,12 +15,3 @@ endif() add_library(${DPTF_TYPES_LIB} STATIC ${dptf_types_lib_SOURCES}) set_target_properties(${DPTF_TYPES_LIB} PROPERTIES PREFIX "") -if (CMAKE_BUILD_TYPE MATCHES Release AND NOT CHROMIUM_BUILD MATCHES YES) - add_custom_command(TARGET ${DPTF_TYPES_LIB} - POST_BUILD - COMMAND cp ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DPTF_TYPES_LIB}.a ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DPTF_TYPES_LIB}.a.debug - COMMAND ${CMAKE_STRIP} --strip-debug ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DPTF_TYPES_LIB}.a - COMMAND ${CMAKE_OBJCOPY} --add-gnu-debuglink=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DPTF_TYPES_LIB}.a.debug ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DPTF_TYPES_LIB}.a - BYPRODUCTS ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DPTF_TYPES_LIB}.a.debug - ) -endif() \ No newline at end of file diff --git a/DPTF/Linux/SharedLib/EsifTypesLib/CMakeLists.txt b/DPTF/Linux/SharedLib/EsifTypesLib/CMakeLists.txt index 813e7f32..d92fe375 100644 --- a/DPTF/Linux/SharedLib/EsifTypesLib/CMakeLists.txt +++ b/DPTF/Linux/SharedLib/EsifTypesLib/CMakeLists.txt @@ -15,12 +15,3 @@ endif() add_library(${ESIF_TYPES_LIB} STATIC ${esif_types_lib_SOURCES}) set_target_properties(${ESIF_TYPES_LIB} PROPERTIES PREFIX "") -if (CMAKE_BUILD_TYPE MATCHES Release AND NOT CHROMIUM_BUILD MATCHES YES) - add_custom_command(TARGET ${ESIF_TYPES_LIB} - POST_BUILD - COMMAND cp ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${ESIF_TYPES_LIB}.a ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${ESIF_TYPES_LIB}.a.debug - COMMAND ${CMAKE_STRIP} --strip-debug ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${ESIF_TYPES_LIB}.a - COMMAND ${CMAKE_OBJCOPY} --add-gnu-debuglink=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${ESIF_TYPES_LIB}.a.debug ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${ESIF_TYPES_LIB}.a - BYPRODUCTS ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${ESIF_TYPES_LIB}.a.debug - ) -endif() \ No newline at end of file diff --git a/DPTF/Linux/SharedLib/EventsLib/CMakeLists.txt b/DPTF/Linux/SharedLib/EventsLib/CMakeLists.txt index d0fcab0e..1b48995e 100644 --- a/DPTF/Linux/SharedLib/EventsLib/CMakeLists.txt +++ b/DPTF/Linux/SharedLib/EventsLib/CMakeLists.txt @@ -13,12 +13,3 @@ endif() add_library(${EVENTS_LIB} STATIC ${events_lib_SOURCES}) set_target_properties(${EVENTS_LIB} PROPERTIES PREFIX "") -if (CMAKE_BUILD_TYPE MATCHES Release AND NOT CHROMIUM_BUILD MATCHES YES) - add_custom_command(TARGET ${EVENTS_LIB} - POST_BUILD - COMMAND cp ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${EVENTS_LIB}.a ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${EVENTS_LIB}.a.debug - COMMAND ${CMAKE_STRIP} --strip-debug ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${EVENTS_LIB}.a - COMMAND ${CMAKE_OBJCOPY} --add-gnu-debuglink=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${EVENTS_LIB}.a.debug ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${EVENTS_LIB}.a - BYPRODUCTS ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${EVENTS_LIB}.a.debug - ) -endif() \ No newline at end of file diff --git a/DPTF/Linux/SharedLib/MessageLoggingLib/CMakeLists.txt b/DPTF/Linux/SharedLib/MessageLoggingLib/CMakeLists.txt index e131bcf3..d25c7b0f 100644 --- a/DPTF/Linux/SharedLib/MessageLoggingLib/CMakeLists.txt +++ b/DPTF/Linux/SharedLib/MessageLoggingLib/CMakeLists.txt @@ -15,12 +15,3 @@ endif() add_library(${MESSAGE_LOGGING_LIB} STATIC ${message_logging_lib_SOURCES}) set_target_properties(${MESSAGE_LOGGING_LIB} PROPERTIES PREFIX "") -if (CMAKE_BUILD_TYPE MATCHES Release AND NOT CHROMIUM_BUILD MATCHES YES) - add_custom_command(TARGET ${MESSAGE_LOGGING_LIB} - POST_BUILD - COMMAND cp ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${MESSAGE_LOGGING_LIB}.a ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${MESSAGE_LOGGING_LIB}.a.debug - COMMAND ${CMAKE_STRIP} --strip-debug ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${MESSAGE_LOGGING_LIB}.a - COMMAND ${CMAKE_OBJCOPY} --add-gnu-debuglink=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${MESSAGE_LOGGING_LIB}.a.debug ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${MESSAGE_LOGGING_LIB}.a - BYPRODUCTS ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${MESSAGE_LOGGING_LIB}.a.debug - ) -endif() \ No newline at end of file diff --git a/DPTF/Linux/SharedLib/ParticipantControlsLib/CMakeLists.txt b/DPTF/Linux/SharedLib/ParticipantControlsLib/CMakeLists.txt index 93d41fb8..21c449a4 100644 --- a/DPTF/Linux/SharedLib/ParticipantControlsLib/CMakeLists.txt +++ b/DPTF/Linux/SharedLib/ParticipantControlsLib/CMakeLists.txt @@ -21,12 +21,3 @@ endif() add_library(${PARTICIPANT_CONTROLS_LIB} STATIC ${participant_controls_lib_SOURCES}) set_target_properties(${PARTICIPANT_CONTROLS_LIB} PROPERTIES PREFIX "") -if (CMAKE_BUILD_TYPE MATCHES Release AND NOT CHROMIUM_BUILD MATCHES YES) - add_custom_command(TARGET ${PARTICIPANT_CONTROLS_LIB} - POST_BUILD - COMMAND cp ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${PARTICIPANT_CONTROLS_LIB}.a ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${PARTICIPANT_CONTROLS_LIB}.a.debug - COMMAND ${CMAKE_STRIP} --strip-debug ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${PARTICIPANT_CONTROLS_LIB}.a - COMMAND ${CMAKE_OBJCOPY} --add-gnu-debuglink=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${PARTICIPANT_CONTROLS_LIB}.a.debug ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${PARTICIPANT_CONTROLS_LIB}.a - BYPRODUCTS ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${PARTICIPANT_CONTROLS_LIB}.a.debug - ) -endif() \ No newline at end of file diff --git a/DPTF/Linux/SharedLib/ParticipantLib/CMakeLists.txt b/DPTF/Linux/SharedLib/ParticipantLib/CMakeLists.txt index eb3a06e8..d75db712 100644 --- a/DPTF/Linux/SharedLib/ParticipantLib/CMakeLists.txt +++ b/DPTF/Linux/SharedLib/ParticipantLib/CMakeLists.txt @@ -25,12 +25,3 @@ endif() add_library(${PARTICIPANT_LIB} STATIC ${participant_lib_SOURCES}) set_target_properties(${PARTICIPANT_LIB} PROPERTIES PREFIX "") -if (CMAKE_BUILD_TYPE MATCHES Release AND NOT CHROMIUM_BUILD MATCHES YES) - add_custom_command(TARGET ${PARTICIPANT_LIB} - POST_BUILD - COMMAND cp ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${PARTICIPANT_LIB}.a ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${PARTICIPANT_LIB}.a.debug - COMMAND ${CMAKE_STRIP} --strip-debug ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${PARTICIPANT_LIB}.a - COMMAND ${CMAKE_OBJCOPY} --add-gnu-debuglink=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${PARTICIPANT_LIB}.a.debug ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${PARTICIPANT_LIB}.a - BYPRODUCTS ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${PARTICIPANT_LIB}.a.debug - ) -endif() \ No newline at end of file diff --git a/DPTF/Linux/SharedLib/ResourceLib/CMakeLists.txt b/DPTF/Linux/SharedLib/ResourceLib/CMakeLists.txt index 4660cfe1..ebccaa75 100644 --- a/DPTF/Linux/SharedLib/ResourceLib/CMakeLists.txt +++ b/DPTF/Linux/SharedLib/ResourceLib/CMakeLists.txt @@ -15,12 +15,3 @@ endif() add_library(${RESOURCE_LIB} STATIC ${resource_lib_SOURCES}) set_target_properties(${RESOURCE_LIB} PROPERTIES PREFIX "") -if (CMAKE_BUILD_TYPE MATCHES Release AND NOT CHROMIUM_BUILD MATCHES YES) - add_custom_command(TARGET ${RESOURCE_LIB} - POST_BUILD - COMMAND cp ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${RESOURCE_LIB}.a ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${RESOURCE_LIB}.a.debug - COMMAND ${CMAKE_STRIP} --strip-debug ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${RESOURCE_LIB}.a - COMMAND ${CMAKE_OBJCOPY} --add-gnu-debuglink=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${RESOURCE_LIB}.a.debug ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${RESOURCE_LIB}.a - BYPRODUCTS ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${RESOURCE_LIB}.a.debug - ) -endif() \ No newline at end of file diff --git a/DPTF/Linux/SharedLib/XmlLib/CMakeLists.txt b/DPTF/Linux/SharedLib/XmlLib/CMakeLists.txt index 3782eb6d..a2b9f3a3 100644 --- a/DPTF/Linux/SharedLib/XmlLib/CMakeLists.txt +++ b/DPTF/Linux/SharedLib/XmlLib/CMakeLists.txt @@ -15,12 +15,3 @@ endif() add_library(${XML_LIB} STATIC ${xml_lib_SOURCES}) set_target_properties(${XML_LIB} PROPERTIES PREFIX "") -if (CMAKE_BUILD_TYPE MATCHES Release AND NOT CHROMIUM_BUILD MATCHES YES) - add_custom_command(TARGET ${XML_LIB} - POST_BUILD - COMMAND cp ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${XML_LIB}.a ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${XML_LIB}.a.debug - COMMAND ${CMAKE_STRIP} --strip-debug ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${XML_LIB}.a - COMMAND ${CMAKE_OBJCOPY} --add-gnu-debuglink=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${XML_LIB}.a.debug ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${XML_LIB}.a - BYPRODUCTS ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${XML_LIB}.a.debug - ) -endif() \ No newline at end of file diff --git a/DPTF/Linux/UnifiedParticipant/CMakeLists.txt b/DPTF/Linux/UnifiedParticipant/CMakeLists.txt index 5ac36123..b86bf356 100644 --- a/DPTF/Linux/UnifiedParticipant/CMakeLists.txt +++ b/DPTF/Linux/UnifiedParticipant/CMakeLists.txt @@ -37,13 +37,3 @@ set_target_properties(${UNIFIED_PARTICIPANT} PROPERTIES PREFIX "") target_link_libraries(${UNIFIED_PARTICIPANT} ${SHARED_LIB} ${BASIC_TYPES_LIB} ${ESIF_TYPES_LIB} ${DPTF_TYPES_LIB} ${DPTF_OBJECTS_LIB} ${XML_LIB} ${PARTICIPANT_CONTROLS_LIB} ${MESSAGE_LOGGING_LIB} ${PARTICIPANT_LIB} ${EVENTS_LIB}) - -if (CMAKE_BUILD_TYPE MATCHES Release AND NOT CHROMIUM_BUILD MATCHES YES) - add_custom_command(TARGET ${UNIFIED_PARTICIPANT} - POST_BUILD - COMMAND cp ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${UNIFIED_PARTICIPANT}.a ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${UNIFIED_PARTICIPANT}.a.debug - COMMAND ${CMAKE_STRIP} --strip-debug ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${UNIFIED_PARTICIPANT}.a - COMMAND ${CMAKE_OBJCOPY} --add-gnu-debuglink=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${UNIFIED_PARTICIPANT}.a.debug ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${UNIFIED_PARTICIPANT}.a - BYPRODUCTS ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${UNIFIED_PARTICIPANT}.a.debug - ) -endif() \ No newline at end of file diff --git a/DPTF/Sources/.clang-format b/DPTF/Sources/.clang-format new file mode 100644 index 00000000..50986d64 --- /dev/null +++ b/DPTF/Sources/.clang-format @@ -0,0 +1,96 @@ +--- +Language: Cpp +# BasedOnStyle: LLVM +AccessModifierOffset: -4 +AlignAfterOpenBracket: AlwaysBreak +AlignConsecutiveAssignments: false +AlignConsecutiveDeclarations: false +AlignEscapedNewlinesLeft: false +AlignOperands: true +AlignTrailingComments: false +AllowAllParametersOfDeclarationOnNextLine: false +AllowShortBlocksOnASingleLine: false +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: false +AllowShortIfStatementsOnASingleLine: false +AllowShortLoopsOnASingleLine: false +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: true +AlwaysBreakTemplateDeclarations: false +BinPackArguments: false +BinPackParameters: false +BraceWrapping: + AfterClass: false + AfterControlStatement: false + AfterEnum: false + AfterFunction: false + AfterNamespace: false + AfterObjCDeclaration: false + AfterStruct: false + AfterUnion: false + BeforeCatch: false + BeforeElse: false + IndentBraces: false +BreakBeforeBinaryOperators: NonAssignment +BreakBeforeBraces: Allman +BreakBeforeTernaryOperators: true +BreakConstructorInitializersBeforeComma: true +BreakAfterJavaFieldAnnotations: false +BreakStringLiterals: true +ColumnLimit: 120 +CommentPragmas: '^ IWYU pragma:' +ConstructorInitializerAllOnOneLineOrOnePerLine: false +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: true +DerivePointerAlignment: false +DisableFormat: false +ExperimentalAutoDetectBinPacking: false +ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ] +FixNamespaceComments: false +IncludeCategories: + - Regex: '^"(llvm|llvm-c|clang|clang-c)/' + Priority: 2 + - Regex: '^(<|"(gtest|isl|json)/)' + Priority: 3 + - Regex: '.*' + Priority: 1 +IncludeIsMainRegex: '$' +IndentCaseLabels: false +IndentWidth: 4 +IndentWrappedFunctionNames: false +JavaScriptQuotes: Leave +JavaScriptWrapImports: true +KeepEmptyLinesAtTheStartOfBlocks: true +MacroBlockBegin: '' +MacroBlockEnd: '' +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: All +ObjCBlockIndentWidth: 4 +ObjCSpaceAfterProperty: false +ObjCSpaceBeforeProtocolList: true +PenaltyBreakBeforeFirstCallParameter: 0 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakString: 1000 +PenaltyExcessCharacter: 1000000 +PenaltyReturnTypeOnItsOwnLine: 2000 +PointerAlignment: Left +ReflowComments: true +SortIncludes: false +SpaceAfterCStyleCast: false +SpaceBeforeAssignmentOperators: true +SpaceBeforeParens: ControlStatements +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 1 +SpacesInAngles: false +SpacesInContainerLiterals: true +SpacesInCStyleCastParentheses: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +Standard: Cpp11 +TabWidth: 4 +UseTab: Always +... + diff --git a/DPTF/Sources/DptfVer.h b/DPTF/Sources/DptfVer.h index 77601644..82464bf7 100644 --- a/DPTF/Sources/DptfVer.h +++ b/DPTF/Sources/DptfVer.h @@ -20,8 +20,8 @@ #define VER_MAJOR 9 #define VER_MINOR 0 -#define VER_HOTFIX 11100 -#define VER_BUILD 29358 +#define VER_HOTFIX 11001 +#define VER_BUILD 28546 #define ARG_TOSTR(arg) #arg #define VER_TOSTR(arg) ARG_TOSTR(arg) diff --git a/DPTF/Sources/Manager/CaptureCommand.cpp b/DPTF/Sources/Manager/CaptureCommand.cpp deleted file mode 100644 index 5da2e1c8..00000000 --- a/DPTF/Sources/Manager/CaptureCommand.cpp +++ /dev/null @@ -1,115 +0,0 @@ -/****************************************************************************** -** Copyright (c) 2013-2022 Intel Corporation All Rights Reserved -** -** Licensed under the Apache License, Version 2.0 (the "License"); you may not -** use this file except in compliance with the License. -** -** You may obtain a copy of the License at -** http://www.apache.org/licenses/LICENSE-2.0 -** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -** WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** -** See the License for the specific language governing permissions and -** limitations under the License. -** -******************************************************************************/ -#include "CaptureCommand.h" -#include "DptfManagerInterface.h" -#include "ParticipantTripPointsCaptureDataGenerator.h" -#include "ParticipantListCaptureDataGenerator.h" -#include "PolicyListCaptureDataGenerator.h" -#include "WorkItemQueueManagerInterface.h" -#include "TimeOps.h" - -using namespace std; - -CaptureCommand::CaptureCommand(DptfManagerInterface* dptfManager, shared_ptr fileIo) - : CommandHandler(dptfManager) - , m_fileIo(fileIo) -{ - m_dataGenerators.emplace_back(make_shared(dptfManager)); - m_dataGenerators.emplace_back(make_shared(dptfManager)); - m_dataGenerators.emplace_back(make_shared(dptfManager)); -} - -string CaptureCommand::getCommandName() const -{ - return "capture"; -} - -void CaptureCommand::execute(const CommandArguments& arguments) -{ - try - { - throwIfBadArgumentCount(arguments); - throwIfBadFileNameGiven(arguments); - const auto exportFilePath = generateExportPath(arguments); - const auto captureData = generateCaptureData(); - m_fileIo->writeData(exportFilePath, captureData); - setResultCode(ESIF_OK); - setResultMessage(string("Successfully exported settings to " + exportFilePath)); - } - catch (const command_failure& e) - { - setResultCode(e.getErrorCode()); - setResultMessage(e.getDescription()); - } -} - -string CaptureCommand::generateExportPath(const CommandArguments& arguments) const -{ - const auto exportPath = m_dptfManager->getDptfReportDirectoryPath(); - const auto exportFileName = getExportFileName(arguments); - return FileIO::generatePathWithTrailingSeparator(exportPath) + exportFileName; -} - -Bool CaptureCommand::exportFileNameProvided(const CommandArguments& arguments) -{ - return (arguments.size() > 1) && (arguments[1].isDataTypeString()); -} - -string CaptureCommand::getExportFileName(const CommandArguments& arguments) -{ - string exportFileName = Constants::EmptyString; - - if (exportFileNameProvided(arguments)) - { - exportFileName = arguments[1].getDataAsString(); - } - else - { - exportFileName = TimeOps::generateTimestampNowAsString() + ".txt"; - } - - return exportFileName; -} - -string CaptureCommand::generateCaptureData() const -{ - stringstream compiledData; - for (const auto& dataGenerator : m_dataGenerators) - { - compiledData << dataGenerator->generate()->toString(); - } - return compiledData.str(); -} - -void CaptureCommand::throwIfBadArgumentCount(const CommandArguments& arguments) -{ - // capture - if (arguments.size() > 2) - { - throw command_failure(ESIF_E_INVALID_ARGUMENT_COUNT, "Invalid argument count."); - } -} - -void CaptureCommand::throwIfBadFileNameGiven(const CommandArguments& arguments) -{ - // capture - if ((arguments.size() == 2) && (IFileIO::fileNameContainsIllegalCharacters(arguments[1].getDataAsString()))) - { - throw command_failure(ESIF_E_COMMAND_DATA_INVALID, "Invalid file name given."); - } -} diff --git a/DPTF/Sources/Manager/CaptureCommand.h b/DPTF/Sources/Manager/CaptureCommand.h deleted file mode 100644 index 76cac4b1..00000000 --- a/DPTF/Sources/Manager/CaptureCommand.h +++ /dev/null @@ -1,42 +0,0 @@ -/****************************************************************************** -** Copyright (c) 2013-2022 Intel Corporation All Rights Reserved -** -** Licensed under the Apache License, Version 2.0 (the "License"); you may not -** use this file except in compliance with the License. -** -** You may obtain a copy of the License at -** http://www.apache.org/licenses/LICENSE-2.0 -** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -** WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** -** See the License for the specific language governing permissions and -** limitations under the License. -** -******************************************************************************/ -#pragma once - -#include "CommandHandler.h" -#include "PolicyManagerInterface.h" -#include "FileIO.h" -#include "CaptureDataGenerator.h" - -class dptf_export CaptureCommand : public CommandHandler -{ -public: - CaptureCommand(DptfManagerInterface* dptfManager, std::shared_ptr fileIo); - virtual ~CaptureCommand() = default; - virtual std::string getCommandName() const override; - virtual void execute(const CommandArguments& arguments) override; - -private: - std::shared_ptr m_fileIo; - std::list> m_dataGenerators; - static Bool exportFileNameProvided(const CommandArguments& arguments); - std::string generateExportPath(const CommandArguments& arguments) const; - static std::string getExportFileName(const CommandArguments& arguments); - std::string generateCaptureData() const; - static void throwIfBadArgumentCount(const CommandArguments& arguments); - static void throwIfBadFileNameGiven(const CommandArguments& arguments); -}; diff --git a/DPTF/Sources/Manager/CaptureDataGenerator.cpp b/DPTF/Sources/Manager/CaptureDataGenerator.cpp deleted file mode 100644 index 96a56451..00000000 --- a/DPTF/Sources/Manager/CaptureDataGenerator.cpp +++ /dev/null @@ -1,34 +0,0 @@ -/****************************************************************************** -** Copyright (c) 2013-2022 Intel Corporation All Rights Reserved -** -** Licensed under the Apache License, Version 2.0 (the "License"); you may not -** use this file except in compliance with the License. -** -** You may obtain a copy of the License at -** http://www.apache.org/licenses/LICENSE-2.0 -** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -** WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** -** See the License for the specific language governing permissions and -** limitations under the License. -** -******************************************************************************/ - -#include "CaptureDataGenerator.h" -#include "EsifServicesInterface.h" -#include - -using namespace std; - -CaptureDataGenerator::CaptureDataGenerator(DptfManagerInterface* dptfManager) - : m_dptfManager(dptfManager) -{ -} - -void CaptureDataGenerator::logMessage(const std::string& message) const -{ - m_dptfManager->getEsifServices()->writeMessageWarning( - "DTT Capture Command: "s + std::string{message}, MessageCategory::Default); -} diff --git a/DPTF/Sources/Manager/CaptureDataGenerator.h b/DPTF/Sources/Manager/CaptureDataGenerator.h deleted file mode 100644 index ac462827..00000000 --- a/DPTF/Sources/Manager/CaptureDataGenerator.h +++ /dev/null @@ -1,32 +0,0 @@ -/****************************************************************************** -** Copyright (c) 2013-2022 Intel Corporation All Rights Reserved -** -** Licensed under the Apache License, Version 2.0 (the "License"); you may not -** use this file except in compliance with the License. -** -** You may obtain a copy of the License at -** http://www.apache.org/licenses/LICENSE-2.0 -** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -** WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** -** See the License for the specific language governing permissions and -** limitations under the License. -** -******************************************************************************/ -#pragma once -#include "DptfManagerInterface.h" -#include "XmlNode.h" - -class dptf_export CaptureDataGenerator -{ -public: - CaptureDataGenerator(DptfManagerInterface* dptfManager); - virtual ~CaptureDataGenerator() = default; - virtual std::shared_ptr generate() const = 0; - -protected: - virtual void logMessage(const std::string& message) const; - DptfManagerInterface* m_dptfManager; -}; diff --git a/DPTF/Sources/Manager/CommandDispatcher.cpp b/DPTF/Sources/Manager/CommandDispatcher.cpp index 5902ba98..e01d5093 100644 --- a/DPTF/Sources/Manager/CommandDispatcher.cpp +++ b/DPTF/Sources/Manager/CommandDispatcher.cpp @@ -39,21 +39,23 @@ CommandDispatcher::~CommandDispatcher() void CommandDispatcher::dispatch(const CommandArguments& arguments) { throwIfBadArguments(arguments); - const string command = arguments[0].getDataAsString(); - const auto it = m_registeredCommands.find(command); + m_lastSuccessfulCommandMessage = defaultCommandMessage; + m_lastCommandReturnCode = ESIF_OK; + string command = arguments[0].getDataAsString(); + auto it = m_registeredCommands.find(command); if (it != m_registeredCommands.end()) { it->second->execute(arguments); m_lastCommandReturnCode = it->second->getLastExecutionResultCode(); - m_lastSuccessfulCommandMessage = it->second->getLastExecutionMessage(); - if ((m_lastCommandReturnCode == ESIF_OK) && (m_lastSuccessfulCommandMessage.empty())) + + if (m_lastCommandReturnCode == ESIF_OK) { - m_lastSuccessfulCommandMessage = defaultCommandMessage; + m_lastSuccessfulCommandMessage = it->second->getLastExecutionMessage(); } } else { - const string message = command + string(" not supported."); + string message = command + string(" not supported."); throw command_failure(ESIF_E_NOT_SUPPORTED, message); } } @@ -82,12 +84,6 @@ eEsifError CommandDispatcher::getLastReturnCode() const return m_lastCommandReturnCode; } -bool CommandDispatcher::isCommandRegistered(const std::string& command) -{ - const auto findResult = m_registeredCommands.find(command); - return findResult != m_registeredCommands.end(); -} - void CommandDispatcher::throwIfBadArguments(const CommandArguments& arguments) { if (arguments.size() < 1) diff --git a/DPTF/Sources/Manager/CommandDispatcher.h b/DPTF/Sources/Manager/CommandDispatcher.h index 747bb5c6..9fb5b33e 100644 --- a/DPTF/Sources/Manager/CommandDispatcher.h +++ b/DPTF/Sources/Manager/CommandDispatcher.h @@ -47,7 +47,6 @@ class CommandDispatcher : public ICommandDispatcher void unregisterHandler(const std::string commandName) override; virtual std::string getLastSuccessfulCommandMessage() const override; virtual eEsifError getLastReturnCode() const override; - bool isCommandRegistered(const std::string& command); private: void throwIfBadArguments(const CommandArguments& arguments); diff --git a/DPTF/Sources/Manager/CommandHandler.cpp b/DPTF/Sources/Manager/CommandHandler.cpp index b980f1e4..aaeb7eb0 100644 --- a/DPTF/Sources/Manager/CommandHandler.cpp +++ b/DPTF/Sources/Manager/CommandHandler.cpp @@ -36,7 +36,7 @@ CommandHandler::~CommandHandler() { } -string CommandHandler::getLastExecutionMessage() const +string CommandHandler::getLastExecutionMessage() { return m_resultMessage; } @@ -46,12 +46,7 @@ void CommandHandler::setResultMessage(const string& message) m_resultMessage = message; } -void CommandHandler::setDefaultResultMessage() -{ - m_resultMessage = defaultSuccessMessage; -} - -eEsifError CommandHandler::getLastExecutionResultCode() const +eEsifError CommandHandler::getLastExecutionResultCode() { return m_resultCode; } diff --git a/DPTF/Sources/Manager/CommandHandler.h b/DPTF/Sources/Manager/CommandHandler.h index 9d02df63..fbe01a92 100644 --- a/DPTF/Sources/Manager/CommandHandler.h +++ b/DPTF/Sources/Manager/CommandHandler.h @@ -27,12 +27,11 @@ class dptf_export CommandHandler virtual ~CommandHandler(); virtual void execute(const CommandArguments& arguments) = 0; virtual std::string getCommandName() const = 0; - virtual std::string getLastExecutionMessage() const; - virtual eEsifError getLastExecutionResultCode() const; + virtual std::string getLastExecutionMessage(); + virtual eEsifError getLastExecutionResultCode(); protected: void setResultMessage(const std::string& message); - void setDefaultResultMessage(); void setResultCode(const eEsifError resultCode); std::string m_resultMessage; eEsifError m_resultCode; diff --git a/DPTF/Sources/Manager/DataManager.cpp b/DPTF/Sources/Manager/DataManager.cpp index 1e98f8cb..31facab4 100644 --- a/DPTF/Sources/Manager/DataManager.cpp +++ b/DPTF/Sources/Manager/DataManager.cpp @@ -24,15 +24,15 @@ #include "WorkItem.h" #include "WorkItemQueueManagerInterface.h" #include "WIPolicyTableObjectChanged.h" -#include "ParticipantManagerInterface.h" - using namespace TableObjectType; using namespace std; DataManager::DataManager(DptfManagerInterface* dptfManager) : m_dptfManager(dptfManager) , m_tableObjectMap() + , m_tableRevisions() { + loadTableRevisions(); loadTableObjectMap(); } @@ -40,13 +40,12 @@ DataManager::~DataManager() { } -TableObject DataManager::getTableObject(TableObjectType::Type tableType, string uuid, UIntN participantIndex) +TableObject DataManager::getTableObject(TableObjectType::Type tableType, string uuid) { if (tableObjectExists(tableType)) { auto table = m_tableObjectMap.find(tableType)->second; auto dataVaultPaths = table.dataVaultPathForGet(); - for (auto path = dataVaultPaths.begin(); path != dataVaultPaths.end(); path++) { string nameSpace = DataVaultType::ToString(path->first); @@ -63,16 +62,7 @@ TableObject DataManager::getTableObject(TableObjectType::Type tableType, string try { - DptfBuffer data; - if (table.getReadTablePrimitive() != (esif_primitive_type_t)0) - { - data = m_dptfManager->getEsifServices()->primitiveExecuteGet( - table.getReadTablePrimitive(), ESIF_DATA_BINARY, participantIndex); - } - else - { - data = m_dptfManager->getEsifServices()->readConfigurationBinary(nameSpace, elementPath); - } + DptfBuffer data = m_dptfManager->getEsifServices()->readConfigurationBinary(nameSpace, elementPath); table.setData(data); return table; } @@ -89,11 +79,7 @@ TableObject DataManager::getTableObject(TableObjectType::Type tableType, string } } -void DataManager::setTableObject( - const DptfBuffer& tableData, - TableObjectType::Type tableType, - string uuid, - UIntN participantIndex) +void DataManager::setTableObject(UInt32 tableDataLength, UInt8* tableData, TableObjectType::Type tableType, string uuid) { if (!tableObjectExists(tableType)) { @@ -105,7 +91,6 @@ void DataManager::setTableObject( auto path = dataVaultPaths.begin(); string nameSpace = DataVaultType::ToString(path->first); string elementPath = path->second; - Bool isParticipantTable = m_dptfManager->getDataManager()->isParticipantTable(tableType); if (uuid.empty()) { @@ -117,25 +102,18 @@ void DataManager::setTableObject( elementPath = StringParser::replaceAll(elementPath, "UUID", StringConverter::toLower(uuid)); } - if (isParticipantTable) - { - string participantName = - m_dptfManager->getParticipantManager()->getParticipantPtr(participantIndex)->getParticipantName(); - elementPath = StringParser::replaceAll(elementPath, "%nm%", participantName + ".D0"); - } - try { m_dptfManager->getEsifServices()->writeConfigurationBinary( - tableData.get(), tableData.size(), tableData.size(), nameSpace, elementPath); - sendTableChangedEvent(tableType, uuid, participantIndex); + tableData, tableDataLength, tableDataLength, nameSpace, elementPath); + sendTableChangedEvent(tableType, uuid); } catch (...) { } } -void DataManager::deleteTableObject(TableObjectType::Type tableType, string uuid, UIntN participantIndex) +void DataManager::deleteTableObject(TableObjectType::Type tableType, string uuid) { if (!tableObjectExists(tableType)) { @@ -147,7 +125,6 @@ void DataManager::deleteTableObject(TableObjectType::Type tableType, string uuid auto path = dataVaultPaths.begin(); string nameSpace = DataVaultType::ToString(path->first); string elementPath = path->second; - Bool isParticipantTable = m_dptfManager->getDataManager()->isParticipantTable(tableType); if (uuid.empty()) { @@ -159,25 +136,18 @@ void DataManager::deleteTableObject(TableObjectType::Type tableType, string uuid elementPath = StringParser::replaceAll(elementPath, "UUID", StringConverter::toLower(uuid)); } - if (isParticipantTable) - { - string participantName = - m_dptfManager->getParticipantManager()->getParticipantPtr(participantIndex)->getParticipantName(); - elementPath = StringParser::replaceAll(elementPath, "%nm%", participantName + ".D0"); - } - try { m_dptfManager->getEsifServices()->deleteConfigurationBinary(nameSpace, elementPath); - sendTableChangedEvent(tableType, uuid, participantIndex); + sendTableChangedEvent(tableType, uuid); } - catch (const dptf_exception&) + catch (const dptf_exception& ) { // nothing to do } } -void DataManager::deleteAllTableObject(TableObjectType::Type tableType, string uuid, UIntN participantIndex) +void DataManager::deleteAllTableObject(TableObjectType::Type tableType, string uuid) { if (!tableObjectExists(tableType)) { @@ -186,8 +156,6 @@ void DataManager::deleteAllTableObject(TableObjectType::Type tableType, string u auto table = m_tableObjectMap.find(tableType)->second; auto dataVaultPaths = table.dataVaultPathForGet(); - Bool isParticipantTable = m_dptfManager->getDataManager()->isParticipantTable(tableType); - for (auto path = dataVaultPaths.begin(); path != dataVaultPaths.end(); path++) { string nameSpace = DataVaultType::ToString(path->first); @@ -202,17 +170,10 @@ void DataManager::deleteAllTableObject(TableObjectType::Type tableType, string u elementPath = StringParser::replaceAll(elementPath, "UUID", StringConverter::toLower(uuid)); } - if (isParticipantTable) - { - string participantName = - m_dptfManager->getParticipantManager()->getParticipantPtr(participantIndex)->getParticipantName(); - elementPath = StringParser::replaceAll(elementPath, "%nm%", participantName + ".D0"); - } - try { m_dptfManager->getEsifServices()->deleteConfigurationBinary(nameSpace, elementPath); - sendTableChangedEvent(tableType, uuid, participantIndex); + sendTableChangedEvent(tableType, uuid); } catch (...) { @@ -248,7 +209,8 @@ TableObject DataManager::getTableObjectBasedOnAlternativeDataSourceAndKey( } void DataManager::setTableObjectBasedOnAlternativeDataSourceAndKey( - const DptfBuffer& tableData, + UInt32 tableDataLength, + UInt8* tableData, TableObjectType::Type tableType, DataVaultType::Type dvType, string key) @@ -264,7 +226,7 @@ void DataManager::setTableObjectBasedOnAlternativeDataSourceAndKey( try { m_dptfManager->getEsifServices()->writeConfigurationBinary( - tableData.get(), tableData.size(), tableData.size(), nameSpace, elementPath); + tableData, tableDataLength, tableDataLength, nameSpace, elementPath); } catch (...) { @@ -286,7 +248,7 @@ void DataManager::setTableObjectForNoPersist(DptfBuffer tableData, TableObjectTy m_dptfManager->getEsifServices()->writeConfigurationBinary( tableData.get(), tableData.size(), tableData.size(), DataVaultType::ToString(dvType), elementPath); - sendTableChangedEvent(tableType, Constants::EmptyString, Constants::Esif::NoParticipant); + sendTableChangedEvent(tableType, Constants::EmptyString); } void DataManager::deleteTableObjectKeyForNoPersist(TableObjectType::Type tableType) @@ -310,17 +272,6 @@ void DataManager::deleteConfigKey(DataVaultType::Type dvType, string key) m_dptfManager->getEsifServices()->deleteConfigurationBinary(DataVaultType::ToString(dvType), key); } -Bool DataManager::isParticipantTable(TableObjectType::Type tableType) -{ - if (!tableObjectExists(tableType)) - { - throw dptf_exception("TableObject schema not found."); - } - - auto table = m_tableObjectMap.find(tableType)->second; - return table.isParticipantTable(); -} - Bool DataManager::tableObjectExists(TableObjectType::Type tableType) { auto table = m_tableObjectMap.find(tableType); @@ -331,732 +282,185 @@ Bool DataManager::tableObjectExists(TableObjectType::Type tableType) return false; } +UInt32 DataManager::getLatestSupportedTableRevision(TableObjectType::Type tableType) +{ + auto table = m_tableRevisions.find(tableType); + if (table != m_tableRevisions.end()) + { + return table->second; + } + + throw dptf_exception("TableObject revision not found."); +} + map DataManager::getTableObjectMap() { return m_tableObjectMap; } -void DataManager::sendTableChangedEvent(TableObjectType::Type tableObjectType, string uuid, UIntN participantIndex) +void DataManager::sendTableChangedEvent(TableObjectType::Type tableObjectType, string uuid) { - std::shared_ptr wi = - std::make_shared(m_dptfManager, tableObjectType, uuid, participantIndex); + std::shared_ptr wi = std::make_shared(m_dptfManager, tableObjectType, uuid); m_dptfManager->getWorkItemQueueManager()->enqueueImmediateWorkItemAndReturn(wi); } -void DataManager::loadTableObjectMap() +void DataManager::loadTableRevisions() { - loadAcprTableObject(); - loadApatTableObject(); - loadApctTableObject(); - loadArtTableObject(); - loadDdrfTableObject(); - loadDynamicIdspTableObject(); - loadEpotTableObject(); - loadItmtTableObject(); - loadOdvpTableObject(); - loadPbatTableObject(); - loadPbctTableObject(); - loadPbmtTableObject(); - loadPidaTableObject(); - loadPsh2TableObject(); - loadPshaTableObject(); - loadPsvtTableObject(); - loadSwOemVariablesTableObject(); - loadTpgaTableObject(); - loadTrtTableObject(); - loadVsctTableObject(); - loadVsptTableObject(); - loadVtmtTableObject(); + m_tableRevisions.insert({TableObjectType::Apat, 2}); + m_tableRevisions.insert({TableObjectType::Apct, 2}); + m_tableRevisions.insert({TableObjectType::Dynamic_Idsp, 1}); + m_tableRevisions.insert({TableObjectType::Ddrf, 1}); + m_tableRevisions.insert({TableObjectType::Itmt, 1}); + m_tableRevisions.insert({TableObjectType::Epot, 1}); + m_tableRevisions.insert({TableObjectType::Tpga, 1}); + m_tableRevisions.insert({TableObjectType::SwOemVariables, 1}); } -void DataManager::loadApatTableObject() +void DataManager::loadTableObjectMap() { auto dataVaultString = DataVaultPathBasePaths::ExportRoot + "/UUID/" + TableObjectType::ToString(TableObjectType::Apat); - set revisionsUsingEsifDataVariant = {2}; - map> fieldsMap; - fieldsMap.insert( - {2, - {{"fld1", "fld1", ESIF_DATA_UINT64}, - {"fld2", "fld2", ESIF_DATA_STRING}, - {"fld3", "fld3", ESIF_DATA_STRING}, - {"fld4", "fld4", ESIF_DATA_UINT64}, - {"fld5", "fld5", ESIF_DATA_STRING}, - {"fld6", "fld6", ESIF_DATA_STRING}}}); - m_tableObjectMap.insert( {TableObjectType::Apat, {TableObjectType::Apat, - fieldsMap, + {{"fld1", "fld1", ESIF_DATA_UINT64}, + {"fld2", "fld2", ESIF_DATA_STRING}, + {"fld3", "fld3", ESIF_DATA_STRING}, + {"fld4", "fld4", ESIF_DATA_UINT64}, + {"fld5", "fld5", ESIF_DATA_STRING}, + {"fld6", "fld6", ESIF_DATA_STRING}}, {{DataVaultType::Override, dataVaultString}, {DataVaultType::Dptf, dataVaultString}}, - {{DataVaultType::Override, dataVaultString}}, - revisionsUsingEsifDataVariant}}); -} - -void DataManager::loadApctTableObject() -{ - auto dataVaultString = - DataVaultPathBasePaths::ExportRoot + "/UUID/" + TableObjectType::ToString(TableObjectType::Apct); - set revisionsUsingEsifDataVariant = {2}; - map> fieldsMap; - fieldsMap.insert({2, {{"fld1", "fld1", ESIF_DATA_UINT64}, {"fld2", "fld2", ESIF_DATA_UINT64}, - {"fld3", "fld3", ESIF_DATA_UINT64}, {"fld4", "fld4", ESIF_DATA_STRING}, - {"fld5", "fld5", ESIF_DATA_UINT64}, {"fld6", "fld6", ESIF_DATA_UINT64}, - {"fld7", "fld7", ESIF_DATA_UINT64}, {"fld8", "fld8", ESIF_DATA_UINT64}, - {"fld9", "fld9", ESIF_DATA_UINT64}, {"fld10", "fld10", ESIF_DATA_STRING}, - {"fld11", "fld11", ESIF_DATA_UINT64}, {"fld12", "fld12", ESIF_DATA_UINT64}, - {"fld13", "fld13", ESIF_DATA_UINT64}, {"fld14", "fld14", ESIF_DATA_UINT64}, - {"fld15", "fld15", ESIF_DATA_UINT64}, {"fld16", "fld16", ESIF_DATA_STRING}, - {"fld17", "fld17", ESIF_DATA_UINT64}, {"fld18", "fld18", ESIF_DATA_UINT64}, - {"fld19", "fld19", ESIF_DATA_UINT64}, {"fld20", "fld20", ESIF_DATA_UINT64}, - {"fld21", "fld21", ESIF_DATA_UINT64}, {"fld22", "fld22", ESIF_DATA_STRING}, - {"fld23", "fld23", ESIF_DATA_UINT64}, {"fld24", "fld24", ESIF_DATA_UINT64}, - {"fld25", "fld25", ESIF_DATA_UINT64}, {"fld26", "fld26", ESIF_DATA_UINT64}, - {"fld27", "fld27", ESIF_DATA_UINT64}, {"fld28", "fld28", ESIF_DATA_STRING}, - {"fld29", "fld29", ESIF_DATA_UINT64}, {"fld30", "fld30", ESIF_DATA_UINT64}, - {"fld31", "fld31", ESIF_DATA_UINT64}, {"fld32", "fld32", ESIF_DATA_UINT64}, - {"fld33", "fld33", ESIF_DATA_UINT64}, {"fld34", "fld34", ESIF_DATA_STRING}, - {"fld35", "fld35", ESIF_DATA_UINT64}, {"fld36", "fld36", ESIF_DATA_UINT64}, - {"fld37", "fld37", ESIF_DATA_UINT64}, {"fld38", "fld38", ESIF_DATA_UINT64}, - {"fld39", "fld39", ESIF_DATA_UINT64}, {"fld40", "fld40", ESIF_DATA_STRING}, - {"fld41", "fld41", ESIF_DATA_UINT64}, {"fld42", "fld42", ESIF_DATA_UINT64}, - {"fld43", "fld43", ESIF_DATA_UINT64}, {"fld44", "fld44", ESIF_DATA_UINT64}, - {"fld45", "fld45", ESIF_DATA_UINT64}, {"fld46", "fld46", ESIF_DATA_STRING}, - {"fld47", "fld47", ESIF_DATA_UINT64}, {"fld48", "fld48", ESIF_DATA_UINT64}, - {"fld49", "fld49", ESIF_DATA_UINT64}, {"fld50", "fld50", ESIF_DATA_UINT64}, - {"fld51", "fld51", ESIF_DATA_UINT64}, {"fld52", "fld52", ESIF_DATA_STRING}, - {"fld53", "fld53", ESIF_DATA_UINT64}, {"fld54", "fld54", ESIF_DATA_UINT64}, - {"fld55", "fld55", ESIF_DATA_UINT64}, {"fld56", "fld56", ESIF_DATA_UINT64}, - {"fld57", "fld57", ESIF_DATA_UINT64}, {"fld58", "fld58", ESIF_DATA_STRING}, - {"fld59", "fld59", ESIF_DATA_UINT64}, {"fld60", "fld60", ESIF_DATA_UINT64}, - {"fld61", "fld61", ESIF_DATA_UINT64}}}); + {{DataVaultType::Override, dataVaultString}}}}); + dataVaultString = DataVaultPathBasePaths::ExportRoot + "/UUID/" + TableObjectType::ToString(TableObjectType::Apct); m_tableObjectMap.insert( {TableObjectType::Apct, {TableObjectType::Apct, - fieldsMap, + {{"fld1", "fld1", ESIF_DATA_UINT64}, {"fld2", "fld2", ESIF_DATA_UINT64}, + {"fld3", "fld3", ESIF_DATA_UINT64}, {"fld4", "fld4", ESIF_DATA_STRING}, + {"fld5", "fld5", ESIF_DATA_UINT64}, {"fld6", "fld6", ESIF_DATA_UINT64}, + {"fld7", "fld7", ESIF_DATA_UINT64}, {"fld8", "fld8", ESIF_DATA_UINT64}, + {"fld9", "fld9", ESIF_DATA_UINT64}, {"fld10", "fld10", ESIF_DATA_STRING}, + {"fld11", "fld11", ESIF_DATA_UINT64}, {"fld12", "fld12", ESIF_DATA_UINT64}, + {"fld13", "fld13", ESIF_DATA_UINT64}, {"fld14", "fld14", ESIF_DATA_UINT64}, + {"fld15", "fld15", ESIF_DATA_UINT64}, {"fld16", "fld16", ESIF_DATA_STRING}, + {"fld17", "fld17", ESIF_DATA_UINT64}, {"fld18", "fld18", ESIF_DATA_UINT64}, + {"fld19", "fld19", ESIF_DATA_UINT64}, {"fld20", "fld20", ESIF_DATA_UINT64}, + {"fld21", "fld21", ESIF_DATA_UINT64}, {"fld22", "fld22", ESIF_DATA_STRING}, + {"fld23", "fld23", ESIF_DATA_UINT64}, {"fld24", "fld24", ESIF_DATA_UINT64}, + {"fld25", "fld25", ESIF_DATA_UINT64}, {"fld26", "fld26", ESIF_DATA_UINT64}, + {"fld27", "fld27", ESIF_DATA_UINT64}, {"fld28", "fld28", ESIF_DATA_STRING}, + {"fld29", "fld29", ESIF_DATA_UINT64}, {"fld30", "fld30", ESIF_DATA_UINT64}, + {"fld31", "fld31", ESIF_DATA_UINT64}, {"fld32", "fld32", ESIF_DATA_UINT64}, + {"fld33", "fld33", ESIF_DATA_UINT64}, {"fld34", "fld34", ESIF_DATA_STRING}, + {"fld35", "fld35", ESIF_DATA_UINT64}, {"fld36", "fld36", ESIF_DATA_UINT64}, + {"fld37", "fld37", ESIF_DATA_UINT64}, {"fld38", "fld38", ESIF_DATA_UINT64}, + {"fld39", "fld39", ESIF_DATA_UINT64}, {"fld40", "fld40", ESIF_DATA_STRING}, + {"fld41", "fld41", ESIF_DATA_UINT64}, {"fld42", "fld42", ESIF_DATA_UINT64}, + {"fld43", "fld43", ESIF_DATA_UINT64}, {"fld44", "fld44", ESIF_DATA_UINT64}, + {"fld45", "fld45", ESIF_DATA_UINT64}, {"fld46", "fld46", ESIF_DATA_STRING}, + {"fld47", "fld47", ESIF_DATA_UINT64}, {"fld48", "fld48", ESIF_DATA_UINT64}, + {"fld49", "fld49", ESIF_DATA_UINT64}, {"fld50", "fld50", ESIF_DATA_UINT64}, + {"fld51", "fld51", ESIF_DATA_UINT64}, {"fld52", "fld52", ESIF_DATA_STRING}, + {"fld53", "fld53", ESIF_DATA_UINT64}, {"fld54", "fld54", ESIF_DATA_UINT64}, + {"fld55", "fld55", ESIF_DATA_UINT64}, {"fld56", "fld56", ESIF_DATA_UINT64}, + {"fld57", "fld57", ESIF_DATA_UINT64}, {"fld58", "fld58", ESIF_DATA_STRING}, + {"fld59", "fld59", ESIF_DATA_UINT64}, {"fld60", "fld60", ESIF_DATA_UINT64}, + {"fld61", "fld61", ESIF_DATA_UINT64}}, {{DataVaultType::Override, dataVaultString}, {DataVaultType::Dptf, dataVaultString}}, - {{DataVaultType::Override, dataVaultString}}, - revisionsUsingEsifDataVariant}}); -} + {{DataVaultType::Override, dataVaultString}}}}); -void DataManager::loadDynamicIdspTableObject() -{ - auto dataVaultString = + dataVaultString = DataVaultPathBasePaths::ExportRoot + "/UUID/" + TableObjectType::ToString(TableObjectType::Dynamic_Idsp); - set revisionsUsingEsifDataVariant = {1}; - map> fieldsMap; - fieldsMap.insert( - {1, - {{"uuid", "uuid", ESIF_DATA_STRING}, - {"templateGuid", "templateGuid", ESIF_DATA_STRING}, - {"policyName", "policyName", ESIF_DATA_STRING}}}); - m_tableObjectMap.insert( {TableObjectType::Dynamic_Idsp, {TableObjectType::Dynamic_Idsp, - fieldsMap, - {{DataVaultType::Dptf, dataVaultString}}, + {{"uuid", "uuid", ESIF_DATA_STRING}, + {"templateGuid", "templateGuid", ESIF_DATA_STRING}, + {"policyName", "policyName", ESIF_DATA_STRING}}, {{DataVaultType::Dptf, dataVaultString}}, - revisionsUsingEsifDataVariant}}); -} - -void DataManager::loadDdrfTableObject() -{ - auto dataVaultString = - DataVaultPathBasePaths::ExportRoot + "/UUID/" + TableObjectType::ToString(TableObjectType::Ddrf); - set revisionsUsingEsifDataVariant = {1}; - map> fieldsMap; - fieldsMap.insert( - {1, - {{"fld1", "fld1", ESIF_DATA_UINT64}, - {"fld2", "fld2", ESIF_DATA_UINT64}, - {"fld3", "fld3", ESIF_DATA_UINT64}, - {"fld4", "fld4", ESIF_DATA_UINT64}, - {"fld5", "fld5", ESIF_DATA_UINT64}, - {"fld6", "fld6", ESIF_DATA_UINT64}, - {"fld7", "fld7", ESIF_DATA_UINT64}, - {"fld8", "fld8", ESIF_DATA_UINT64}, - {"fld9", "fld9", ESIF_DATA_UINT64}, - {"fld10", "fld10", ESIF_DATA_UINT64}, - {"fld11", "fld11", ESIF_DATA_UINT64}, - {"fld12", "fld12", ESIF_DATA_UINT64}, - {"fld13", "fld13", ESIF_DATA_UINT64}, - {"fld14", "fld14", ESIF_DATA_UINT64}, - {"fld15", "fld15", ESIF_DATA_UINT64}, - {"fld16", "fld16", ESIF_DATA_UINT64}, - {"fld17", "fld17", ESIF_DATA_UINT64}}}); + {{DataVaultType::Dptf, dataVaultString}}}}); + dataVaultString = DataVaultPathBasePaths::ExportRoot + "/UUID/" + TableObjectType::ToString(TableObjectType::Ddrf); m_tableObjectMap.insert( {TableObjectType::Ddrf, {TableObjectType::Ddrf, - fieldsMap, + {{"fld1", "fld1", ESIF_DATA_UINT64}, + {"fld2", "fld2", ESIF_DATA_UINT64}, + {"fld3", "fld3", ESIF_DATA_UINT64}, + {"fld4", "fld4", ESIF_DATA_UINT64}, + {"fld5", "fld5", ESIF_DATA_UINT64}, + {"fld6", "fld6", ESIF_DATA_UINT64}, + {"fld7", "fld7", ESIF_DATA_UINT64}, + {"fld8", "fld8", ESIF_DATA_UINT64}, + {"fld9", "fld9", ESIF_DATA_UINT64}, + {"fld10", "fld10", ESIF_DATA_UINT64}, + {"fld11", "fld11", ESIF_DATA_UINT64}, + {"fld12", "fld12", ESIF_DATA_UINT64}, + {"fld13", "fld13", ESIF_DATA_UINT64}, + {"fld14", "fld14", ESIF_DATA_UINT64}, + {"fld15", "fld15", ESIF_DATA_UINT64}, + {"fld16", "fld16", ESIF_DATA_UINT64}, + {"fld17", "fld17", ESIF_DATA_UINT64}}, {{DataVaultType::Override, dataVaultString}, {DataVaultType::Dptf, dataVaultString}}, - {{DataVaultType::Override, dataVaultString}}, - revisionsUsingEsifDataVariant}}); -} + {{DataVaultType::Override, dataVaultString}}}}); -void DataManager::loadItmtTableObject() -{ - auto dataVaultString = - DataVaultPathBasePaths::ExportRoot + "/UUID/" + TableObjectType::ToString(TableObjectType::Itmt); + dataVaultString = DataVaultPathBasePaths::ExportRoot + "/UUID/" + TableObjectType::ToString(TableObjectType::Itmt); auto noPersistPath = "/nopersist/%nm%/" + TableObjectType::ToString(TableObjectType::Itmt); noPersistPath = StringParser::replaceAll(noPersistPath, "%nm%", DefaultScope::IETMParticipantScope + ".D0"); - set revisionsUsingEsifDataVariant = {1, 2}; - map> fieldsMap; - fieldsMap.insert( - {1, - {{"fld1", "fld1", ESIF_DATA_STRING}, - {"fld2", "fld2", ESIF_DATA_UINT64}, - {"fld3", "fld3", ESIF_DATA_STRING}, - {"fld4", "fld4", ESIF_DATA_STRING}, - {"fld5", "fld5", ESIF_DATA_STRING}, - {"fld6", "fld6", ESIF_DATA_UINT64}}}); - - fieldsMap.insert( - {2, - {{"fld1", "fld1", ESIF_DATA_STRING}, - {"fld2", "fld2", ESIF_DATA_UINT64}, - {"fld3", "fld3", ESIF_DATA_STRING}, - {"fld4", "fld4", ESIF_DATA_STRING}, - {"fld5", "fld5", ESIF_DATA_STRING}, - {"fld6", "fld6", ESIF_DATA_UINT64}, - {"fld7", "fld7", ESIF_DATA_STRING}, - {"fld8", "fld8", ESIF_DATA_UINT64}, - {"fld9", "fld9", ESIF_DATA_UINT64}}}); - m_tableObjectMap.insert( {TableObjectType::Itmt, {TableObjectType::Itmt, - fieldsMap, + {{"fld1", "fld1", ESIF_DATA_STRING}, + {"fld2", "fld2", ESIF_DATA_UINT64}, + {"fld3", "fld3", ESIF_DATA_STRING}, + {"fld4", "fld4", ESIF_DATA_STRING}, + {"fld5", "fld5", ESIF_DATA_STRING}, + {"fld6", "fld6", ESIF_DATA_UINT64}}, {{DataVaultType::Override, noPersistPath}, {DataVaultType::Override, dataVaultString}, {DataVaultType::Dptf, dataVaultString}}, - {{DataVaultType::Override, dataVaultString}}, - revisionsUsingEsifDataVariant}}); -} + {{DataVaultType::Override, dataVaultString}}}}); -void DataManager::loadEpotTableObject() -{ - auto dataVaultString = - DataVaultPathBasePaths::ExportRoot + "/UUID/" + TableObjectType::ToString(TableObjectType::Epot); - auto noPersistPath = "/nopersist/%nm%/" + TableObjectType::ToString(TableObjectType::Epot); + dataVaultString = DataVaultPathBasePaths::ExportRoot + "/UUID/" + TableObjectType::ToString(TableObjectType::Epot); + noPersistPath = "/nopersist/%nm%/" + TableObjectType::ToString(TableObjectType::Epot); noPersistPath = StringParser::replaceAll(noPersistPath, "%nm%", DefaultScope::IETMParticipantScope + ".D0"); - set revisionsUsingEsifDataVariant = {1, 2}; - map> fieldsMap; - - fieldsMap.insert( - {1, - {{"fld1", "fld1", ESIF_DATA_STRING}, - {"fld2", "fld2", ESIF_DATA_STRING}, - {"fld3", "fld3", ESIF_DATA_UINT64}, - {"fld4", "fld4", ESIF_DATA_UINT64}}}); - - fieldsMap.insert( - {2, - {{"fld1", "fld1", ESIF_DATA_STRING}, - {"fld2", "fld2", ESIF_DATA_STRING}, - {"fld3", "fld3", ESIF_DATA_UINT64}, - {"fld4", "fld4", ESIF_DATA_UINT64}}}); - m_tableObjectMap.insert( {TableObjectType::Epot, {TableObjectType::Epot, - fieldsMap, + {{"fld1", "fld1", ESIF_DATA_STRING}, + {"fld2", "fld2", ESIF_DATA_STRING}, + {"fld3", "fld3", ESIF_DATA_UINT64}, + {"fld4", "fld4", ESIF_DATA_UINT64}}, {{DataVaultType::Override, noPersistPath}, {DataVaultType::Override, dataVaultString}, {DataVaultType::Dptf, dataVaultString}}, - {{DataVaultType::Override, dataVaultString}}, - revisionsUsingEsifDataVariant}}); -} + {{DataVaultType::Override, dataVaultString}}}}); -void DataManager::loadTpgaTableObject() -{ - auto dataVaultString = - DataVaultPathBasePaths::ExportRoot + "/UUID/" + TableObjectType::ToString(TableObjectType::Tpga); - auto noPersistPath = "/nopersist/%nm%/" + TableObjectType::ToString(TableObjectType::Tpga); + dataVaultString = DataVaultPathBasePaths::ExportRoot + "/UUID/" + TableObjectType::ToString(TableObjectType::Tpga); + noPersistPath = "/nopersist/%nm%/" + TableObjectType::ToString(TableObjectType::Tpga); noPersistPath = StringParser::replaceAll(noPersistPath, "%nm%", DefaultScope::IETMParticipantScope + ".D0"); - set revisionsUsingEsifDataVariant = {1}; - map> fieldsMap; - fieldsMap.insert( - {1, - {{"fld1", "fld1", ESIF_DATA_STRING}, {"fld2", "fld2", ESIF_DATA_UINT64}, {"fld3", "fld3", ESIF_DATA_UINT64}}}); - m_tableObjectMap.insert( {TableObjectType::Tpga, {TableObjectType::Tpga, - fieldsMap, + {{"fld1", "fld1", ESIF_DATA_STRING}, + {"fld2", "fld2", ESIF_DATA_UINT64}, + {"fld3", "fld3", ESIF_DATA_UINT64}}, {{DataVaultType::Override, noPersistPath}, {DataVaultType::Override, dataVaultString}, {DataVaultType::Dptf, dataVaultString}}, - {{DataVaultType::Override, dataVaultString}}, - revisionsUsingEsifDataVariant}}); -} + {{DataVaultType::Override, dataVaultString}}}}); -void DataManager::loadSwOemVariablesTableObject() -{ - auto dataVaultString = - DataVaultPathBasePaths::ExportRoot + "/UUID/" + TableObjectType::ToString(TableObjectType::SwOemVariables); - auto noPersistPath = "/nopersist/%nm%/" + TableObjectType::ToString(TableObjectType::SwOemVariables); + dataVaultString = DataVaultPathBasePaths::ExportRoot + "/UUID/" + TableObjectType::ToString(TableObjectType::SwOemVariables); + noPersistPath = "/nopersist/%nm%/" + TableObjectType::ToString(TableObjectType::SwOemVariables); noPersistPath = StringParser::replaceAll(noPersistPath, "%nm%", DefaultScope::IETMParticipantScope + ".D0"); - set revisionsUsingEsifDataVariant = {1}; - map> fieldsMap; - fieldsMap.insert({1, {{"fld1", "fld1", ESIF_DATA_UINT64}, {"fld2", "fld2", ESIF_DATA_UINT64}}}); - m_tableObjectMap.insert( {TableObjectType::SwOemVariables, {TableObjectType::SwOemVariables, - fieldsMap, - {{DataVaultType::Override, noPersistPath}, - {DataVaultType::Override, dataVaultString}, - {DataVaultType::Dptf, dataVaultString}}, - {{DataVaultType::Override, dataVaultString}}, - revisionsUsingEsifDataVariant}}); -} - -void DataManager::loadPsvtTableObject() -{ - auto dataVaultString = "/participants/%nm%/UUID/" + TableObjectType::ToString(TableObjectType::Psvt); - dataVaultString = StringParser::replaceAll(dataVaultString, "%nm%", DefaultScope::IETMParticipantScope + ".D0"); - auto noPersistPath = "/nopersist/%nm%/" + TableObjectType::ToString(TableObjectType::Psvt); - noPersistPath = StringParser::replaceAll(noPersistPath, "%nm%", DefaultScope::IETMParticipantScope + ".D0"); - set revisionsUsingEsifDataVariant = {1,2}; - map> fieldsMap; - fieldsMap.insert( - {1, - {{"fld1", "fld1", ESIF_DATA_STRING}, - {"fld2", "fld2", ESIF_DATA_STRING}, - {"fld3", "fld3", ESIF_DATA_UINT64}, - {"fld4", "fld4", ESIF_DATA_UINT64}, - {"fld5", "fld5", ESIF_DATA_UINT64}, - {"fld6", "fld6", ESIF_DATA_UINT64}, - {"fld7", "fld7", ESIF_DATA_UINT64}, - {"fld8", "fld8", ESIF_DATA_STRING, true}, - {"fld9", "fld9", ESIF_DATA_UINT64}, - {"fld10", "fld10", ESIF_DATA_UINT64}, - {"fld11", "fld11", ESIF_DATA_UINT64}, - {"fld12", "fld12", ESIF_DATA_UINT64}}}); - - fieldsMap.insert( - {2, - {{"fld1", "fld1", ESIF_DATA_STRING}, - {"fld2", "fld2", ESIF_DATA_STRING}, - {"fld3", "fld3", ESIF_DATA_UINT64}, - {"fld4", "fld4", ESIF_DATA_UINT64}, - {"fld5", "fld5", ESIF_DATA_UINT64}, - {"fld6", "fld6", ESIF_DATA_UINT64}, - {"fld7", "fld7", ESIF_DATA_UINT64}, - {"fld8", "fld8", ESIF_DATA_STRING, true}, - {"fld9", "fld9", ESIF_DATA_UINT64}, - {"fld10", "fld10", ESIF_DATA_UINT64}, - {"fld11", "fld11", ESIF_DATA_UINT64}, - {"fld12", "fld12", ESIF_DATA_UINT64}}}); - - m_tableObjectMap.insert( - {TableObjectType::Psvt, - {TableObjectType::Psvt, - fieldsMap, + {{"fld1", "fld1", ESIF_DATA_UINT64}, + {"fld2", "fld2", ESIF_DATA_UINT64}}, {{DataVaultType::Override, noPersistPath}, {DataVaultType::Override, dataVaultString}, {DataVaultType::Dptf, dataVaultString}}, - {{DataVaultType::Override, dataVaultString}}, - revisionsUsingEsifDataVariant, - 0, - GET_PASSIVE_RELATIONSHIP_TABLE}}); -} - -void DataManager::loadVsctTableObject() -{ - auto dataVaultString = "/participants/%nm%/" + TableObjectType::ToString(TableObjectType::Vsct); - set revisionsUsingEsifDataVariant = {1}; - map> fieldsMap; - fieldsMap.insert( - {1, - {{"fld1", "fld1", ESIF_DATA_STRING}, - {"fld2", "fld2", ESIF_DATA_UINT64}, - {"fld3", "fld3", ESIF_DATA_UINT64}, - {"fld4", "fld4", ESIF_DATA_UINT64}, - {"fld5", "fld5", ESIF_DATA_UINT64}, - {"fld6", "fld6", ESIF_DATA_UINT64}, - {"fld7", "fld7", ESIF_DATA_UINT64}}}); - - m_tableObjectMap.insert( - {TableObjectType::Vsct, - {TableObjectType::Vsct, - fieldsMap, - {{DataVaultType::Override, dataVaultString}, {DataVaultType::Dptf, dataVaultString}}, - {{DataVaultType::Override, dataVaultString}}, - revisionsUsingEsifDataVariant, - 0, - GET_VIRTUAL_SENSOR_CALIB_TABLE, - true}}); + {{DataVaultType::Override, dataVaultString}}}}); } - -void DataManager::loadVsptTableObject() -{ - auto dataVaultString = "/participants/%nm%/" + TableObjectType::ToString(TableObjectType::Vspt); - map> fieldsMap; - set revisionsUsingEsifDataVariant = {1}; - fieldsMap.insert({1, {{"fld1", "fld1", ESIF_DATA_UINT64}, {"fld2", "fld2", ESIF_DATA_UINT64}}}); - - m_tableObjectMap.insert( - {TableObjectType::Vspt, - {TableObjectType::Vspt, - fieldsMap, - {{DataVaultType::Override, dataVaultString}, {DataVaultType::Dptf, dataVaultString}}, - {{DataVaultType::Override, dataVaultString}}, - revisionsUsingEsifDataVariant, - 0, - GET_VIRTUAL_SENSOR_POLLING_TABLE, - true}}); -} - -void DataManager::loadAcprTableObject() -{ - auto dataVaultString = - DataVaultPathBasePaths::ExportRoot + "/UUID/" + TableObjectType::ToString(TableObjectType::Acpr); - auto noPersistPath = "/nopersist/%nm%/" + TableObjectType::ToString(TableObjectType::Acpr); - noPersistPath = StringParser::replaceAll(noPersistPath, "%nm%", DefaultScope::IETMParticipantScope + ".D0"); - UInt32 mode = 2; - set revisionsUsingEsifDataVariant = {1}; - map> fieldsMap; - fieldsMap.insert( - {1, - {{"fld1", "fld1", ESIF_DATA_STRING}, - {"fld2", "fld2", ESIF_DATA_UINT64}, - {"fld3", "fld3", ESIF_DATA_STRING}, - {"fld4", "fld4", ESIF_DATA_UINT64}, - {"fld5", "fld5", ESIF_DATA_UINT64}, - {"fld6", "fld6", ESIF_DATA_UINT64}, - {"fld7", "fld7", ESIF_DATA_UINT64}}}); - - m_tableObjectMap.insert( - {TableObjectType::Acpr, - {TableObjectType::Acpr, - fieldsMap, - {{DataVaultType::Override, noPersistPath}, - {DataVaultType::Override, dataVaultString}, - {DataVaultType::Dptf, dataVaultString}}, - {{DataVaultType::Override, dataVaultString}}, - revisionsUsingEsifDataVariant, - mode}}); -} - -void DataManager::loadPbatTableObject() -{ - auto dataVaultString = - DataVaultPathBasePaths::ExportRoot + "/UUID/" + TableObjectType::ToString(TableObjectType::Pbat); - set revisionsUsingEsifDataVariant = {2}; - map> fieldsMap; - fieldsMap.insert( - {2, - {{"fld1", "fld1", ESIF_DATA_UINT64}, - {"fld2", "fld2", ESIF_DATA_STRING}, - {"fld3", "fld3", ESIF_DATA_STRING}, - {"fld4", "fld4", ESIF_DATA_UINT64}, - {"fld5", "fld5", ESIF_DATA_STRING}, - {"fld6", "fld6", ESIF_DATA_STRING}}}); - - m_tableObjectMap.insert( - {TableObjectType::Pbat, - {TableObjectType::Pbat, - fieldsMap, - {{DataVaultType::Override, dataVaultString}, {DataVaultType::Dptf, dataVaultString}}, - {{DataVaultType::Override, dataVaultString}}, - revisionsUsingEsifDataVariant}}); -} - -void DataManager::loadPbctTableObject() -{ - auto dataVaultString = - DataVaultPathBasePaths::ExportRoot + "/UUID/" + TableObjectType::ToString(TableObjectType::Pbct); - set revisionsUsingEsifDataVariant = {2}; - map> fieldsMap; - fieldsMap.insert({2, {{"fld1", "fld1", ESIF_DATA_UINT64}, {"fld2", "fld2", ESIF_DATA_UINT64}, - {"fld3", "fld3", ESIF_DATA_UINT64}, {"fld4", "fld4", ESIF_DATA_STRING}, - {"fld5", "fld5", ESIF_DATA_UINT64}, {"fld6", "fld6", ESIF_DATA_UINT64}, - {"fld7", "fld7", ESIF_DATA_UINT64}, {"fld8", "fld8", ESIF_DATA_UINT64}, - {"fld9", "fld9", ESIF_DATA_UINT64}, {"fld10", "fld10", ESIF_DATA_STRING}, - {"fld11", "fld11", ESIF_DATA_UINT64}, {"fld12", "fld12", ESIF_DATA_UINT64}, - {"fld13", "fld13", ESIF_DATA_UINT64}, {"fld14", "fld14", ESIF_DATA_UINT64}, - {"fld15", "fld15", ESIF_DATA_UINT64}, {"fld16", "fld16", ESIF_DATA_STRING}, - {"fld17", "fld17", ESIF_DATA_UINT64}, {"fld18", "fld18", ESIF_DATA_UINT64}, - {"fld19", "fld19", ESIF_DATA_UINT64}, {"fld20", "fld20", ESIF_DATA_UINT64}, - {"fld21", "fld21", ESIF_DATA_UINT64}, {"fld22", "fld22", ESIF_DATA_STRING}, - {"fld23", "fld23", ESIF_DATA_UINT64}, {"fld24", "fld24", ESIF_DATA_UINT64}, - {"fld25", "fld25", ESIF_DATA_UINT64}, {"fld26", "fld26", ESIF_DATA_UINT64}, - {"fld27", "fld27", ESIF_DATA_UINT64}, {"fld28", "fld28", ESIF_DATA_STRING}, - {"fld29", "fld29", ESIF_DATA_UINT64}, {"fld30", "fld30", ESIF_DATA_UINT64}, - {"fld31", "fld31", ESIF_DATA_UINT64}, {"fld32", "fld32", ESIF_DATA_UINT64}, - {"fld33", "fld33", ESIF_DATA_UINT64}, {"fld34", "fld34", ESIF_DATA_STRING}, - {"fld35", "fld35", ESIF_DATA_UINT64}, {"fld36", "fld36", ESIF_DATA_UINT64}, - {"fld37", "fld37", ESIF_DATA_UINT64}, {"fld38", "fld38", ESIF_DATA_UINT64}, - {"fld39", "fld39", ESIF_DATA_UINT64}, {"fld40", "fld40", ESIF_DATA_STRING}, - {"fld41", "fld41", ESIF_DATA_UINT64}, {"fld42", "fld42", ESIF_DATA_UINT64}, - {"fld43", "fld43", ESIF_DATA_UINT64}, {"fld44", "fld44", ESIF_DATA_UINT64}, - {"fld45", "fld45", ESIF_DATA_UINT64}, {"fld46", "fld46", ESIF_DATA_STRING}, - {"fld47", "fld47", ESIF_DATA_UINT64}, {"fld48", "fld48", ESIF_DATA_UINT64}, - {"fld49", "fld49", ESIF_DATA_UINT64}, {"fld50", "fld50", ESIF_DATA_UINT64}, - {"fld51", "fld51", ESIF_DATA_UINT64}, {"fld52", "fld52", ESIF_DATA_STRING}, - {"fld53", "fld53", ESIF_DATA_UINT64}, {"fld54", "fld54", ESIF_DATA_UINT64}, - {"fld55", "fld55", ESIF_DATA_UINT64}, {"fld56", "fld56", ESIF_DATA_UINT64}, - {"fld57", "fld57", ESIF_DATA_UINT64}, {"fld58", "fld58", ESIF_DATA_STRING}, - {"fld59", "fld59", ESIF_DATA_UINT64}, {"fld60", "fld60", ESIF_DATA_UINT64}, - {"fld61", "fld61", ESIF_DATA_UINT64}}}); - - m_tableObjectMap.insert( - {TableObjectType::Pbct, - {TableObjectType::Pbct, - fieldsMap, - {{DataVaultType::Override, dataVaultString}, {DataVaultType::Dptf, dataVaultString}}, - {{DataVaultType::Override, dataVaultString}}, - revisionsUsingEsifDataVariant}}); -} - -void DataManager::loadPbmtTableObject() -{ - auto dataVaultString = - DataVaultPathBasePaths::ExportRoot + "/UUID/" + TableObjectType::ToString(TableObjectType::Pbmt); - set revisionsUsingEsifDataVariant = {2}; - map> fieldsMap; - fieldsMap.insert({2, {{"fld1", "fld1", ESIF_DATA_STRING}, {"fld2", "fld2", ESIF_DATA_UINT64}, - {"fld3", "fld3", ESIF_DATA_STRING}, {"fld4", "fld4", ESIF_DATA_STRING}, - {"fld5", "fld5", ESIF_DATA_STRING}, {"fld6", "fld6", ESIF_DATA_STRING}, - {"fld7", "fld7", ESIF_DATA_UINT64}, {"fld8", "fld8", ESIF_DATA_STRING}, - {"fld9", "fld9", ESIF_DATA_UINT64}, {"fld10", "fld10", ESIF_DATA_UINT64}, - {"fld11", "fld11", ESIF_DATA_UINT64}, {"fld12", "fld12", ESIF_DATA_STRING}, - {"fld13", "fld13", ESIF_DATA_UINT64}, {"fld14", "fld14", ESIF_DATA_UINT64}, - {"fld15", "fld15", ESIF_DATA_UINT64}, {"fld16", "fld16", ESIF_DATA_UINT64}, - {"fld17", "fld17", ESIF_DATA_UINT64}, {"fld18", "fld18", ESIF_DATA_UINT64}, - {"fld19", "fld19", ESIF_DATA_STRING}, {"fld20", "fld20", ESIF_DATA_STRING}, - {"fld21", "fld21", ESIF_DATA_UINT64}, {"fld22", "fld22", ESIF_DATA_UINT64}, - {"fld23", "fld23", ESIF_DATA_UINT64}, {"fld24", "fld24", ESIF_DATA_UINT64}}}); - - m_tableObjectMap.insert( - {TableObjectType::Pbmt, - {TableObjectType::Pbmt, - fieldsMap, - {{DataVaultType::Override, dataVaultString}, {DataVaultType::Dptf, dataVaultString}}, - {{DataVaultType::Override, dataVaultString}}, - revisionsUsingEsifDataVariant}}); -} - -void DataManager::loadVtmtTableObject() -{ - auto dataVaultString = - DataVaultPathBasePaths::ExportRoot + "/UUID/" + TableObjectType::ToString(TableObjectType::Vtmt); - set revisionsUsingEsifDataVariant = {1}; - UInt32 mode = 4; - map> fieldsMap; - fieldsMap.insert({1, {{"fld1", "fld1", ESIF_DATA_STRING}, {"fld2", "fld2", ESIF_DATA_STRING}, - {"fld3", "fld3", ESIF_DATA_UINT64}, {"fld4", "fld4", ESIF_DATA_UINT64}, - {"fld5", "fld5", ESIF_DATA_UINT64}, {"fld6", "fld6", ESIF_DATA_UINT64}, - {"fld7", "fld7", ESIF_DATA_UINT64}, {"fld8", "fld8", ESIF_DATA_UINT64}, - {"fld9", "fld9", ESIF_DATA_UINT64}, {"fld10", "fld10", ESIF_DATA_UINT64}, - {"fld11", "fld11", ESIF_DATA_UINT64}, {"fld12", "fld12", ESIF_DATA_STRING}, - {"fld13", "fld13", ESIF_DATA_STRING}, {"fld14", "fld14", ESIF_DATA_STRING}, - {"fld15", "fld15", ESIF_DATA_UINT64}, {"fld16", "fld16", ESIF_DATA_UINT64}, - {"fld17", "fld17", ESIF_DATA_UINT64}, {"fld18", "fld18", ESIF_DATA_UINT64}, - {"fld19", "fld19", ESIF_DATA_UINT64}, {"fld20", "fld20", ESIF_DATA_UINT64}, - {"fld21", "fld21", ESIF_DATA_STRING}, {"fld22", "fld22", ESIF_DATA_STRING}, - {"fld23", "fld23", ESIF_DATA_UINT64}, {"fld24", "fld24", ESIF_DATA_UINT64}, - {"fld25", "fld25", ESIF_DATA_UINT64}, {"fld26", "fld26", ESIF_DATA_UINT64}, - {"fld27", "fld27", ESIF_DATA_UINT64}, {"fld28", "fld28", ESIF_DATA_UINT64}, - {"fld29", "fld29", ESIF_DATA_UINT64}}}); - - m_tableObjectMap.insert( - {TableObjectType::Vtmt, - {TableObjectType::Vtmt, - fieldsMap, - {{DataVaultType::Override, dataVaultString}, {DataVaultType::Dptf, dataVaultString}}, - {{DataVaultType::Override, dataVaultString}}, - revisionsUsingEsifDataVariant, - mode}}); -} - -void DataManager::loadPshaTableObject() -{ - auto dataVaultString = - DataVaultPathBasePaths::ExportRoot + "/UUID/" + TableObjectType::ToString(TableObjectType::Psha); - auto noPersistPath = "/nopersist/%nm%/" + TableObjectType::ToString(TableObjectType::Psha); - noPersistPath = StringParser::replaceAll(noPersistPath, "%nm%", DefaultScope::IETMParticipantScope + ".D0"); - set revisionsUsingEsifDataVariant = {1}; - map> fieldsMap; - fieldsMap.insert( - {1, - {{"fld1", "fld1", ESIF_DATA_STRING}, {"fld2", "fld2", ESIF_DATA_UINT64}, {"fld3", "fld3", ESIF_DATA_UINT64}}}); - - m_tableObjectMap.insert( - {TableObjectType::Psha, - {TableObjectType::Psha, - fieldsMap, - {{DataVaultType::Override, noPersistPath}, - {DataVaultType::Override, dataVaultString}, - {DataVaultType::Dptf, dataVaultString}}, - {{DataVaultType::Override, dataVaultString}}, - revisionsUsingEsifDataVariant}}); -} - -void DataManager::loadPsh2TableObject() -{ - auto dataVaultString = - DataVaultPathBasePaths::ExportRoot + "/UUID/" + TableObjectType::ToString(TableObjectType::Psh2); - auto noPersistPath = "/nopersist/%nm%/" + TableObjectType::ToString(TableObjectType::Psh2); - noPersistPath = StringParser::replaceAll(noPersistPath, "%nm%", DefaultScope::IETMParticipantScope + ".D0"); - set revisionsUsingEsifDataVariant = {1}; - map> fieldsMap; - fieldsMap.insert( - {1, - {{"fld1", "fld1", ESIF_DATA_STRING, false, 64}, - {"fld2", "fld2", ESIF_DATA_UINT64, false, 8}, - {"fld3", "fld3", ESIF_DATA_UINT64, false, 8}}}); - - fieldsMap.insert( - {2, - {{"fld1", "fld1", ESIF_DATA_STRING, false, 64}, - {"fld2", "fld2", ESIF_DATA_UINT32, false, 4}, - {"fld3", "fld3", ESIF_DATA_UINT32, false, 4}, - {"fld4", "fld4", ESIF_DATA_UINT32, false, 4}, - {"fld5", "fld5", ESIF_DATA_UINT32, false, 4}, - {"fld6", "fld6", ESIF_DATA_UINT32, false, 4}, - {"fld7", "fld7", ESIF_DATA_UINT32, false, 4}}}); - - m_tableObjectMap.insert( - {TableObjectType::Psh2, - {TableObjectType::Psh2, - fieldsMap, - {{DataVaultType::Override, noPersistPath}, - {DataVaultType::Override, dataVaultString}, - {DataVaultType::Dptf, dataVaultString}}, - {{DataVaultType::Override, dataVaultString}}, - revisionsUsingEsifDataVariant, - 0, - (esif_primitive_type_t)0, - false}}); -} - - -void DataManager::loadTrtTableObject() -{ - auto dataVaultString = "/participants/%nm%/UUID/" + TableObjectType::ToString(TableObjectType::Trt); - dataVaultString = StringParser::replaceAll(dataVaultString, "%nm%", DefaultScope::IETMParticipantScope + ".D0"); - auto noPersistPath = "/nopersist/%nm%/" + TableObjectType::ToString(TableObjectType::Trt); - noPersistPath = StringParser::replaceAll(noPersistPath, "%nm%", DefaultScope::IETMParticipantScope + ".D0"); - set revisionsUsingEsifDataVariant = {0}; - map> fieldsMap; - fieldsMap.insert( - {0, - {{"fld1", "fld1", ESIF_DATA_STRING}, - {"fld2", "fld2", ESIF_DATA_STRING}, - {"fld3", "fld3", ESIF_DATA_UINT64}, - {"fld4", "fld4", ESIF_DATA_UINT64}, - {"fld5", "fld5", ESIF_DATA_UINT64}, - {"fld6", "fld6", ESIF_DATA_UINT64}, - {"fld7", "fld7", ESIF_DATA_UINT64}, - {"fld8", "fld8", ESIF_DATA_UINT64}}}); - - m_tableObjectMap.insert( - {TableObjectType::Trt, - {TableObjectType::Trt, - fieldsMap, - {{DataVaultType::Override, noPersistPath}, - {DataVaultType::Override, dataVaultString}, - {DataVaultType::Dptf, dataVaultString}}, - {{DataVaultType::Override, dataVaultString}}, - revisionsUsingEsifDataVariant, - 0, - GET_THERMAL_RELATIONSHIP_TABLE, - false}}); -} - -void DataManager::loadOdvpTableObject() -{ - auto dataVaultString = "/participants/%nm%/UUID/" + TableObjectType::ToString(TableObjectType::Odvp); - dataVaultString = StringParser::replaceAll(dataVaultString, "%nm%", DefaultScope::IETMParticipantScope + ".D0"); - set revisionsUsingEsifDataVariant = {0}; - map> fieldsMap; - fieldsMap.insert({0, {{"field", "field", ESIF_DATA_UINT64}}}); - - m_tableObjectMap.insert( - {TableObjectType::Odvp, - {TableObjectType::Odvp, - fieldsMap, - {{DataVaultType::Override, dataVaultString}}, - {{DataVaultType::Override, dataVaultString}}, - revisionsUsingEsifDataVariant, - 0, - GET_OEM_VARS, - false}}); -} - -void DataManager::loadPidaTableObject() -{ - auto dataVaultString = - DataVaultPathBasePaths::ExportRoot + "/UUID/" + TableObjectType::ToString(TableObjectType::Pida); - auto noPersistPath = "/nopersist/%nm%/" + TableObjectType::ToString(TableObjectType::Pida); - noPersistPath = StringParser::replaceAll(noPersistPath, "%nm%", DefaultScope::IETMParticipantScope + ".D0"); - set revisionsUsingEsifDataVariant = {2}; - map> fieldsMap; - fieldsMap.insert( - {2, - {{"fld1", "fld1", ESIF_DATA_STRING}, - {"fld2", "fld2", ESIF_DATA_UINT64}, - {"fld3", "fld3", ESIF_DATA_UINT64}, - {"fld4", "fld4", ESIF_DATA_STRING}, - {"fld5", "fld5", ESIF_DATA_UINT64}, - {"fld6", "fld6", ESIF_DATA_UINT64}, - {"fld7", "fld7", ESIF_DATA_UINT64}, - {"fld8", "fld8", ESIF_DATA_UINT64}, - {"fld9", "fld9", ESIF_DATA_UINT64}, - {"fld10", "fld10", ESIF_DATA_UINT64}, - {"fld11", "fld11", ESIF_DATA_UINT64}, - {"fld12", "fld12", ESIF_DATA_UINT64}}}); - - m_tableObjectMap.insert( - {TableObjectType::Pida, - {TableObjectType::Pida, - fieldsMap, - {{DataVaultType::Override, noPersistPath}, - {DataVaultType::Override, dataVaultString}, - {DataVaultType::Dptf, dataVaultString}}, - {{DataVaultType::Override, dataVaultString}}, - revisionsUsingEsifDataVariant}}); -} - -void DataManager::loadArtTableObject() -{ - auto dataVaultString = "/participants/%nm%/UUID/" + TableObjectType::ToString(TableObjectType::Art); - dataVaultString = StringParser::replaceAll(dataVaultString, "%nm%", DefaultScope::IETMParticipantScope + ".D0"); - auto noPersistPath = "/nopersist/%nm%/" + TableObjectType::ToString(TableObjectType::Art); - noPersistPath = StringParser::replaceAll(noPersistPath, "%nm%", DefaultScope::IETMParticipantScope + ".D0"); - set revisionsUsingEsifDataVariant = {1}; - map> fieldsMap; - fieldsMap.insert( - {1, - {{"fld1", "fld1", ESIF_DATA_STRING}, - {"fld2", "fld2", ESIF_DATA_STRING}, - {"fld3", "fld3", ESIF_DATA_UINT64}, - {"fld4", "fld4", ESIF_DATA_UINT64}, - {"fld5", "fld5", ESIF_DATA_UINT64}, - {"fld6", "fld6", ESIF_DATA_UINT64}, - {"fld7", "fld7", ESIF_DATA_UINT64}, - {"fld8", "fld8", ESIF_DATA_UINT64}, - {"fld9", "fld9", ESIF_DATA_UINT64}, - {"fld10", "fld10", ESIF_DATA_UINT64}, - {"fld11", "fld11", ESIF_DATA_UINT64}, - {"fld12", "fld12", ESIF_DATA_UINT64}, - {"fld13", "fld13", ESIF_DATA_UINT64}}}); - - m_tableObjectMap.insert( - {TableObjectType::Art, - {TableObjectType::Art, - fieldsMap, - {{DataVaultType::Override, noPersistPath}, - {DataVaultType::Override, dataVaultString}, - {DataVaultType::Dptf, dataVaultString}}, - {{DataVaultType::Override, dataVaultString}}, - revisionsUsingEsifDataVariant, - 0, - GET_ACTIVE_RELATIONSHIP_TABLE, - false}}); -} \ No newline at end of file diff --git a/DPTF/Sources/Manager/DataManager.h b/DPTF/Sources/Manager/DataManager.h index cc3a4a56..6bf106b7 100644 --- a/DPTF/Sources/Manager/DataManager.h +++ b/DPTF/Sources/Manager/DataManager.h @@ -27,32 +27,25 @@ class dptf_export DataManagerInterface { public: virtual ~DataManagerInterface(){}; - virtual TableObject getTableObject( - TableObjectType::Type tableType, - std::string uuid, - UIntN participantIndex = Constants::Esif::NoParticipant) = 0; + virtual TableObject getTableObject(TableObjectType::Type tableType, std::string uuid) = 0; virtual void setTableObject( - const DptfBuffer& tableData, - TableObjectType::Type tableType, - std::string uuid, - UIntN participantIndex = Constants::Esif::NoParticipant) = 0; - virtual void deleteTableObject( - TableObjectType::Type tableType, - std::string uuid, - UIntN participantIndex = Constants::Esif::NoParticipant) = 0; - virtual void deleteAllTableObject( + UInt32 tableDataLength, + UInt8* tableData, TableObjectType::Type tableType, - std::string uuid, - UIntN participantIndex = Constants::Esif::NoParticipant) = 0; + std::string uuid) = 0; + virtual void deleteTableObject(TableObjectType::Type tableType, std::string uuid) = 0; + virtual void deleteAllTableObject(TableObjectType::Type tableType, std::string uuid) = 0; virtual Bool tableObjectExists(TableObjectType::Type tableType) = 0; virtual std::map getTableObjectMap() = 0; + virtual UInt32 getLatestSupportedTableRevision(TableObjectType::Type) = 0; virtual TableObject getTableObjectBasedOnAlternativeDataSourceAndKey( TableObjectType::Type tableType, DataVaultType::Type dvType, std::string key) = 0; virtual void setTableObjectBasedOnAlternativeDataSourceAndKey( - const DptfBuffer& tableData, + UInt32 tableDataLength, + UInt8* tableData, TableObjectType::Type tableType, DataVaultType::Type dvType, std::string key) = 0; @@ -61,8 +54,6 @@ class dptf_export DataManagerInterface virtual void deleteTableObjectKeyForNoPersist(TableObjectType::Type tableType) = 0; virtual void deleteConfigKey(DataVaultType::Type dvType, std::string key) = 0; - - virtual Bool isParticipantTable(TableObjectType::Type tableType) = 0; }; class DataManager : public DataManagerInterface @@ -71,24 +62,25 @@ class DataManager : public DataManagerInterface DataManager(DptfManagerInterface* dptfManager); ~DataManager(void); - virtual TableObject getTableObject(TableObjectType::Type tableType, std::string uuid, UIntN participantIndex) - override; + virtual TableObject getTableObject(TableObjectType::Type tableType, std::string uuid) override; virtual void setTableObject( - const DptfBuffer& tableData, + UInt32 tableDataLength, + UInt8* tableData, TableObjectType::Type tableType, - std::string uuid, - UIntN participantIndex) override; - virtual void deleteTableObject(TableObjectType::Type tableType, std::string, UIntN participantIndex) override; - virtual void deleteAllTableObject(TableObjectType::Type tableType, std::string, UIntN participantIndex) override; + std::string uuid) override; + virtual void deleteTableObject(TableObjectType::Type tableType, std::string) override; + virtual void deleteAllTableObject(TableObjectType::Type tableType, std::string) override; virtual Bool tableObjectExists(TableObjectType::Type tableType) override; virtual std::map getTableObjectMap() override; + virtual UInt32 getLatestSupportedTableRevision(TableObjectType::Type tableType) override; virtual TableObject getTableObjectBasedOnAlternativeDataSourceAndKey( TableObjectType::Type tableType, DataVaultType::Type dvType, std::string key) override; virtual void setTableObjectBasedOnAlternativeDataSourceAndKey( - const DptfBuffer& tableData, + UInt32 tableDataLength, + UInt8* tableData, TableObjectType::Type tableType, DataVaultType::Type dvType, std::string key) override; @@ -98,34 +90,12 @@ class DataManager : public DataManagerInterface virtual void deleteConfigKey(DataVaultType::Type dvType, std::string key) override; - virtual Bool isParticipantTable(TableObjectType::Type tableType) override; - private: DptfManagerInterface* m_dptfManager; std::map m_tableObjectMap; + std::map m_tableRevisions; - void sendTableChangedEvent(TableObjectType::Type tableObjectType, std::string uuid, UIntN participantIndex); + void sendTableChangedEvent(TableObjectType::Type tableObjectType, std::string uuid); + void loadTableRevisions(); void loadTableObjectMap(); - void loadAcprTableObject(); - void loadApatTableObject(); - void loadApctTableObject(); - void loadArtTableObject(); - void loadDynamicIdspTableObject(); - void loadDdrfTableObject(); - void loadEpotTableObject(); - void loadItmtTableObject(); - void loadOdvpTableObject(); - void loadPbatTableObject(); - void loadPbctTableObject(); - void loadPbmtTableObject(); - void loadPidaTableObject(); - void loadPsh2TableObject(); - void loadPshaTableObject(); - void loadPsvtTableObject(); - void loadSwOemVariablesTableObject(); - void loadTpgaTableObject(); - void loadTrtTableObject(); - void loadVsctTableObject(); - void loadVsptTableObject(); - void loadVtmtTableObject(); }; diff --git a/DPTF/Sources/Manager/DiagParticipant.cpp b/DPTF/Sources/Manager/DiagParticipant.cpp index ab70038f..c087bd79 100644 --- a/DPTF/Sources/Manager/DiagParticipant.cpp +++ b/DPTF/Sources/Manager/DiagParticipant.cpp @@ -117,7 +117,7 @@ void DiagParticipantCommand::throwIfReportNameIsInvalid(const CommandArguments& } auto reportName = arguments[2].getDataAsString(); - if (IFileIO::fileNameContainsIllegalCharacters(reportName)) + if (IFileIO::fileNameHasIllegalChars(reportName)) { string description = string("Invalid characters used in report name given."); setResultMessage(description); diff --git a/DPTF/Sources/Manager/DiagPolicy.cpp b/DPTF/Sources/Manager/DiagPolicy.cpp index 244e01b5..a9c70290 100644 --- a/DPTF/Sources/Manager/DiagPolicy.cpp +++ b/DPTF/Sources/Manager/DiagPolicy.cpp @@ -125,7 +125,7 @@ void DiagPolicyCommand::throwIfReportNameIsInvalid(const CommandArguments& argum } auto reportName = arguments[2].getDataAsString(); - if (IFileIO::fileNameContainsIllegalCharacters(reportName)) + if (IFileIO::fileNameHasIllegalChars(reportName)) { string description = string("Invalid characters used in report name given to 'diag policy' command."); setResultMessage(description); diff --git a/DPTF/Sources/Manager/Domain.cpp b/DPTF/Sources/Manager/Domain.cpp index 07db5b99..4aca07c9 100644 --- a/DPTF/Sources/Manager/Domain.cpp +++ b/DPTF/Sources/Manager/Domain.cpp @@ -19,10 +19,7 @@ #include "Domain.h" #include "EsifDataString.h" #include "EsifDataGuid.h" -#include "PolicyServicesInterfaceContainer.h" -#include "EsifServicesInterface.h" -#include "PolicyManagerInterface.h" -#include "ParticipantManagerInterface.h" +#include "DptfStatusInterface.h" Domain::Domain(DptfManagerInterface* dptfManager) : m_domainCreated(false) @@ -100,6 +97,7 @@ void Domain::createDomain( m_domainFunctionalityVersions = DomainFunctionalityVersions(domainDataPtr->fCapabilityBytes); m_arbitrator = new Arbitrator(); + m_dptfManager->getDptfStatus()->clearCache(); m_theRealParticipant->createDomain( m_domainGuid, m_participantIndex, @@ -124,6 +122,7 @@ void Domain::destroyDomain(void) { try { + m_dptfManager->getDptfStatus()->clearCache(); m_theRealParticipant->destroyDomain(m_domainGuid); } catch (...) @@ -165,6 +164,7 @@ std::string Domain::getDomainName(void) const void Domain::clearDomainCachedData(void) { + m_dptfManager->getDptfStatus()->clearCache(); clearDomainCachedDataCoreControl(); clearDomainCachedDataDisplayControl(); clearDomainCachedDataPerformanceControl(); @@ -570,12 +570,6 @@ void Domain::setPerformanceControl(UIntN policyIndex, UIntN performanceControlIn if (shouldSetPerformanceControlIndex) { m_theRealParticipant->setPerformanceControl(m_participantIndex, m_domainIndex, newIndex); - const auto policyName = m_dptfManager->getPolicyManager()->getPolicyPtr(policyIndex)->getName(); - const auto participantName = m_theRealParticipant->getName(); - m_dptfManager->getEsifServices()->writeMessageDebug( - " Policy : " + std::string(policyName) - + " -- Participant : " + std::string(participantName) - + " -- Control PerformanceControl : " + std::to_string(performanceControlIndex)); clearDomainCachedDataPerformanceControl(); } performanceControlArbitrator->commitPolicyRequest(policyIndex, performanceControlIndex); @@ -717,12 +711,6 @@ void Domain::setPowerLimit(UIntN policyIndex, PowerControlType::Type controlType if (shouldSetPowerLimit) { m_theRealParticipant->setPowerLimit(m_participantIndex, m_domainIndex, controlType, newPowerLimit); - const auto policyName = m_dptfManager->getPolicyManager()->getPolicyPtr(policyIndex)->getName(); - const auto participantName = m_theRealParticipant->getName(); - m_dptfManager->getEsifServices()->writeMessageDebug( - " Policy : " + std::string(policyName) + " -- Participant : " - + std::string(participantName) + " -- ControlType : " + std::to_string(controlType) - + " -- Request new Power Limit : " + std::to_string(newPowerLimit)); clearDomainCachedDataPowerControl(); } powerControlArbitrator->commitPolicyRequest(policyIndex, controlType, powerLimit); diff --git a/DPTF/Sources/Manager/DptfManager.cpp b/DPTF/Sources/Manager/DptfManager.cpp index 40dc16a2..4c79f8e9 100644 --- a/DPTF/Sources/Manager/DptfManager.cpp +++ b/DPTF/Sources/Manager/DptfManager.cpp @@ -24,6 +24,7 @@ #include "UniqueIdGenerator.h" #include "IndexContainer.h" #include "esif_sdk_iface_app.h" +#include "DptfStatus.h" #include "EsifDataString.h" #include "EsifAppServices.h" #include "StringParser.h" @@ -31,6 +32,7 @@ #include "HelpCommand.h" #include "DiagCommand.h" #include "ReloadCommand.h" +#include "StatusCommand.h" #include "TableObjectCommand.h" #include "ConfigCommand.h" #include "ManagerLogger.h" @@ -38,8 +40,6 @@ #include "EsifLibrary.h" #include "DataManager.h" #include "SystemModeManager.h" -#include "UiCommand.h" -#include "CaptureCommand.h" DptfManager::DptfManager(void) : m_dptfManagerCreateStarted(false) @@ -55,6 +55,7 @@ DptfManager::DptfManager(void) , m_commandDispatcher(nullptr) , m_commands() , m_fileIo(nullptr) + , m_dptfStatus(nullptr) , m_indexContainer(nullptr) , m_dataManager(nullptr) , m_systemModeManager(nullptr) @@ -119,6 +120,8 @@ void DptfManager::createDptfManager( m_participantManager = new ParticipantManager(this); m_commandDispatcher = new CommandDispatcher(); m_fileIo = std::make_shared(); + createCommands(); + registerCommands(); m_dataManager = new DataManager(this); @@ -133,14 +136,13 @@ void DptfManager::createDptfManager( m_requestDispatcher = std::make_shared(); m_platformRequestHandler = std::make_shared(this); + m_dptfStatus = new DptfStatus(this); + m_policyManager->createAllPolicies(m_dptfPolicyDirectoryPath); registerDptfFrameworkEvents(); m_systemModeManager->registerFrameworkEvents(); - createCommands(); - registerCommands(); - m_dptfManagerCreateFinished = true; m_esifServices->sendDptfEvent(FrameworkEvent::DptfAppLoaded, Constants::Invalid, Constants::Invalid, eventData); @@ -211,6 +213,11 @@ ICommandDispatcher* DptfManager::getCommandDispatcher() const return m_commandDispatcher; } +DptfStatusInterface* DptfManager::getDptfStatus(void) +{ + return m_dptfStatus; +} + IndexContainerInterface* DptfManager::getIndexContainer(void) const { return m_indexContainer; @@ -262,6 +269,7 @@ void DptfManager::shutDown(void) deleteIndexContainer(); destroyUniqueIdGenerator(); destroyFrameworkEventInfo(); + deleteDptfStatus(); DELETE_MEMORY_TC(m_commandDispatcher); DELETE_MEMORY_TC(m_dataManager); } @@ -315,6 +323,11 @@ void DptfManager::destroyAllParticipants(void) } } +void DptfManager::deleteDptfStatus() +{ + DELETE_MEMORY_TC(m_dptfStatus); +} + void DptfManager::deleteWorkItemQueueManager(void) { DELETE_MEMORY_TC(m_workItemQueueManager); @@ -548,10 +561,9 @@ void DptfManager::createCommands() m_commands.push_back(std::make_shared(this)); m_commands.push_back(std::make_shared(this, m_fileIo)); m_commands.push_back(std::make_shared(this)); + m_commands.push_back(std::make_shared(this)); m_commands.push_back(std::make_shared(this)); m_commands.push_back(std::make_shared(this)); - m_commands.push_back(std::make_shared(this)); - m_commands.push_back(std::make_shared(this, m_fileIo)); } std::shared_ptr DptfManager::getEventCache(void) const diff --git a/DPTF/Sources/Manager/DptfManager.h b/DPTF/Sources/Manager/DptfManager.h index cdf467b8..e4a40790 100644 --- a/DPTF/Sources/Manager/DptfManager.h +++ b/DPTF/Sources/Manager/DptfManager.h @@ -29,6 +29,7 @@ class EsifServicesInterface; class WorkItemQueueManagerInterface; class PolicyManagerInterface; class ParticipantManagerInterface; +class DptfStatusInterface; class DataManagerInterface; class SystemModeManagerInterface; @@ -64,6 +65,7 @@ class DptfManager : public DptfManagerInterface virtual PolicyManagerInterface* getPolicyManager(void) const override; virtual ParticipantManagerInterface* getParticipantManager(void) const override; virtual ICommandDispatcher* getCommandDispatcher() const override; + virtual DptfStatusInterface* getDptfStatus(void) override; virtual IndexContainerInterface* getIndexContainer(void) const override; virtual DataManagerInterface* getDataManager(void) const override; virtual std::shared_ptr getRequestDispatcher() const override; @@ -119,6 +121,9 @@ class DptfManager : public DptfManagerInterface std::shared_ptr m_eventCache; std::shared_ptr m_userPreferredCache; + // Creates XML needed for requests from the UI + DptfStatusInterface* m_dptfStatus; + IndexContainerInterface* m_indexContainer; DataManagerInterface* m_dataManager; @@ -131,6 +136,7 @@ class DptfManager : public DptfManagerInterface void shutDown(void); void disableAndEmptyAllQueues(void); + void deleteDptfStatus(void); void destroyAllPolicies(void); void destroyAllParticipants(void); void deleteWorkItemQueueManager(void); diff --git a/DPTF/Sources/Manager/DptfManagerInterface.h b/DPTF/Sources/Manager/DptfManagerInterface.h index 2a1fe4b8..8905d708 100644 --- a/DPTF/Sources/Manager/DptfManagerInterface.h +++ b/DPTF/Sources/Manager/DptfManagerInterface.h @@ -32,6 +32,7 @@ class EsifServicesInterface; class WorkItemQueueManagerInterface; class PolicyManagerInterface; class ParticipantManagerInterface; +class DptfStatusInterface; class DataManagerInterface; class SystemModeManagerInterface; @@ -56,6 +57,7 @@ class DptfManagerInterface virtual PolicyManagerInterface* getPolicyManager(void) const = 0; virtual ParticipantManagerInterface* getParticipantManager(void) const = 0; virtual ICommandDispatcher* getCommandDispatcher() const = 0; + virtual DptfStatusInterface* getDptfStatus(void) = 0; virtual IndexContainerInterface* getIndexContainer(void) const = 0; virtual DataManagerInterface* getDataManager(void) const = 0; virtual std::string getDptfHomeDirectoryPath(void) const = 0; diff --git a/DPTF/Sources/Manager/DptfStatus.cpp b/DPTF/Sources/Manager/DptfStatus.cpp new file mode 100644 index 00000000..4e5f56d7 --- /dev/null +++ b/DPTF/Sources/Manager/DptfStatus.cpp @@ -0,0 +1,675 @@ +/****************************************************************************** +** Copyright (c) 2013-2022 Intel Corporation All Rights Reserved +** +** Licensed under the Apache License, Version 2.0 (the "License"); you may not +** use this file except in compliance with the License. +** +** You may obtain a copy of the License at +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +** WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** +** See the License for the specific language governing permissions and +** limitations under the License. +** +******************************************************************************/ + +#include "DptfStatus.h" +#include "Indent.h" +#include "esif_sdk_iface_app.h" +#include "Participant.h" +#include "Policy.h" +#include +#include "PolicyManagerInterface.h" +#include "ParticipantManagerInterface.h" +#include "WorkItemQueueManagerInterface.h" +#include "BinaryParse.h" +#include "XmlNode.h" +#include "ParticipantStatusMap.h" +#include "EsifDataString.h" +#include +#include "PlatformRequestHandler.h" + +// clang-format off +const Guid ManagerPolicyStatusFormatId(0x3E, 0x58, 0x63, 0x46, 0xF8, 0xF7, 0x45, 0x4A, 0xA8, 0xF7, 0xDE, 0x7E, 0xC6, 0xF7, 0x61, 0xA8); +const Guid ManagerParticipantStatusFormatId(0x98, 0x3F, 0x90, 0x5D, 0x9E, 0x39, 0x93, 0x4D, 0xBC, 0xCD, 0xA1, 0xA5, 0x8F, 0x61, 0x18, 0x5F); +// clang-format on + +DptfStatus::DptfStatus(DptfManagerInterface* dptfManager) + : m_dptfManager(dptfManager) +{ + m_policyManager = m_dptfManager->getPolicyManager(); + m_participantManager = m_dptfManager->getParticipantManager(); + m_participantStatusMap = new ParticipantStatusMap(m_participantManager); +} + +DptfStatus::~DptfStatus() +{ + DELETE_MEMORY_TC(m_participantStatusMap); +} + +namespace GroupType +{ + enum Type + { + Policies = 0, + Participants = 1, + Framework = 2, + Arbitrator = 3, + System = 4 + }; +} + +namespace ManagerModuleType +{ + enum Type + { + Events = 0, + Participants = 1, + Policies = 2, + Statistics = 3 + }; + + std::string ToString(ManagerModuleType::Type type) + { + switch (type) + { + case Events: + return "Event Status"; + case Participants: + return "Participant Status"; + case Policies: + return "Policy Status"; + case Statistics: + return "Work Item Statistics"; + default: + return Constants::InvalidString; + } + } +} + +namespace SystemModuleType +{ + enum Type + { + SystemConfiguration = 0 + }; + + std::string ToString(SystemModuleType::Type type) + { + switch (type) + { + case SystemConfiguration: + // it is important that this name matches the name in the "policy" cpp file + return "System Configuration"; + default: + return Constants::InvalidString; + } + } +} + +std::pair DptfStatus::getStatus(const eAppStatusCommand command, const UInt32 appStatusIn) +{ + std::string response; + std::pair statusResult; + eEsifError returnCode = ESIF_OK; + + switch (command) + { + case eAppStatusCommandGetXSLT: + returnCode = ESIF_E_NOT_IMPLEMENTED; + break; + case eAppStatusCommandGetGroups: + response = getGroupsXml(&returnCode); + break; + case eAppStatusCommandGetModulesInGroup: + response = getModulesInGroup(appStatusIn, &returnCode); + break; + case eAppStatusCommandGetModuleData: + response = getModuleData(appStatusIn, &returnCode); + break; + default: + returnCode = ESIF_E_UNSPECIFIED; + throw dptf_exception("Received invalid command status code."); + } + + statusResult.first = response; + statusResult.second = returnCode; + + return statusResult; +} + +void DptfStatus::clearCache() +{ + m_participantStatusMap->clearCachedData(); +} + +void DptfStatus::checkAndDropSymLink(std::string fileName) +{ + EsifLibrary* esifLibrary; + esifLibrary = new EsifLibrary(fileName); + if (esifLibrary == nullptr) + { + throw dptf_exception("Failed to allocate memory."); + } + + try + { + // Check if file is a symlink and remove it if it is + esifLibrary->dropSymLink(); + DELETE_MEMORY_TC(esifLibrary); + } + catch (dptf_exception& ex) + { + DELETE_MEMORY_TC(esifLibrary); + throw dptf_exception(ex.getDescription()); + } +} + +std::string DptfStatus::getGroupsXml(eEsifError* returnCode) +{ + auto groups = XmlNode::createWrapperElement("groups"); + + auto group0 = XmlNode::createWrapperElement("group"); + groups->addChild(group0); + group0->addChild(XmlNode::createDataElement("id", "0")); + group0->addChild(XmlNode::createDataElement("name", "Policies")); + + auto group1 = XmlNode::createWrapperElement("group"); + groups->addChild(group1); + group1->addChild(XmlNode::createDataElement("id", "1")); + group1->addChild(XmlNode::createDataElement("name", "Participants")); + + auto group2 = XmlNode::createWrapperElement("group"); + groups->addChild(group2); + group2->addChild(XmlNode::createDataElement("id", "2")); + group2->addChild(XmlNode::createDataElement("name", "Manager")); + + auto group3 = XmlNode::createWrapperElement("group"); + groups->addChild(group3); + group3->addChild(XmlNode::createDataElement("id", "3")); + group3->addChild(XmlNode::createDataElement("name", "Arbitrator")); + + auto group4 = XmlNode::createWrapperElement("group"); + groups->addChild(group4); + group4->addChild(XmlNode::createDataElement("id", "4")); + group4->addChild(XmlNode::createDataElement("name", "System")); + + std::string s = groups->toString(); + + return s; +} + +std::string DptfStatus::getModulesInGroup(const UInt32 appStatusIn, eEsifError* returnCode) +{ + std::string modulesInGroup; + + switch (appStatusIn) + { + case GroupType::Policies: + modulesInGroup = getPoliciesGroup(); + break; + case GroupType::Participants: + modulesInGroup = getParticipantsGroup(); + break; + case GroupType::Framework: + modulesInGroup = getFrameworkGroup(); + break; + case GroupType::Arbitrator: + modulesInGroup = getArbitratorGroup(); + break; + case GroupType::System: + modulesInGroup = getSystemGroup(); + break; + default: + *returnCode = ESIF_E_UNSPECIFIED; + throw dptf_exception("Invalid group ID specified."); + } + return modulesInGroup; +} + +std::string DptfStatus::getPoliciesGroup() +{ + auto modules = XmlNode::createWrapperElement("modules"); + + auto policyIndexes = m_policyManager->getPolicyIndexes(); + for (auto policyIndex = policyIndexes.begin(); policyIndex != policyIndexes.end(); ++policyIndex) + { + try + { + // Get the policy variables before adding nodes. This forces + // exceptions to be thrown first. + auto policy = m_policyManager->getPolicyPtr(*policyIndex); + std::string name = policy->getName(); + + auto module = XmlNode::createWrapperElement("module"); + modules->addChild(module); + + auto policyId = XmlNode::createDataElement("id", std::to_string(*policyIndex)); + module->addChild(policyId); + + auto policyName = XmlNode::createDataElement("name", name); + module->addChild(policyName); + } + catch (...) + { + // policy not available, don't add it to the list + } + } + + std::string s = modules->toString(); + + return s; +} + +std::string DptfStatus::getParticipantsGroup() +{ + return m_participantStatusMap->getGroupsString(); +} + +std::string DptfStatus::getFrameworkGroup() +{ + auto modules = XmlNode::createWrapperElement("modules"); + + for (UIntN moduleType = 0; moduleType < (UIntN)ManagerModuleType::Statistics; ++moduleType) + { + auto module = XmlNode::createWrapperElement("module"); + modules->addChild(module); + + auto moduleId = XmlNode::createDataElement("id", std::to_string(moduleType)); + module->addChild(moduleId); + + auto moduleName = + XmlNode::createDataElement("name", ManagerModuleType::ToString((ManagerModuleType::Type)moduleType)); + module->addChild(moduleName); + } + +#ifdef INCLUDE_WORK_ITEM_STATISTICS + + // Work Item Statistics + + module = XmlNode::createWrapperElement("module"); + modules->addChild(module); + + moduleId = XmlNode::createDataElement("id", std::to_string(ManagerModuleType::Statistics)); + module->addChild(moduleId); + + moduleName = XmlNode::createDataElement("name", ManagerModuleType::ToString(ManagerModuleType::Statistics)); + module->addChild(moduleName); + +#endif + + std::string s = modules->toString(); + + return s; +} + +std::string DptfStatus::getArbitratorGroup() +{ + auto modules = XmlNode::createWrapperElement("modules"); + + // in alphabetical order + modules->addChild(getArbitratorModuleInGroup(ControlFactoryType::Active)); + modules->addChild(getArbitratorModuleInGroup(ControlFactoryType::Core)); + modules->addChild(getArbitratorModuleInGroup(ControlFactoryType::Display)); + modules->addChild(getArbitratorModuleInGroup(ControlFactoryType::PeakPowerControl)); + modules->addChild(getArbitratorModuleInGroup(ControlFactoryType::Performance)); + modules->addChild(getArbitratorModuleInGroup(ControlFactoryType::PowerControl)); + modules->addChild(getArbitratorModuleInGroup(ControlFactoryType::ProcessorControl)); + modules->addChild(getArbitratorModuleInGroup(ControlFactoryType::SystemPower)); + modules->addChild(getArbitratorModuleInGroup(ControlFactoryType::Temperature)); + + std::string s = modules->toString(); + + return s; +} + +std::string DptfStatus::getSystemGroup() +{ + auto modules = XmlNode::createWrapperElement("modules"); + auto module = XmlNode::createWrapperElement("module"); + modules->addChild(module); + + auto moduleId = XmlNode::createDataElement("id", std::to_string((UIntN)SystemModuleType::SystemConfiguration)); + module->addChild(moduleId); + + auto moduleName = + XmlNode::createDataElement("name", SystemModuleType::ToString(SystemModuleType::SystemConfiguration)); + module->addChild(moduleName); + + return modules->toString(); +} + +std::shared_ptr DptfStatus::getArbitratorModuleInGroup(ControlFactoryType::Type type) +{ + auto module = XmlNode::createWrapperElement("module"); + auto moduleId = XmlNode::createDataElement("id", std::to_string(type)); + module->addChild(moduleId); + + auto moduleName = + XmlNode::createDataElement("name", ControlFactoryType::getArbitratorString((ControlFactoryType::Type)type)); + module->addChild(moduleName); + return module; +} + +std::string DptfStatus::getModuleData(const UInt32 appStatusIn, eEsifError* returnCode) +{ + std::string moduleData; + + UInt32 groupId = static_cast(BinaryParse::extractBits(32, 16, appStatusIn)); + UInt32 moduleId = static_cast(BinaryParse::extractBits(15, 0, appStatusIn)); + + switch (groupId) + { + case GroupType::Policies: + moduleData = getXmlForPolicy(moduleId, returnCode); + break; + case GroupType::Participants: + moduleData = getXmlForParticipant(moduleId, returnCode); + break; + case GroupType::Framework: + moduleData = getXmlForFramework(moduleId, returnCode); + break; + case GroupType::Arbitrator: + moduleData = getXmlForArbitrator(moduleId, returnCode); + break; + case GroupType::System: + moduleData = getXmlForSystem(moduleId, returnCode); + break; + default: + *returnCode = ESIF_E_UNSPECIFIED; + throw dptf_exception("Invalid group ID specified."); + } + return moduleData; +} + +std::string DptfStatus::getXmlForPolicy(UInt32 policyIndex, eEsifError* returnCode) +{ + try + { + auto policy = m_policyManager->getPolicyPtr(policyIndex); + + // SystemConfiguration has its own getXml function, and does not go through this + if (policy->getName() == SystemModuleType::ToString(SystemModuleType::SystemConfiguration)) + { + throw policy_index_invalid(); + } + + return policy->getStatusAsXml(); + } + catch (policy_index_invalid&) + { + *returnCode = ESIF_E_UNSPECIFIED; + throw dptf_exception("Invalid policy status requested."); + } + catch (...) + { + *returnCode = ESIF_E_UNSPECIFIED; + throw; + } +} + +std::string DptfStatus::getXmlForParticipant(UInt32 mappedIndex, eEsifError* returnCode) +{ + auto participantIndexList = m_participantManager->getParticipantIndexes(); + UIntN totalDomainCount = 0; + + // Total # of participants + domains for error checking + for (auto i = participantIndexList.begin(); i != participantIndexList.end(); ++i) + { + try + { + Participant* participant = m_participantManager->getParticipantPtr(*i); + totalDomainCount += participant->getDomainCount(); + } + catch (...) + { + // If participant pointer couldn't be returned or couldn't get domain count + // Most likely, a participant was removed and left bind a null pointer + } + } + + if (mappedIndex >= totalDomainCount) + { + *returnCode = ESIF_E_UNSPECIFIED; + throw dptf_exception("Invalid participant status requested."); + } + + try + { + auto participantData = m_participantStatusMap->getStatusAsXml(mappedIndex); + std::string s = participantData->toString(); + + return s; + } + catch (...) + { + *returnCode = ESIF_E_UNSPECIFIED; + throw; + } +} + +std::string DptfStatus::getXmlForFramework(UInt32 moduleIndex, eEsifError* returnCode) +{ + switch (moduleIndex) + { + case ManagerModuleType::Policies: + { + *returnCode = ESIF_OK; + + auto managerPolicyRoot = XmlNode::createRoot(); + managerPolicyRoot->addChild(XmlNode::createComment("format_id=" + ManagerPolicyStatusFormatId.toString())); + auto policyStatus = XmlNode::createWrapperElement("manager_policy_status"); + policyStatus->addChild(getXmlForFrameworkLoadedPolicies()); + policyStatus->addChild(getXmlForPlatformRequests()); + managerPolicyRoot->addChild(policyStatus); + return managerPolicyRoot->toString(); + } + case ManagerModuleType::Participants: + { + *returnCode = ESIF_OK; + auto managerParticipantRoot = XmlNode::createRoot(); + managerParticipantRoot->addChild(XmlNode::createComment("format_id=" + ManagerParticipantStatusFormatId.toString())); + auto participantStatus = XmlNode::createWrapperElement("manager_participant_status"); + participantStatus->addChild(getXmlForFrameworkLoadedParticipants()); + managerParticipantRoot->addChild(participantStatus); + return managerParticipantRoot->toString(); + } + case ManagerModuleType::Events: + { + *returnCode = ESIF_OK; + auto frameworkRoot = m_policyManager->getStatusAsXml(); + return frameworkRoot->toString(); + } + case ManagerModuleType::Statistics: + { + *returnCode = ESIF_OK; + auto frameworkRoot = m_dptfManager->getWorkItemQueueManager()->getStatusAsXml(); + return frameworkRoot->toString(); + } + default: + *returnCode = ESIF_E_UNSPECIFIED; + return std::string(); + } +} + +std::string DptfStatus::getXmlForArbitrator(UInt32 moduleIndex, eEsifError* returnCode) +{ + *returnCode = ESIF_OK; + auto frameworkRoot = getArbitratorXmlForLoadedParticipants(moduleIndex); + return frameworkRoot->toString(); +} + +std::string DptfStatus::getXmlForSystem(UInt32 moduleIndex, eEsifError* returnCode) +{ + // System group "modules" are implemented as though they are policies to leverage currently implemented interfaces + // As they are not really a policy, we do not want them to appear under the Policies group + switch (moduleIndex) + { + case SystemModuleType::SystemConfiguration: + { + *returnCode = ESIF_OK; + + try + { + auto policy = m_policyManager->getPolicy(SystemModuleType::ToString(SystemModuleType::SystemConfiguration)); + return policy->getStatusAsXml(); + } + catch (policy_index_invalid&) + { + *returnCode = ESIF_E_UNSPECIFIED; + throw dptf_exception("Invalid policy status requested."); + } + catch (...) + { + *returnCode = ESIF_E_UNSPECIFIED; + throw; + } + } + default: + *returnCode = ESIF_E_UNSPECIFIED; + return std::string(); + } +} + +std::shared_ptr DptfStatus::getXmlForFrameworkLoadedPolicies() +{ + auto policiesRoot = XmlNode::createWrapperElement("policies"); + + auto policyIndexes = m_policyManager->getPolicyIndexes(); + policiesRoot->addChild(XmlNode::createDataElement("policy_count", std::to_string(policyIndexes.size()))); + + for (auto i = policyIndexes.begin(); i != policyIndexes.end(); ++i) + { + try + { + auto policy = m_policyManager->getPolicyPtr(*i); + std::string name = policy->getName(); + + if (name == SystemModuleType::ToString(SystemModuleType::SystemConfiguration)) + { + // do not want to add System Configuration as part of the Policies table + continue; + } + + auto policyRoot = XmlNode::createWrapperElement("policy"); + + auto policyIndex = XmlNode::createDataElement("policy_index", std::to_string(*i)); + policyRoot->addChild(policyIndex); + + auto policyName = XmlNode::createDataElement("policy_name", name); + policyRoot->addChild(policyName); + + policiesRoot->addChild(policyRoot); + } + catch (...) + { + // Policy not available, do not add. + } + } + + return policiesRoot; +} + +std::shared_ptr DptfStatus::getXmlForFrameworkLoadedParticipants() +{ + auto participantsRoot = XmlNode::createWrapperElement("participants"); + + auto participantIndexList = m_participantManager->getParticipantIndexes(); + for (auto i = participantIndexList.begin(); i != participantIndexList.end(); ++i) + { + try + { + Participant* participant = m_participantManager->getParticipantPtr(*i); + participantsRoot->addChild(participant->getXml(Constants::Invalid)); + } + catch (...) + { + // Participant not available + } + } + + return participantsRoot; +} + +std::shared_ptr DptfStatus::getXmlForPlatformRequests() +{ + return std::dynamic_pointer_cast(m_dptfManager->getPlatformRequestHandler())->getXml(); +} + +void DptfStatus::fillEsifString(EsifDataPtr outputLocation, std::string inputString, eEsifError* returnCode) +{ + *returnCode = FillDataPtrWithString(outputLocation, inputString); +} + +UIntN DptfStatus::getNumberOfUniqueDomains(std::set participantIndexList) +{ + UIntN numberOfUniqueDomains = 0; + for (auto participantIndex = participantIndexList.begin(); participantIndex != participantIndexList.end(); + ++participantIndex) + { + try + { + Participant* participant = m_participantManager->getParticipantPtr(*participantIndex); + numberOfUniqueDomains = numberOfUniqueDomains + participant->getDomainCount(); + } + catch (...) + { + // Participant not available + } + } + + return numberOfUniqueDomains; +} + +std::shared_ptr DptfStatus::getArbitratorXmlForLoadedParticipants(UInt32 moduleIndex) +{ + auto root = XmlNode::createRoot(); + auto type = (ControlFactoryType::Type)moduleIndex; + root->addChild(XmlNode::createComment("format_id=" + ControlFactoryType::getArbitratorFormatId(type).toString())); + + auto arbitratorRoot = XmlNode::createWrapperElement("arbitrator_status"); + auto participantIndexList = m_participantManager->getParticipantIndexes(); + auto numberOfUniqueDomains = getNumberOfUniqueDomains(participantIndexList); + + arbitratorRoot->addChild( + XmlNode::createDataElement("number_of_domains", StatusFormat::friendlyValue(numberOfUniqueDomains))); + + auto policyIndexes = m_policyManager->getPolicyIndexes(); + for (auto policyIndex = policyIndexes.begin(); policyIndex != policyIndexes.end(); ++policyIndex) + { + try + { + auto policy = m_policyManager->getPolicyPtr(*policyIndex); + std::string name = policy->getName(); + auto policyRoot = XmlNode::createWrapperElement("policy"); + auto policyName = XmlNode::createDataElement("policy_name", name); + policyRoot->addChild(policyName); + + for (auto participantIndex = participantIndexList.begin(); participantIndex != participantIndexList.end(); + ++participantIndex) + { + try + { + Participant* participant = m_participantManager->getParticipantPtr(*participantIndex); + policyRoot->addChild(participant->getArbitrationXmlForPolicy(*policyIndex, type)); + } + catch (...) + { + // Participant not available + } + } + + arbitratorRoot->addChild(policyRoot); + } + catch (...) + { + // Policy not available, do not add. + } + } + + root->addChild(arbitratorRoot); + return root; +} diff --git a/DPTF/Sources/Manager/DptfStatus.h b/DPTF/Sources/Manager/DptfStatus.h new file mode 100644 index 00000000..9e16c57d --- /dev/null +++ b/DPTF/Sources/Manager/DptfStatus.h @@ -0,0 +1,76 @@ +/****************************************************************************** +** Copyright (c) 2013-2022 Intel Corporation All Rights Reserved +** +** Licensed under the Apache License, Version 2.0 (the "License"); you may not +** use this file except in compliance with the License. +** +** You may obtain a copy of the License at +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +** WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** +** See the License for the specific language governing permissions and +** limitations under the License. +** +******************************************************************************/ + +#pragma once + +#include "Dptf.h" +#include "DptfStatusInterface.h" +#include "ControlFactoryType.h" + +class XmlNode; +class Indent; +class Participant; +class ParticipantStatusMap; + +class DptfStatus : public DptfStatusInterface +{ +public: + DptfStatus(DptfManagerInterface* dptfManager); + ~DptfStatus(); + + virtual std::pair getStatus(const eAppStatusCommand command, const UInt32 appStatusIn) + override; + virtual void clearCache() override; + +private: + DptfManagerInterface* m_dptfManager; + PolicyManagerInterface* m_policyManager; + ParticipantManagerInterface* m_participantManager; + ParticipantStatusMap* m_participantStatusMap; + + std::string getGroupsXml(eEsifError* returnCode); + std::string getModulesInGroup(const UInt32 appStatusIn, eEsifError* returnCode); + std::string getPoliciesGroup(); + std::string getParticipantsGroup(); + std::string getFrameworkGroup(); + std::string getArbitratorGroup(); + std::string getSystemGroup(); + std::shared_ptr getArbitratorModuleInGroup(ControlFactoryType::Type type); + std::string getModuleData(const UInt32 appStatusIn, eEsifError* returnCode); + std::string getXmlForPolicy(UInt32 policyIndex, eEsifError* returnCode); + std::string getXmlForParticipant(UInt32 mappedIndex, eEsifError* returnCode); + std::string getXmlForFramework(UInt32 moduleIndex, eEsifError* returnCode); + std::string getXmlForArbitrator(UInt32 moduleIndex, eEsifError* returnCode); + std::string getXmlForSystem(UInt32 moduleIndex, eEsifError* returnCode); + std::shared_ptr getXmlForFrameworkLoadedPolicies(); + std::shared_ptr getXmlForFrameworkLoadedParticipants(); + std::shared_ptr getArbitratorXmlForLoadedParticipants(UInt32 moduleIndex); + std::shared_ptr getXmlForPlatformRequests(); + void checkAndDropSymLink(std::string fileName); + + void fillEsifString(EsifDataPtr outputLocation, std::string inputString, eEsifError* returnCode); + UIntN getNumberOfUniqueDomains(std::set participantIndexList); + + // KW error resolution + DptfStatus(const DptfStatus&); + + DptfStatus& operator=(const DptfStatus&) + { + return *this; + } +}; diff --git a/DPTF/Sources/Manager/DptfStatusInterface.h b/DPTF/Sources/Manager/DptfStatusInterface.h new file mode 100644 index 00000000..f62b4dc5 --- /dev/null +++ b/DPTF/Sources/Manager/DptfStatusInterface.h @@ -0,0 +1,34 @@ +/****************************************************************************** +** Copyright (c) 2013-2022 Intel Corporation All Rights Reserved +** +** Licensed under the Apache License, Version 2.0 (the "License"); you may not +** use this file except in compliance with the License. +** +** You may obtain a copy of the License at +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +** WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** +** See the License for the specific language governing permissions and +** limitations under the License. +** +******************************************************************************/ + +#pragma once + +#include "Dptf.h" +#include "DptfManagerInterface.h" +#include "esif_ccb_rc.h" + +class DptfStatusInterface +{ +public: + virtual ~DptfStatusInterface(){}; + + virtual std::pair getStatus( + const eAppStatusCommand command, + const UInt32 appStatusIn) = 0; + virtual void clearCache() = 0; +}; diff --git a/DPTF/Sources/Manager/EsifApplicationInterface.cpp b/DPTF/Sources/Manager/EsifApplicationInterface.cpp index c98b0a4a..f361a602 100644 --- a/DPTF/Sources/Manager/EsifApplicationInterface.cpp +++ b/DPTF/Sources/Manager/EsifApplicationInterface.cpp @@ -38,7 +38,7 @@ #include "EsifAppBroadcastProcessing.h" // Minimum Required IPF SDK Version for this App to load (i.e., NULL, "1.0.0", IPF_SDK_VERSION, Specific Version, etc.) -#define IPFSDK_MINIMUM_VERSION_REQUIRED IPF_SDK_VERSION +#define IPFSDK_MINIMUM_VERSION_REQUIRED "1.0.0" // // Macros must be used to reduce the code and still allow writing out the file name, line number, and function name @@ -443,6 +443,15 @@ extern "C" eEsifError rc = ESIF_E_UNSPECIFIED; + try + { + auto workItem = std::make_shared(dptfManager, command, appStatusIn, appStatusOut, &rc); + dptfManager->getWorkItemQueueManager()->enqueueImmediateWorkItemAndWait(workItem); + } + catch (...) + { + } + return rc; } @@ -736,6 +745,14 @@ extern "C" case FrameworkEvent::DomainTemperatureThresholdCrossed: wi = std::make_shared(dptfManager, participantIndex, domainIndex); break; + case FrameworkEvent::DomainVirtualSensorCalibrationTableChanged: + wi = std::make_shared( + dptfManager, participantIndex, domainIndex); + break; + case FrameworkEvent::DomainVirtualSensorPollingTableChanged: + wi = std::make_shared( + dptfManager, participantIndex, domainIndex); + break; case FrameworkEvent::DomainVirtualSensorRecalcChanged: wi = std::make_shared(dptfManager, participantIndex, domainIndex); break; @@ -805,6 +822,9 @@ extern "C" wi = std::make_shared( dptfManager, participantIndex, domainIndex, (MbtHint::Type)uint32param); break; + case FrameworkEvent::PolicyActiveRelationshipTableChanged: + wi = std::make_shared(dptfManager); + break; case FrameworkEvent::PolicyCoolingModePolicyChanged: uint32param = EsifDataUInt32(esifEventDataPtr); wi = std::make_shared(dptfManager, (CoolingMode::Type)uint32param); @@ -855,6 +875,9 @@ extern "C" wi = std::make_shared( dptfManager, OsPowerSlider::toType(uint32param)); break; + case FrameworkEvent::PolicyPassiveTableChanged: + wi = std::make_shared(dptfManager); + break; case FrameworkEvent::PolicySensorOrientationChanged: uint32param = EsifDataUInt32(esifEventDataPtr); wi = std::make_shared( @@ -869,6 +892,24 @@ extern "C" wi = std::make_shared( dptfManager, (SensorSpatialOrientation::Type)uint32param); break; + case FrameworkEvent::PolicyThermalRelationshipTableChanged: + wi = std::make_shared(dptfManager); + break; + case FrameworkEvent::PolicyOemVariablesChanged: + wi = std::make_shared(dptfManager); + break; + case FrameworkEvent::PolicyPowerBossConditionsTableChanged: + wi = std::make_shared(dptfManager); + break; + case FrameworkEvent::PolicyPowerBossActionsTableChanged: + wi = std::make_shared(dptfManager); + break; + case FrameworkEvent::PolicyPowerBossMathTableChanged: + wi = std::make_shared(dptfManager); + break; + case FrameworkEvent::PolicyVoltageThresholdMathTableChanged: + wi = std::make_shared(dptfManager); + break; case FrameworkEvent::PolicyOperatingSystemPowerSchemePersonalityChanged: { EsifDataGuid guidParam(esifEventDataPtr); @@ -895,9 +936,21 @@ extern "C" case FrameworkEvent::PolicyEmergencyCallModeTableChanged: wi = std::make_shared(dptfManager); break; + case FrameworkEvent::PolicyPidAlgorithmTableChanged: + wi = std::make_shared(dptfManager); + break; + case FrameworkEvent::PolicyActiveControlPointRelationshipTableChanged: + wi = std::make_shared(dptfManager); + break; + case FrameworkEvent::PolicyPowerShareAlgorithmTableChanged: + wi = std::make_shared(dptfManager); + break; case FrameworkEvent::PolicyWorkloadHintConfigurationChanged: wi = std::make_shared(dptfManager); break; + case FrameworkEvent::PolicyPowerShareAlgorithmTable2Changed: + wi = std::make_shared(dptfManager); + break; case FrameworkEvent::DptfAppUnloading: break; case FrameworkEvent::DptfSupportedPoliciesChanged: diff --git a/DPTF/Sources/Manager/HelpCommand.cpp b/DPTF/Sources/Manager/HelpCommand.cpp index 18743b2f..23c08915 100644 --- a/DPTF/Sources/Manager/HelpCommand.cpp +++ b/DPTF/Sources/Manager/HelpCommand.cpp @@ -38,49 +38,33 @@ void HelpCommand::execute(const CommandArguments& arguments) { // TODO: possibly require each command to report its own help and this // command would just compile all of the helps for each command - const string message = - "DPTF Help Command. Version " VERSION_STR " [" ESIF_ATTR_OS " " ESIF_PLATFORM_TYPE " " ESIF_BUILD_TYPE "]" - "\n" - "Key: <> Required parameters\n" - " [] Optional parameters\n" - "\n" - "help Shows help info for available commands\n" - "reload policies Reloads all policies\n" - "diag all Runs diagnostics on all policies and\n" - " participants\n" - "diag policy [file name]\n" - " Runs diagnostics on a policy\n" - "diag part [file name]\n" - " Runs diagnostics on a participant\n" - "dptf tableobject get [dynamic policy uuid]\n" - " Gets table from DataVault\n" - "dptf tableobject get \n" - " Gets table from alternative DataVault source and key\n" - "dptf tableobject get \n" - " Gets participant table from DataVault\n" - "dptf tableobject set [dynamic policy uuid]\n" - " Sets table value to DataVault\n" - "dptf tableobject set \n" - " Sets table value to alternative DataVault source and key\n" - "dptf tableobject set \n" - " Sets participant table value to DataVault\n" - "dptf tableobject delete [dynamic policy uuid]\n" - " Deletes table from DataVault\n" - "dptf tableobject delete [dynamic policy uuid] \n" - " Deletes table from all DataVaults\n" - "dptf tableobject delete \n" - " Deletes participant table from DataVault\n" - "dptf tableobject delete \n" - " Deletes participant table from all DataVault\n" - "dptf config delete \n" - " Deletes DataVault key\n" - "dptf ui getgroups\n" - " Returns list of high level groups for UI menu\n" - "dptf ui getmodulesingroup \n" - " Returns list of module IDs for the groupID given\n" - "dptf ui getmoduledata \n" - " Returns detailed XML data for a given group ID and module ID\n" - "dptf capture [file name] Export settings to file specified\n"; + string message = "DPTF Help Command. Version " VERSION_STR " [" ESIF_ATTR_OS " " ESIF_PLATFORM_TYPE " " ESIF_BUILD_TYPE "]" + "\n" + "Key: <> Required parameters\n" + " [] Optional parameters\n" + "\n" + "help Shows help info for available commands\n" + "reload policies Reloads all policies\n" + "diag all Runs diagnostics on all policies and\n" + " participants\n" + "diag policy [file name]\n" + " Runs diagnostics on a policy\n" + "diag part [file name]\n" + " Runs diagnostics on a participant\n" + "dptf tableobject get [dynamic policy uuid]\n" + " Gets table from DataVault\n" + "dptf tableobject get \n" + " Gets table from alternative DataVault source and key\n" + "dptf tableobject set [dynamic policy uuid]\n" + " Sets table value to DataVault\n" + "dptf tableobject set \n" + " Sets table value to alternative DataVault source and key\n" + "dptf tableobject delete [dynamic policy uuid]\n" + " Deletes table from DataVault\n" + "dptf tableobject delete [dynamic policy uuid] \n" + " Deletes table from all DataVaults\n" + "dptf config delete \n" + " Deletes DataVault key\n"; setResultMessage(message); } diff --git a/DPTF/Sources/Manager/Participant.cpp b/DPTF/Sources/Manager/Participant.cpp index 25db10d0..a9876bbb 100644 --- a/DPTF/Sources/Manager/Participant.cpp +++ b/DPTF/Sources/Manager/Participant.cpp @@ -310,11 +310,6 @@ std::string Participant::getParticipantName(void) const return m_participantName; } -UIntN Participant::getParticipantIndex(void) const -{ - return m_participantIndex; -} - std::string Participant::getDomainName(UIntN domainIndex) { throwIfDomainInvalid(domainIndex); @@ -1421,7 +1416,7 @@ void Participant::setPowerSharePolicyPower(UIntN domainIndex, const Power& power } std::map Participant::getParticipantSpecificInfo( - const std::vector& requestedInfo) const + const std::vector& requestedInfo) { throwIfRealParticipantIsInvalid(); return m_theRealParticipant->getParticipantSpecificInfo(m_participantIndex, requestedInfo); @@ -1482,3 +1477,4 @@ UInt32 Participant::getSocDgpuPerformanceHintPoints(UIntN domainIndex) throwIfDomainInvalid(domainIndex); return m_domains[domainIndex]->getSocDgpuPerformanceHintPoints(); } + diff --git a/DPTF/Sources/Manager/Participant.h b/DPTF/Sources/Manager/Participant.h index def0c976..5d904a8e 100644 --- a/DPTF/Sources/Manager/Participant.h +++ b/DPTF/Sources/Manager/Participant.h @@ -35,16 +35,6 @@ class dptf_export IParticipant public: virtual ~IParticipant(void){}; virtual std::string getDiagnosticsAsXml() const = 0; - virtual UIntN getDomainCount(void) const = 0; - virtual std::string getParticipantName(void) const = 0; - virtual UIntN getParticipantIndex(void) const = 0; - virtual std::shared_ptr getStatusAsXml(UIntN domainIndex) const = 0; - virtual std::shared_ptr getXml(UIntN domainIndex) const = 0; - virtual std::shared_ptr getArbitrationXmlForPolicy(UIntN policyIndex, ControlFactoryType::Type type) const = 0; - virtual ParticipantProperties getParticipantProperties(void) const = 0; - virtual DomainPropertiesSet getDomainPropertiesSet(void) const = 0; - virtual std::map getParticipantSpecificInfo( - const std::vector& requestedInfo) const = 0; }; class dptf_export Participant : public IParticipant @@ -73,7 +63,7 @@ class dptf_export Participant : public IParticipant void disableDomain(UIntN domainIndex); Bool isDomainEnabled(UIntN domainIndex); - UIntN getDomainCount(void) const override; + UIntN getDomainCount(void) const; // This will clear the cached data stored within the participant and associated domains within the framework. // It will not ask the actual participant to clear any of its data. @@ -85,14 +75,12 @@ class dptf_export Participant : public IParticipant void unregisterEvent(ParticipantEvent::Type participantEvent); Bool isEventRegistered(ParticipantEvent::Type participantEvent); - std::string getParticipantName(void) const override; - UIntN getParticipantIndex(void) const override; + std::string getParticipantName(void) const; std::string getDomainName(UIntN domainIndex); - virtual std::shared_ptr getXml(UIntN domainIndex) const override; - virtual std::shared_ptr getStatusAsXml(UIntN domainIndex) const override; + std::shared_ptr getXml(UIntN domainIndex) const; + std::shared_ptr getStatusAsXml(UIntN domainIndex) const; virtual std::string getDiagnosticsAsXml() const override; - virtual std::shared_ptr getArbitrationXmlForPolicy(UIntN policyIndex, ControlFactoryType::Type type) - const override; + std::shared_ptr getArbitrationXmlForPolicy(UIntN policyIndex, ControlFactoryType::Type type) const; // // Event handlers @@ -137,7 +125,7 @@ class dptf_export Participant : public IParticipant void domainFanCapabilityChanged(void); void domainSocWorkloadClassificationChanged(UInt32 socWorkloadClassification); void domainEppSensitivityHintChanged(UInt32 eppSensitivityHint); - + // // The following set of functions implement the ParticipantInterface related functionality // @@ -323,11 +311,11 @@ class dptf_export Participant : public IParticipant // Get specific info std::map getParticipantSpecificInfo( - const std::vector& requestedInfo) const override; + const std::vector& requestedInfo); // Participant properties - ParticipantProperties getParticipantProperties(void) const override; - DomainPropertiesSet getDomainPropertiesSet(void) const override; + ParticipantProperties getParticipantProperties(void) const; + DomainPropertiesSet getDomainPropertiesSet(void) const; // Set specific info void setParticipantDeviceTemperatureIndication(const Temperature& temperature); diff --git a/DPTF/Sources/Manager/ParticipantListCaptureDataGenerator.cpp b/DPTF/Sources/Manager/ParticipantListCaptureDataGenerator.cpp deleted file mode 100644 index ad3efd33..00000000 --- a/DPTF/Sources/Manager/ParticipantListCaptureDataGenerator.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/****************************************************************************** -** Copyright (c) 2013-2022 Intel Corporation All Rights Reserved -** -** Licensed under the Apache License, Version 2.0 (the "License"); you may not -** use this file except in compliance with the License. -** -** You may obtain a copy of the License at -** http://www.apache.org/licenses/LICENSE-2.0 -** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -** WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** -** See the License for the specific language governing permissions and -** limitations under the License. -** -******************************************************************************/ -#include "ParticipantListCaptureDataGenerator.h" -#include "ParticipantManagerInterface.h" -#include "TemperatureThresholds.h" -using namespace std; - -ParticipantListCaptureDataGenerator::ParticipantListCaptureDataGenerator(DptfManagerInterface* dptfManager) - : CaptureDataGenerator(dptfManager) - , m_participantManager(dptfManager->getParticipantManager()) -{ -} - -/* -Example: - - - IETM - - ... - -*/ -shared_ptr ParticipantListCaptureDataGenerator::generate() const -{ - auto root = XmlNode::createRoot(); - const auto participantIds = m_participantManager->getParticipantIndexes(); - const auto participantsRoot = XmlNode::createWrapperElement("participants"); - addIetmParticipantName(participantsRoot); - for (const auto participantId : participantIds) - { - addParticipantName(participantId, participantsRoot); - } - root->addChild(participantsRoot); - return root; -} - -void ParticipantListCaptureDataGenerator::addIetmParticipantName(const shared_ptr& root) const -{ - try - { - const auto participantRoot = XmlNode::createWrapperElement("participant"); - participantRoot->addChild(XmlNode::createDataElement("name"s, "IETM"s)); - root->addChild(participantRoot); - } - catch (const exception& e) - { - logMessage(e.what()); - } -} - -void ParticipantListCaptureDataGenerator::addParticipantName(UIntN participantId, const shared_ptr& root) - const -{ - try - { - const auto participant = m_participantManager->getParticipantPtr(participantId); - const auto name = participant->getParticipantName(); - const auto participantRoot = XmlNode::createWrapperElement("participant"); - participantRoot->addChild(XmlNode::createDataElement("name"s, name)); - root->addChild(participantRoot); - } - catch (const exception& e) - { - logMessage(e.what()); - } -} \ No newline at end of file diff --git a/DPTF/Sources/Manager/ParticipantListCaptureDataGenerator.h b/DPTF/Sources/Manager/ParticipantListCaptureDataGenerator.h deleted file mode 100644 index a9d36089..00000000 --- a/DPTF/Sources/Manager/ParticipantListCaptureDataGenerator.h +++ /dev/null @@ -1,33 +0,0 @@ -/****************************************************************************** -** Copyright (c) 2013-2022 Intel Corporation All Rights Reserved -** -** Licensed under the Apache License, Version 2.0 (the "License"); you may not -** use this file except in compliance with the License. -** -** You may obtain a copy of the License at -** http://www.apache.org/licenses/LICENSE-2.0 -** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -** WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** -** See the License for the specific language governing permissions and -** limitations under the License. -** -******************************************************************************/ -#pragma once -#include "DptfManagerInterface.h" -#include "CaptureDataGenerator.h" -#include "XmlNode.h" - -class dptf_export ParticipantListCaptureDataGenerator : public CaptureDataGenerator -{ -public: - ParticipantListCaptureDataGenerator(DptfManagerInterface* dptfManager); - std::shared_ptr generate() const override; - -private: - ParticipantManagerInterface* m_participantManager; - void addParticipantName(UIntN participantId, const std::shared_ptr& root) const; - void addIetmParticipantName(const std::shared_ptr& root) const; -}; diff --git a/DPTF/Sources/Manager/ParticipantManager.cpp b/DPTF/Sources/Manager/ParticipantManager.cpp index b6e91d04..0b1378a5 100644 --- a/DPTF/Sources/Manager/ParticipantManager.cpp +++ b/DPTF/Sources/Manager/ParticipantManager.cpp @@ -20,6 +20,7 @@ #include "WorkItemQueueManagerInterface.h" #include "WIParticipantDestroy.h" #include "EsifServicesInterface.h" +#include "DptfStatusInterface.h" #include "MapOps.h" #include "Utility.h" #include "ManagerLogger.h" @@ -60,6 +61,7 @@ void ParticipantManager::createParticipant( // create an instance of the participant class and save at the first available index. // When this completes the actual participant will be instantiated and the functionality will // be available through the interface function pointers. + m_dptfManager->getDptfStatus()->clearCache(); m_participants[participantIndex] = std::make_shared(m_dptfManager); m_participants[participantIndex]->createParticipant(participantIndex, participantDataPtr, participantEnabled); } @@ -77,6 +79,7 @@ void ParticipantManager::destroyAllParticipants(void) try { // Queue up a work item and wait for the return. + m_dptfManager->getDptfStatus()->clearCache(); auto workItem = std::make_shared(m_dptfManager, *index); m_dptfManager->getWorkItemQueueManager()->enqueueImmediateWorkItemAndWait(workItem); } @@ -105,6 +108,7 @@ void ParticipantManager::destroyParticipant(UIntN participantIndex) { try { + m_dptfManager->getDptfStatus()->clearCache(); requestedParticipant->second->destroyParticipant(); } catch (...) @@ -140,6 +144,7 @@ Participant* ParticipantManager::getParticipantPtr(UIntN participantIndex) const void ParticipantManager::clearAllParticipantCachedData() { + m_dptfManager->getDptfStatus()->clearCache(); for (auto p = m_participants.begin(); p != m_participants.end(); p++) { if (p->second != nullptr) diff --git a/DPTF/Sources/Manager/ParticipantServices.cpp b/DPTF/Sources/Manager/ParticipantServices.cpp index c89d31f0..21b2aeca 100644 --- a/DPTF/Sources/Manager/ParticipantServices.cpp +++ b/DPTF/Sources/Manager/ParticipantServices.cpp @@ -22,7 +22,6 @@ #include "WIDomainPerformanceControlCapabilityChanged.h" #include "WIDomainPowerControlCapabilityChanged.h" #include "WIPowerLimitChanged.h" -#include "WIPowerLimitTimeWindowChanged.h" #include "WIPerformanceCapabilitiesChanged.h" #include "EsifServicesInterface.h" #include "ManagerMessage.h" @@ -322,12 +321,6 @@ void ParticipantServices::createEventPowerLimitChanged() m_dptfManager->getWorkItemQueueManager()->enqueueImmediateWorkItemAndReturn(wi); } -void ParticipantServices::createEventPowerLimitTimeWindowChanged() -{ - auto wi = std::make_shared(m_dptfManager); - m_dptfManager->getWorkItemQueueManager()->enqueueImmediateWorkItemAndReturn(wi); -} - void ParticipantServices::createEventPerformanceCapabilitiesChanged() { auto wi = std::make_shared(m_dptfManager, m_participantIndex); diff --git a/DPTF/Sources/Manager/ParticipantServices.h b/DPTF/Sources/Manager/ParticipantServices.h index 7729193c..4850a648 100644 --- a/DPTF/Sources/Manager/ParticipantServices.h +++ b/DPTF/Sources/Manager/ParticipantServices.h @@ -163,7 +163,6 @@ class ParticipantServices final : public ParticipantServicesInterface virtual void createEventDomainPowerControlCapabilityChanged() override final; virtual void createEventPowerLimitChanged() override final; virtual void createEventPerformanceCapabilitiesChanged() override final; - virtual void createEventPowerLimitTimeWindowChanged() override final; virtual void sendDptfEvent(ParticipantEvent::Type participantEvent, UIntN domainId, esif_data eventData) override final; diff --git a/DPTF/Sources/Manager/ParticipantTripPointsCaptureDataGenerator.cpp b/DPTF/Sources/Manager/ParticipantTripPointsCaptureDataGenerator.cpp deleted file mode 100644 index 927582be..00000000 --- a/DPTF/Sources/Manager/ParticipantTripPointsCaptureDataGenerator.cpp +++ /dev/null @@ -1,196 +0,0 @@ -/****************************************************************************** -** Copyright (c) 2013-2022 Intel Corporation All Rights Reserved -** -** Licensed under the Apache License, Version 2.0 (the "License"); you may not -** use this file except in compliance with the License. -** -** You may obtain a copy of the License at -** http://www.apache.org/licenses/LICENSE-2.0 -** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -** WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** -** See the License for the specific language governing permissions and -** limitations under the License. -** -******************************************************************************/ -#include "ParticipantTripPointsCaptureDataGenerator.h" -#include "ParticipantManagerInterface.h" -#include "TemperatureThresholds.h" -using namespace std; - -ParticipantTripPointsCaptureDataGenerator::ParticipantTripPointsCaptureDataGenerator(DptfManagerInterface* dptfManager) - : CaptureDataGenerator(dptfManager) - , m_participantManager(dptfManager->getParticipantManager()) -{ -} - -shared_ptr ParticipantTripPointsCaptureDataGenerator::generate() const -{ - auto root = XmlNode::createRoot(); - const auto participantIds = m_participantManager->getParticipantIndexes(); - for (const auto participantId : participantIds) - { - addParticipantDetails(participantId, root); - } - return root; -} - -/* -Example: - - ... - -*/ -void ParticipantTripPointsCaptureDataGenerator::addParticipantDetails(UIntN participantId, std::shared_ptr root) const -{ - try - { - const auto participantDomainRoot = XmlNode::createWrapperElement("participant"); - addBasicInfo(participantId, participantDomainRoot); - addTripPoints(participantId, participantDomainRoot); - root->addChild(participantDomainRoot); - } - catch (const exception& e) - { - logMessage(e.what()); - } -} - -/* -Example: -SEN1 -D0 -EXTZ-External/Remote 1 Sensor -*/ -void ParticipantTripPointsCaptureDataGenerator::addBasicInfo(const UIntN participantId, const shared_ptr& root) - const -{ - const auto participant = m_participantManager->getParticipantPtr(participantId); - const auto name = participant->getParticipantName(); - root->addChild(XmlNode::createDataElement("name", name)); - root->addChild(XmlNode::createDataElement("domainID", "D"s + to_string(0))); - const auto participantProperties = participant->getParticipantProperties(); - const auto participantDescription = participantProperties.getDescription(); - root->addChild(XmlNode::createDataElement("description", participantDescription)); -} - -/* -Example: - - 65.0 - 70.0 - 75.0 - 80.0 - 55.0 - 59.0 - X - X - X - X - X - X - X - X - 2.0 - 5.0 - -*/ -const vector tripPoints{ - ParticipantSpecificInfoKey::PSV, - ParticipantSpecificInfoKey::Warm, - ParticipantSpecificInfoKey::Hot, - ParticipantSpecificInfoKey::Critical, - ParticipantSpecificInfoKey::AC0, - ParticipantSpecificInfoKey::AC1, - ParticipantSpecificInfoKey::AC2, - ParticipantSpecificInfoKey::AC3, - ParticipantSpecificInfoKey::AC4, - ParticipantSpecificInfoKey::AC5, - ParticipantSpecificInfoKey::AC6, - ParticipantSpecificInfoKey::AC7, - ParticipantSpecificInfoKey::AC8, - ParticipantSpecificInfoKey::AC9, - ParticipantSpecificInfoKey::NTT -}; - -void ParticipantTripPointsCaptureDataGenerator::addTripPoints( - const UIntN participantId, - const shared_ptr& root) const -{ - try - { - if (hasTemperatureControls(participantId)) - { - const auto participant = m_participantManager->getParticipantPtr(participantId); - const auto specInfoResult = participant->getParticipantSpecificInfo(tripPoints); - const auto tripPointsRoot = XmlNode::createWrapperElement("trippoints"); - for (const auto& specInfo : specInfoResult) - { - addTripPoint(specInfo, participantId, tripPointsRoot); - } - addHysteresis(participantId, tripPointsRoot); - root->addChild(tripPointsRoot); - } - } - catch (const exception& e) - { - logMessage(e.what()); - } -} - -void ParticipantTripPointsCaptureDataGenerator::addTripPoint( - pair specInfo, - const UIntN participantId, - const shared_ptr& root) const -{ - const auto name = ParticipantSpecificInfoKey::ToString(specInfo.first); - const auto value = specInfo.second.toString(); - root->addChild(XmlNode::createDataElement(name, value)); -} - -void ParticipantTripPointsCaptureDataGenerator::addHysteresis( - const UIntN participantId, - const shared_ptr& root) const -{ - auto hysteresis = Temperature::createInvalid(); - const auto domains = getDomainsWithTemperatureThresholdControls(participantId); - if (!domains.empty()) - { - const DptfRequest request(DptfRequestType::TemperatureControlGetTemperatureThresholds, participantId, 0); - const auto result = m_dptfManager->getRequestDispatcher()->dispatch(PolicyRequest(Constants::Invalid, request)); - const auto tempThresholds = TemperatureThresholds::createFromDptfBuffer(result.getData()); - hysteresis = tempThresholds.getHysteresis(); - } - root->addChild(XmlNode::createDataElement("hyst", hysteresis.toString())); -} - -bool ParticipantTripPointsCaptureDataGenerator::hasTemperatureControls(const UIntN participantId) const -{ - const auto participant = m_participantManager->getParticipantPtr(participantId); - const auto domainPropertySet = participant->getDomainPropertiesSet(); - for (UIntN d = 0; d < domainPropertySet.getDomainCount(); ++d) - { - if (domainPropertySet.getDomainProperties(d).implementsTemperatureInterface()) - { - return true; - } - } - return false; -} - -set ParticipantTripPointsCaptureDataGenerator::getDomainsWithTemperatureThresholdControls(const UIntN participantId) const -{ - set domains; - const auto participant = m_participantManager->getParticipantPtr(participantId); - const auto domainPropertySet = participant->getDomainPropertiesSet(); - for (UIntN d = 0; d < domainPropertySet.getDomainCount(); ++d) - { - if (domainPropertySet.getDomainProperties(d).implementsTemperatureThresholdInterface()) - { - domains.insert(d); - } - } - return domains; -} \ No newline at end of file diff --git a/DPTF/Sources/Manager/ParticipantTripPointsCaptureDataGenerator.h b/DPTF/Sources/Manager/ParticipantTripPointsCaptureDataGenerator.h deleted file mode 100644 index c2b039e9..00000000 --- a/DPTF/Sources/Manager/ParticipantTripPointsCaptureDataGenerator.h +++ /dev/null @@ -1,41 +0,0 @@ -/****************************************************************************** -** Copyright (c) 2013-2022 Intel Corporation All Rights Reserved -** -** Licensed under the Apache License, Version 2.0 (the "License"); you may not -** use this file except in compliance with the License. -** -** You may obtain a copy of the License at -** http://www.apache.org/licenses/LICENSE-2.0 -** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -** WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** -** See the License for the specific language governing permissions and -** limitations under the License. -** -******************************************************************************/ -#pragma once -#include "DptfManagerInterface.h" -#include "CaptureDataGenerator.h" -#include "XmlNode.h" - -class dptf_export ParticipantTripPointsCaptureDataGenerator : public CaptureDataGenerator -{ -public: - ParticipantTripPointsCaptureDataGenerator(DptfManagerInterface* dptfManager); - std::shared_ptr generate() const override; - -private: - ParticipantManagerInterface* m_participantManager; - void addParticipantDetails(UIntN participantId, std::shared_ptr root) const; - void addBasicInfo(const UIntN participantId, const std::shared_ptr& root) const; - void addTripPoints(const UIntN participantId, const std::shared_ptr& root) const; - void addTripPoint( - std::pair specInfo, - const UIntN participantId, - const std::shared_ptr& root) const; - void addHysteresis(const UIntN participantId, const std::shared_ptr& root) const; - bool hasTemperatureControls(UIntN participantId) const; - std::set getDomainsWithTemperatureThresholdControls(UIntN participantId) const; -}; diff --git a/DPTF/Sources/Manager/PlatformRequestHandler.h b/DPTF/Sources/Manager/PlatformRequestHandler.h index a73c1156..cbdb976e 100644 --- a/DPTF/Sources/Manager/PlatformRequestHandler.h +++ b/DPTF/Sources/Manager/PlatformRequestHandler.h @@ -6,14 +6,7 @@ #include "ArbitratorOscRequest.h" #include -class dptf_export PlatformRequestHandlerInterface : public RequestHandlerInterface -{ -public: - PlatformRequestHandlerInterface() = default; - virtual std::shared_ptr getXml() = 0; -}; - -class dptf_export PlatformRequestHandler : public PlatformRequestHandlerInterface +class dptf_export PlatformRequestHandler : public RequestHandlerInterface { public: PlatformRequestHandler(DptfManagerInterface* dptfManager); @@ -21,7 +14,7 @@ class dptf_export PlatformRequestHandler : public PlatformRequestHandlerInterfac virtual Bool canProcessRequest(const PolicyRequest& policyRequest) override; virtual DptfRequestResult processRequest(const PolicyRequest& policyRequest) override; - virtual std::shared_ptr getXml() override; + std::shared_ptr getXml(); private: DptfManagerInterface* m_dptfManager; diff --git a/DPTF/Sources/Manager/Policy.cpp b/DPTF/Sources/Manager/Policy.cpp index 62e62cfd..434d8ca7 100644 --- a/DPTF/Sources/Manager/Policy.cpp +++ b/DPTF/Sources/Manager/Policy.cpp @@ -813,14 +813,6 @@ void Policy::executePowerLimitChanged(void) } } -void Policy::executePowerLimitTimeWindowChanged(void) -{ - if (isEventRegistered(PolicyEvent::PowerLimitTimeWindowChanged)) - { - m_theRealPolicy->powerLimitTimeWindowChanged(); - } -} - void Policy::executePerformanceCapabilitiesChanged(UIntN participantIndex) { if (isEventRegistered(PolicyEvent::PerformanceCapabilitiesChanged)) diff --git a/DPTF/Sources/Manager/Policy.h b/DPTF/Sources/Manager/Policy.h index 9c514efe..34e9d35e 100644 --- a/DPTF/Sources/Manager/Policy.h +++ b/DPTF/Sources/Manager/Policy.h @@ -154,7 +154,6 @@ class dptf_export IPolicy virtual void executePolicyActiveControlPointRelationshipTableChanged(void) = 0; virtual void executePolicyPowerShareAlgorithmTableChanged(void) = 0; virtual void executePowerLimitChanged(void) = 0; - virtual void executePowerLimitTimeWindowChanged(void) = 0; virtual void executePerformanceCapabilitiesChanged(UIntN participantIndex) = 0; virtual void executePolicyWorkloadHintConfigurationChanged(void) = 0; virtual void executePolicyOperatingSystemGameModeChanged(OnOffToggle::Type osGameMode) = 0; @@ -300,7 +299,6 @@ class dptf_export Policy : public IPolicy virtual void executePolicyIntelligentThermalManagementTableChanged(void) override; virtual void executePolicyEnergyPerformanceOptimizerTableChanged(void) override; virtual void executePowerLimitChanged(void) override; - virtual void executePowerLimitTimeWindowChanged(void) override; virtual void executePerformanceCapabilitiesChanged(UIntN participantIndex) override; virtual void executePolicyWorkloadHintConfigurationChanged(void) override; virtual void executePolicyOperatingSystemGameModeChanged(OnOffToggle::Type osMixedRealityMode) override; diff --git a/DPTF/Sources/Manager/PolicyListCaptureDataGenerator.cpp b/DPTF/Sources/Manager/PolicyListCaptureDataGenerator.cpp deleted file mode 100644 index f1e5ba45..00000000 --- a/DPTF/Sources/Manager/PolicyListCaptureDataGenerator.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/****************************************************************************** -** Copyright (c) 2013-2022 Intel Corporation All Rights Reserved -** -** Licensed under the Apache License, Version 2.0 (the "License"); you may not -** use this file except in compliance with the License. -** -** You may obtain a copy of the License at -** http://www.apache.org/licenses/LICENSE-2.0 -** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -** WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** -** See the License for the specific language governing permissions and -** limitations under the License. -** -******************************************************************************/ -#include "PolicyListCaptureDataGenerator.h" -#include "PolicyManagerInterface.h" -using namespace std; - -PolicyListCaptureDataGenerator::PolicyListCaptureDataGenerator(DptfManagerInterface* dptfManager) - : CaptureDataGenerator(dptfManager) - , m_policyManager(m_dptfManager->getPolicyManager()) -{ - -} - -/* -Example: - - 0F27BE63-111C-FD48-A6F7-3AF253FF3E2D - 78563412-BBAA-DDCC-EEFF-ABCDEF123456 - -*/ -std::shared_ptr PolicyListCaptureDataGenerator::generate() const -{ - const auto supportedPolicyList = m_policyManager->getSupportedPolicyList(); - const auto categoryRoot = XmlNode::createWrapperElement("idsp"); - for (UIntN policy = 0; policy < supportedPolicyList->getCount(); ++policy) - { - const auto policyGuid = supportedPolicyList->get(policy); - categoryRoot->addChild(XmlNode::createDataElement("fld", policyGuid.toClassicString())); - } - - auto root = XmlNode::createRoot(); - root->addChild(categoryRoot); - return root; -} \ No newline at end of file diff --git a/DPTF/Sources/Manager/PolicyListCaptureDataGenerator.h b/DPTF/Sources/Manager/PolicyListCaptureDataGenerator.h deleted file mode 100644 index 68d6e881..00000000 --- a/DPTF/Sources/Manager/PolicyListCaptureDataGenerator.h +++ /dev/null @@ -1,31 +0,0 @@ -/****************************************************************************** -** Copyright (c) 2013-2022 Intel Corporation All Rights Reserved -** -** Licensed under the Apache License, Version 2.0 (the "License"); you may not -** use this file except in compliance with the License. -** -** You may obtain a copy of the License at -** http://www.apache.org/licenses/LICENSE-2.0 -** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -** WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** -** See the License for the specific language governing permissions and -** limitations under the License. -** -******************************************************************************/ -#pragma once -#include "DptfManagerInterface.h" -#include "CaptureDataGenerator.h" -#include "XmlNode.h" - -class dptf_export PolicyListCaptureDataGenerator : public CaptureDataGenerator -{ -public: - PolicyListCaptureDataGenerator(DptfManagerInterface* dptfManager); - std::shared_ptr generate() const override; - -private: - PolicyManagerInterface* m_policyManager; -}; diff --git a/DPTF/Sources/Manager/PolicyServicesPlatformConfigurationData.cpp b/DPTF/Sources/Manager/PolicyServicesPlatformConfigurationData.cpp index 91006cc9..6cb0d05a 100644 --- a/DPTF/Sources/Manager/PolicyServicesPlatformConfigurationData.cpp +++ b/DPTF/Sources/Manager/PolicyServicesPlatformConfigurationData.cpp @@ -120,7 +120,15 @@ void PolicyServicesPlatformConfigurationData::setActiveRelationshipTable(DptfBuf { throwIfNotWorkItemThread(); - getDptfManager()->getDataManager()->setTableObjectForNoPersist(data, TableObjectType::Type::Art); + getEsifServices()->primitiveExecuteSet( + esif_primitive_type::SET_ACTIVE_RELATIONSHIP_TABLE, + esif_data_type::ESIF_DATA_BINARY, + data.get(), + data.size(), + data.size(), + Constants::Esif::NoParticipant, + Constants::Esif::NoDomain, + Constants::Esif::NoPersistInstance); } DptfBuffer PolicyServicesPlatformConfigurationData::getThermalRelationshipTable(void) @@ -135,8 +143,15 @@ void PolicyServicesPlatformConfigurationData::setThermalRelationshipTable(DptfBu { throwIfNotWorkItemThread(); - getDptfManager()->getDataManager()->setTableObjectForNoPersist(data, TableObjectType::Type::Trt); - + getEsifServices()->primitiveExecuteSet( + esif_primitive_type::SET_THERMAL_RELATIONSHIP_TABLE, + esif_data_type::ESIF_DATA_BINARY, + data.get(), + data.size(), + data.size(), + Constants::Esif::NoParticipant, + Constants::Esif::NoDomain, + Constants::Esif::NoPersistInstance); } DptfBuffer PolicyServicesPlatformConfigurationData::getPassiveTable(void) @@ -151,7 +166,15 @@ void PolicyServicesPlatformConfigurationData::setPassiveTable(DptfBuffer data) { throwIfNotWorkItemThread(); - getDptfManager()->getDataManager()->setTableObjectForNoPersist(data, TableObjectType::Psvt); + getEsifServices()->primitiveExecuteSet( + esif_primitive_type::SET_PASSIVE_RELATIONSHIP_TABLE, + esif_data_type::ESIF_DATA_BINARY, + data.get(), + data.size(), + data.size(), + Constants::Esif::NoParticipant, + Constants::Esif::NoDomain, + Constants::Esif::NoPersistInstance); } DptfBuffer PolicyServicesPlatformConfigurationData::getAdaptivePerformanceConditionsTable(std::string uuid) @@ -179,10 +202,7 @@ DptfBuffer PolicyServicesPlatformConfigurationData::getSwOemVariables(void) { throwIfNotWorkItemThread(); - return getDptfManager() - ->getDataManager() - ->getTableObject(TableObjectType::Type::SwOemVariables, Constants::EmptyString) - .getData(); + return getDptfManager()->getDataManager()->getTableObject(TableObjectType::Type::SwOemVariables, Constants::EmptyString).getData(); } void PolicyServicesPlatformConfigurationData::setSwOemVariables(const DptfBuffer& swOemVariablesData) @@ -190,7 +210,10 @@ void PolicyServicesPlatformConfigurationData::setSwOemVariables(const DptfBuffer throwIfNotWorkItemThread(); getDptfManager()->getDataManager()->setTableObject( - swOemVariablesData, TableObjectType::SwOemVariables, Constants::EmptyString); + swOemVariablesData.size(), + swOemVariablesData.get(), + TableObjectType::SwOemVariables, + Constants::EmptyString); } UInt64 PolicyServicesPlatformConfigurationData::getHwpfState(UIntN participantIndex, UIntN domainIndex) @@ -283,20 +306,15 @@ DptfBuffer PolicyServicesPlatformConfigurationData::getPowerBossConditionsTable( { throwIfNotWorkItemThread(); - return getDptfManager() - ->getDataManager() - ->getTableObject(TableObjectType::Type::Pbct, Constants::EmptyString) - .getData(); + return getEsifServices()->primitiveExecuteGet( + esif_primitive_type::GET_POWER_BOSS_CONDITIONS_TABLE, ESIF_DATA_BINARY); } DptfBuffer PolicyServicesPlatformConfigurationData::getPowerBossActionsTable(void) { throwIfNotWorkItemThread(); - return getDptfManager() - ->getDataManager() - ->getTableObject(TableObjectType::Type::Pbat, Constants::EmptyString) - .getData(); + return getEsifServices()->primitiveExecuteGet(esif_primitive_type::GET_POWER_BOSS_ACTIONS_TABLE, ESIF_DATA_BINARY); } DptfBuffer PolicyServicesPlatformConfigurationData::getEmergencyCallModeTable(void) @@ -317,44 +335,53 @@ void PolicyServicesPlatformConfigurationData::setPidAlgorithmTable(DptfBuffer da { throwIfNotWorkItemThread(); - getDptfManager()->getDataManager()->setTableObjectForNoPersist(data, TableObjectType::Type::Pida); + getEsifServices()->primitiveExecuteSet( + esif_primitive_type::SET_PID_ALGORITHM_TABLE, + esif_data_type::ESIF_DATA_BINARY, + data.get(), + data.size(), + data.size(), + Constants::Esif::NoParticipant, + Constants::Esif::NoDomain, + Constants::Esif::NoPersistInstance); } DptfBuffer PolicyServicesPlatformConfigurationData::getPowerBossMathTable(void) { throwIfNotWorkItemThread(); - return getDptfManager() - ->getDataManager() - ->getTableObject(TableObjectType::Type::Pbmt, Constants::EmptyString) - .getData(); + return getEsifServices()->primitiveExecuteGet(esif_primitive_type::GET_POWER_BOSS_MATH_TABLE, ESIF_DATA_BINARY); } DptfBuffer PolicyServicesPlatformConfigurationData::getVoltageThresholdMathTable(void) { throwIfNotWorkItemThread(); - return getDptfManager() - ->getDataManager() - ->getTableObject(TableObjectType::Type::Vtmt, Constants::EmptyString) - .getData(); + return getEsifServices()->primitiveExecuteGet( + esif_primitive_type::GET_VOLTAGE_THRESHOLD_MATH_TABLE, ESIF_DATA_BINARY); } DptfBuffer PolicyServicesPlatformConfigurationData::getActiveControlPointRelationshipTable(void) { throwIfNotWorkItemThread(); - return getDptfManager() - ->getDataManager() - ->getTableObject(TableObjectType::Type::Acpr, Constants::EmptyString) - .getData(); + return getEsifServices()->primitiveExecuteGet( + esif_primitive_type::GET_ACTIVE_CONTROL_POINT_RELATIONSHIP_TABLE, ESIF_DATA_BINARY); } void PolicyServicesPlatformConfigurationData::setActiveControlPointRelationshipTable(DptfBuffer data) { throwIfNotWorkItemThread(); - getDptfManager()->getDataManager()->setTableObjectForNoPersist(data, TableObjectType::Acpr); + getEsifServices()->primitiveExecuteSet( + esif_primitive_type::SET_ACTIVE_CONTROL_POINT_RELATIONSHIP_TABLE, + esif_data_type::ESIF_DATA_BINARY, + data.get(), + data.size(), + data.size(), + Constants::Esif::NoParticipant, + Constants::Esif::NoDomain, + Constants::Esif::NoPersistInstance); } DptfBuffer PolicyServicesPlatformConfigurationData::getIntelligentThermalManagementTable() @@ -395,34 +422,46 @@ DptfBuffer PolicyServicesPlatformConfigurationData::getPowerShareAlgorithmTable( { throwIfNotWorkItemThread(); - return getDptfManager() - ->getDataManager() - ->getTableObject(TableObjectType::Type::Psha, Constants::EmptyString) - .getData(); + return getEsifServices()->primitiveExecuteGet( + esif_primitive_type::GET_POWER_SHARING_ALGORITHM_TABLE, ESIF_DATA_BINARY); } void PolicyServicesPlatformConfigurationData::setPowerShareAlgorithmTable(DptfBuffer data) { throwIfNotWorkItemThread(); - getDptfManager()->getDataManager()->setTableObjectForNoPersist(data, TableObjectType::Psha); + getEsifServices()->primitiveExecuteSet( + esif_primitive_type::SET_POWER_SHARING_ALGORITHM_TABLE, + esif_data_type::ESIF_DATA_BINARY, + data.get(), + data.size(), + data.size(), + Constants::Esif::NoParticipant, + Constants::Esif::NoDomain, + Constants::Esif::NoPersistInstance); } DptfBuffer PolicyServicesPlatformConfigurationData::getPowerShareAlgorithmTable2() { throwIfNotWorkItemThread(); - return getDptfManager() - ->getDataManager() - ->getTableObject(TableObjectType::Type::Psh2, Constants::EmptyString) - .getData(); + return getEsifServices()->primitiveExecuteGet( + esif_primitive_type::GET_POWER_SHARING_ALGORITHM_TABLE_2, ESIF_DATA_BINARY); } void PolicyServicesPlatformConfigurationData::setPowerShareAlgorithmTable2(DptfBuffer data) { throwIfNotWorkItemThread(); - getDptfManager()->getDataManager()->setTableObjectForNoPersist(data, TableObjectType::Psh2); + getEsifServices()->primitiveExecuteSet( + esif_primitive_type::SET_POWER_SHARING_ALGORITHM_TABLE_2, + esif_data_type::ESIF_DATA_BINARY, + data.get(), + data.size(), + data.size(), + Constants::Esif::NoParticipant, + Constants::Esif::NoDomain, + Constants::Esif::NoPersistInstance); } DptfBuffer PolicyServicesPlatformConfigurationData::createResetPrimitiveTupleBinary( @@ -455,7 +494,18 @@ void PolicyServicesPlatformConfigurationData::resetActiveRelationshipTable(void) { try { - getDptfManager()->getDataManager()->deleteTableObjectKeyForNoPersist(TableObjectType::Art); + DptfBuffer tableBuffer = createResetPrimitiveTupleBinary( + esif_primitive_type::SET_ACTIVE_RELATIONSHIP_TABLE, Constants::Esif::NoPersistInstance); + + getEsifServices()->primitiveExecuteSet( + esif_primitive_type::SET_CONFIG_RESET, + ESIF_DATA_BINARY, + tableBuffer.get(), + tableBuffer.size(), + tableBuffer.size(), + Constants::Esif::NoParticipant, + Constants::Esif::NoDomain, + Constants::Esif::NoInstance); } catch (...) { @@ -467,8 +517,18 @@ void PolicyServicesPlatformConfigurationData::resetThermalRelationshipTable(void { try { - getDptfManager()->getDataManager()->deleteTableObjectKeyForNoPersist(TableObjectType::Trt); - + DptfBuffer tableBuffer = createResetPrimitiveTupleBinary( + esif_primitive_type::SET_THERMAL_RELATIONSHIP_TABLE, Constants::Esif::NoPersistInstance); + + getEsifServices()->primitiveExecuteSet( + esif_primitive_type::SET_CONFIG_RESET, + ESIF_DATA_BINARY, + tableBuffer.get(), + tableBuffer.size(), + tableBuffer.size(), + Constants::Esif::NoParticipant, + Constants::Esif::NoDomain, + Constants::Esif::NoInstance); } catch (...) { @@ -480,7 +540,18 @@ void PolicyServicesPlatformConfigurationData::resetPassiveTable(void) { try { - getDptfManager()->getDataManager()->deleteTableObjectKeyForNoPersist(TableObjectType::Psvt); + DptfBuffer tableBuffer = createResetPrimitiveTupleBinary( + esif_primitive_type::SET_PASSIVE_RELATIONSHIP_TABLE, Constants::Esif::NoPersistInstance); + + getEsifServices()->primitiveExecuteSet( + esif_primitive_type::SET_CONFIG_RESET, + ESIF_DATA_BINARY, + tableBuffer.get(), + tableBuffer.size(), + tableBuffer.size(), + Constants::Esif::NoParticipant, + Constants::Esif::NoDomain, + Constants::Esif::NoInstance); } catch (...) { @@ -492,7 +563,18 @@ void PolicyServicesPlatformConfigurationData::resetPidAlgorithmTable(void) { try { - getDptfManager()->getDataManager()->deleteTableObjectKeyForNoPersist(TableObjectType::Pida); + DptfBuffer tableBuffer = createResetPrimitiveTupleBinary( + esif_primitive_type::SET_PID_ALGORITHM_TABLE, Constants::Esif::NoPersistInstance); + + getEsifServices()->primitiveExecuteSet( + esif_primitive_type::SET_CONFIG_RESET, + ESIF_DATA_BINARY, + tableBuffer.get(), + tableBuffer.size(), + tableBuffer.size(), + Constants::Esif::NoParticipant, + Constants::Esif::NoDomain, + Constants::Esif::NoInstance); } catch (...) { @@ -637,17 +719,22 @@ Bool PolicyServicesPlatformConfigurationData::getDisplayRequired(void) void PolicyServicesPlatformConfigurationData::setPpmPackage(DptfBuffer package) { throwIfNotWorkItemThread(); - EsifPpmParamValuesHeader* pkgHeader = (EsifPpmParamValuesHeader*)package.get(); + EsifPpmParamValuesHeader* pkgHeader = (EsifPpmParamValuesHeader *) package.get(); UInt32 numParams = pkgHeader->numberElement; - UInt32 ppmParameterSize = - (numParams - 1) * sizeof(EsifPpmParamValues); // One less since package already accounts for one parameter + UInt32 ppmParameterSize = (numParams - 1) * sizeof(EsifPpmParamValues); // One less since package already accounts for one parameter UInt32 ppmPackageSize = sizeof(EsifPpmParamValuesHeader) + ppmParameterSize; getEsifServices()->primitiveExecuteSet( - esif_primitive_type::SET_PPM_PARAM_VALUES, ESIF_DATA_STRUCTURE, pkgHeader, ppmPackageSize, ppmPackageSize); + esif_primitive_type::SET_PPM_PARAM_VALUES, + ESIF_DATA_STRUCTURE, + pkgHeader, + ppmPackageSize, + ppmPackageSize); } -DptfBuffer PolicyServicesPlatformConfigurationData::getPpmPackage(DptfBuffer requestpackage) +DptfBuffer PolicyServicesPlatformConfigurationData::getPpmPackage( + DptfBuffer requestpackage + ) { throwIfNotWorkItemThread(); @@ -655,10 +742,11 @@ DptfBuffer PolicyServicesPlatformConfigurationData::getPpmPackage(DptfBuffer req buffer = getEsifServices()->primitiveExecuteGetWithArgument( esif_primitive_type::GET_PPM_PARAM_VALUES, - requestpackage, + requestpackage, Constants::Esif::NoParticipant, Constants::Esif::NoDomain, - Constants::Esif::NoInstance); + Constants::Esif::NoInstance + ); return buffer; } @@ -759,7 +847,7 @@ DptfBuffer PolicyServicesPlatformConfigurationData::getAggregateDisplayInformati DptfBuffer PolicyServicesPlatformConfigurationData::getTpgaTable(void) { throwIfNotWorkItemThread(); - + return getDptfManager() ->getDataManager() ->getTableObject(TableObjectType::Type::Tpga, Constants::EmptyString) @@ -806,27 +894,10 @@ UInt64 PolicyServicesPlatformConfigurationData::getPlatformCpuId() { throwIfNotWorkItemThread(); - esif_ccb_cpuid_t cpuInfo = {0}; + esif_ccb_cpuid_t cpuInfo = { 0 }; cpuInfo.leaf = ESIF_CPUID_LEAF_PROCESSOR_SIGNATURE; esif_ccb_cpuid(&cpuInfo); UInt64 platformCpuId = cpuInfo.eax & CPUID_FAMILY_MODEL_MASK; return platformCpuId; -} - -UInt32 PolicyServicesPlatformConfigurationData::getLogicalProcessorCount(UIntN participantIndex, UIntN domainIndex) -{ - throwIfNotWorkItemThread(); - - return getEsifServices()->primitiveExecuteGetAsUInt32( - esif_primitive_type::GET_PROC_LOGICAL_PROCESSOR_COUNT, participantIndex, domainIndex); - -} - -UInt32 PolicyServicesPlatformConfigurationData::getPhysicalCoreCount(UIntN participantIndex, UIntN domainIndex) -{ - throwIfNotWorkItemThread(); - - return getEsifServices()->primitiveExecuteGetAsUInt32( - esif_primitive_type::GET_PROC_PHYSICAL_CORE_COUNT, participantIndex, domainIndex); } \ No newline at end of file diff --git a/DPTF/Sources/Manager/PolicyServicesPlatformConfigurationData.h b/DPTF/Sources/Manager/PolicyServicesPlatformConfigurationData.h index 1946d365..ca82b79a 100644 --- a/DPTF/Sources/Manager/PolicyServicesPlatformConfigurationData.h +++ b/DPTF/Sources/Manager/PolicyServicesPlatformConfigurationData.h @@ -95,9 +95,8 @@ class PolicyServicesPlatformConfigurationData final : public PolicyServices, pub virtual void setDynamicBoostState(UIntN participantIndex, UIntN domainIndex, UInt32 value) override final; virtual UInt32 getTpgPowerStateWithoutCache(UIntN participantIndex, UIntN domainIndex) override final; virtual UInt64 getPlatformCpuId() override final; + virtual void clearPpmPackageSettings(void) override final; - virtual UInt32 getLogicalProcessorCount(UIntN participantIndex, UIntN domainIndex) override final; - virtual UInt32 getPhysicalCoreCount(UIntN participantIndex, UIntN domainIndex) override final; private: TimeSpan m_defaultSamplePeriod; diff --git a/DPTF/Sources/Manager/StatusCommand.cpp b/DPTF/Sources/Manager/StatusCommand.cpp new file mode 100644 index 00000000..d7fd7e49 --- /dev/null +++ b/DPTF/Sources/Manager/StatusCommand.cpp @@ -0,0 +1,77 @@ +/****************************************************************************** +** Copyright (c) 2013-2022 Intel Corporation All Rights Reserved +** +** Licensed under the Apache License, Version 2.0 (the "License"); you may not +** use this file except in compliance with the License. +** +** You may obtain a copy of the License at +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +** WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** +** See the License for the specific language governing permissions and +** limitations under the License. +** +******************************************************************************/ +#include "StatusCommand.h" +#include "DptfManagerInterface.h" +#include "DptfStatusInterface.h" +#include "WorkItemQueueManagerInterface.h" + +using namespace std; + +StatusCommand::StatusCommand(DptfManagerInterface* dptfManager) + : CommandHandler(dptfManager) +{ +} + +StatusCommand::~StatusCommand() +{ +} + +string StatusCommand::getCommandName() const +{ + return "status"; +} + +void StatusCommand::execute(const CommandArguments& arguments) +{ + throwIfBadArguments(arguments); + + eAppStatusCommand command = (eAppStatusCommand)(UInt32) * (UInt32*)arguments[1].getData().get(); + UInt8 groupId = 0; + UInt8 moduleId = 0; + UInt32 appStatusIn = 0; + if (arguments.size() > 2) + { + groupId = (UInt8) * (UInt8*)arguments[2].getData().get(); + appStatusIn = groupId; + } + if (arguments.size() > 3) + { + moduleId = (UInt8) * (UInt8*)arguments[3].getData().get(); + appStatusIn = appStatusIn << 16; + appStatusIn = appStatusIn | moduleId; + } + + pair statusResult = m_dptfManager->getDptfStatus()->getStatus(command, appStatusIn); + + eEsifError resultCode = statusResult.second; + setResultCode(resultCode); + if (resultCode == ESIF_OK) + { + setResultMessage(statusResult.first); + } +} + +void StatusCommand::throwIfBadArguments(const CommandArguments& arguments) +{ + if (arguments.size() < 2) + { + string description = string("Invalid argument count given."); + setResultMessage(description); + throw command_failure(ESIF_E_INVALID_ARGUMENT_COUNT, description); + } +} diff --git a/DPTF/Sources/Manager/UiGetGroupsCommand.h b/DPTF/Sources/Manager/StatusCommand.h similarity index 85% rename from DPTF/Sources/Manager/UiGetGroupsCommand.h rename to DPTF/Sources/Manager/StatusCommand.h index cc5034f9..dd1e684c 100644 --- a/DPTF/Sources/Manager/UiGetGroupsCommand.h +++ b/DPTF/Sources/Manager/StatusCommand.h @@ -16,17 +16,18 @@ ** ******************************************************************************/ #pragma once + #include "CommandHandler.h" +#include "PolicyManagerInterface.h" -class dptf_export UiGetGroupsCommand : public CommandHandler +class dptf_export StatusCommand : public CommandHandler { public: - UiGetGroupsCommand(DptfManagerInterface* dptfManager); - virtual ~UiGetGroupsCommand(); + StatusCommand(DptfManagerInterface* dptfManager); + virtual ~StatusCommand(); virtual std::string getCommandName() const override; virtual void execute(const CommandArguments& arguments) override; private: void throwIfBadArguments(const CommandArguments& arguments); - std::string getGroups() const; }; diff --git a/DPTF/Sources/Manager/SupportedDynamicPolicyList.cpp b/DPTF/Sources/Manager/SupportedDynamicPolicyList.cpp index 7501e79b..22720ea2 100644 --- a/DPTF/Sources/Manager/SupportedDynamicPolicyList.cpp +++ b/DPTF/Sources/Manager/SupportedDynamicPolicyList.cpp @@ -101,13 +101,12 @@ void SupportedDynamicPolicyList::update(void) } catch (const exception& ex) { - MANAGER_LOG_MESSAGE_WARNING_EX( - { - stringstream message; - message << ex.what(); - ManagerMessage warningMessage = ManagerMessage(m_dptfManager, _file, _line, _function, message.str()); - return warningMessage; - }); + MANAGER_LOG_MESSAGE_WARNING_EX({ + stringstream message; + message << ex.what(); + ManagerMessage warningMessage = ManagerMessage(m_dptfManager, _file, _line, _function, message.str()); + return warningMessage; + }); m_dynamicPolicyList.clear(); } diff --git a/DPTF/Sources/Manager/TableObject.cpp b/DPTF/Sources/Manager/TableObject.cpp index 6f994e57..1533f7c5 100644 --- a/DPTF/Sources/Manager/TableObject.cpp +++ b/DPTF/Sources/Manager/TableObject.cpp @@ -18,25 +18,18 @@ #include "TableObject.h" #include "StatusFormat.h" +#include "XmlNode.h" using namespace std; TableObject::TableObject( TableObjectType::Type type, - map> fieldsMap, + vector fields, vector> dataVaultPathForGet, - vector> dataVaultPathForSet, - std::set revisionsUsingEsifDataVariant, - UInt32 supportedMode, - esif_primitive_type_t readPrimitive, - Bool isParticipantTable) + vector> dataVaultPathForSet) : m_type(type) - , m_fieldsMap(fieldsMap) + , m_fields(fields) , m_dataVaultPathForGet(dataVaultPathForGet) , m_dataVaultPathForSet(dataVaultPathForSet) - , m_revisionsUsingEsifDataVariant(revisionsUsingEsifDataVariant) - , m_supportedMode(supportedMode) - , m_readPrimitive(readPrimitive) - , m_isParticipantTable(isParticipantTable) { } @@ -59,9 +52,9 @@ TableObjectType::Type TableObject::getType() const return m_type; } -const map>& TableObject::getFieldsMap() const +vector TableObject::getFields() const { - return m_fieldsMap; + return m_fields; } vector> TableObject::dataVaultPathForGet() const @@ -74,12 +67,7 @@ vector> TableObject::dataVaultPathForSet() con return m_dataVaultPathForSet; } -esif_primitive_type_t TableObject::getReadTablePrimitive() const -{ - return m_readPrimitive; -} - -string TableObject::getXmlString() +string TableObject::getXmlString(UInt32 supportedRevision) { if (m_data.size()) { @@ -88,25 +76,39 @@ string TableObject::getXmlString() auto remain_bytes = m_data.size(); auto resultRoot = XmlNode::createWrapperElement("result"); - auto revision = (u32)obj->integer.value; - - if (m_fieldsMap.find(0) != m_fieldsMap.end()) + auto revision = (u64)obj->integer.value; + if (revision == supportedRevision) { - revision = 0; - } + obj = (union esif_data_variant*)((u8*)obj + sizeof(*obj)); - vector fields; + remain_bytes -= sizeof(*obj); - if (m_fieldsMap.find(revision) != m_fieldsMap.end()) - { - addRevisionFields(remain_bytes, obj, fields, resultRoot, revision); - addModeFields(remain_bytes, obj, fields, resultRoot); + resultRoot->addChild(XmlNode::createDataElement("revision", StatusFormat::friendlyValue(revision))); - if (addValueFields(remain_bytes, obj, fields, resultRoot, revision) == false) + while (remain_bytes >= sizeof(*obj)) { - return "TableObject field datatype not supported."; + auto rowRoot = XmlNode::createWrapperElement("row"); + for (auto field = m_fields.begin(); field != m_fields.end(); field++) + { + remain_bytes -= sizeof(*obj); + if (field->m_fieldDataType == ESIF_DATA_UINT64) + { + UInt64 int64FieldValue = (u64)obj->integer.value; + obj = (union esif_data_variant*)((u8*)obj + sizeof(*obj)); + rowRoot->addChild(XmlNode::createDataElement( + field->m_fieldLabel, StatusFormat::friendlyValue(int64FieldValue))); + } + else if (field->m_fieldDataType == ESIF_DATA_STRING) + { + char* strFieldValue = (char*)((u8*)obj + sizeof(*obj)); + remain_bytes -= obj->string.length; + obj = (union esif_data_variant*)((u8*)obj + (sizeof(*obj) + obj->string.length)); + rowRoot->addChild(XmlNode::createDataElement(field->m_fieldLabel, strFieldValue)); + } + } + resultRoot->addChild(rowRoot); } - + return resultRoot->toString(); } else @@ -119,174 +121,3 @@ string TableObject::getXmlString() return "TableObject is empty."; } } - -void TableObject::addRevisionFields( - UInt32& remain_bytes, - esif_data_variant*& obj, - vector& fields, - shared_ptr& resultRoot, - UInt32 revision) -{ - if (m_fieldsMap.find(revision) != m_fieldsMap.end() && revision != 0) - { - obj = (union esif_data_variant*)((u8*)obj + sizeof(*obj)); - remain_bytes -= sizeof(*obj); - resultRoot->addChild(XmlNode::createDataElement("revision", StatusFormat::friendlyValue(revision))); - fields = m_fieldsMap.find(revision)->second; - } - else - { - const auto result = m_fieldsMap.find(0); - if (result != m_fieldsMap.end()) - { - fields = result->second; - } - else - { - throw dptf_exception("Failed to find field mapping for revision 0"s); - } - } -} - -void TableObject::addModeFields( - UInt32& remain_bytes, - esif_data_variant*& obj, - vector& fields, - shared_ptr& resultRoot) -{ - if (m_supportedMode) - { - auto mode = (u64)obj->integer.value; - obj = (union esif_data_variant*)((u8*)obj + sizeof(*obj)); - remain_bytes -= sizeof(*obj); - resultRoot->addChild(XmlNode::createDataElement("mode", StatusFormat::friendlyValue(mode))); - } -} - -Bool TableObject::addValueFields( - UInt32& remain_bytes, - esif_data_variant*& obj, - vector& fields, - shared_ptr& resultRoot, - UInt32 revision) -{ - if (isUsingEsifDataVariant(revision)) - { - return addValueFieldsWithEsifDataVariant(remain_bytes, obj, fields, resultRoot); - } - else - { - return addValueFieldsWithOutEsifDataVariant(remain_bytes, obj, fields, resultRoot); - } -} - -Bool TableObject::addValueFieldsWithEsifDataVariant( - UInt32& remain_bytes, - esif_data_variant*& obj, - vector& fields, - shared_ptr& resultRoot) -{ - while (remain_bytes >= sizeof(*obj)) - { - auto rowRoot = XmlNode::createWrapperElement("row"); - for (auto field = fields.begin(); field != fields.end(); field++) - { - remain_bytes -= sizeof(*obj); - if (obj->type == ESIF_DATA_UINT64) - { - UInt64 int64FieldValue = (u64)obj->integer.value; - obj = (union esif_data_variant*)((u8*)obj + sizeof(*obj)); - rowRoot->addChild( - XmlNode::createDataElement(field->m_fieldLabel, StatusFormat::friendlyValue(int64FieldValue))); - } - else if (obj->type == ESIF_DATA_UINT32) - { - UInt32 int32FieldValue = (u32)obj->integer.value; - obj = (union esif_data_variant*)((u8*)obj + sizeof(*obj)); - rowRoot->addChild( - XmlNode::createDataElement(field->m_fieldLabel, StatusFormat::friendlyValue(int32FieldValue))); - } - else if (obj->type == ESIF_DATA_STRING) - { - char* strFieldValue = (char*)((u8*)obj + sizeof(*obj)); - remain_bytes -= obj->string.length; - obj = (union esif_data_variant*)((u8*)obj + (sizeof(*obj) + obj->string.length)); - rowRoot->addChild(XmlNode::createDataElement(field->m_fieldLabel, strFieldValue)); - } - else - { - return false; - } - } - resultRoot->addChild(rowRoot); - } - - return true; -} - -Bool TableObject::addValueFieldsWithOutEsifDataVariant( - UInt32& remain_bytes, - esif_data_variant*& obj, - vector& fields, - shared_ptr& resultRoot) -{ - char* data = (char*)obj; - - while (remain_bytes > 0) - { - auto rowRoot = XmlNode::createWrapperElement("row"); - for (auto field = fields.begin(); field != fields.end(); field++) - { - if (field->m_fieldDataType == ESIF_DATA_UINT64) - { - UInt64* int64FieldValue = reinterpret_cast(data); - remain_bytes -= sizeof(*int64FieldValue); - data = data + sizeof(*int64FieldValue); - rowRoot->addChild( - XmlNode::createDataElement(field->m_fieldLabel, StatusFormat::friendlyValue(*int64FieldValue))); - } - else if (field->m_fieldDataType == ESIF_DATA_UINT32) - { - UInt32* int32FieldValue = reinterpret_cast(data); - remain_bytes -= sizeof(*int32FieldValue); - data = data + sizeof(*int32FieldValue); - rowRoot->addChild( - XmlNode::createDataElement(field->m_fieldLabel, StatusFormat::friendlyValue(*int32FieldValue))); - } - else if (field->m_fieldDataType == ESIF_DATA_STRING) - { - char* strFieldValue = data; - remain_bytes -= field->m_fieldLength; - data = data + field->m_fieldLength; - rowRoot->addChild(XmlNode::createDataElement(field->m_fieldLabel, strFieldValue)); - } - else - { - return false; - } - } - resultRoot->addChild(rowRoot); - } - - return true; -} - -const Bool TableObject::isParticipantTable() const -{ - return m_isParticipantTable; -} - -const Bool TableObject::hasRevisionField() const -{ - return m_fieldsMap.find(0) == m_fieldsMap.end(); -} - -const Bool TableObject::hasModeField() const -{ - return (m_supportedMode > 0); -} - -const Bool TableObject::isUsingEsifDataVariant(UInt64 revision) const -{ - return m_revisionsUsingEsifDataVariant.find(revision) != m_revisionsUsingEsifDataVariant.end(); -} \ No newline at end of file diff --git a/DPTF/Sources/Manager/TableObject.h b/DPTF/Sources/Manager/TableObject.h index bd0c076d..ba3679d2 100644 --- a/DPTF/Sources/Manager/TableObject.h +++ b/DPTF/Sources/Manager/TableObject.h @@ -21,80 +21,32 @@ #include "TableObjectType.h" #include "DataVaultType.h" #include "DptfBuffer.h" -#include "esif_sdk_primitive_type.h" -#include "XmlNode.h" class dptf_export TableObject { public: TableObject( TableObjectType::Type type, - std::map> fieldsMap, + std::vector fields, std::vector> dataVaultPathForGet, - std::vector> dataVaultPathForSet, - std::set revisionsUsingEsifDataVariant, - UInt32 supportedMode = 0, - esif_primitive_type_t readPrimitive = (esif_primitive_type_t)0, - Bool isParticipantTable = false); + std::vector> dataVaultPathForSet); ~TableObject(); TableObjectType::Type getType() const; - const std::map>& getFieldsMap() const; + std::vector getFields() const; std::vector> dataVaultPathForGet() const; std::vector> dataVaultPathForSet() const; - esif_primitive_type_t getReadTablePrimitive() const; const DptfBuffer& getData() const; void setData(const DptfBuffer& data); - std::string getXmlString(); - - const Bool isParticipantTable() const; - const Bool hasRevisionField() const; - const Bool hasModeField() const; - const Bool isUsingEsifDataVariant(UInt64 revision) const; + std::string getXmlString(UInt32 supportedRevision); private: - - void addRevisionFields( - UInt32& remain_bytes, - esif_data_variant*& obj, - std::vector& fields, - std::shared_ptr& resultRoot, - UInt32 revision); - - void addModeFields( - UInt32& remain_bytes, - esif_data_variant*& obj, - std::vector& fields, - std::shared_ptr& resultRoot); - - Bool addValueFields( - UInt32& remain_bytes, - esif_data_variant*& obj, - std::vector& fields, - std::shared_ptr& resultRoot, - UInt32 revision); - - Bool addValueFieldsWithEsifDataVariant( - UInt32& remain_bytes, - esif_data_variant*& obj, - std::vector& fields, - std::shared_ptr& resultRoot); - - Bool addValueFieldsWithOutEsifDataVariant( - UInt32& remain_bytes, - esif_data_variant*& obj, - std::vector& fields, - std::shared_ptr& resultRoot); - TableObjectType::Type m_type; - std::map> m_fieldsMap; + std::vector m_fields; std::vector> m_dataVaultPathForGet; std::vector> m_dataVaultPathForSet; - std::set m_revisionsUsingEsifDataVariant; - UInt32 m_supportedMode; - esif_primitive_type m_readPrimitive; + DptfBuffer m_data; - Bool m_isParticipantTable; }; diff --git a/DPTF/Sources/Manager/TableObjectBinaryTableParser.cpp b/DPTF/Sources/Manager/TableObjectBinaryTableParser.cpp deleted file mode 100644 index aad237d6..00000000 --- a/DPTF/Sources/Manager/TableObjectBinaryTableParser.cpp +++ /dev/null @@ -1,143 +0,0 @@ -/****************************************************************************** -** Copyright (c) 2013-2022 Intel Corporation All Rights Reserved -** -** Licensed under the Apache License, Version 2.0 (the "License"); you may not -** use this file except in compliance with the License. -** -** You may obtain a copy of the License at -** http://www.apache.org/licenses/LICENSE-2.0 -** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -** WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** -** See the License for the specific language governing permissions and -** limitations under the License. -** -******************************************************************************/ -#include "TableObjectBinaryTableParser.h" -#include "StringConverter.h" - -using namespace std; - - -TableObjectBinaryTableParser::TableObjectBinaryTableParser(const TableObject& tableFormat, const std::string& input) - : m_tableFormat(tableFormat) - , m_input(input) -{ -} - -DptfBuffer TableObjectBinaryTableParser::extractTable() const -{ - DptfBuffer tableData; - tableData.append(extractRevision()); - tableData.append(extractMode()); - tableData.append(extractRows()); - return tableData; -} - -DptfBuffer TableObjectBinaryTableParser::extractRevision() const -{ - DptfBuffer tableData; - if (m_tableFormat.hasRevisionField()) - { - UInt32 reserved = 4; - tableData.append((UInt8*)&reserved, sizeof(reserved)); - UInt64 revision = StringConverter::toUInt64(m_input.getRevision()); - tableData.append((UInt8*)&revision, sizeof(revision)); - } - return tableData; -} - -DptfBuffer TableObjectBinaryTableParser::extractMode() const -{ - DptfBuffer tableData; - if (m_tableFormat.hasModeField()) - { - UInt32 reserved = 4; - tableData.append((UInt8*)&reserved, sizeof(reserved)); - UInt64 mode = StringConverter::toUInt64(m_input.getMode()); - tableData.append((UInt8*)&mode, sizeof(mode)); - } - return tableData; -} - -DptfBuffer TableObjectBinaryTableParser::extractRows() const -{ - DptfBuffer tableData; - const auto tableObjectFields = m_tableFormat.getFieldsMap().find(getRevisionValue()); - if (tableObjectFields != m_tableFormat.getFieldsMap().end()) - { - const auto inputRows = m_input.getRows(); - for (auto& inputRow : inputRows) - { - tableData.append(extractRow(inputRow, tableObjectFields->second)); - } - } - return tableData; -} - -DptfBuffer TableObjectBinaryTableParser::extractRow( - const std::vector& inputRow, - const std::vector& fieldDefinitions) const -{ - DptfBuffer rowData; - if (inputRow.size() == fieldDefinitions.size()) - { - for (UInt32 i = 0; i < inputRow.size(); ++i) - { - rowData.append(extractField(inputRow[i], fieldDefinitions[i])); - } - } - return rowData; -} - -DptfBuffer TableObjectBinaryTableParser::extractField( - const std::string& fieldValue, - const TableObjectField& fieldDefinition) const -{ - if (fieldDefinition.m_fieldDataType == ESIF_DATA_STRING) - { - return extractFieldString(fieldValue, fieldDefinition); - } - else - { - return extractFieldNumber(fieldValue, fieldDefinition); - } -} - -DptfBuffer TableObjectBinaryTableParser::extractFieldString( - const std::string& fieldValue, - const TableObjectField& fieldDefinition) const -{ - DptfBuffer fieldData(fieldDefinition.m_fieldLength); - fieldData.put(0, (UInt8*)fieldValue.data(), (UInt32)fieldValue.size()); - return fieldData; -} - -DptfBuffer TableObjectBinaryTableParser::extractFieldNumber( - const std::string& fieldValue, - const TableObjectField& fieldDefinition) const -{ - if (fieldDefinition.m_fieldLength <= 8) - { - UInt64 fieldDataValue = StringConverter::toUInt64(fieldValue); - DptfBuffer fieldData = - DptfBuffer::fromExistingByteArray((UInt8*)&fieldDataValue, fieldDefinition.m_fieldLength); - return fieldData; - } - else - { - return {}; - } -} - -UInt64 TableObjectBinaryTableParser::getRevisionValue() const -{ - UInt64 revision = 0; - if (m_tableFormat.hasRevisionField()) - { - revision = StringConverter::toUInt64(m_input.getRevision()); - } - return revision; -} diff --git a/DPTF/Sources/Manager/TableObjectBinaryTableParser.h b/DPTF/Sources/Manager/TableObjectBinaryTableParser.h deleted file mode 100644 index cc62fb49..00000000 --- a/DPTF/Sources/Manager/TableObjectBinaryTableParser.h +++ /dev/null @@ -1,45 +0,0 @@ -/****************************************************************************** -** Copyright (c) 2013-2022 Intel Corporation All Rights Reserved -** -** Licensed under the Apache License, Version 2.0 (the "License"); you may not -** use this file except in compliance with the License. -** -** You may obtain a copy of the License at -** http://www.apache.org/licenses/LICENSE-2.0 -** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -** WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** -** See the License for the specific language governing permissions and -** limitations under the License. -** -******************************************************************************/ -#pragma once -#include -#include -#include "Dptf.h" -#include "TableObject.h" -#include "TableObjectInputString.h" - -class dptf_export TableObjectBinaryTableParser -{ -public: - TableObjectBinaryTableParser(const TableObject& tableFormat, const std::string& input); - virtual ~TableObjectBinaryTableParser() = default; - - DptfBuffer extractTable() const; - -private: - TableObject m_tableFormat; - TableObjectInputString m_input; - - DptfBuffer extractRevision() const; - DptfBuffer extractMode() const; - DptfBuffer extractRows() const; - DptfBuffer extractRow(const std::vector& inputRow, const std::vector& fieldDefinitions) const; - DptfBuffer extractField(const std::string& fieldValue, const TableObjectField& fieldDefinition) const; - DptfBuffer extractFieldString(const std::string& fieldValue, const TableObjectField& fieldDefinition) const; - DptfBuffer extractFieldNumber(const std::string& fieldValue, const TableObjectField& fieldDefinition) const; - UInt64 getRevisionValue() const; -}; diff --git a/DPTF/Sources/Manager/TableObjectCommand.h b/DPTF/Sources/Manager/TableObjectCommand.h index c6b776bf..60e09846 100644 --- a/DPTF/Sources/Manager/TableObjectCommand.h +++ b/DPTF/Sources/Manager/TableObjectCommand.h @@ -15,7 +15,6 @@ ** limitations under the License. ** ******************************************************************************/ -#pragma once #include "CommandHandler.h" #include "CommandDispatcher.h" diff --git a/DPTF/Sources/Manager/TableObjectDeleteCommand.cpp b/DPTF/Sources/Manager/TableObjectDeleteCommand.cpp index 78bf5c7e..3a69ee9d 100644 --- a/DPTF/Sources/Manager/TableObjectDeleteCommand.cpp +++ b/DPTF/Sources/Manager/TableObjectDeleteCommand.cpp @@ -18,7 +18,6 @@ #include "TableObjectDeleteCommand.h" #include "DptfManagerInterface.h" #include "DataManager.h" -#include "ParticipantManagerInterface.h" using namespace std; TableObjectDeleteCommand::TableObjectDeleteCommand(DptfManagerInterface* dptfManager) @@ -37,39 +36,13 @@ string TableObjectDeleteCommand::getCommandName() const void TableObjectDeleteCommand::execute(const CommandArguments& arguments) { - setDefaultResultMessage(); - throwIfBadArguments(arguments); throwIfTableObjectNotExist(arguments); auto tableName = arguments[1].getDataAsString(); string uuid = Constants::EmptyString; string all = Constants::EmptyString; - Bool isParticipantTable = m_dptfManager->getDataManager()->isParticipantTable(TableObjectType::ToType(tableName)); - - if (isParticipantTable) - { - // tableobject delete vsct VIR1 - // tableobject delete vsct VIR1 all - throwIfBadArgumentsForParticipantTable(arguments); - throwIfParticipantNotExist(arguments); - - string participantName = arguments[2].getDataAsString(); - UIntN participantIndex = - m_dptfManager->getParticipantManager()->getParticipant(participantName)->getParticipantIndex(); - - if (arguments.size() > 3 && arguments[3].getDataAsString() == "all") - { - m_dptfManager->getDataManager()->deleteAllTableObject( - TableObjectType::ToType(tableName), uuid, participantIndex); - } - else - { - m_dptfManager->getDataManager()->deleteTableObject( - TableObjectType::ToType(tableName), uuid, participantIndex); - } - } - else if (arguments.size() > 3) + if (arguments.size() > 3) { if (arguments[3].getDataAsString() == "all") { @@ -97,7 +70,6 @@ void TableObjectDeleteCommand::execute(const CommandArguments& arguments) // tableobject delete apat m_dptfManager->getDataManager()->deleteTableObject(TableObjectType::ToType(tableName), uuid); } - setResultCode(ESIF_OK); } @@ -133,26 +105,3 @@ void TableObjectDeleteCommand::throwIfTableObjectNotExist(const CommandArguments throw command_failure(ESIF_E_NOT_FOUND, description); } } - -void TableObjectDeleteCommand::throwIfParticipantNotExist(const CommandArguments& arguments) -{ - auto participantExists = m_dptfManager->getParticipantManager()->participantExists(arguments[2].getDataAsString()); - if (participantExists == false) - { - string description = string("The participant specified was not found."); - setResultMessage(description); - throw command_failure(ESIF_E_NOT_FOUND, description); - } -} - -void TableObjectDeleteCommand::throwIfBadArgumentsForParticipantTable(const CommandArguments& arguments) -{ - if (arguments.size() < 3) - { - string description = string( - "Invalid argument count given to 'tableobject delete' command for a participant table. " - "Run 'dptf help' command for more information."); - setResultMessage(description); - throw command_failure(ESIF_E_INVALID_ARGUMENT_COUNT, description); - } -} \ No newline at end of file diff --git a/DPTF/Sources/Manager/TableObjectDeleteCommand.h b/DPTF/Sources/Manager/TableObjectDeleteCommand.h index bd8bd687..bec87624 100644 --- a/DPTF/Sources/Manager/TableObjectDeleteCommand.h +++ b/DPTF/Sources/Manager/TableObjectDeleteCommand.h @@ -15,7 +15,6 @@ ** limitations under the License. ** ******************************************************************************/ -#pragma once #include "CommandHandler.h" class dptf_export TableObjectDeleteCommand : public CommandHandler @@ -29,6 +28,4 @@ class dptf_export TableObjectDeleteCommand : public CommandHandler private: void throwIfBadArguments(const CommandArguments& arguments); void throwIfTableObjectNotExist(const CommandArguments& arguments); - void throwIfParticipantNotExist(const CommandArguments& arguments); - void throwIfBadArgumentsForParticipantTable(const CommandArguments& arguments); }; diff --git a/DPTF/Sources/Manager/TableObjectField.h b/DPTF/Sources/Manager/TableObjectField.h index a0e25493..fb6b9f59 100644 --- a/DPTF/Sources/Manager/TableObjectField.h +++ b/DPTF/Sources/Manager/TableObjectField.h @@ -22,13 +22,11 @@ class TableObjectField final { public: - TableObjectField(std::string name, std::string label, esif_data_type dataType, bool isPowerLimit = false, UInt32 fieldLength = 64) + TableObjectField(std::string name, std::string label, esif_data_type dataType) { m_fieldName = name; m_fieldLabel = label; m_fieldDataType = dataType; - m_isPowerLimit = isPowerLimit; - m_fieldLength = fieldLength; } ~TableObjectField() @@ -38,6 +36,4 @@ class TableObjectField final std::string m_fieldName; std::string m_fieldLabel; esif_data_type m_fieldDataType; - UInt32 m_fieldLength; - bool m_isPowerLimit; }; diff --git a/DPTF/Sources/Manager/TableObjectGetCommand.cpp b/DPTF/Sources/Manager/TableObjectGetCommand.cpp index 4d88b8ac..787bde85 100644 --- a/DPTF/Sources/Manager/TableObjectGetCommand.cpp +++ b/DPTF/Sources/Manager/TableObjectGetCommand.cpp @@ -18,7 +18,6 @@ #include "TableObjectGetCommand.h" #include "DptfManagerInterface.h" #include "DataManager.h" -#include "ParticipantManagerInterface.h" using namespace std; TableObjectGetCommand::TableObjectGetCommand(DptfManagerInterface* dptfManager) @@ -40,22 +39,9 @@ void TableObjectGetCommand::execute(const CommandArguments& arguments) throwIfBadArguments(arguments); throwIfTableObjectNotExist(arguments); - try - { - auto results = getTableObjectXmlString(arguments); - setResultMessage(results); - setResultCode(ESIF_OK); - } - catch (const command_failure& cf) - { - throw cf; - } - catch (...) - { - string message = string("Error generating TableObject XML."); - setResultMessage(message); - throw command_failure(ESIF_E_UNSPECIFIED, message); - } + auto results = getTableObjectXmlString(arguments); + setResultMessage(results); + setResultCode(ESIF_OK); } string TableObjectGetCommand::getTableObjectXmlString(const CommandArguments& arguments) @@ -64,40 +50,29 @@ string TableObjectGetCommand::getTableObjectXmlString(const CommandArguments& ar string uuid = Constants::EmptyString; auto dataManager = m_dptfManager->getDataManager(); auto tableType = TableObjectType::ToType(tableName); - Bool isParticipantTable = m_dptfManager->getDataManager()->isParticipantTable(TableObjectType::ToType(tableName)); + auto revision = dataManager->getLatestSupportedTableRevision(tableType); - if (isParticipantTable) - { - // tableobject get vsct VIR1 - throwIfBadArgumentsForParticipantTable(arguments); - throwIfParticipantNotExist(arguments); - - string participantName = arguments[2].getDataAsString(); - UIntN participantIndex = - m_dptfManager->getParticipantManager()->getParticipant(participantName)->getParticipantIndex(); - - return dataManager->getTableObject(tableType, uuid, participantIndex).getXmlString(); - } - else if (arguments.size() > 3) + if (arguments.size() > 3) { auto dvName = arguments[2].getDataAsString(); auto dvType = DataVaultType::ToType(dvName); auto key = arguments[3].getDataAsString(); // tableobject get itmt override /shared/tables/itmt/test - return dataManager->getTableObjectBasedOnAlternativeDataSourceAndKey(tableType, dvType, key).getXmlString(); + return dataManager->getTableObjectBasedOnAlternativeDataSourceAndKey(tableType, dvType, key) + .getXmlString(revision); } else if (arguments.size() == 3) { uuid = arguments[2].getDataAsString(); // tableobject get apat uuid - return dataManager->getTableObject(tableType, uuid).getXmlString(); + return dataManager->getTableObject(tableType, uuid).getXmlString(revision); } else { // tableobject get apat - return dataManager->getTableObject(tableType, uuid).getXmlString(); + return dataManager->getTableObject(tableType, uuid).getXmlString(revision); } } @@ -133,26 +108,3 @@ void TableObjectGetCommand::throwIfTableObjectNotExist(const CommandArguments& a throw command_failure(ESIF_E_NOT_FOUND, description); } } - -void TableObjectGetCommand::throwIfParticipantNotExist(const CommandArguments& arguments) -{ - auto participantExists = m_dptfManager->getParticipantManager()->participantExists(arguments[2].getDataAsString()); - if (participantExists == false) - { - string description = string("The participant specified was not found."); - setResultMessage(description); - throw command_failure(ESIF_E_NOT_FOUND, description); - } -} - -void TableObjectGetCommand::throwIfBadArgumentsForParticipantTable(const CommandArguments& arguments) -{ - if (arguments.size() < 3) - { - string description = string( - "Invalid argument count given to 'tableobject get' command for a participant table. " - "Run 'dptf help' command for more information."); - setResultMessage(description); - throw command_failure(ESIF_E_INVALID_ARGUMENT_COUNT, description); - } -} \ No newline at end of file diff --git a/DPTF/Sources/Manager/TableObjectGetCommand.h b/DPTF/Sources/Manager/TableObjectGetCommand.h index 32809fa6..348cada6 100644 --- a/DPTF/Sources/Manager/TableObjectGetCommand.h +++ b/DPTF/Sources/Manager/TableObjectGetCommand.h @@ -15,7 +15,6 @@ ** limitations under the License. ** ******************************************************************************/ -#pragma once #include "CommandHandler.h" class dptf_export TableObjectGetCommand : public CommandHandler @@ -29,7 +28,5 @@ class dptf_export TableObjectGetCommand : public CommandHandler private: void throwIfBadArguments(const CommandArguments& arguments); void throwIfTableObjectNotExist(const CommandArguments& arguments); - void throwIfParticipantNotExist(const CommandArguments& arguments); - void throwIfBadArgumentsForParticipantTable(const CommandArguments& arguments); std::string getTableObjectXmlString(const CommandArguments& arguments); }; diff --git a/DPTF/Sources/Manager/TableObjectInputString.cpp b/DPTF/Sources/Manager/TableObjectInputString.cpp deleted file mode 100644 index dfc61353..00000000 --- a/DPTF/Sources/Manager/TableObjectInputString.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/****************************************************************************** -** Copyright (c) 2013-2022 Intel Corporation All Rights Reserved -** -** Licensed under the Apache License, Version 2.0 (the "License"); you may not -** use this file except in compliance with the License. -** -** You may obtain a copy of the License at -** http://www.apache.org/licenses/LICENSE-2.0 -** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -** WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** -** See the License for the specific language governing permissions and -** limitations under the License. -** -******************************************************************************/ -#include "TableObjectInputString.h" -#include "StringParser.h" -using namespace std; - -#define DELIMITER_ROW '!' -#define DELIMITER_FIELD ',' -#define DELIMITER_REVISION_MODE ':' - -TableObjectInputString::TableObjectInputString(const std::string& input) - : m_input(input) -{ - -} - -std::string TableObjectInputString::getRevision() const -{ - const auto pieces = StringParser::split(m_input, DELIMITER_REVISION_MODE); - if (pieces.size() > 1) - { - return pieces[0]; - } - else - { - return {}; - } -} - -std::string TableObjectInputString::getMode() const -{ - const auto pieces = StringParser::split(m_input, DELIMITER_REVISION_MODE); - if (pieces.size() > 2) - { - return pieces[1]; - } - else - { - return {}; - } -} - -vector> TableObjectInputString::getRows() const -{ - const size_t inputRowStartPosition = std::min(m_input.find_last_of(DELIMITER_REVISION_MODE) + 1, m_input.size()); - const auto rows = StringParser::split(m_input.substr(inputRowStartPosition), DELIMITER_ROW); - vector> rowsAndFields(rows.size()); - for (auto& row : rows) - { - rowsAndFields.push_back(StringParser::split(row, DELIMITER_FIELD)); - } - return rowsAndFields; -} diff --git a/DPTF/Sources/Manager/TableObjectSetCommand.cpp b/DPTF/Sources/Manager/TableObjectSetCommand.cpp index 442ec25b..d7cabb3b 100644 --- a/DPTF/Sources/Manager/TableObjectSetCommand.cpp +++ b/DPTF/Sources/Manager/TableObjectSetCommand.cpp @@ -19,13 +19,12 @@ #include "DptfManagerInterface.h" #include "DataManager.h" #include "esif_ccb_string.h" -#include "ParticipantManagerInterface.h" -#include "TableObjectBinaryTableParser.h" +#include "esif_ccb_memtrace.h" using namespace std; #define REVISION_INDICATOR_LENGTH 2 -#define MODE_INDICATOR_LENGTH 2 #define COLUMN_MAX_SIZE 64 +#define MIN_BUFFER_LENGTH 1 TableObjectSetCommand::TableObjectSetCommand(DptfManagerInterface* dptfManager) : CommandHandler(dptfManager) @@ -43,8 +42,6 @@ string TableObjectSetCommand::getCommandName() const void TableObjectSetCommand::execute(const CommandArguments& arguments) { - setDefaultResultMessage(); - throwIfBadArguments(arguments); throwIfTableObjectNotExist(arguments); @@ -59,21 +56,8 @@ void TableObjectSetCommand::setTableObjectXmlString(const CommandArguments& argu string uuid = Constants::EmptyString; string dvName = Constants::EmptyString; string key = Constants::EmptyString; - UIntN participantIndex = Constants::Esif::NoParticipant; - Bool isParticipantTable = m_dptfManager->getDataManager()->isParticipantTable(TableObjectType::ToType(tableName)); - if (isParticipantTable) - { - // tableobject set vsct VIR1 "value" - throwIfBadArgumentsForParticipantTable(arguments); - throwIfParticipantNotExist(arguments); - - string participantName = arguments[2].getDataAsString(); - participantIndex = - m_dptfManager->getParticipantManager()->getParticipant(participantName)->getParticipantIndex(); - tableString = arguments[3].getDataAsString(); - } - else if (arguments.size() == 4) + if (arguments.size() == 4) { // tableobject set apat "value" uuid uuid = arguments[3].getDataAsString(); @@ -86,9 +70,9 @@ void TableObjectSetCommand::setTableObjectXmlString(const CommandArguments& argu } auto textInput = tableString.c_str(); - if (esif_ccb_strlen(textInput, REVISION_INDICATOR_LENGTH + 1) > 0) + if (esif_ccb_strlen(textInput, REVISION_INDICATOR_LENGTH + 1) > REVISION_INDICATOR_LENGTH) { - convertToBinaryAndSet(TableObjectType::ToType(tableName), textInput, uuid, dvName, key, participantIndex); + convertToBinaryAndSet(TableObjectType::ToType(tableName), textInput, uuid, dvName, key); } } @@ -97,48 +81,14 @@ void TableObjectSetCommand::convertToBinaryAndSet( const char* textInput, string uuid, string dvName, - string key, - UIntN participantIndex) + string key) { auto table = m_dptfManager->getDataManager()->getTableObjectMap().find(tableType)->second; - char revisionNumString[REVISION_INDICATOR_LENGTH + 1]; - UInt64 revisionNumInt = 0; - - if (table.hasRevisionField()) - { - esif_ccb_memcpy(&revisionNumString, textInput, REVISION_INDICATOR_LENGTH); - revisionNumString[REVISION_INDICATOR_LENGTH] = '\0'; - revisionNumInt = extractInteger(revisionNumString); - } - - if (table.isUsingEsifDataVariant(revisionNumInt)) - { - convertToEsifDataVariantBinaryAndSet(tableType, textInput, uuid, dvName, key, participantIndex); - } - else - { - convertToNonEsifDataVariantBinaryAndSet(tableType, textInput, uuid, dvName, key, participantIndex); - } - -} - -void TableObjectSetCommand::convertToEsifDataVariantBinaryAndSet( - TableObjectType::Type tableType, - const char* textInput, - string uuid, - string dvName, - string key, - UIntN participantIndex) -{ - TableObject table = findTableObjectByType(tableType); - auto fieldsMap = table.getFieldsMap(); - vector fields; + auto fields = table.getFields(); size_t numberOfFields = 0; int fieldIndex = 0; char revisionNumString[REVISION_INDICATOR_LENGTH + 1]; UInt64 revisionNumInt = 0; - char modeNumString[MODE_INDICATOR_LENGTH + 1]; - UInt64 modeNumInt = 0; UInt32 totalDataOutputLength = 0; UInt32 stringType = ESIF_DATA_STRING; UInt32 numberType = ESIF_DATA_UINT64; @@ -159,64 +109,23 @@ void TableObjectSetCommand::convertToEsifDataVariantBinaryAndSet( try { - if (table.hasRevisionField()) - { - esif_ccb_memcpy(&revisionNumString, textInput, REVISION_INDICATOR_LENGTH); - revisionNumString[REVISION_INDICATOR_LENGTH] = '\0'; - textInput += REVISION_INDICATOR_LENGTH + 1; - revisionNumInt = extractInteger(revisionNumString); - totalDataOutputLength += sizeof(numberType) + sizeof(revisionNumInt); - tableData = (u8*)esif_ccb_malloc(totalDataOutputLength); - throwIfFailedToAllocateMemory(tableData); - - dataOutput = tableData; - esif_ccb_memcpy(dataOutput, &numberType, sizeof(numberType)); - dataOutput += sizeof(numberType); - counter += sizeof(numberType); - esif_ccb_memcpy(dataOutput, &revisionNumInt, sizeof(revisionNumInt)); - dataOutput += sizeof(revisionNumInt); - counter += sizeof(revisionNumInt); - - if (fieldsMap.find(revisionNumInt) != fieldsMap.end()) - { - fields = fieldsMap.find(revisionNumInt)->second; - } - } - else if (fieldsMap.find(0) != fieldsMap.end()) - { - fields = fieldsMap.find(0)->second; - } - else - { - string description = string( - "Invalid/Unsupported revision detected" - "Run 'dptf help' command for more information."); - setResultMessage(description); - throw command_failure(ESIF_E_COMMAND_DATA_INVALID, description); - } - - if (table.hasModeField()) - { - esif_ccb_memcpy(&modeNumString, textInput, MODE_INDICATOR_LENGTH); - modeNumString[MODE_INDICATOR_LENGTH] = '\0'; - textInput += MODE_INDICATOR_LENGTH + 1; - - modeNumInt = extractInteger(modeNumString); - totalDataOutputLength += sizeof(numberType) + (UInt32)sizeof(modeNumInt); - newTableData = (u8*)esif_ccb_realloc(tableData, totalDataOutputLength); - throwIfFailedToAllocateMemory(newTableData); - tableData = newTableData; - dataOutput = tableData; - dataOutput += counter; - esif_ccb_memcpy(dataOutput, &numberType, sizeof(numberType)); - dataOutput += sizeof(numberType); - counter += sizeof(numberType); - esif_ccb_memcpy(dataOutput, &modeNumInt, sizeof(modeNumInt)); - dataOutput += sizeof(modeNumInt); - counter += sizeof(modeNumInt); - } + esif_ccb_memcpy(&revisionNumString, textInput, REVISION_INDICATOR_LENGTH); + revisionNumString[REVISION_INDICATOR_LENGTH] = '\0'; + textInput += REVISION_INDICATOR_LENGTH + 1; + revisionNumInt = extractInteger(revisionNumString); + totalDataOutputLength += sizeof(numberType) + sizeof(revisionNumInt); + tableData = (u8*)esif_ccb_malloc(totalDataOutputLength); + throwIfFailedToAllocateMemory(tableData); numberOfFields = fields.size(); + dataOutput = tableData; + esif_ccb_memcpy(dataOutput, &numberType, sizeof(numberType)); + dataOutput += sizeof(numberType); + counter += sizeof(numberType); + esif_ccb_memcpy(dataOutput, &revisionNumInt, sizeof(revisionNumInt)); + dataOutput += sizeof(revisionNumInt); + counter += sizeof(revisionNumInt); + tableRow = esif_ccb_strtok((char*)textInput, rowDelimiter, &rowToken); while (tableRow != NULL) @@ -238,17 +147,7 @@ void TableObjectSetCommand::convertToEsifDataVariantBinaryAndSet( *temp = 0; } - esif_data_type targetType; - if (fields[fieldIndex].m_isPowerLimit) - { - targetType = (extractInteger(tableColumnValue) > 0 || strcmp(tableColumnValue, "0") == 0) - ? ESIF_DATA_UINT64 - : ESIF_DATA_STRING; - } - else - { - targetType = fields[fieldIndex].m_fieldDataType; - } + auto targetType = fields[fieldIndex].m_fieldDataType; switch (targetType) { @@ -287,7 +186,7 @@ void TableObjectSetCommand::convertToEsifDataVariantBinaryAndSet( counter += sizeof(columnValueNumber); break; default: - throw command_failure(ESIF_E_NOT_FOUND, "TableObject field type not recognized."s); + break; } } @@ -302,12 +201,7 @@ void TableObjectSetCommand::convertToEsifDataVariantBinaryAndSet( tableRow = esif_ccb_strtok(NULL, rowDelimiter, &rowToken); } - if (tableData) - { - DptfBuffer tableDataBuffer(totalDataOutputLength); - tableDataBuffer.put(0, tableData, totalDataOutputLength); - setTableData(tableDataBuffer, tableType, uuid, dvName, key, participantIndex); - } + setTableData(totalDataOutputLength, tableData, tableType, uuid, dvName, key); } catch (command_failure& cmd_failure) { @@ -322,28 +216,6 @@ void TableObjectSetCommand::convertToEsifDataVariantBinaryAndSet( esif_ccb_free(tableColumnValue); } -void TableObjectSetCommand::convertToNonEsifDataVariantBinaryAndSet( - TableObjectType::Type tableType, - const char* textInput, - string uuid, - string dvName, - string key, - UIntN participantIndex) -{ - const auto tableObjectMap = m_dptfManager->getDataManager()->getTableObjectMap(); - const auto table = tableObjectMap.find(tableType); - if (table != tableObjectMap.end()) - { - TableObjectBinaryTableParser tableParser(table->second, textInput); - DptfBuffer tableData = tableParser.extractTable(); - setTableData(tableData, tableType, uuid, dvName, key, participantIndex); - } - else - { - throw dptf_exception("Unable to find table object definition for "s + TableObjectType::ToString(tableType)); - } -} - UInt32 TableObjectSetCommand::extractInteger(const esif_string str) { UInt32 val = 0; @@ -362,40 +234,37 @@ UInt32 TableObjectSetCommand::extractInteger(const esif_string str) } void TableObjectSetCommand::setTableData( - const DptfBuffer& tableData, + UInt32 totalDataOutputLength, + UInt8* tableData, TableObjectType::Type tableType, string uuid, string dvName, - string key, - UIntN participantIndex) + string key) { + UInt32 tableDataLength = MIN_BUFFER_LENGTH; + UInt8* finalTableData = NULL; + + if (totalDataOutputLength) + { + tableDataLength = totalDataOutputLength; + } + + finalTableData = (u8*)esif_ccb_malloc(tableDataLength); + throwIfFailedToAllocateMemory(finalTableData); + esif_ccb_memcpy((u8*)finalTableData, (u8*)tableData, tableDataLength); + if (dvName != Constants::EmptyString && key != Constants::EmptyString) { auto dvType = DataVaultType::ToType(dvName); m_dptfManager->getDataManager()->setTableObjectBasedOnAlternativeDataSourceAndKey( - tableData, tableType, dvType, key); + tableDataLength, finalTableData, tableType, dvType, key); } else { - m_dptfManager->getDataManager()->setTableObject( - tableData, tableType, uuid, participantIndex); + m_dptfManager->getDataManager()->setTableObject(tableDataLength, finalTableData, tableType, uuid); } -} -TableObject TableObjectSetCommand::findTableObjectByType(TableObjectType::Type type) const -{ - auto dataManager = m_dptfManager->getDataManager(); - if (dataManager) - { - auto tableObjectMap = dataManager->getTableObjectMap(); - auto tableObject = tableObjectMap.find(type); - if (tableObject != tableObjectMap.end()) - { - return tableObject->second; - } - } - - throw dptf_exception("Could not find TableObject for type "s + TableObjectType::ToString(type)); + esif_ccb_free(finalTableData); } void TableObjectSetCommand::throwIfBadArguments(const CommandArguments& arguments) @@ -451,26 +320,3 @@ void TableObjectSetCommand::throwIfFailedToAllocateMemory(UInt8* tableData) throw command_failure(ESIF_E_NO_MEMORY, description); } } - -void TableObjectSetCommand::throwIfParticipantNotExist(const CommandArguments& arguments) -{ - auto participantExists = m_dptfManager->getParticipantManager()->participantExists(arguments[2].getDataAsString()); - if (participantExists == false) - { - string description = string("The participant specified was not found."); - setResultMessage(description); - throw command_failure(ESIF_E_NOT_FOUND, description); - } -} - -void TableObjectSetCommand::throwIfBadArgumentsForParticipantTable(const CommandArguments& arguments) -{ - if (arguments.size() < 4) - { - string description = string( - "Invalid argument count given to 'tableobject set' command for a participant table. " - "Run 'dptf help' command for more information."); - setResultMessage(description); - throw command_failure(ESIF_E_INVALID_ARGUMENT_COUNT, description); - } -} \ No newline at end of file diff --git a/DPTF/Sources/Manager/TableObjectSetCommand.h b/DPTF/Sources/Manager/TableObjectSetCommand.h index 323b9519..4a100c76 100644 --- a/DPTF/Sources/Manager/TableObjectSetCommand.h +++ b/DPTF/Sources/Manager/TableObjectSetCommand.h @@ -15,10 +15,8 @@ ** limitations under the License. ** ******************************************************************************/ -#pragma once #include "CommandHandler.h" #include "TableObjectType.h" -class TableObject; class dptf_export TableObjectSetCommand : public CommandHandler { @@ -33,37 +31,19 @@ class dptf_export TableObjectSetCommand : public CommandHandler void throwIfTableObjectNotExist(const CommandArguments& arguments); void throwIfFailedToAllocateMemory(char* tableValue); void throwIfFailedToAllocateMemory(UInt8* tableValue); - void throwIfParticipantNotExist(const CommandArguments& arguments); - void throwIfBadArgumentsForParticipantTable(const CommandArguments& arguments); void setTableObjectXmlString(const CommandArguments& arguments); void convertToBinaryAndSet( TableObjectType::Type tableType, const char* textInput, std::string uuid, std::string dvName, - std::string key, - UIntN participantIndex); - void convertToEsifDataVariantBinaryAndSet( - TableObjectType::Type tableType, - const char* textInput, - std::string uuid, - std::string dvName, - std::string key, - UIntN participantIndex); - void convertToNonEsifDataVariantBinaryAndSet( - TableObjectType::Type tableType, - const char* textInput, - std::string uuid, - std::string dvName, - std::string key, - UIntN participantIndex); + std::string key); UInt32 extractInteger(const esif_string str); void setTableData( - const DptfBuffer& tableData, + UInt32 totalBytesNeeded, + UInt8* tableMem, TableObjectType::Type tableType, std::string uuid, std::string dvName, - std::string key, - UIntN participantIndex); - TableObject findTableObjectByType(TableObjectType::Type type) const; + std::string key); }; diff --git a/DPTF/Sources/Manager/TableObjectType.cpp b/DPTF/Sources/Manager/TableObjectType.cpp index d68e28a9..507eee56 100644 --- a/DPTF/Sources/Manager/TableObjectType.cpp +++ b/DPTF/Sources/Manager/TableObjectType.cpp @@ -23,50 +23,22 @@ std::string TableObjectType::ToString(TableObjectType::Type type) { switch (type) { - case Acpr: - return "acpr"; case Apat: return "apat"; case Apct: return "apct"; - case Art: - return "_art"; - case Ddrf: - return "ddrf"; case Dynamic_Idsp: return "dynamic-idsp"; - case Epot: - return "epot"; + case Ddrf: + return "ddrf"; case Itmt: return "itmt"; - case Odvp: - return "odvp"; - case Pbat: - return "pbat"; - case Pbct: - return "pbct"; - case Pbmt: - return "pbmt"; - case Pida: - return "pida"; - case Psh2: - return "psh2"; - case Psha: - return "psha"; - case Psvt: - return "psvt"; - case SwOemVariables: - return "sw-oem-variables"; + case Epot: + return "epot"; case Tpga: return "tpga"; - case Trt: - return "_trt"; - case Vsct: - return "vsct"; - case Vspt: - return "vspt"; - case Vtmt: - return "uvth"; + case SwOemVariables: + return "sw-oem-variables"; default: throw dptf_exception("Invalid table type."); } @@ -74,11 +46,7 @@ std::string TableObjectType::ToString(TableObjectType::Type type) TableObjectType::Type TableObjectType::ToType(std::string value) { - if (value == "acpr") - { - return TableObjectType::Acpr; - } - else if (value == "apat") + if (value == "apat") { return TableObjectType::Apat; } @@ -86,84 +54,32 @@ TableObjectType::Type TableObjectType::ToType(std::string value) { return TableObjectType::Apct; } - else if ((value == "art") || (value == "_art")) - { - return TableObjectType::Art; - } - else if (value == "ddrf") - { - return TableObjectType::Ddrf; - } else if (value == "dynamic-idsp") { return TableObjectType::Dynamic_Idsp; } - else if (value == "epot") + else if (value == "ddrf") { - return TableObjectType::Epot; + return TableObjectType::Ddrf; } else if (value == "itmt") { return TableObjectType::Itmt; } - else if (value == "odvp") - { - return TableObjectType::Odvp; - } - else if (value == "pbat") - { - return TableObjectType::Pbat; - } - else if (value == "pbct") - { - return TableObjectType::Pbct; - } - else if (value == "pbmt") - { - return TableObjectType::Pbmt; - } - else if (value == "pida") - { - return TableObjectType::Pida; - } - else if (value == "psh2") - { - return TableObjectType::Psh2; - } - else if (value == "psha") - { - return TableObjectType::Psha; - } - else if (value == "psvt") - { - return TableObjectType::Psvt; - } - else if (value == "sw-oem-variables") + else if (value == "epot") { - return TableObjectType::SwOemVariables; + return TableObjectType::Epot; } else if (value == "tpga") { return TableObjectType::Tpga; } - else if ((value == "trt") || (value == "_trt")) - { - return TableObjectType::Trt; - } - else if (value == "vsct") - { - return TableObjectType::Vsct; - } - else if (value == "vspt") - { - return TableObjectType::Vspt; - } - else if (value == "vtmt") + else if (value == "sw-oem-variables") { - return TableObjectType::Vtmt; + return TableObjectType::SwOemVariables; } else { throw dptf_exception("Invalid table name."); } -} \ No newline at end of file +} diff --git a/DPTF/Sources/Manager/TableObjectType.h b/DPTF/Sources/Manager/TableObjectType.h index 213e0c84..6d397a5e 100644 --- a/DPTF/Sources/Manager/TableObjectType.h +++ b/DPTF/Sources/Manager/TableObjectType.h @@ -23,28 +23,14 @@ namespace TableObjectType { enum Type { - Acpr, Apat, Apct, - Art, - Ddrf, Dynamic_Idsp, - Epot, + Ddrf, Itmt, - Odvp, - Pbat, - Pbct, - Pbmt, - Pida, - Psh2, - Psha, - Psvt, - SwOemVariables, + Epot, Tpga, - Trt, - Vsct, - Vspt, - Vtmt + SwOemVariables }; std::string ToString(TableObjectType::Type type); diff --git a/DPTF/Sources/Manager/UiCommand.cpp b/DPTF/Sources/Manager/UiCommand.cpp deleted file mode 100644 index 60f4d151..00000000 --- a/DPTF/Sources/Manager/UiCommand.cpp +++ /dev/null @@ -1,106 +0,0 @@ -/****************************************************************************** -** Copyright (c) 2013-2022 Intel Corporation All Rights Reserved -** -** Licensed under the Apache License, Version 2.0 (the "License"); you may not -** use this file except in compliance with the License. -** -** You may obtain a copy of the License at -** http://www.apache.org/licenses/LICENSE-2.0 -** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -** WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** -** See the License for the specific language governing permissions and -** limitations under the License. -** -******************************************************************************/ -#include "UiCommand.h" -#include "PolicyManagerInterface.h" -#include "CommandDispatcher.h" -#include "UiGetGroupsCommand.h" -#include "UiGetModuleDataCommand.h" -#include "UiGetModulesInGroupCommand.h" - -using namespace std; - -UiCommand::UiCommand(DptfManagerInterface* dptfManager) - : CommandHandler(dptfManager) -{ - m_commandDispatcher = make_shared(); - createSubCommands(); - registerSubCommands(); -} - -UiCommand::~UiCommand() -{ - m_subCommands.clear(); -} - -void UiCommand::createSubCommands() -{ - m_subCommands.push_back(make_shared(m_dptfManager)); - m_subCommands.push_back(make_shared(m_dptfManager)); - m_subCommands.push_back(make_shared(m_dptfManager)); -} - -void UiCommand::registerSubCommands() -{ - for (auto c = m_subCommands.begin(); c != m_subCommands.end(); ++c) - { - m_commandDispatcher->registerHandler((*c)->getCommandName(), *c); - } -} - -string UiCommand::getCommandName() const -{ - return "ui"; -} - -void UiCommand::execute(const CommandArguments& arguments) -{ - try - { - throwIfInvalidArgumentCount(arguments); - throwIfInvalidArgumentData(arguments); - throwIfInvalidCommand(arguments); - CommandArguments subArguments = arguments; - subArguments.remove(0); - m_commandDispatcher->dispatch(subArguments); - setResultCode(m_commandDispatcher->getLastReturnCode()); - setResultMessage(m_commandDispatcher->getLastSuccessfulCommandMessage()); - } - catch (const command_failure& cf) - { - setResultCode(cf.getErrorCode()); - setResultMessage(cf.getDescription()); - throw cf; - } -} - -void UiCommand::throwIfInvalidCommand(const CommandArguments& arguments) const -{ - const auto subCommandText = arguments[1].getDataAsString(); - if (!m_commandDispatcher->isCommandRegistered(subCommandText)) - { - throw command_failure(ESIF_E_COMMAND_DATA_INVALID, "Subcommand given for ui command not found."); - } -} - -void UiCommand::throwIfInvalidArgumentData(const CommandArguments& arguments) -{ - if (arguments[1].isDataTypeString() == false) - { - throw command_failure( - ESIF_E_COMMAND_DATA_INVALID, "Invalid argument type given to 'ui' command. Expected a string."); - } -} - -void UiCommand::throwIfInvalidArgumentCount(const CommandArguments& arguments) -{ - // arguments[0] = 'ui', arguments[1] = the intended sub command. So expect minimum of 2 arguments. - if (arguments.size() < 2) - { - throw command_failure(ESIF_E_INVALID_ARGUMENT_COUNT, "Too few arguments: expected a valid sub-command but none given."); - } -} diff --git a/DPTF/Sources/Manager/UiCommand.h b/DPTF/Sources/Manager/UiCommand.h deleted file mode 100644 index 0db62d2c..00000000 --- a/DPTF/Sources/Manager/UiCommand.h +++ /dev/null @@ -1,40 +0,0 @@ -/****************************************************************************** -** Copyright (c) 2013-2022 Intel Corporation All Rights Reserved -** -** Licensed under the Apache License, Version 2.0 (the "License"); you may not -** use this file except in compliance with the License. -** -** You may obtain a copy of the License at -** http://www.apache.org/licenses/LICENSE-2.0 -** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -** WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** -** See the License for the specific language governing permissions and -** limitations under the License. -** -******************************************************************************/ -#pragma once -#include "CommandHandler.h" - -class CommandDispatcher; - -class dptf_export UiCommand : public CommandHandler -{ -public: - UiCommand(DptfManagerInterface* dptfManager); - virtual ~UiCommand(); - virtual std::string getCommandName() const override; - virtual void execute(const CommandArguments& arguments) override; - -private: - void throwIfInvalidCommand(const CommandArguments& arguments) const; - static void throwIfInvalidArgumentData(const CommandArguments& arguments); - static void throwIfInvalidArgumentCount(const CommandArguments& arguments); - - void registerSubCommands(); - void createSubCommands(); - std::shared_ptr m_commandDispatcher; - std::list> m_subCommands; -}; diff --git a/DPTF/Sources/Manager/UiCommandTypes.cpp b/DPTF/Sources/Manager/UiCommandTypes.cpp deleted file mode 100644 index a651738a..00000000 --- a/DPTF/Sources/Manager/UiCommandTypes.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/****************************************************************************** -** Copyright (c) 2013-2022 Intel Corporation All Rights Reserved -** -** Licensed under the Apache License, Version 2.0 (the "License"); you may not -** use this file except in compliance with the License. -** -** You may obtain a copy of the License at -** http://www.apache.org/licenses/LICENSE-2.0 -** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -** WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** -** See the License for the specific language governing permissions and -** limitations under the License. -** -******************************************************************************/ -#include "UiCommandTypes.h" -#include -#include "Constants.h" - -std::string UiCommandGroupType::ToString(UiCommandGroupType::Type type) -{ - switch (type) - { - case Policies: - return "Policies"; - case Participants: - return "Participants"; - case Framework: - return "Framework"; - case Arbitrator: - return "Arbitrator"; - case System: - return "System"; - default: - return Constants::InvalidString; - } -} - -std::string UiCommandManagerModuleType::ToString(UiCommandManagerModuleType::Type type) -{ - switch (type) - { - case Events: - return "Event Status"; - case Participants: - return "Participant Status"; - case Policies: - return "Policy Status"; - case Statistics: - return "Work Item Statistics"; - default: - return Constants::InvalidString; - } -} - -std::string UiCommandSystemModuleType::ToString(UiCommandSystemModuleType::Type type) -{ - switch (type) - { - case SystemConfiguration: - // it is important that this name matches the name in the "policy" cpp file - return "System Configuration"; - default: - return Constants::InvalidString; - } -} \ No newline at end of file diff --git a/DPTF/Sources/Manager/UiCommandTypes.h b/DPTF/Sources/Manager/UiCommandTypes.h deleted file mode 100644 index cee321a5..00000000 --- a/DPTF/Sources/Manager/UiCommandTypes.h +++ /dev/null @@ -1,59 +0,0 @@ -/****************************************************************************** -** Copyright (c) 2013-2022 Intel Corporation All Rights Reserved -** -** Licensed under the Apache License, Version 2.0 (the "License"); you may not -** use this file except in compliance with the License. -** -** You may obtain a copy of the License at -** http://www.apache.org/licenses/LICENSE-2.0 -** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -** WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** -** See the License for the specific language governing permissions and -** limitations under the License. -** -******************************************************************************/ -#pragma once -#include -#include "Constants.h" - -namespace UiCommandGroupType -{ - enum Type - { - Policies = 0, - Participants = 1, - Framework = 2, - Arbitrator = 3, - System = 4, - MAX - }; - - std::string ToString(UiCommandGroupType::Type type); -} - -namespace UiCommandManagerModuleType -{ - enum Type - { - Events = 0, - Participants = 1, - Policies = 2, - Statistics = 3, - MAX - }; - - std::string ToString(UiCommandManagerModuleType::Type type); -} - -namespace UiCommandSystemModuleType -{ - enum Type - { - SystemConfiguration = 0 - }; - - std::string ToString(UiCommandSystemModuleType::Type type); -} \ No newline at end of file diff --git a/DPTF/Sources/Manager/UiGetGroupsCommand.cpp b/DPTF/Sources/Manager/UiGetGroupsCommand.cpp deleted file mode 100644 index 7f6ccfb8..00000000 --- a/DPTF/Sources/Manager/UiGetGroupsCommand.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/****************************************************************************** -** Copyright (c) 2013-2022 Intel Corporation All Rights Reserved -** -** Licensed under the Apache License, Version 2.0 (the "License"); you may not -** use this file except in compliance with the License. -** -** You may obtain a copy of the License at -** http://www.apache.org/licenses/LICENSE-2.0 -** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -** WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** -** See the License for the specific language governing permissions and -** limitations under the License. -** -******************************************************************************/ -#include "UiGetGroupsCommand.h" -#include "DptfManagerInterface.h" -#include "PolicyManagerInterface.h" -using namespace std; - -UiGetGroupsCommand::UiGetGroupsCommand(DptfManagerInterface* dptfManager) - : CommandHandler(dptfManager) -{ -} - -UiGetGroupsCommand::~UiGetGroupsCommand() -{ -} - -string UiGetGroupsCommand::getCommandName() const -{ - return "getgroups"; -} - -void UiGetGroupsCommand::execute(const CommandArguments& arguments) -{ - throwIfBadArguments(arguments); - setResultMessage(getGroups()); - setResultCode(ESIF_OK); -} - -void UiGetGroupsCommand::throwIfBadArguments(const CommandArguments& arguments) -{ - if (arguments.size() != 1) - { - setResultCode(ESIF_E_INVALID_ARGUMENT_COUNT); - string description = string( - "Invalid argument count given to 'ui getgroups' command. " - "Run 'dptf help' command for more information."); - setResultMessage(description); - throw command_failure(ESIF_E_INVALID_ARGUMENT_COUNT, description); - } -} - -std::string UiGetGroupsCommand::getGroups() const -{ - auto groups = XmlNode::createWrapperElement("groups"); - - auto group0 = XmlNode::createWrapperElement("group"); - groups->addChild(group0); - group0->addChild(XmlNode::createDataElement("id", "0")); - group0->addChild(XmlNode::createDataElement("name", "Policies")); - - auto group1 = XmlNode::createWrapperElement("group"); - groups->addChild(group1); - group1->addChild(XmlNode::createDataElement("id", "1")); - group1->addChild(XmlNode::createDataElement("name", "Participants")); - - auto group2 = XmlNode::createWrapperElement("group"); - groups->addChild(group2); - group2->addChild(XmlNode::createDataElement("id", "2")); - group2->addChild(XmlNode::createDataElement("name", "Manager")); - - auto group3 = XmlNode::createWrapperElement("group"); - groups->addChild(group3); - group3->addChild(XmlNode::createDataElement("id", "3")); - group3->addChild(XmlNode::createDataElement("name", "Arbitrator")); - - auto group4 = XmlNode::createWrapperElement("group"); - groups->addChild(group4); - group4->addChild(XmlNode::createDataElement("id", "4")); - group4->addChild(XmlNode::createDataElement("name", "System")); - - return groups->toString(); -} diff --git a/DPTF/Sources/Manager/UiGetModuleDataCommand.cpp b/DPTF/Sources/Manager/UiGetModuleDataCommand.cpp deleted file mode 100644 index f7c777d0..00000000 --- a/DPTF/Sources/Manager/UiGetModuleDataCommand.cpp +++ /dev/null @@ -1,433 +0,0 @@ -/****************************************************************************** -** Copyright (c) 2013-2022 Intel Corporation All Rights Reserved -** -** Licensed under the Apache License, Version 2.0 (the "License"); you may not -** use this file except in compliance with the License. -** -** You may obtain a copy of the License at -** http://www.apache.org/licenses/LICENSE-2.0 -** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -** WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** -** See the License for the specific language governing permissions and -** limitations under the License. -** -******************************************************************************/ -#include "UiGetModuleDataCommand.h" -#include "DptfManagerInterface.h" -#include "ParticipantManagerInterface.h" -#include "PlatformRequestHandler.h" -#include "PolicyManagerInterface.h" -#include "StatusFormat.h" -#include "StringConverter.h" -#include "UiCommandTypes.h" -#include "WorkItemQueueManagerInterface.h" -using namespace std; - -UiGetModuleDataCommand::UiGetModuleDataCommand(DptfManagerInterface* dptfManager) - : UiSubCommand(dptfManager) -{ -} - -UiGetModuleDataCommand::~UiGetModuleDataCommand() -{ -} - -string UiGetModuleDataCommand::getCommandName() const -{ - return "getmoduledata"; -} - -void UiGetModuleDataCommand::execute(const CommandArguments& arguments) -{ - try - { - throwIfBadArgumentCount(arguments); - throwIfBadArgumentData(arguments); - throwIfBadGroupNumber(arguments); - throwIfBadModuleNumber(arguments); - const UInt32 groupNumber = StringConverter::toUInt32(arguments[1].getDataAsString()); - const UInt32 moduleNumber = StringConverter::toUInt32(arguments[2].getDataAsString()); - const std::string result = getModuleData(groupNumber, moduleNumber); - setResultCode(ESIF_OK); - setResultMessage(result); - } - catch (const command_failure& e) - { - setResultCode(e.getErrorCode()); - setResultMessage(e.getDescription()); - } -} - -std::string UiGetModuleDataCommand::getModuleData(const UInt32 group, const UInt32 module) const -{ - switch (group) - { - case UiCommandGroupType::Policies: - return getModuleDataForPolicy(module); - case UiCommandGroupType::Participants: - return getModuleDataForParticipant(module); - case UiCommandGroupType::Framework: - return getModuleDataForFramework(module); - case UiCommandGroupType::Arbitrator: - return getModuleDataForArbitrator(module); - case UiCommandGroupType::System: - return getModuleDataForSystem(module); - default: - throw command_failure(ESIF_E_COMMAND_DATA_INVALID, "Invalid group ID specified."); - } -} - -std::string UiGetModuleDataCommand::getModuleDataForPolicy(const UInt32 module) const -{ - try - { - const auto policy = m_dptfManager->getPolicyManager()->getPolicyPtr(module); - return policy->getStatusAsXml(); - } - catch (...) - { - throw command_failure(ESIF_E_UNSPECIFIED, "Error getting policy status data."); - } -} - -std::string UiGetModuleDataCommand::getModuleDataForParticipant(const UInt32 module) const -{ - const auto participantDomainsList = buildParticipantDomainsList(); - const auto participantId = participantDomainsList[module].first; - const auto participantManager = m_dptfManager->getParticipantManager(); - const auto participant = participantManager->getParticipantPtr(participantId); - const auto domainId = participantDomainsList[module].second; - return participant->getStatusAsXml(domainId)->toString(); -} - -std::string UiGetModuleDataCommand::getModuleDataForFramework(const UInt32 module) const -{ - try - { - std::string status; - switch (module) - { - case UiCommandManagerModuleType::Policies: - status = getModuleDataForFrameworkPolicies(); - break; - case UiCommandManagerModuleType::Participants: - status = getModuleDataForFrameworkParticipants(); - break; - case UiCommandManagerModuleType::Events: - status = getModuleDataForFrameworkEvents(); - break; - case UiCommandManagerModuleType::Statistics: - status = getModuleDataForFrameworkStatistics(); - break; - default: - throw command_failure(ESIF_E_UNSPECIFIED, "Invalid module selected for Framework status"); - } - return status; - } - catch (const command_failure&) - { - throw; - } - catch (...) - { - throw command_failure(ESIF_E_UNSPECIFIED, "Error generating status for framework module."); - } -} - -// clang-format off -const Guid ManagerPolicyStatusFormatId(0x3E, 0x58, 0x63, 0x46, 0xF8, 0xF7, 0x45, 0x4A, 0xA8, 0xF7, 0xDE, 0x7E, 0xC6, 0xF7, 0x61, 0xA8); -// clang-format on - -std::string UiGetModuleDataCommand::getModuleDataForFrameworkPolicies() const -{ - const auto managerPolicyRoot = XmlNode::createRoot(); - managerPolicyRoot->addChild(XmlNode::createComment("format_id=" + ManagerPolicyStatusFormatId.toString())); - const auto policyStatus = XmlNode::createWrapperElement("manager_policy_status"); - policyStatus->addChild(getXmlForFrameworkLoadedPolicies()); - policyStatus->addChild(getXmlForPlatformRequests()); - managerPolicyRoot->addChild(policyStatus); - return managerPolicyRoot->toString(); -} - -void UiGetModuleDataCommand::addXmlForFrameworkPolicy(const std::shared_ptr& root) const -{ - const auto policyManager = m_dptfManager->getPolicyManager(); - const auto policyIndexes = policyManager->getPolicyIndexes(); - for (auto i = policyIndexes.begin(); i != policyIndexes.end(); ++i) - { - try - { - // do not want to add System Configuration as part of the Policies table - const auto policy = policyManager->getPolicyPtr(*i); - std::string name = policy->getName(); - if (name != UiCommandSystemModuleType::ToString(UiCommandSystemModuleType::SystemConfiguration)) - { - const auto policyRoot = XmlNode::createWrapperElement("policy"); - const auto policyIndex = XmlNode::createDataElement("policy_index", std::to_string(*i)); - policyRoot->addChild(policyIndex); - const auto policyName = XmlNode::createDataElement("policy_name", name); - policyRoot->addChild(policyName); - root->addChild(policyRoot); - } - } - catch (...) - { - // Policy not available, do not add. - } - } -} - -std::shared_ptr UiGetModuleDataCommand::getXmlForFrameworkLoadedPolicies() const -{ - const auto policyManager = m_dptfManager->getPolicyManager(); - const auto policyIndexes = policyManager->getPolicyIndexes(); - auto policiesRoot = XmlNode::createWrapperElement("policies"); - policiesRoot->addChild(XmlNode::createDataElement("policy_count", std::to_string(policyIndexes.size()))); - addXmlForFrameworkPolicy(policiesRoot); - return policiesRoot; -} - -std::shared_ptr UiGetModuleDataCommand::getXmlForPlatformRequests() const -{ - const auto requestHandler = std::dynamic_pointer_cast(m_dptfManager->getPlatformRequestHandler()); - if (requestHandler == nullptr) - throw dptf_exception("Failed to get platform request handler."); - return requestHandler->getXml(); -} - -// clang-format off -const Guid ManagerParticipantStatusFormatId(0x98, 0x3F, 0x90, 0x5D, 0x9E, 0x39, 0x93, 0x4D, 0xBC, 0xCD, 0xA1, 0xA5, 0x8F, 0x61, 0x18, 0x5F); -// clang-format on - -std::string UiGetModuleDataCommand::getModuleDataForFrameworkParticipants() const -{ - const auto managerParticipantRoot = XmlNode::createRoot(); - managerParticipantRoot->addChild( - XmlNode::createComment("format_id=" + ManagerParticipantStatusFormatId.toString())); - const auto participantStatus = XmlNode::createWrapperElement("manager_participant_status"); - participantStatus->addChild(getXmlForFrameworkLoadedParticipants()); - managerParticipantRoot->addChild(participantStatus); - return managerParticipantRoot->toString(); -} - -std::shared_ptr UiGetModuleDataCommand::getXmlForFrameworkLoadedParticipants() const -{ - const auto participantManager = m_dptfManager->getParticipantManager(); - auto participantsRoot = XmlNode::createWrapperElement("participants"); - const auto participantIndexList = participantManager->getParticipantIndexes(); - for (auto i = participantIndexList.begin(); i != participantIndexList.end(); ++i) - { - try - { - const auto participant = participantManager->getParticipantPtr(*i); - participantsRoot->addChild(participant->getXml(Constants::Invalid)); - } - catch (...) - { - // Participant not available - } - } - - return participantsRoot; -} - -std::string UiGetModuleDataCommand::getModuleDataForFrameworkEvents() const -{ - const auto policyManager = m_dptfManager->getPolicyManager(); - const auto policyManagerStatus = policyManager->getStatusAsXml(); - return policyManagerStatus->toString(); -} - -std::string UiGetModuleDataCommand::getModuleDataForFrameworkStatistics() const -{ - const auto workItemQueueManager = m_dptfManager->getWorkItemQueueManager(); - const auto workItemQueueManagerStatus = workItemQueueManager->getStatusAsXml(); - return workItemQueueManagerStatus->toString(); -} - -void UiGetModuleDataCommand::addXmlForArbitratorPolicy( - ControlFactoryType::Type type, const std::shared_ptr& root) const -{ - const auto participantManager = m_dptfManager->getParticipantManager(); - const auto participantIndexList = participantManager->getParticipantIndexes(); - const auto policyManager = m_dptfManager->getPolicyManager(); - auto policyIndexes = policyManager->getPolicyIndexes(); - for (auto policyIndex = policyIndexes.begin(); policyIndex != policyIndexes.end(); ++policyIndex) - { - try - { - const auto policy = policyManager->getPolicyPtr(*policyIndex); - const auto policyRoot = XmlNode::createWrapperElement("policy"); - const auto policyName = XmlNode::createDataElement("policy_name", policy->getName()); - policyRoot->addChild(policyName); - - for (auto participantIndex = participantIndexList.begin(); participantIndex != participantIndexList.end(); - ++participantIndex) - { - try - { - const Participant* participant = participantManager->getParticipantPtr(*participantIndex); - policyRoot->addChild(participant->getArbitrationXmlForPolicy(*policyIndex, type)); - } - catch (...) - { - // Participant not available - } - } - root->addChild(policyRoot); - } - catch (...) - { - // Policy not available, do not add. - } - } -} - -std::string UiGetModuleDataCommand::getModuleDataForArbitrator(const UInt32 module) const -{ - const auto root = XmlNode::createRoot(); - const auto type = (ControlFactoryType::Type)module; - root->addChild(XmlNode::createComment("format_id=" + - ControlFactoryType::getArbitratorFormatId(type).toString())); - - const auto arbitratorRoot = XmlNode::createWrapperElement("arbitrator_status"); - const auto numberOfUniqueDomains = buildParticipantDomainsList().size(); - arbitratorRoot->addChild(XmlNode::createDataElement( - "number_of_domains", StatusFormat::friendlyValue((UInt32)numberOfUniqueDomains))); - addXmlForArbitratorPolicy(type, arbitratorRoot); - root->addChild(arbitratorRoot); - return root->toString(); -} - -std::string UiGetModuleDataCommand::getModuleDataForSystem(const UInt32 module) const -{ - // System group "modules" are implemented as though they are policies to leverage currently implemented interfaces - // As they are not really a policy, we do not want them to appear under the Policies group - try - { - const auto policyManager = m_dptfManager->getPolicyManager(); - const auto policy = policyManager->getPolicy( - UiCommandSystemModuleType::ToString(UiCommandSystemModuleType::SystemConfiguration)); - return policy->getStatusAsXml(); - } - catch (...) - { - throw command_failure(ESIF_E_UNSPECIFIED, "Error retrieving system module data."); - } -} - -void UiGetModuleDataCommand::throwIfBadArgumentCount(const CommandArguments& arguments) -{ - if (arguments.size() != 3) - { - throw command_failure(ESIF_E_INVALID_ARGUMENT_COUNT, "Invalid argument count."); - } -} - -void UiGetModuleDataCommand::throwIfBadArgumentData(const CommandArguments& arguments) -{ - try - { - StringConverter::toUInt32(arguments[1].getDataAsString()); - StringConverter::toUInt32(arguments[2].getDataAsString()); - } - catch (...) - { - throw command_failure(ESIF_E_COMMAND_DATA_INVALID, - "Argument given is not a valid group or module ID."); - } -} - -void UiGetModuleDataCommand::throwIfBadGroupNumber(const CommandArguments& arguments) -{ - const UInt32 groupNumber = StringConverter::toUInt32(arguments[1].getDataAsString()); - if (groupNumber >= UiCommandGroupType::MAX) - { - throw command_failure(ESIF_E_COMMAND_DATA_INVALID, - "Invalid group ID specified."); - } -} - -void UiGetModuleDataCommand::throwIfBadModuleNumber(const CommandArguments& arguments) const -{ - const UInt32 group = StringConverter::toUInt32(arguments[1].getDataAsString()); - switch (group) - { - case UiCommandGroupType::Policies: - throwIfBadPolicyModule(arguments); - return; - case UiCommandGroupType::Participants: - throwIfBadParticipantModule(arguments); - return; - case UiCommandGroupType::Framework: - throwIfBadFrameworkModule(arguments); - return; - case UiCommandGroupType::Arbitrator: - throwIfBadArbitratorModule(arguments); - return; - case UiCommandGroupType::System: - throwIfBadSystemModule(arguments); - return; - default: - throw command_failure(ESIF_E_COMMAND_DATA_INVALID, "Invalid group ID specified."); - } -} - -void UiGetModuleDataCommand::throwIfBadPolicyModule(const CommandArguments& arguments) const -{ - const UInt32 module = StringConverter::toUInt32(arguments[2].getDataAsString()); - const auto policyIndexes = m_dptfManager->getPolicyManager()->getPolicyIndexes(); - const auto it = policyIndexes.find(module); - if (it == policyIndexes.end()) - { - throw command_failure(ESIF_E_COMMAND_DATA_INVALID, "Module ID for Policy is invalid."); - } - - // SystemConfiguration has its own getXml function, and does not go through this - const auto policy = m_dptfManager->getPolicyManager()->getPolicyPtr(module); - if (policy->getName() == UiCommandSystemModuleType::ToString(UiCommandSystemModuleType::SystemConfiguration)) - { - throw command_failure(ESIF_E_COMMAND_DATA_INVALID, "Invalid Module ID."); - } - -} - -void UiGetModuleDataCommand::throwIfBadParticipantModule(const CommandArguments& arguments) const -{ - const auto participantDomainsList = buildParticipantDomainsList(); - const UInt32 moduleId = StringConverter::toUInt32(arguments[2].getDataAsString()); - if (moduleId >= participantDomainsList.size()) - { - throw command_failure(ESIF_E_COMMAND_DATA_INVALID, "Invalid participant ID given."); - } -} - -void UiGetModuleDataCommand::throwIfBadFrameworkModule(const CommandArguments& arguments) -{ - const auto module = StringConverter::toUInt32(arguments[2].getDataAsString()); - if (module >= UiCommandManagerModuleType::MAX) - { - throw command_failure(ESIF_E_COMMAND_DATA_INVALID, "Invalid framework module given."); - } -} - -void UiGetModuleDataCommand::throwIfBadArbitratorModule(const CommandArguments& arguments) -{ - const auto module = StringConverter::toUInt32(arguments[2].getDataAsString()); - if (module >= ControlFactoryType::MAX) - { - throw command_failure(ESIF_E_COMMAND_DATA_INVALID, "Invalid arbitrator control type given."); - } -} - -void UiGetModuleDataCommand::throwIfBadSystemModule(const CommandArguments& arguments) -{ - const auto module = StringConverter::toUInt32(arguments[2].getDataAsString()); - if (module != UiCommandSystemModuleType::SystemConfiguration) - { - throw command_failure(ESIF_E_COMMAND_DATA_INVALID, "Invalid system module ID given."); - } -} diff --git a/DPTF/Sources/Manager/UiGetModuleDataCommand.h b/DPTF/Sources/Manager/UiGetModuleDataCommand.h deleted file mode 100644 index 51e4626c..00000000 --- a/DPTF/Sources/Manager/UiGetModuleDataCommand.h +++ /dev/null @@ -1,57 +0,0 @@ -/****************************************************************************** -** Copyright (c) 2013-2022 Intel Corporation All Rights Reserved -** -** Licensed under the Apache License, Version 2.0 (the "License"); you may not -** use this file except in compliance with the License. -** -** You may obtain a copy of the License at -** http://www.apache.org/licenses/LICENSE-2.0 -** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -** WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** -** See the License for the specific language governing permissions and -** limitations under the License. -** -******************************************************************************/ -#pragma once -#include "ControlFactoryType.h" -#include "UiSubCommand.h" -class XmlNode; - -class dptf_export UiGetModuleDataCommand : public UiSubCommand -{ -public: - UiGetModuleDataCommand(DptfManagerInterface* dptfManager); - virtual ~UiGetModuleDataCommand(); - virtual std::string getCommandName() const override; - virtual void execute(const CommandArguments& arguments) override; - -private: - static void throwIfBadArgumentCount(const CommandArguments& arguments); - static void throwIfBadArgumentData(const CommandArguments& arguments); - static void throwIfBadGroupNumber(const CommandArguments& arguments); - void throwIfBadModuleNumber(const CommandArguments& arguments) const; - void throwIfBadPolicyModule(const CommandArguments& arguments) const; - void throwIfBadParticipantModule(const CommandArguments& arguments) const; - static void throwIfBadFrameworkModule(const CommandArguments& arguments); - static void throwIfBadArbitratorModule(const CommandArguments& arguments); - static void throwIfBadSystemModule(const CommandArguments& arguments); - - std::string getModuleData(const UInt32 group, const UInt32 module) const; - std::string getModuleDataForPolicy(const UInt32 module) const; - std::string getModuleDataForParticipant(const UInt32 module) const; - std::string getModuleDataForFramework(const UInt32 module) const; - std::string getModuleDataForFrameworkPolicies() const; - void addXmlForFrameworkPolicy(const std::shared_ptr& root) const; - std::shared_ptr getXmlForFrameworkLoadedPolicies() const; - std::shared_ptr getXmlForPlatformRequests() const; - std::string getModuleDataForFrameworkParticipants() const; - std::shared_ptr getXmlForFrameworkLoadedParticipants() const; - std::string getModuleDataForFrameworkEvents() const; - std::string getModuleDataForFrameworkStatistics() const; - void addXmlForArbitratorPolicy(ControlFactoryType::Type type, const std::shared_ptr& root) const; - std::string getModuleDataForArbitrator(const UInt32 module) const; - std::string getModuleDataForSystem(const UInt32 module) const; -}; diff --git a/DPTF/Sources/Manager/UiGetModulesInGroupCommand.cpp b/DPTF/Sources/Manager/UiGetModulesInGroupCommand.cpp deleted file mode 100644 index 9677ab6c..00000000 --- a/DPTF/Sources/Manager/UiGetModulesInGroupCommand.cpp +++ /dev/null @@ -1,228 +0,0 @@ -/****************************************************************************** -** Copyright (c) 2013-2022 Intel Corporation All Rights Reserved -** -** Licensed under the Apache License, Version 2.0 (the "License"); you may not -** use this file except in compliance with the License. -** -** You may obtain a copy of the License at -** http://www.apache.org/licenses/LICENSE-2.0 -** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -** WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** -** See the License for the specific language governing permissions and -** limitations under the License. -** -******************************************************************************/ -#include "UiGetModulesInGroupCommand.h" -#include "DptfManagerInterface.h" -#include "ParticipantManagerInterface.h" -#include "PolicyManagerInterface.h" -#include "StringConverter.h" -#include "UiCommandTypes.h" -using namespace std; - -UiGetModulesInGroupCommand::UiGetModulesInGroupCommand(DptfManagerInterface* dptfManager) - : UiSubCommand(dptfManager) -{ -} - -UiGetModulesInGroupCommand::~UiGetModulesInGroupCommand() -{ -} - -string UiGetModulesInGroupCommand::getCommandName() const -{ - return "getmodulesingroup"; -} - -void UiGetModulesInGroupCommand::execute(const CommandArguments& arguments) -{ - try - { - throwIfBadArgumentNumber(arguments); - throwIfBadArgumentData(arguments); - throwIfBadGroupNumber(arguments); - const UInt32 groupNumber = StringConverter::toUInt32(arguments[1].getDataAsString()); - const std::string result = getModulesInGroup(groupNumber); - setResultCode(ESIF_OK); - setResultMessage(result); - } - catch (const command_failure& e) - { - setResultCode(e.getErrorCode()); - setResultMessage(e.getDescription()); - } -} - -std::string UiGetModulesInGroupCommand::getModulesInGroup(UInt32 groupNumber) const -{ - switch (groupNumber) - { - case UiCommandGroupType::Policies: - return getPoliciesGroup(); - case UiCommandGroupType::Participants: - return getParticipantsGroup(); - case UiCommandGroupType::Framework: - return getFrameworkGroup(); - case UiCommandGroupType::Arbitrator: - return getArbitratorGroup(); - case UiCommandGroupType::System: - return getSystemGroup(); - default: - throw command_failure(ESIF_E_COMMAND_DATA_INVALID , "Invalid group ID specified."); - } -} - -std::string UiGetModulesInGroupCommand::getPoliciesGroup() const -{ - const auto policyManager = m_dptfManager->getPolicyManager(); - const auto modules = XmlNode::createWrapperElement("modules"); - const auto policyIndexes = policyManager->getPolicyIndexes(); - for (const auto policyIndex : policyIndexes) - { - try - { - auto const module = XmlNode::createWrapperElement("module"); - module->addChild(XmlNode::createDataElement("id", std::to_string(policyIndex))); - module->addChild(XmlNode::createDataElement("name", policyManager->getPolicyPtr(policyIndex)->getName())); - modules->addChild(module); - } - catch (...) - { - // policy not available, don't add it to the list - } - } - - return modules->toString(); -} - -std::string UiGetModulesInGroupCommand::getParticipantsGroup() const -{ - const auto participantDomainsList = buildParticipantDomainsList(); - const auto participantManager = m_dptfManager->getParticipantManager(); - const auto modules = XmlNode::createWrapperElement("modules"); - for (UIntN i = 0; i < participantDomainsList.size(); i++) - { - try - { - const auto participant = participantManager->getParticipantPtr(participantDomainsList[i].first); - - std::stringstream name; - name << participant->getParticipantName(); - - if (participant->getDomainCount() > 1) - { - name << '(' << participantDomainsList[i].second << ')'; - } - - const auto module = XmlNode::createWrapperElement("module"); - module->addChild(XmlNode::createDataElement("id", std::to_string(i))); - module->addChild(XmlNode::createDataElement("name", name.str())); - modules->addChild(module); - } - catch (dptf_exception&) - { - // Participant Not available. - } - } - - return modules->toString(); -} - -std::string UiGetModulesInGroupCommand::getFrameworkGroup() const -{ - const auto modules = XmlNode::createWrapperElement("modules"); - for (UIntN moduleType = 0; moduleType < (UIntN)UiCommandManagerModuleType::Statistics; ++moduleType) - { - const auto module = XmlNode::createWrapperElement("module"); - module->addChild(XmlNode::createDataElement("id", std::to_string(moduleType))); - module->addChild(XmlNode::createDataElement("name", UiCommandManagerModuleType::ToString((UiCommandManagerModuleType::Type)moduleType))); - modules->addChild(module); - } - -#ifdef INCLUDE_WORK_ITEM_STATISTICS - // Work Item Statistics - const auto module = XmlNode::createWrapperElement("module"); - module->addChild(XmlNode::createDataElement("id", std::to_string(UiCommandManagerModuleType::Statistics))); - module->addChild(XmlNode::createDataElement("name", UiCommandManagerModuleType::ToString(UiCommandManagerModuleType::Statistics))); - modules->addChild(module); -#endif - - return modules->toString(); -} - -std::string UiGetModulesInGroupCommand::getArbitratorGroup() const -{ - const std::list> arbitratorModules = { - {ControlFactoryType::Active, ControlFactoryType::getArbitratorString(ControlFactoryType::Active)}, - {ControlFactoryType::Core, ControlFactoryType::getArbitratorString(ControlFactoryType::Core)}, - {ControlFactoryType::Display, ControlFactoryType::getArbitratorString(ControlFactoryType::Display)}, - {ControlFactoryType::PeakPowerControl, - ControlFactoryType::getArbitratorString(ControlFactoryType::PeakPowerControl)}, - {ControlFactoryType::Performance, ControlFactoryType::getArbitratorString(ControlFactoryType::Performance)}, - {ControlFactoryType::PowerControl, ControlFactoryType::getArbitratorString(ControlFactoryType::PowerControl)}, - {ControlFactoryType::ProcessorControl, - ControlFactoryType::getArbitratorString(ControlFactoryType::ProcessorControl)}, - {ControlFactoryType::SystemPower, ControlFactoryType::getArbitratorString(ControlFactoryType::SystemPower)}, - {ControlFactoryType::Temperature, ControlFactoryType::getArbitratorString(ControlFactoryType::Temperature)}}; - - auto modules = XmlNode::createWrapperElement("modules"); - for (const auto& arbitratorModule : arbitratorModules) - { - const auto module = XmlNode::createWrapperElement("module"); - module->addChild(XmlNode::createDataElement("id", std::to_string(arbitratorModule.first))); - module->addChild(XmlNode::createDataElement("name", arbitratorModule.second)); - modules->addChild(module); - } - return modules->toString(); -} - -std::string UiGetModulesInGroupCommand::getSystemGroup() const -{ - const auto modules = XmlNode::createWrapperElement("modules"); - const auto module = XmlNode::createWrapperElement("module"); - module->addChild(XmlNode::createDataElement("id", std::to_string((UIntN)UiCommandSystemModuleType::SystemConfiguration))); - module->addChild(XmlNode::createDataElement("name", UiCommandSystemModuleType::ToString(UiCommandSystemModuleType::SystemConfiguration))); - modules->addChild(module); - return modules->toString(); -} - -void UiGetModulesInGroupCommand::throwIfBadArgumentNumber(const CommandArguments& arguments) -{ - if (arguments.size() != 2) - { - string description = string( - "Invalid argument count given to 'ui getmodulesingroup' command. " - "Run 'dptf help' command for more information."); - throw command_failure(ESIF_E_INVALID_ARGUMENT_COUNT, description); - } -} - -void UiGetModulesInGroupCommand::throwIfBadArgumentData(const CommandArguments& arguments) -{ - try - { - StringConverter::toUInt32(arguments[1].getDataAsString()); - } - catch (...) - { - string description = string( - "Invalid argument given to 'ui getmodulesingroup' command. " - "Run 'dptf help' command for more information."); - throw command_failure(ESIF_E_COMMAND_DATA_INVALID, description); - } -} - -void UiGetModulesInGroupCommand::throwIfBadGroupNumber(const CommandArguments& arguments) -{ - UInt32 groupNumber = StringConverter::toUInt32(arguments[1].getDataAsString()); - if (groupNumber >= UiCommandGroupType::MAX) - { - string description = string( - "Invalid group specified to 'ui getmodulesingroup' command. " - "Run 'dptf help' command for more information."); - throw command_failure(ESIF_E_COMMAND_DATA_INVALID, description); - } -} diff --git a/DPTF/Sources/Manager/UiGetModulesInGroupCommand.h b/DPTF/Sources/Manager/UiGetModulesInGroupCommand.h deleted file mode 100644 index 4bf73d36..00000000 --- a/DPTF/Sources/Manager/UiGetModulesInGroupCommand.h +++ /dev/null @@ -1,40 +0,0 @@ -/****************************************************************************** -** Copyright (c) 2013-2022 Intel Corporation All Rights Reserved -** -** Licensed under the Apache License, Version 2.0 (the "License"); you may not -** use this file except in compliance with the License. -** -** You may obtain a copy of the License at -** http://www.apache.org/licenses/LICENSE-2.0 -** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -** WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** -** See the License for the specific language governing permissions and -** limitations under the License. -** -******************************************************************************/ -#pragma once -#include "UiSubCommand.h" - -class dptf_export UiGetModulesInGroupCommand : public UiSubCommand -{ -public: - UiGetModulesInGroupCommand(DptfManagerInterface* dptfManager); - virtual ~UiGetModulesInGroupCommand(); - virtual std::string getCommandName() const override; - - virtual void execute(const CommandArguments& arguments) override; - -private: - static void throwIfBadArgumentNumber(const CommandArguments& arguments); - static void throwIfBadArgumentData(const CommandArguments& arguments); - static void throwIfBadGroupNumber(const CommandArguments& arguments); - std::string getModulesInGroup(UInt32 groupNumber) const; - std::string getPoliciesGroup() const; - std::string getParticipantsGroup() const; - std::string getFrameworkGroup() const; - std::string getArbitratorGroup() const; - std::string getSystemGroup() const; -}; diff --git a/DPTF/Sources/Manager/UiSubCommand.cpp b/DPTF/Sources/Manager/UiSubCommand.cpp deleted file mode 100644 index f7963d55..00000000 --- a/DPTF/Sources/Manager/UiSubCommand.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/****************************************************************************** -** Copyright (c) 2013-2022 Intel Corporation All Rights Reserved -** -** Licensed under the Apache License, Version 2.0 (the "License"); you may not -** use this file except in compliance with the License. -** -** You may obtain a copy of the License at -** http://www.apache.org/licenses/LICENSE-2.0 -** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -** WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** -** See the License for the specific language governing permissions and -** limitations under the License. -** -******************************************************************************/ -#include "PolicyManagerInterface.h" -#include "UiSubCommand.h" - -#include "ParticipantManagerInterface.h" - -using namespace std; - -UiSubCommand::UiSubCommand(DptfManagerInterface* dptfManager) - : CommandHandler(dptfManager) -{ -} - -std::vector> UiSubCommand::buildParticipantDomainsList() const -{ - std::vector> participantDomainsList; - const auto participantManager = m_dptfManager->getParticipantManager(); - const auto participantIndexes = participantManager->getParticipantIndexes(); - for (auto participantIndex = participantIndexes.begin(); participantIndex != participantIndexes.end(); - ++participantIndex) - { - try - { - const auto participant = participantManager->getParticipantPtr(*participantIndex); - const UIntN domainCount = participant->getDomainCount(); - for (UIntN domainIndex = 0; domainIndex < domainCount; domainIndex++) - { - participantDomainsList.push_back(std::make_pair(*participantIndex, domainIndex)); - } - } - catch (...) - { - // participant not available, don't add it to the list - } - } - return participantDomainsList; -} \ No newline at end of file diff --git a/DPTF/Sources/Manager/UiSubCommand.h b/DPTF/Sources/Manager/UiSubCommand.h deleted file mode 100644 index 60d35cbd..00000000 --- a/DPTF/Sources/Manager/UiSubCommand.h +++ /dev/null @@ -1,31 +0,0 @@ -/****************************************************************************** -** Copyright (c) 2013-2022 Intel Corporation All Rights Reserved -** -** Licensed under the Apache License, Version 2.0 (the "License"); you may not -** use this file except in compliance with the License. -** -** You may obtain a copy of the License at -** http://www.apache.org/licenses/LICENSE-2.0 -** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -** WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** -** See the License for the specific language governing permissions and -** limitations under the License. -** -******************************************************************************/ -#pragma once -#include "CommandHandler.h" - -class CommandDispatcher; - -class dptf_export UiSubCommand : public CommandHandler -{ -public: - UiSubCommand(DptfManagerInterface* dptfManager); - virtual ~UiSubCommand() = default; - -protected: - std::vector> buildParticipantDomainsList() const; -}; diff --git a/DPTF/Sources/Manager/WIAll.h b/DPTF/Sources/Manager/WIAll.h index 50318f1d..2276ad81 100644 --- a/DPTF/Sources/Manager/WIAll.h +++ b/DPTF/Sources/Manager/WIAll.h @@ -30,6 +30,8 @@ #include "WIDomainRadioConnectionStatusChanged.h" #include "WIDomainRfProfileChanged.h" #include "WIDomainTemperatureThresholdCrossed.h" +#include "WIDomainVirtualSensorCalibrationTableChanged.h" +#include "WIDomainVirtualSensorPollingTableChanged.h" #include "WIDomainVirtualSensorRecalcChanged.h" #include "WIDomainBatteryStatusChanged.h" #include "WIDomainBatteryInformationChanged.h" @@ -56,12 +58,14 @@ #include "WIDptfConnectedStandbyExit.h" #include "WIDptfResume.h" #include "WIDptfSuspend.h" +#include "WIDptfGetStatus.h" #include "WIDptfParticipantActivityLoggingEnabled.h" #include "WIDptfParticipantActivityLoggingDisabled.h" #include "WIParticipantAllocate.h" #include "WIParticipantCreate.h" #include "WIParticipantDestroy.h" #include "WIParticipantSpecificInfoChanged.h" +#include "WIPolicyActiveRelationshipTableChanged.h" #include "WIPolicyCoolingModePolicyChanged.h" #include "WIPolicyCreateAll.h" #include "WIPolicyDestroy.h" @@ -80,19 +84,29 @@ #include "WIPolicyOperatingSystemScreenStateChanged.h" #include "WIPolicyOperatingSystemBatteryCountChanged.h" #include "WIPolicyOperatingSystemPowerSliderChanged.h" +#include "WIPolicyPassiveTableChanged.h" #include "WIPolicySensorOrientationChanged.h" #include "WIPolicySensorMotionChanged.h" #include "WIPolicySensorSpatialOrientationChanged.h" #include "WIPolicySupportedListChanged.h" +#include "WIPolicyThermalRelationshipTableChanged.h" +#include "WIPolicyOemVariablesChanged.h" +#include "WIPolicyPowerBossConditionsTableChanged.h" +#include "WIPolicyPowerBossActionsTableChanged.h" +#include "WIPolicyPowerBossMathTableChanged.h" +#include "WIPolicyVoltageThresholdMathTableChanged.h" #include "WIDptfPolicyActivityLoggingEnabled.h" #include "WIDptfPolicyActivityLoggingDisabled.h" #include "WIPolicyEmergencyCallModeTableChanged.h" +#include "WIPolicyPidAlgorithmTableChanged.h" +#include "WIPolicyActiveControlPointRelationshipTableChanged.h" +#include "WIPolicyPowerShareAlgorithmTableChanged.h" #include "WIPowerLimitChanged.h" -#include "WIPowerLimitTimeWindowChanged.h" #include "WIPerformanceCapabilitiesChanged.h" #include "WIPolicyWorkloadHintConfigurationChanged.h" #include "WIApplicationAliveRequest.h" #include "WIPolicyOperatingSystemGameModeChanged.h" +#include "WIPolicyPowerShareAlgorithmTable2Changed.h" #include "WIPolicyPlatformUserPresenceChanged.h" #include "WIPolicyExternalMonitorStateChanged.h" #include "WIPolicyUserInteractionChanged.h" diff --git a/DPTF/Sources/Manager/WIDptfGetStatus.cpp b/DPTF/Sources/Manager/WIDptfGetStatus.cpp new file mode 100644 index 00000000..1f3a15c3 --- /dev/null +++ b/DPTF/Sources/Manager/WIDptfGetStatus.cpp @@ -0,0 +1,66 @@ +/****************************************************************************** +** Copyright (c) 2013-2022 Intel Corporation All Rights Reserved +** +** Licensed under the Apache License, Version 2.0 (the "License"); you may not +** use this file except in compliance with the License. +** +** You may obtain a copy of the License at +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +** WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** +** See the License for the specific language governing permissions and +** limitations under the License. +** +******************************************************************************/ + +#include "WIDptfGetStatus.h" +#include "DptfStatusInterface.h" +#include "EsifServicesInterface.h" +#include "esif_ccb_string.h" + +WIDptfGetStatus::WIDptfGetStatus( + DptfManagerInterface* dptfManager, + const eAppStatusCommand command, + const UInt32 appStatusIn, + EsifDataPtr appStatusOut, + eEsifError* returnCode) + : WorkItem(dptfManager, FrameworkEvent::DptfGetStatus) + , m_command(command) + , m_appStatusIn(appStatusIn) + , m_appStatusOut(appStatusOut) + , m_returnCode(returnCode) +{ +} + +WIDptfGetStatus::~WIDptfGetStatus(void) +{ +} + +void WIDptfGetStatus::onExecute(void) +{ + writeWorkItemStartingInfoMessage(); + std::pair statusResult; + try + { + statusResult = getDptfManager()->getDptfStatus()->getStatus(m_command, m_appStatusIn); + } + catch (std::exception& ex) + { + writeWorkItemWarningMessage(ex, "DptfStatus::getStatus"); + } + + UIntN requiredBufferLength = static_cast(statusResult.first.length() + 1); + if (m_appStatusOut->buf_len >= requiredBufferLength) + { + esif_ccb_strcpy((char *)m_appStatusOut->buf_ptr, statusResult.first.c_str(), requiredBufferLength); + *m_returnCode = statusResult.second; + } + else + { + *m_returnCode = ESIF_E_NEED_LARGER_BUFFER; + } + m_appStatusOut->data_len = (u32)requiredBufferLength; +} diff --git a/DPTF/Sources/Manager/TableObjectInputString.h b/DPTF/Sources/Manager/WIDptfGetStatus.h similarity index 64% rename from DPTF/Sources/Manager/TableObjectInputString.h rename to DPTF/Sources/Manager/WIDptfGetStatus.h index 5707a537..64a7e2ba 100644 --- a/DPTF/Sources/Manager/TableObjectInputString.h +++ b/DPTF/Sources/Manager/WIDptfGetStatus.h @@ -15,21 +15,29 @@ ** limitations under the License. ** ******************************************************************************/ + #pragma once -#include -#include + #include "Dptf.h" +#include "WorkItem.h" +#include "esif_sdk_iface_app.h" -class dptf_export TableObjectInputString +class WIDptfGetStatus : public WorkItem { public: - TableObjectInputString(const std::string& input); - virtual ~TableObjectInputString() = default; + WIDptfGetStatus( + DptfManagerInterface* dptfManager, + const eAppStatusCommand command, + const UInt32 appStatusIn, + EsifDataPtr appStatusOut, + eEsifError* returnCode); + virtual ~WIDptfGetStatus(void); - std::string getRevision() const; - std::string getMode() const; - std::vector> getRows() const; + virtual void onExecute(void) override final; private: - std::string m_input; + const eAppStatusCommand m_command; + const UInt32 m_appStatusIn; + EsifDataPtr m_appStatusOut; + eEsifError* m_returnCode; }; diff --git a/DPTF/Sources/Manager/WIPolicyActiveControlPointRelationshipTableChanged.cpp b/DPTF/Sources/Manager/WIPolicyActiveControlPointRelationshipTableChanged.cpp new file mode 100644 index 00000000..9f12f720 --- /dev/null +++ b/DPTF/Sources/Manager/WIPolicyActiveControlPointRelationshipTableChanged.cpp @@ -0,0 +1,56 @@ +/****************************************************************************** +** Copyright (c) 2013-2022 Intel Corporation All Rights Reserved +** +** Licensed under the Apache License, Version 2.0 (the "License"); you may not +** use this file except in compliance with the License. +** +** You may obtain a copy of the License at +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +** WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** +** See the License for the specific language governing permissions and +** limitations under the License. +** +******************************************************************************/ + +#include "WIPolicyActiveControlPointRelationshipTableChanged.h" +#include "PolicyManagerInterface.h" +#include "EsifServicesInterface.h" + +WIPolicyActiveControlPointRelationshipTableChanged::WIPolicyActiveControlPointRelationshipTableChanged( + DptfManagerInterface* dptfManager) + : WorkItem(dptfManager, FrameworkEvent::PolicyActiveControlPointRelationshipTableChanged) +{ +} + +WIPolicyActiveControlPointRelationshipTableChanged::~WIPolicyActiveControlPointRelationshipTableChanged(void) +{ +} + +void WIPolicyActiveControlPointRelationshipTableChanged::onExecute(void) +{ + writeWorkItemStartingInfoMessage(); + + auto policyManager = getPolicyManager(); + auto policyIndexes = policyManager->getPolicyIndexes(); + + for (auto i = policyIndexes.begin(); i != policyIndexes.end(); ++i) + { + try + { + auto policy = policyManager->getPolicyPtr(*i); + policy->executePolicyActiveControlPointRelationshipTableChanged(); + } + catch (policy_index_invalid&) + { + // do nothing. No item in the policy list at this index. + } + catch (std::exception& ex) + { + writeWorkItemErrorMessagePolicy(ex, "Policy::executePolicyActiveControlPointRelationshipTableChanged", *i); + } + } +} diff --git a/DPTF/Sources/Manager/WIPolicyActiveControlPointRelationshipTableChanged.h b/DPTF/Sources/Manager/WIPolicyActiveControlPointRelationshipTableChanged.h new file mode 100644 index 00000000..a353738e --- /dev/null +++ b/DPTF/Sources/Manager/WIPolicyActiveControlPointRelationshipTableChanged.h @@ -0,0 +1,31 @@ +/****************************************************************************** +** Copyright (c) 2013-2022 Intel Corporation All Rights Reserved +** +** Licensed under the Apache License, Version 2.0 (the "License"); you may not +** use this file except in compliance with the License. +** +** You may obtain a copy of the License at +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +** WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** +** See the License for the specific language governing permissions and +** limitations under the License. +** +******************************************************************************/ + +#pragma once + +#include "Dptf.h" +#include "WorkItem.h" + +class WIPolicyActiveControlPointRelationshipTableChanged : public WorkItem +{ +public: + WIPolicyActiveControlPointRelationshipTableChanged(DptfManagerInterface* dptfManager); + virtual ~WIPolicyActiveControlPointRelationshipTableChanged(void); + + virtual void onExecute(void) override final; +}; diff --git a/DPTF/Sources/Manager/WIPolicyActiveRelationshipTableChanged.cpp b/DPTF/Sources/Manager/WIPolicyActiveRelationshipTableChanged.cpp new file mode 100644 index 00000000..ac76599a --- /dev/null +++ b/DPTF/Sources/Manager/WIPolicyActiveRelationshipTableChanged.cpp @@ -0,0 +1,55 @@ +/****************************************************************************** +** Copyright (c) 2013-2022 Intel Corporation All Rights Reserved +** +** Licensed under the Apache License, Version 2.0 (the "License"); you may not +** use this file except in compliance with the License. +** +** You may obtain a copy of the License at +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +** WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** +** See the License for the specific language governing permissions and +** limitations under the License. +** +******************************************************************************/ + +#include "WIPolicyActiveRelationshipTableChanged.h" +#include "PolicyManagerInterface.h" +#include "EsifServicesInterface.h" + +WIPolicyActiveRelationshipTableChanged::WIPolicyActiveRelationshipTableChanged(DptfManagerInterface* dptfManager) + : WorkItem(dptfManager, FrameworkEvent::PolicyActiveRelationshipTableChanged) +{ +} + +WIPolicyActiveRelationshipTableChanged::~WIPolicyActiveRelationshipTableChanged(void) +{ +} + +void WIPolicyActiveRelationshipTableChanged::onExecute(void) +{ + writeWorkItemStartingInfoMessage(); + + auto policyManager = getPolicyManager(); + auto policyIndexes = policyManager->getPolicyIndexes(); + + for (auto i = policyIndexes.begin(); i != policyIndexes.end(); ++i) + { + try + { + auto policy = policyManager->getPolicyPtr(*i); + policy->executePolicyActiveRelationshipTableChanged(); + } + catch (policy_index_invalid&) + { + // do nothing. No item in the policy list at this index. + } + catch (std::exception& ex) + { + writeWorkItemErrorMessagePolicy(ex, "Policy::executePolicyActiveRelationshipTableChanged", *i); + } + } +} diff --git a/DPTF/Sources/Manager/WIPowerLimitTimeWindowChanged.h b/DPTF/Sources/Manager/WIPolicyActiveRelationshipTableChanged.h similarity index 81% rename from DPTF/Sources/Manager/WIPowerLimitTimeWindowChanged.h rename to DPTF/Sources/Manager/WIPolicyActiveRelationshipTableChanged.h index c913643a..17fca92f 100644 --- a/DPTF/Sources/Manager/WIPowerLimitTimeWindowChanged.h +++ b/DPTF/Sources/Manager/WIPolicyActiveRelationshipTableChanged.h @@ -20,13 +20,12 @@ #include "Dptf.h" #include "WorkItem.h" -#include "DptfManagerInterface.h" -class WIPowerLimitTimeWindowChanged : public WorkItem +class WIPolicyActiveRelationshipTableChanged : public WorkItem { public: - WIPowerLimitTimeWindowChanged(DptfManagerInterface* dptfManager); - virtual ~WIPowerLimitTimeWindowChanged(void); + WIPolicyActiveRelationshipTableChanged(DptfManagerInterface* dptfManager); + virtual ~WIPolicyActiveRelationshipTableChanged(void); virtual void onExecute(void) override final; }; diff --git a/DPTF/Sources/Manager/WIPowerLimitTimeWindowChanged.cpp b/DPTF/Sources/Manager/WIPolicyOemVariablesChanged.cpp similarity index 73% rename from DPTF/Sources/Manager/WIPowerLimitTimeWindowChanged.cpp rename to DPTF/Sources/Manager/WIPolicyOemVariablesChanged.cpp index a8614d04..48c2495f 100644 --- a/DPTF/Sources/Manager/WIPowerLimitTimeWindowChanged.cpp +++ b/DPTF/Sources/Manager/WIPolicyOemVariablesChanged.cpp @@ -16,20 +16,20 @@ ** ******************************************************************************/ -#include "WIPowerLimitTimeWindowChanged.h" +#include "WIPolicyOemVariablesChanged.h" #include "PolicyManagerInterface.h" #include "EsifServicesInterface.h" -WIPowerLimitTimeWindowChanged::WIPowerLimitTimeWindowChanged(DptfManagerInterface* dptfManager) - : WorkItem(dptfManager, FrameworkEvent::PowerLimitTimeWindowChanged) +WIPolicyOemVariablesChanged::WIPolicyOemVariablesChanged(DptfManagerInterface* dptfManager) + : WorkItem(dptfManager, FrameworkEvent::PolicyOemVariablesChanged) { } -WIPowerLimitTimeWindowChanged::~WIPowerLimitTimeWindowChanged(void) +WIPolicyOemVariablesChanged::~WIPolicyOemVariablesChanged(void) { } -void WIPowerLimitTimeWindowChanged::onExecute(void) +void WIPolicyOemVariablesChanged::onExecute(void) { writeWorkItemStartingInfoMessage(); @@ -41,7 +41,7 @@ void WIPowerLimitTimeWindowChanged::onExecute(void) try { auto policy = policyManager->getPolicyPtr(*i); - policy->executePowerLimitTimeWindowChanged(); + policy->executePolicyOemVariablesChanged(); } catch (policy_index_invalid&) { @@ -49,7 +49,7 @@ void WIPowerLimitTimeWindowChanged::onExecute(void) } catch (std::exception& ex) { - writeWorkItemErrorMessagePolicy(ex, "Policy::executePowerLimitTimeWindowChanged", *i); + writeWorkItemErrorMessagePolicy(ex, "Policy::executePolicyOemVariablesChanged", *i); } } } diff --git a/DPTF/Sources/SharedLib/DptfTypesLib/CustomizationType.h b/DPTF/Sources/Manager/WIPolicyOemVariablesChanged.h similarity index 77% rename from DPTF/Sources/SharedLib/DptfTypesLib/CustomizationType.h rename to DPTF/Sources/Manager/WIPolicyOemVariablesChanged.h index 7a9ac74e..004447ab 100644 --- a/DPTF/Sources/SharedLib/DptfTypesLib/CustomizationType.h +++ b/DPTF/Sources/Manager/WIPolicyOemVariablesChanged.h @@ -19,15 +19,13 @@ #pragma once #include "Dptf.h" +#include "WorkItem.h" -namespace CustomizationType +class WIPolicyOemVariablesChanged : public WorkItem { - enum Type - { - PpmCustomization = 0, - Invalid - }; +public: + WIPolicyOemVariablesChanged(DptfManagerInterface* dptfManager); + virtual ~WIPolicyOemVariablesChanged(void); - std::string toString(CustomizationType::Type customizationType); - CustomizationType::Type fromString(std::string customizationType); -} + virtual void onExecute(void) override final; +}; diff --git a/DPTF/Sources/Manager/WIPolicyPassiveTableChanged.cpp b/DPTF/Sources/Manager/WIPolicyPassiveTableChanged.cpp new file mode 100644 index 00000000..4727f231 --- /dev/null +++ b/DPTF/Sources/Manager/WIPolicyPassiveTableChanged.cpp @@ -0,0 +1,55 @@ +/****************************************************************************** +** Copyright (c) 2013-2022 Intel Corporation All Rights Reserved +** +** Licensed under the Apache License, Version 2.0 (the "License"); you may not +** use this file except in compliance with the License. +** +** You may obtain a copy of the License at +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +** WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** +** See the License for the specific language governing permissions and +** limitations under the License. +** +******************************************************************************/ + +#include "WIPolicyPassiveTableChanged.h" +#include "PolicyManagerInterface.h" +#include "EsifServicesInterface.h" + +WIPolicyPassiveTableChanged::WIPolicyPassiveTableChanged(DptfManagerInterface* dptfManager) + : WorkItem(dptfManager, FrameworkEvent::PolicyPassiveTableChanged) +{ +} + +WIPolicyPassiveTableChanged::~WIPolicyPassiveTableChanged(void) +{ +} + +void WIPolicyPassiveTableChanged::onExecute(void) +{ + writeWorkItemStartingInfoMessage(); + + auto policyManager = getPolicyManager(); + auto policyIndexes = policyManager->getPolicyIndexes(); + + for (auto i = policyIndexes.begin(); i != policyIndexes.end(); ++i) + { + try + { + auto policy = policyManager->getPolicyPtr(*i); + policy->executePolicyPassiveTableChanged(); + } + catch (policy_index_invalid&) + { + // do nothing. No item in the policy list at this index. + } + catch (std::exception& ex) + { + writeWorkItemErrorMessagePolicy(ex, "Policy::executePolicyPassiveTableChanged", *i); + } + } +} diff --git a/DPTF/Sources/SharedLib/DptfTypesLib/CustomizationActionType.h b/DPTF/Sources/Manager/WIPolicyPassiveTableChanged.h similarity index 77% rename from DPTF/Sources/SharedLib/DptfTypesLib/CustomizationActionType.h rename to DPTF/Sources/Manager/WIPolicyPassiveTableChanged.h index 8eb6cd04..6bd21414 100644 --- a/DPTF/Sources/SharedLib/DptfTypesLib/CustomizationActionType.h +++ b/DPTF/Sources/Manager/WIPolicyPassiveTableChanged.h @@ -19,16 +19,13 @@ #pragma once #include "Dptf.h" +#include "WorkItem.h" -namespace CustomizationAction +class WIPolicyPassiveTableChanged : public WorkItem { - enum Type - { - PpmReset = 0, - PpmSet, - Invalid - }; +public: + WIPolicyPassiveTableChanged(DptfManagerInterface* dptfManager); + virtual ~WIPolicyPassiveTableChanged(void); - std::string toString(CustomizationAction::Type actionType); - CustomizationAction::Type fromString(std::string actionType); -} + virtual void onExecute(void) override final; +}; diff --git a/DPTF/Sources/Manager/WIPolicyPidAlgorithmTableChanged.cpp b/DPTF/Sources/Manager/WIPolicyPidAlgorithmTableChanged.cpp new file mode 100644 index 00000000..499e1f57 --- /dev/null +++ b/DPTF/Sources/Manager/WIPolicyPidAlgorithmTableChanged.cpp @@ -0,0 +1,55 @@ +/****************************************************************************** +** Copyright (c) 2013-2022 Intel Corporation All Rights Reserved +** +** Licensed under the Apache License, Version 2.0 (the "License"); you may not +** use this file except in compliance with the License. +** +** You may obtain a copy of the License at +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +** WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** +** See the License for the specific language governing permissions and +** limitations under the License. +** +******************************************************************************/ + +#include "WIPolicyPidAlgorithmTableChanged.h" +#include "PolicyManagerInterface.h" +#include "EsifServicesInterface.h" + +WIPolicyPidAlgorithmTableChanged::WIPolicyPidAlgorithmTableChanged(DptfManagerInterface* dptfManager) + : WorkItem(dptfManager, FrameworkEvent::PolicyPidAlgorithmTableChanged) +{ +} + +WIPolicyPidAlgorithmTableChanged::~WIPolicyPidAlgorithmTableChanged(void) +{ +} + +void WIPolicyPidAlgorithmTableChanged::onExecute(void) +{ + writeWorkItemStartingInfoMessage(); + + auto policyManager = getPolicyManager(); + auto policyIndexes = policyManager->getPolicyIndexes(); + + for (auto i = policyIndexes.begin(); i != policyIndexes.end(); ++i) + { + try + { + auto policy = policyManager->getPolicyPtr(*i); + policy->executePolicyPidAlgorithmTableChanged(); + } + catch (policy_index_invalid&) + { + // do nothing. No item in the policy list at this index. + } + catch (std::exception& ex) + { + writeWorkItemErrorMessagePolicy(ex, "Policy::executePolicyPidAlgorithmTableChanged", *i); + } + } +} diff --git a/DPTF/Sources/SharedLib/DptfTypesLib/SmtType.h b/DPTF/Sources/Manager/WIPolicyPidAlgorithmTableChanged.h similarity index 76% rename from DPTF/Sources/SharedLib/DptfTypesLib/SmtType.h rename to DPTF/Sources/Manager/WIPolicyPidAlgorithmTableChanged.h index 07fb76dc..33c5a2a0 100644 --- a/DPTF/Sources/SharedLib/DptfTypesLib/SmtType.h +++ b/DPTF/Sources/Manager/WIPolicyPidAlgorithmTableChanged.h @@ -19,17 +19,13 @@ #pragma once #include "Dptf.h" +#include "WorkItem.h" -namespace SmtType +class WIPolicyPidAlgorithmTableChanged : public WorkItem { - enum Type - { - NoSmt = 0, - SymmetricSmt, - AsymmetricSmt, - InvalidSmt - }; +public: + WIPolicyPidAlgorithmTableChanged(DptfManagerInterface* dptfManager); + virtual ~WIPolicyPidAlgorithmTableChanged(void); - std::string toString(SmtType::Type smtType); - SmtType::Type fromString(std::string smtType); -} + virtual void onExecute(void) override final; +}; diff --git a/DPTF/Sources/Manager/WIPolicyPowerBossActionsTableChanged.cpp b/DPTF/Sources/Manager/WIPolicyPowerBossActionsTableChanged.cpp new file mode 100644 index 00000000..cd9bad3e --- /dev/null +++ b/DPTF/Sources/Manager/WIPolicyPowerBossActionsTableChanged.cpp @@ -0,0 +1,55 @@ +/****************************************************************************** +** Copyright (c) 2013-2022 Intel Corporation All Rights Reserved +** +** Licensed under the Apache License, Version 2.0 (the "License"); you may not +** use this file except in compliance with the License. +** +** You may obtain a copy of the License at +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +** WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** +** See the License for the specific language governing permissions and +** limitations under the License. +** +******************************************************************************/ + +#include "WIPolicyPowerBossActionsTableChanged.h" +#include "PolicyManagerInterface.h" +#include "EsifServicesInterface.h" + +WIPolicyPowerBossActionsTableChanged::WIPolicyPowerBossActionsTableChanged(DptfManagerInterface* dptfManager) + : WorkItem(dptfManager, FrameworkEvent::PolicyPowerBossActionsTableChanged) +{ +} + +WIPolicyPowerBossActionsTableChanged::~WIPolicyPowerBossActionsTableChanged(void) +{ +} + +void WIPolicyPowerBossActionsTableChanged::onExecute(void) +{ + writeWorkItemStartingInfoMessage(); + + auto policyManager = getPolicyManager(); + auto policyIndexes = policyManager->getPolicyIndexes(); + + for (auto i = policyIndexes.begin(); i != policyIndexes.end(); ++i) + { + try + { + auto policy = policyManager->getPolicyPtr(*i); + policy->executePolicyPowerBossActionsTableChanged(); + } + catch (policy_index_invalid&) + { + // do nothing. No item in the policy list at this index. + } + catch (std::exception& ex) + { + writeWorkItemErrorMessagePolicy(ex, "Policy::executePolicyPowerBossActionsTableChanged", *i); + } + } +} diff --git a/DPTF/Sources/Manager/WIPolicyPowerBossActionsTableChanged.h b/DPTF/Sources/Manager/WIPolicyPowerBossActionsTableChanged.h new file mode 100644 index 00000000..a2364e6d --- /dev/null +++ b/DPTF/Sources/Manager/WIPolicyPowerBossActionsTableChanged.h @@ -0,0 +1,31 @@ +/****************************************************************************** +** Copyright (c) 2013-2022 Intel Corporation All Rights Reserved +** +** Licensed under the Apache License, Version 2.0 (the "License"); you may not +** use this file except in compliance with the License. +** +** You may obtain a copy of the License at +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +** WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** +** See the License for the specific language governing permissions and +** limitations under the License. +** +******************************************************************************/ + +#pragma once + +#include "Dptf.h" +#include "WorkItem.h" + +class WIPolicyPowerBossActionsTableChanged : public WorkItem +{ +public: + WIPolicyPowerBossActionsTableChanged(DptfManagerInterface* dptfManager); + virtual ~WIPolicyPowerBossActionsTableChanged(void); + + virtual void onExecute(void) override final; +}; diff --git a/DPTF/Sources/Manager/WIPolicyPowerBossConditionsTableChanged.cpp b/DPTF/Sources/Manager/WIPolicyPowerBossConditionsTableChanged.cpp new file mode 100644 index 00000000..452f645e --- /dev/null +++ b/DPTF/Sources/Manager/WIPolicyPowerBossConditionsTableChanged.cpp @@ -0,0 +1,55 @@ +/****************************************************************************** +** Copyright (c) 2013-2022 Intel Corporation All Rights Reserved +** +** Licensed under the Apache License, Version 2.0 (the "License"); you may not +** use this file except in compliance with the License. +** +** You may obtain a copy of the License at +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +** WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** +** See the License for the specific language governing permissions and +** limitations under the License. +** +******************************************************************************/ + +#include "WIPolicyPowerBossConditionsTableChanged.h" +#include "PolicyManagerInterface.h" +#include "EsifServicesInterface.h" + +WIPolicyPowerBossConditionsTableChanged::WIPolicyPowerBossConditionsTableChanged(DptfManagerInterface* dptfManager) + : WorkItem(dptfManager, FrameworkEvent::PolicyPowerBossConditionsTableChanged) +{ +} + +WIPolicyPowerBossConditionsTableChanged::~WIPolicyPowerBossConditionsTableChanged(void) +{ +} + +void WIPolicyPowerBossConditionsTableChanged::onExecute(void) +{ + writeWorkItemStartingInfoMessage(); + + auto policyManager = getPolicyManager(); + auto policyIndexes = policyManager->getPolicyIndexes(); + + for (auto i = policyIndexes.begin(); i != policyIndexes.end(); ++i) + { + try + { + auto policy = policyManager->getPolicyPtr(*i); + policy->executePolicyPowerBossConditionsTableChanged(); + } + catch (policy_index_invalid&) + { + // do nothing. No item in the policy list at this index. + } + catch (std::exception& ex) + { + writeWorkItemErrorMessagePolicy(ex, "Policy::executePolicyPowerBossConditionsTableChanged", *i); + } + } +} diff --git a/DPTF/Sources/SharedLib/DptfTypesLib/ForegroundRatioChoice.h b/DPTF/Sources/Manager/WIPolicyPowerBossConditionsTableChanged.h similarity index 74% rename from DPTF/Sources/SharedLib/DptfTypesLib/ForegroundRatioChoice.h rename to DPTF/Sources/Manager/WIPolicyPowerBossConditionsTableChanged.h index 8c1027c4..95e2b837 100644 --- a/DPTF/Sources/SharedLib/DptfTypesLib/ForegroundRatioChoice.h +++ b/DPTF/Sources/Manager/WIPolicyPowerBossConditionsTableChanged.h @@ -19,18 +19,13 @@ #pragma once #include "Dptf.h" +#include "WorkItem.h" -namespace ForegroundRatioChoice +class WIPolicyPowerBossConditionsTableChanged : public WorkItem { - enum Type - { - SingleCore = 0, - TotalPhysicalCores, - TotalLogicalProcessors, - TotalSmtCores, - Invalid - }; +public: + WIPolicyPowerBossConditionsTableChanged(DptfManagerInterface* dptfManager); + virtual ~WIPolicyPowerBossConditionsTableChanged(void); - std::string toString(ForegroundRatioChoice::Type choiceType); - ForegroundRatioChoice::Type fromString(std::string choice); -} + virtual void onExecute(void) override final; +}; diff --git a/DPTF/Sources/Manager/WIPolicyPowerBossMathTableChanged.cpp b/DPTF/Sources/Manager/WIPolicyPowerBossMathTableChanged.cpp new file mode 100644 index 00000000..c398aa9d --- /dev/null +++ b/DPTF/Sources/Manager/WIPolicyPowerBossMathTableChanged.cpp @@ -0,0 +1,55 @@ +/****************************************************************************** +** Copyright (c) 2013-2022 Intel Corporation All Rights Reserved +** +** Licensed under the Apache License, Version 2.0 (the "License"); you may not +** use this file except in compliance with the License. +** +** You may obtain a copy of the License at +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +** WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** +** See the License for the specific language governing permissions and +** limitations under the License. +** +******************************************************************************/ + +#include "WIPolicyPowerBossMathTableChanged.h" +#include "PolicyManagerInterface.h" +#include "EsifServicesInterface.h" + +WIPolicyPowerBossMathTableChanged::WIPolicyPowerBossMathTableChanged(DptfManagerInterface* dptfManager) + : WorkItem(dptfManager, FrameworkEvent::PolicyPowerBossMathTableChanged) +{ +} + +WIPolicyPowerBossMathTableChanged::~WIPolicyPowerBossMathTableChanged(void) +{ +} + +void WIPolicyPowerBossMathTableChanged::onExecute(void) +{ + writeWorkItemStartingInfoMessage(); + + auto policyManager = getPolicyManager(); + auto policyIndexes = policyManager->getPolicyIndexes(); + + for (auto i = policyIndexes.begin(); i != policyIndexes.end(); ++i) + { + try + { + auto policy = policyManager->getPolicyPtr(*i); + policy->executePolicyPowerBossMathTableChanged(); + } + catch (policy_index_invalid&) + { + // do nothing. No item in the policy list at this index. + } + catch (std::exception& ex) + { + writeWorkItemErrorMessagePolicy(ex, "Policy::executePolicyPowerBossMathTableChanged", *i); + } + } +} diff --git a/DPTF/Sources/Manager/WIPolicyPowerBossMathTableChanged.h b/DPTF/Sources/Manager/WIPolicyPowerBossMathTableChanged.h new file mode 100644 index 00000000..1a089bc0 --- /dev/null +++ b/DPTF/Sources/Manager/WIPolicyPowerBossMathTableChanged.h @@ -0,0 +1,31 @@ +/****************************************************************************** +** Copyright (c) 2013-2022 Intel Corporation All Rights Reserved +** +** Licensed under the Apache License, Version 2.0 (the "License"); you may not +** use this file except in compliance with the License. +** +** You may obtain a copy of the License at +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +** WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** +** See the License for the specific language governing permissions and +** limitations under the License. +** +******************************************************************************/ + +#pragma once + +#include "Dptf.h" +#include "WorkItem.h" + +class WIPolicyPowerBossMathTableChanged : public WorkItem +{ +public: + WIPolicyPowerBossMathTableChanged(DptfManagerInterface* dptfManager); + virtual ~WIPolicyPowerBossMathTableChanged(void); + + virtual void onExecute(void) override final; +}; diff --git a/DPTF/Sources/Manager/WIPolicyPowerShareAlgorithmTable2Changed.cpp b/DPTF/Sources/Manager/WIPolicyPowerShareAlgorithmTable2Changed.cpp new file mode 100644 index 00000000..8819e156 --- /dev/null +++ b/DPTF/Sources/Manager/WIPolicyPowerShareAlgorithmTable2Changed.cpp @@ -0,0 +1,55 @@ +/****************************************************************************** +** Copyright (c) 2013-2022 Intel Corporation All Rights Reserved +** +** Licensed under the Apache License, Version 2.0 (the "License"); you may not +** use this file except in compliance with the License. +** +** You may obtain a copy of the License at +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +** WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** +** See the License for the specific language governing permissions and +** limitations under the License. +** +******************************************************************************/ + +#include "WIPolicyPowerShareAlgorithmTable2Changed.h" +#include "PolicyManagerInterface.h" +#include "EsifServicesInterface.h" + +WIPolicyPowerShareAlgorithmTable2Changed::WIPolicyPowerShareAlgorithmTable2Changed(DptfManagerInterface* dptfManager) + : WorkItem(dptfManager, FrameworkEvent::PolicyPowerShareAlgorithmTable2Changed) +{ +} + +WIPolicyPowerShareAlgorithmTable2Changed::~WIPolicyPowerShareAlgorithmTable2Changed(void) +{ +} + +void WIPolicyPowerShareAlgorithmTable2Changed::onExecute(void) +{ + writeWorkItemStartingInfoMessage(); + + auto policyManager = getPolicyManager(); + auto policyIndexes = policyManager->getPolicyIndexes(); + + for (auto i = policyIndexes.begin(); i != policyIndexes.end(); ++i) + { + try + { + auto policy = policyManager->getPolicyPtr(*i); + policy->executePolicyPowerShareAlgorithmTable2Changed(); + } + catch (policy_index_invalid&) + { + // do nothing. No item in the policy list at this index. + } + catch (std::exception& ex) + { + writeWorkItemErrorMessagePolicy(ex, "Policy::executePolicyPowerShareAlgorithmTable2Changed", *i); + } + } +} diff --git a/DPTF/Sources/Manager/WIPolicyPowerShareAlgorithmTable2Changed.h b/DPTF/Sources/Manager/WIPolicyPowerShareAlgorithmTable2Changed.h new file mode 100644 index 00000000..e05d4ec4 --- /dev/null +++ b/DPTF/Sources/Manager/WIPolicyPowerShareAlgorithmTable2Changed.h @@ -0,0 +1,31 @@ +/****************************************************************************** +** Copyright (c) 2013-2022 Intel Corporation All Rights Reserved +** +** Licensed under the Apache License, Version 2.0 (the "License"); you may not +** use this file except in compliance with the License. +** +** You may obtain a copy of the License at +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +** WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** +** See the License for the specific language governing permissions and +** limitations under the License. +** +******************************************************************************/ + +#pragma once + +#include "Dptf.h" +#include "WorkItem.h" + +class WIPolicyPowerShareAlgorithmTable2Changed : public WorkItem +{ +public: + WIPolicyPowerShareAlgorithmTable2Changed(DptfManagerInterface* dptfManager); + virtual ~WIPolicyPowerShareAlgorithmTable2Changed(void); + + virtual void onExecute(void) override final; +}; diff --git a/DPTF/Sources/Manager/WIPolicyPowerShareAlgorithmTableChanged.cpp b/DPTF/Sources/Manager/WIPolicyPowerShareAlgorithmTableChanged.cpp new file mode 100644 index 00000000..39be8ec7 --- /dev/null +++ b/DPTF/Sources/Manager/WIPolicyPowerShareAlgorithmTableChanged.cpp @@ -0,0 +1,55 @@ +/****************************************************************************** +** Copyright (c) 2013-2022 Intel Corporation All Rights Reserved +** +** Licensed under the Apache License, Version 2.0 (the "License"); you may not +** use this file except in compliance with the License. +** +** You may obtain a copy of the License at +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +** WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** +** See the License for the specific language governing permissions and +** limitations under the License. +** +******************************************************************************/ + +#include "WIPolicyPowerShareAlgorithmTableChanged.h" +#include "PolicyManagerInterface.h" +#include "EsifServicesInterface.h" + +WIPolicyPowerShareAlgorithmTableChanged::WIPolicyPowerShareAlgorithmTableChanged(DptfManagerInterface* dptfManager) + : WorkItem(dptfManager, FrameworkEvent::PolicyPowerShareAlgorithmTableChanged) +{ +} + +WIPolicyPowerShareAlgorithmTableChanged::~WIPolicyPowerShareAlgorithmTableChanged(void) +{ +} + +void WIPolicyPowerShareAlgorithmTableChanged::onExecute(void) +{ + writeWorkItemStartingInfoMessage(); + + auto policyManager = getPolicyManager(); + auto policyIndexes = policyManager->getPolicyIndexes(); + + for (auto i = policyIndexes.begin(); i != policyIndexes.end(); ++i) + { + try + { + auto policy = policyManager->getPolicyPtr(*i); + policy->executePolicyPowerShareAlgorithmTableChanged(); + } + catch (policy_index_invalid&) + { + // do nothing. No item in the policy list at this index. + } + catch (std::exception& ex) + { + writeWorkItemErrorMessagePolicy(ex, "Policy::executePolicyPowerShareAlgorithmTableChanged", *i); + } + } +} diff --git a/DPTF/Sources/Manager/WIPolicyPowerShareAlgorithmTableChanged.h b/DPTF/Sources/Manager/WIPolicyPowerShareAlgorithmTableChanged.h new file mode 100644 index 00000000..c166a17e --- /dev/null +++ b/DPTF/Sources/Manager/WIPolicyPowerShareAlgorithmTableChanged.h @@ -0,0 +1,31 @@ +/****************************************************************************** +** Copyright (c) 2013-2022 Intel Corporation All Rights Reserved +** +** Licensed under the Apache License, Version 2.0 (the "License"); you may not +** use this file except in compliance with the License. +** +** You may obtain a copy of the License at +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +** WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** +** See the License for the specific language governing permissions and +** limitations under the License. +** +******************************************************************************/ + +#pragma once + +#include "Dptf.h" +#include "WorkItem.h" + +class WIPolicyPowerShareAlgorithmTableChanged : public WorkItem +{ +public: + WIPolicyPowerShareAlgorithmTableChanged(DptfManagerInterface* dptfManager); + virtual ~WIPolicyPowerShareAlgorithmTableChanged(void); + + virtual void onExecute(void) override final; +}; diff --git a/DPTF/Sources/Manager/WIPolicyTableObjectChanged.cpp b/DPTF/Sources/Manager/WIPolicyTableObjectChanged.cpp index 328a0595..41c8ed94 100644 --- a/DPTF/Sources/Manager/WIPolicyTableObjectChanged.cpp +++ b/DPTF/Sources/Manager/WIPolicyTableObjectChanged.cpp @@ -24,12 +24,10 @@ WIPolicyTableObjectChanged::WIPolicyTableObjectChanged( DptfManagerInterface* dptfManager, TableObjectType::Type tableType, - std::string uuid, - UIntN participantIndex) + std::string uuid) : WorkItem(dptfManager, FrameworkEvent::PolicyTableObjectChanged) , m_tableType(tableType) , m_uuid(uuid) - , m_participantIndex(participantIndex) { } @@ -43,7 +41,6 @@ void WIPolicyTableObjectChanged::onExecute(void) auto policyManager = getPolicyManager(); auto policyIndexes = policyManager->getPolicyIndexes(); - for (auto i = policyIndexes.begin(); i != policyIndexes.end(); ++i) { try @@ -56,66 +53,23 @@ void WIPolicyTableObjectChanged::onExecute(void) switch (m_tableType) { - case TableObjectType::Acpr: - policy->executePolicyActiveControlPointRelationshipTableChanged(); - break; case TableObjectType::Apat: policy->executePolicyAdaptivePerformanceActionsTableChanged(); break; case TableObjectType::Apct: policy->executePolicyAdaptivePerformanceConditionsTableChanged(); break; - case TableObjectType::Art: - policy->executePolicyActiveRelationshipTableChanged(); - break; case TableObjectType::Ddrf: policy->executePolicyDdrfTableChanged(); break; - case TableObjectType::Epot: - policy->executePolicyEnergyPerformanceOptimizerTableChanged(); - break; case TableObjectType::Itmt: policy->executePolicyIntelligentThermalManagementTableChanged(); break; - case TableObjectType::Odvp: - policy->executePolicyOemVariablesChanged(); - break; - case TableObjectType::Pbat: - policy->executePolicyPowerBossActionsTableChanged(); - break; - case TableObjectType::Pbct: - policy->executePolicyPowerBossConditionsTableChanged(); - break; - case TableObjectType::Pbmt: - policy->executePolicyPowerBossMathTableChanged(); - break; - case TableObjectType::Pida: - policy->executePolicyPidAlgorithmTableChanged(); - break; - case TableObjectType::Psh2: - policy->executePolicyPowerShareAlgorithmTable2Changed(); - break; - case TableObjectType::Psha: - policy->executePolicyPowerShareAlgorithmTableChanged(); - break; - case TableObjectType::Psvt: - policy->executePolicyPassiveTableChanged(); + case TableObjectType::Epot: + policy->executePolicyEnergyPerformanceOptimizerTableChanged(); break; case TableObjectType::Tpga: policy->executePolicyTpgaTableChanged(); - break; - case TableObjectType::Trt: - policy->executePolicyThermalRelationshipTableChanged(); - break; - case TableObjectType::Vsct: - policy->executeDomainVirtualSensorCalibrationTableChanged(m_participantIndex); - break; - case TableObjectType::Vspt: - policy->executeDomainVirtualSensorPollingTableChanged(m_participantIndex); - break; - case TableObjectType::Vtmt: - policy->executePolicyVoltageThresholdMathTableChanged(); - break; default: break; } diff --git a/DPTF/Sources/Manager/WIPolicyTableObjectChanged.h b/DPTF/Sources/Manager/WIPolicyTableObjectChanged.h index 9454a44d..520e23ae 100644 --- a/DPTF/Sources/Manager/WIPolicyTableObjectChanged.h +++ b/DPTF/Sources/Manager/WIPolicyTableObjectChanged.h @@ -25,11 +25,7 @@ class WIPolicyTableObjectChanged : public WorkItem { public: - WIPolicyTableObjectChanged( - DptfManagerInterface* dptfManager, - TableObjectType::Type tableType, - std::string uuid, - UIntN participantIndex); + WIPolicyTableObjectChanged(DptfManagerInterface* dptfManager, TableObjectType::Type tableType, std::string uuid); virtual ~WIPolicyTableObjectChanged(void); virtual void onExecute(void) override final; @@ -37,5 +33,4 @@ class WIPolicyTableObjectChanged : public WorkItem private: TableObjectType::Type m_tableType; std::string m_uuid; - UIntN m_participantIndex; }; diff --git a/DPTF/Sources/Manager/WIPolicyThermalRelationshipTableChanged.cpp b/DPTF/Sources/Manager/WIPolicyThermalRelationshipTableChanged.cpp new file mode 100644 index 00000000..01912932 --- /dev/null +++ b/DPTF/Sources/Manager/WIPolicyThermalRelationshipTableChanged.cpp @@ -0,0 +1,55 @@ +/****************************************************************************** +** Copyright (c) 2013-2022 Intel Corporation All Rights Reserved +** +** Licensed under the Apache License, Version 2.0 (the "License"); you may not +** use this file except in compliance with the License. +** +** You may obtain a copy of the License at +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +** WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** +** See the License for the specific language governing permissions and +** limitations under the License. +** +******************************************************************************/ + +#include "WIPolicyThermalRelationshipTableChanged.h" +#include "PolicyManagerInterface.h" +#include "EsifServicesInterface.h" + +WIPolicyThermalRelationshipTableChanged::WIPolicyThermalRelationshipTableChanged(DptfManagerInterface* dptfManager) + : WorkItem(dptfManager, FrameworkEvent::PolicyThermalRelationshipTableChanged) +{ +} + +WIPolicyThermalRelationshipTableChanged::~WIPolicyThermalRelationshipTableChanged(void) +{ +} + +void WIPolicyThermalRelationshipTableChanged::onExecute(void) +{ + writeWorkItemStartingInfoMessage(); + + auto policyManager = getPolicyManager(); + auto policyIndexes = policyManager->getPolicyIndexes(); + + for (auto i = policyIndexes.begin(); i != policyIndexes.end(); ++i) + { + try + { + auto policy = policyManager->getPolicyPtr(*i); + policy->executePolicyThermalRelationshipTableChanged(); + } + catch (policy_index_invalid&) + { + // do nothing. No item in the policy list at this index. + } + catch (std::exception& ex) + { + writeWorkItemErrorMessagePolicy(ex, "Policy::executePolicyThermalRelationshipTableChanged", *i); + } + } +} diff --git a/DPTF/Sources/Manager/WIPolicyThermalRelationshipTableChanged.h b/DPTF/Sources/Manager/WIPolicyThermalRelationshipTableChanged.h new file mode 100644 index 00000000..18ce0c78 --- /dev/null +++ b/DPTF/Sources/Manager/WIPolicyThermalRelationshipTableChanged.h @@ -0,0 +1,31 @@ +/****************************************************************************** +** Copyright (c) 2013-2022 Intel Corporation All Rights Reserved +** +** Licensed under the Apache License, Version 2.0 (the "License"); you may not +** use this file except in compliance with the License. +** +** You may obtain a copy of the License at +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +** WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** +** See the License for the specific language governing permissions and +** limitations under the License. +** +******************************************************************************/ + +#pragma once + +#include "Dptf.h" +#include "WorkItem.h" + +class WIPolicyThermalRelationshipTableChanged : public WorkItem +{ +public: + WIPolicyThermalRelationshipTableChanged(DptfManagerInterface* dptfManager); + virtual ~WIPolicyThermalRelationshipTableChanged(void); + + virtual void onExecute(void) override final; +}; diff --git a/DPTF/Sources/Manager/WIPolicyVoltageThresholdMathTableChanged.cpp b/DPTF/Sources/Manager/WIPolicyVoltageThresholdMathTableChanged.cpp new file mode 100644 index 00000000..e6ee8628 --- /dev/null +++ b/DPTF/Sources/Manager/WIPolicyVoltageThresholdMathTableChanged.cpp @@ -0,0 +1,55 @@ +/****************************************************************************** +** Copyright (c) 2013-2022 Intel Corporation All Rights Reserved +** +** Licensed under the Apache License, Version 2.0 (the "License"); you may not +** use this file except in compliance with the License. +** +** You may obtain a copy of the License at +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +** WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** +** See the License for the specific language governing permissions and +** limitations under the License. +** +******************************************************************************/ + +#include "WIPolicyVoltageThresholdMathTableChanged.h" +#include "PolicyManagerInterface.h" +#include "EsifServicesInterface.h" + +WIPolicyVoltageThresholdMathTableChanged::WIPolicyVoltageThresholdMathTableChanged(DptfManagerInterface* dptfManager) + : WorkItem(dptfManager, FrameworkEvent::PolicyVoltageThresholdMathTableChanged) +{ +} + +WIPolicyVoltageThresholdMathTableChanged::~WIPolicyVoltageThresholdMathTableChanged(void) +{ +} + +void WIPolicyVoltageThresholdMathTableChanged::onExecute(void) +{ + writeWorkItemStartingInfoMessage(); + + auto policyManager = getPolicyManager(); + auto policyIndexes = policyManager->getPolicyIndexes(); + + for (auto i = policyIndexes.begin(); i != policyIndexes.end(); ++i) + { + try + { + auto policy = policyManager->getPolicyPtr(*i); + policy->executePolicyVoltageThresholdMathTableChanged(); + } + catch (policy_index_invalid&) + { + // do nothing. No item in the policy list at this index. + } + catch (std::exception& ex) + { + writeWorkItemErrorMessagePolicy(ex, "Policy::executePolicyVoltageThresholdMathTableChanged", *i); + } + } +} diff --git a/DPTF/Sources/Manager/WIPolicyVoltageThresholdMathTableChanged.h b/DPTF/Sources/Manager/WIPolicyVoltageThresholdMathTableChanged.h new file mode 100644 index 00000000..3ebf9506 --- /dev/null +++ b/DPTF/Sources/Manager/WIPolicyVoltageThresholdMathTableChanged.h @@ -0,0 +1,31 @@ +/****************************************************************************** +** Copyright (c) 2013-2022 Intel Corporation All Rights Reserved +** +** Licensed under the Apache License, Version 2.0 (the "License"); you may not +** use this file except in compliance with the License. +** +** You may obtain a copy of the License at +** http://www.apache.org/licenses/LICENSE-2.0 +** +** Unless required by applicable law or agreed to in writing, software +** distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +** WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +** +** See the License for the specific language governing permissions and +** limitations under the License. +** +******************************************************************************/ + +#pragma once + +#include "Dptf.h" +#include "WorkItem.h" + +class WIPolicyVoltageThresholdMathTableChanged : public WorkItem +{ +public: + WIPolicyVoltageThresholdMathTableChanged(DptfManagerInterface* dptfManager); + virtual ~WIPolicyVoltageThresholdMathTableChanged(void); + + virtual void onExecute(void) override final; +}; diff --git a/DPTF/Sources/Policies/PolicyLib/LimitRetrieverType.cpp b/DPTF/Sources/Policies/PolicyLib/LimitRetrieverType.cpp index cc4cd45c..5c8daddb 100644 --- a/DPTF/Sources/Policies/PolicyLib/LimitRetrieverType.cpp +++ b/DPTF/Sources/Policies/PolicyLib/LimitRetrieverType.cpp @@ -17,8 +17,6 @@ ******************************************************************************/ #include "LimitRetrieverType.h" -#include "StringConverter.h" -using namespace std; namespace LimitRetrieverType { @@ -36,20 +34,4 @@ namespace LimitRetrieverType throw dptf_exception("LimitRetrieverType::Type is invalid."); } } - LimitRetrieverType::Type FromString(const std::string& value) - { - const string cleanedValue = StringConverter::toUpper(StringConverter::trimWhitespace(value)); - if (cleanedValue == "MAX"s) - { - return LimitRetrieverType::Maximum; - } - else if (cleanedValue == "MIN"s) - { - return LimitRetrieverType::Minimum; - } - else - { - return LimitRetrieverType::Fixed; - } - } } diff --git a/DPTF/Sources/Policies/PolicyLib/LimitRetrieverType.h b/DPTF/Sources/Policies/PolicyLib/LimitRetrieverType.h index ee17722d..939be342 100644 --- a/DPTF/Sources/Policies/PolicyLib/LimitRetrieverType.h +++ b/DPTF/Sources/Policies/PolicyLib/LimitRetrieverType.h @@ -17,6 +17,7 @@ ******************************************************************************/ #pragma once + #include "Dptf.h" namespace LimitRetrieverType @@ -29,5 +30,4 @@ namespace LimitRetrieverType }; std::string ToString(LimitRetrieverType::Type type); - LimitRetrieverType::Type FromString(const std::string& value); }; diff --git a/DPTF/Sources/Policies/PolicyLib/PolicyBase.cpp b/DPTF/Sources/Policies/PolicyLib/PolicyBase.cpp index ffb9e89e..4c1542c3 100644 --- a/DPTF/Sources/Policies/PolicyLib/PolicyBase.cpp +++ b/DPTF/Sources/Policies/PolicyLib/PolicyBase.cpp @@ -955,13 +955,6 @@ void PolicyBase::powerLimitChanged(void) onPowerLimitChanged(); } -void PolicyBase::powerLimitTimeWindowChanged(void) -{ - throwIfPolicyIsDisabled(); - POLICY_LOG_MESSAGE_INFO({ return getName() + ": Power Limit Time Window Changed."; }); - onPowerLimitTimeWindowChanged(); -} - void PolicyBase::performanceCapabilitiesChanged(UIntN participantIndex) { throwIfPolicyIsDisabled(); @@ -1435,11 +1428,6 @@ void PolicyBase::onPowerLimitChanged(void) throw not_implemented(); } -void PolicyBase::onPowerLimitTimeWindowChanged(void) -{ - throw not_implemented(); -} - void PolicyBase::onPerformanceCapabilitiesChanged(UIntN participantIndex) { throw not_implemented(); diff --git a/DPTF/Sources/Policies/PolicyLib/PolicyBase.h b/DPTF/Sources/Policies/PolicyLib/PolicyBase.h index fdd04a7e..92198208 100644 --- a/DPTF/Sources/Policies/PolicyLib/PolicyBase.h +++ b/DPTF/Sources/Policies/PolicyLib/PolicyBase.h @@ -140,7 +140,6 @@ class dptf_export PolicyBase : public PolicyInterface virtual void onActiveControlPointRelationshipTableChanged(void); virtual void onPowerShareAlgorithmTableChanged(void); virtual void onPowerLimitChanged(void); - virtual void onPowerLimitTimeWindowChanged(void); virtual void onPerformanceCapabilitiesChanged(UIntN participantIndex); virtual void onWorkloadHintConfigurationChanged(void); virtual void onOperatingSystemGameModeChanged(OnOffToggle::Type gameMode); @@ -258,7 +257,6 @@ class dptf_export PolicyBase : public PolicyInterface virtual void intelligentThermalManagementTableChanged(void) override final; virtual void energyPerformanceOptimizerTableChanged(void) override final; virtual void powerLimitChanged(void) override final; - virtual void powerLimitTimeWindowChanged(void) override final; virtual void performanceCapabilitiesChanged(UIntN participantIndex) override final; virtual void workloadHintConfigurationChanged(void) override final; virtual void operatingSystemGameModeChanged(OnOffToggle::Type osGameMode) override final; diff --git a/DPTF/Sources/Policies/PolicyLib/PowerControlFacade.cpp b/DPTF/Sources/Policies/PolicyLib/PowerControlFacade.cpp index f2549bda..4f5c7981 100644 --- a/DPTF/Sources/Policies/PolicyLib/PowerControlFacade.cpp +++ b/DPTF/Sources/Policies/PolicyLib/PowerControlFacade.cpp @@ -616,12 +616,6 @@ Percentage PowerControlFacade::getLivePowerLimitDutyCyclePL3() m_participantIndex, m_domainIndex, PowerControlType::PL3); } -void PowerControlFacade::updatePowerLimitTimeWindowPL1(const TimeSpan& timeWindow) -{ - throwIfControlNotSupported(); - m_lastSetTimeWindow[PowerControlType::PL1] = timeWindow; -} - const PolicyServicesInterfaceContainer& PowerControlFacade::getPolicyServices() const { return m_policyServices; diff --git a/DPTF/Sources/Policies/PolicyLib/PowerControlFacade.h b/DPTF/Sources/Policies/PolicyLib/PowerControlFacade.h index 536118a3..727694a7 100644 --- a/DPTF/Sources/Policies/PolicyLib/PowerControlFacade.h +++ b/DPTF/Sources/Policies/PolicyLib/PowerControlFacade.h @@ -82,7 +82,6 @@ class dptf_export PowerControlFacade : public PowerControlFacadeInterface virtual Percentage getLivePowerLimitDutyCyclePL3() override; virtual Bool isSocPowerFloorEnabled() override; virtual Bool isSocPowerFloorSupported() override; - virtual void updatePowerLimitTimeWindowPL1(const TimeSpan& timeWindow) override; private: PolicyServicesInterfaceContainer m_policyServices; diff --git a/DPTF/Sources/Policies/PolicyLib/PowerControlFacadeInterface.h b/DPTF/Sources/Policies/PolicyLib/PowerControlFacadeInterface.h index fe4cc60f..0087249e 100644 --- a/DPTF/Sources/Policies/PolicyLib/PowerControlFacadeInterface.h +++ b/DPTF/Sources/Policies/PolicyLib/PowerControlFacadeInterface.h @@ -75,5 +75,4 @@ class dptf_export PowerControlFacadeInterface virtual Percentage getLivePowerLimitDutyCyclePL3() = 0; virtual Bool isSocPowerFloorEnabled() = 0; virtual Bool isSocPowerFloorSupported() = 0; - virtual void updatePowerLimitTimeWindowPL1(const TimeSpan& timeWindow) = 0; }; diff --git a/DPTF/Sources/SharedLib/BasicTypesLib/Dptf.h b/DPTF/Sources/SharedLib/BasicTypesLib/Dptf.h index b5ae3cd0..ec38cbb8 100644 --- a/DPTF/Sources/SharedLib/BasicTypesLib/Dptf.h +++ b/DPTF/Sources/SharedLib/BasicTypesLib/Dptf.h @@ -66,3 +66,9 @@ // FIXME: these pragma's are temporary while stubbing the header files and source files. // and should be removed once we fill in the code. // +#ifdef ESIF_ATTR_OS_WINDOWS +#pragma warning(disable : 4100) // unreferenced formal parameter +#pragma warning(disable : 4702) // unreachable code +#pragma warning(disable : 4251) // needs to have dll-interface to be used by clients of class +#pragma strict_gs_check(on) +#endif diff --git a/DPTF/Sources/SharedLib/BasicTypesLib/DptfExceptions.cpp b/DPTF/Sources/SharedLib/BasicTypesLib/DptfExceptions.cpp index b5858de2..26dc27d3 100644 --- a/DPTF/Sources/SharedLib/BasicTypesLib/DptfExceptions.cpp +++ b/DPTF/Sources/SharedLib/BasicTypesLib/DptfExceptions.cpp @@ -158,7 +158,7 @@ dptf_out_of_range::dptf_out_of_range(const std::string& description) { } -command_failure::command_failure(esif_error_t errorCode, const std::string& description) +command_failure::command_failure(esif_error_t errorCode, std::string& description) : dptf_exception(description) , m_errorCode(errorCode) { diff --git a/DPTF/Sources/SharedLib/BasicTypesLib/DptfExceptions.h b/DPTF/Sources/SharedLib/BasicTypesLib/DptfExceptions.h index 26acb671..88d5276e 100644 --- a/DPTF/Sources/SharedLib/BasicTypesLib/DptfExceptions.h +++ b/DPTF/Sources/SharedLib/BasicTypesLib/DptfExceptions.h @@ -178,7 +178,7 @@ class acpi_object_not_found : public dptf_exception class command_failure : public dptf_exception { public: - command_failure(esif_error_t errorCode, const std::string& description); + command_failure(esif_error_t errorCode, std::string& description); esif_error_t getErrorCode() const; private: diff --git a/DPTF/Sources/SharedLib/BasicTypesLib/Guid.cpp b/DPTF/Sources/SharedLib/BasicTypesLib/Guid.cpp index ce13e29b..8340c7e1 100644 --- a/DPTF/Sources/SharedLib/BasicTypesLib/Guid.cpp +++ b/DPTF/Sources/SharedLib/BasicTypesLib/Guid.cpp @@ -19,23 +19,18 @@ #include "Guid.h" #include "esif_ccb_memory.h" #include "esif_ccb_string.h" +#include Guid::Guid(void) : m_valid(false) { - m_guid.reserve(GuidSize); - m_guid.assign(GuidSize, 0); + esif_ccb_memset(m_guid, 0, GuidSize); } Guid::Guid(const UInt8 guid[GuidSize]) : m_valid(true) { - m_guid.reserve(GuidSize); - m_guid.assign(GuidSize, 0); - for (UInt32 i = 0; i < GuidSize; ++i) - { - m_guid[i] = guid[i]; - } + esif_ccb_memcpy(m_guid, guid, GuidSize); } Guid::Guid( @@ -57,9 +52,6 @@ Guid::Guid( UInt8 value15) : m_valid(true) { - m_guid.reserve(GuidSize); - m_guid.assign(GuidSize, 0); - m_guid[0] = value00; m_guid[1] = value01; m_guid[2] = value02; @@ -85,7 +77,23 @@ Guid Guid::createInvalid() Bool Guid::operator==(const Guid& rhs) const { - return m_guid == rhs.m_guid; + UIntN mySize = sizeof(this->m_guid) / sizeof(this->m_guid[0]); + UIntN rhsSize = sizeof(rhs.m_guid) / sizeof(rhs.m_guid[0]); + + if (mySize != rhsSize) + { + return false; + } + + // FIXME: this can be switched to memcmp once implemented in esif/ccb + for (UIntN i = 0; i < mySize && i < rhsSize; ++i) + { + if (this->m_guid[i] != rhs.m_guid[i]) + { + return false; + } + } + return true; } Bool Guid::operator!=(const Guid& rhs) const @@ -102,7 +110,7 @@ std::ostream& operator<<(std::ostream& os, const Guid& guid) Guid::operator const UInt8*(void) const { throwIfInvalid(*this); - return m_guid.data(); + return m_guid; } Bool Guid::isValid(void) const @@ -118,7 +126,7 @@ std::string Guid::toString() const { if (isValid()) { - guidTextStream << std::setw(2) << std::uppercase << (IntN)(UInt8) m_guid[i]; + guidTextStream << std::setw(2) << (IntN)(UInt8)m_guid[i]; } else { @@ -130,40 +138,11 @@ std::string Guid::toString() const guidTextStream << "-"; } } - return guidTextStream.str(); -} -std::string Guid::valuesToHexString(const std::list& values) -{ - std::stringstream stream; - stream << std::hex << std::setfill('0'); - for (const auto item : values) - { - stream << std::setw(2) << std::uppercase << (IntN) item; - } - return stream.str(); -} - -std::string Guid::valuesToHexStringReversed(const std::list& values) -{ - std::stringstream stream; - stream << std::hex << std::setfill('0'); - for (auto item = values.crbegin(); item != values.crend(); ++item) - { - stream << std::setw(2) << std::uppercase << (IntN)*item; - } - return stream.str(); -} - -std::string Guid::toClassicString() const -{ - std::stringstream stream; - stream << valuesToHexStringReversed(std::list(m_guid.begin(), m_guid.begin() + 4)); - stream << '-' << valuesToHexStringReversed(std::list(m_guid.begin() + 4, m_guid.begin() + 6)); - stream << '-' << valuesToHexStringReversed(std::list(m_guid.begin() + 6, m_guid.begin() + 8)); - stream << '-' << valuesToHexString(std::list(m_guid.begin() + 8, m_guid.begin() + 10)); - stream << '-' << valuesToHexString(std::list(m_guid.begin() + 10, m_guid.begin() + 16)); - return stream.str(); + std::string guidText = guidTextStream.str(); + std::transform( + guidText.begin(), guidText.end(), guidText.begin(), [](int c) -> char { return (char)::toupper(c); }); + return guidText; } Guid Guid::fromString(const std::string guidString) diff --git a/DPTF/Sources/SharedLib/BasicTypesLib/Guid.h b/DPTF/Sources/SharedLib/BasicTypesLib/Guid.h index ea9b4403..5cb74b04 100644 --- a/DPTF/Sources/SharedLib/BasicTypesLib/Guid.h +++ b/DPTF/Sources/SharedLib/BasicTypesLib/Guid.h @@ -19,8 +19,6 @@ #pragma once #include "Dptf.h" -#include -#include #include "esif_sdk_data.h" class Guid final @@ -56,15 +54,12 @@ class Guid final Bool isValid() const; std::string toString() const; - std::string toClassicString() const; static Guid fromString(std::string guidString); static Guid fromUnmangledString(std::string guidString); void copyToBuffer(UInt8 buffer[GuidSize]) const; private: Bool m_valid; - std::vector m_guid; - static std::string valuesToHexString(const std::list& values); - static std::string valuesToHexStringReversed(const std::list& values); + UInt8 m_guid[GuidSize]; void throwIfInvalid(const Guid& guid) const; }; diff --git a/DPTF/Sources/SharedLib/BasicTypesLib/StringConverter.cpp b/DPTF/Sources/SharedLib/BasicTypesLib/StringConverter.cpp index 6e7a8f46..4acbace9 100644 --- a/DPTF/Sources/SharedLib/BasicTypesLib/StringConverter.cpp +++ b/DPTF/Sources/SharedLib/BasicTypesLib/StringConverter.cpp @@ -18,7 +18,6 @@ #include #include "StringConverter.h" -#include using namespace std; @@ -76,7 +75,6 @@ std::string StringConverter::trimWhitespace(const std::string& input) std::string trimmedString = input; trimmedString.erase(0, trimmedString.find_first_not_of(delimiters)); trimmedString.erase(trimmedString.find_last_not_of(delimiters) + 1); - trimmedString.erase(std::find(trimmedString.begin(), trimmedString.end(), '\0'), trimmedString.end()); return trimmedString; } diff --git a/DPTF/Sources/SharedLib/BasicTypesLib/StringParser.cpp b/DPTF/Sources/SharedLib/BasicTypesLib/StringParser.cpp index 49a319f0..615d8ee8 100644 --- a/DPTF/Sources/SharedLib/BasicTypesLib/StringParser.cpp +++ b/DPTF/Sources/SharedLib/BasicTypesLib/StringParser.cpp @@ -82,20 +82,6 @@ std::string StringParser::removeString(const std::string& input, const std::stri return inputCopy; } -std::string StringParser::removeAllString(const std::string& input, const std::string& substring) -{ - string inputCopy = input; - std::size_t foundPosition = inputCopy.find(substring); - - while (foundPosition != std::string::npos) - { - inputCopy.erase(foundPosition, substring.length()); - foundPosition = inputCopy.find(substring); - } - - return inputCopy; -} - std::string StringParser::removeCharacter(const std::string& input, char character) { string inputCopy = input; diff --git a/DPTF/Sources/SharedLib/BasicTypesLib/StringParser.h b/DPTF/Sources/SharedLib/BasicTypesLib/StringParser.h index 548988b8..b5cc8a2e 100644 --- a/DPTF/Sources/SharedLib/BasicTypesLib/StringParser.h +++ b/DPTF/Sources/SharedLib/BasicTypesLib/StringParser.h @@ -26,7 +26,6 @@ class StringParser final static std::vector split(const std::string& input, char delimiter); static std::string join(std::vector strings, char delimiter); static std::string removeString(const std::string& input, const std::string& substring); - static std::string removeAllString(const std::string& input, const std::string& substring); static std::string removeCharacter(const std::string& input, char character); static std::string replaceAll( const std::string& input, diff --git a/DPTF/Sources/SharedLib/DataVaultPath.h b/DPTF/Sources/SharedLib/DataVaultPath.h index 3187cfb1..d7e28cb0 100644 --- a/DPTF/Sources/SharedLib/DataVaultPath.h +++ b/DPTF/Sources/SharedLib/DataVaultPath.h @@ -78,6 +78,5 @@ namespace DataVaultPath static const std::string Hwpf = DataVaultPathBasePaths::FeaturesRoot + "/hwpf"; static const std::string PowerShare2Pl2Pl4Sharing = DataVaultPathBasePaths::FeaturesRoot + "/pl2_pl4_sharing"; static const std::string Psh2GfxPerfHintDisabled = DataVaultPathBasePaths::FeaturesRoot + "/psh2_gfx_perf_hint_disabled"; - static const std::string EpoCustomizationDisabled = DataVaultPathBasePaths::FeaturesRoot + "/epo_customization_disabled"; }; }; diff --git a/DPTF/Sources/SharedLib/DebugMemoryLeak.h b/DPTF/Sources/SharedLib/DebugMemoryLeak.h index e4646e75..8e9a4abf 100644 --- a/DPTF/Sources/SharedLib/DebugMemoryLeak.h +++ b/DPTF/Sources/SharedLib/DebugMemoryLeak.h @@ -39,4 +39,15 @@ // More information can be found here: http://msdn.microsoft.com/en-us/library/e5ewb1h3(v=vs.80).aspx // +#if defined(ESIF_ATTR_OS_WINDOWS) && defined(_DEBUG) + +#define _CRTDBG_MAP_ALLOC +#include +#include +#define DEBUG_NEW new (_NORMAL_BLOCK, __FILE__, __LINE__) +#define new DEBUG_NEW + +#define DEBUG_MEMORY_LEAK_INIT() _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF) +#else #define DEBUG_MEMORY_LEAK_INIT() +#endif diff --git a/DPTF/Sources/SharedLib/DomainTemperatureInterface.h b/DPTF/Sources/SharedLib/DomainTemperatureInterface.h index d7085b8f..0bfc9bdb 100644 --- a/DPTF/Sources/SharedLib/DomainTemperatureInterface.h +++ b/DPTF/Sources/SharedLib/DomainTemperatureInterface.h @@ -25,12 +25,11 @@ class DomainTemperatureInterface { public: - virtual ~DomainTemperatureInterface(){}; + virtual ~DomainTemperatureInterface() {}; virtual TemperatureStatus getTemperatureStatus() = 0; virtual TemperatureThresholds getTemperatureThresholds() = 0; - virtual void setTemperatureThresholds( - const TemperatureThresholds& temperatureThresholds, + virtual void setTemperatureThresholds(const TemperatureThresholds& temperatureThresholds, const TemperatureThresholds& lastSetTemperatureThresholds) = 0; virtual Temperature getPowerShareTemperatureThreshold() = 0; virtual DptfBuffer getCalibrationTable() = 0; diff --git a/DPTF/Sources/SharedLib/DptfObjectsLib/BinaryParse.cpp b/DPTF/Sources/SharedLib/DptfObjectsLib/BinaryParse.cpp index 42dae303..2c655493 100644 --- a/DPTF/Sources/SharedLib/DptfObjectsLib/BinaryParse.cpp +++ b/DPTF/Sources/SharedLib/DptfObjectsLib/BinaryParse.cpp @@ -17,7 +17,6 @@ ******************************************************************************/ #include "BinaryParse.h" -#include "StringParser.h" UInt64 BinaryParse::extractBits(UInt16 startBit, UInt16 stopBit, UInt64 data) { @@ -36,22 +35,21 @@ UInt64 BinaryParse::extractBits(UInt16 startBit, UInt16 stopBit, UInt64 data) std::string BinaryParse::normalizeAcpiScope(const std::string& acpiScope) { - std::string parsedScope = StringParser::removeCharacter(acpiScope, '\0'); - if (parsedScope == Constants::InvalidString || parsedScope == Constants::NotAvailableString) + if (acpiScope == Constants::InvalidString || acpiScope == Constants::NotAvailableString) { - return parsedScope; + return acpiScope; } std::stringstream normalizedAcpiScope; UIntN charsSinceLastDot(0); - for (UIntN pos = 0; pos < parsedScope.size(); pos++) + for (UIntN pos = 0; pos < acpiScope.size(); pos++) { - if (parsedScope[pos] == '\\') + if (acpiScope[pos] == '\\') { - normalizedAcpiScope << parsedScope[pos]; + normalizedAcpiScope << acpiScope[pos]; charsSinceLastDot = 0; } - else if (parsedScope[pos] == '.') + else if (acpiScope[pos] == '.') { IntN underscoresToAdd = 4 - charsSinceLastDot; while (underscoresToAdd > 0) @@ -59,17 +57,22 @@ std::string BinaryParse::normalizeAcpiScope(const std::string& acpiScope) normalizedAcpiScope << '_'; underscoresToAdd--; } - normalizedAcpiScope << parsedScope[pos]; + normalizedAcpiScope << acpiScope[pos]; charsSinceLastDot = 0; } + else if (acpiScope[pos] == '\0') + { + charsSinceLastDot++; + continue; + } else { - normalizedAcpiScope << parsedScope[pos]; + normalizedAcpiScope << acpiScope[pos]; charsSinceLastDot++; } } - if (parsedScope.size() > 0) + if (acpiScope.size() > 0) { IntN underscoresToAdd = 4 - charsSinceLastDot; while (underscoresToAdd > 0) diff --git a/DPTF/Sources/SharedLib/DptfTypeDefs.h b/DPTF/Sources/SharedLib/DptfTypeDefs.h index e43fc63b..9110a49a 100644 --- a/DPTF/Sources/SharedLib/DptfTypeDefs.h +++ b/DPTF/Sources/SharedLib/DptfTypeDefs.h @@ -30,7 +30,18 @@ typedef int sint; typedef long slong; typedef void* pvoid; -#if defined(LINUX) +#if defined(WINDOWS) + +typedef unsigned char u8; +typedef unsigned short u16; +typedef unsigned int u32; +typedef unsigned long long u64; +typedef char s8; +typedef short s16; +typedef int s32; +typedef long long s64; + +#elif defined(LINUX) typedef unsigned char u8; typedef unsigned short u16; @@ -43,4 +54,4 @@ typedef long s64; #elif defined(MAC) -#endif +#endif \ No newline at end of file diff --git a/DPTF/Sources/SharedLib/DptfTypesLib/CustomizationActionType.cpp b/DPTF/Sources/SharedLib/DptfTypesLib/CustomizationActionType.cpp deleted file mode 100644 index 4923edea..00000000 --- a/DPTF/Sources/SharedLib/DptfTypesLib/CustomizationActionType.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/****************************************************************************** -** Copyright (c) 2013-2022 Intel Corporation All Rights Reserved -** -** Licensed under the Apache License, Version 2.0 (the "License"); you may not -** use this file except in compliance with the License. -** -** You may obtain a copy of the License at -** http://www.apache.org/licenses/LICENSE-2.0 -** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -** WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** -** See the License for the specific language governing permissions and -** limitations under the License. -** -******************************************************************************/ - -#include "CustomizationActionType.h" - -namespace CustomizationAction -{ - std::string toString(CustomizationAction::Type actionType) - { - switch (actionType) - { - case PpmReset: - return "PpmReset"; - case PpmSet: - return "PpmSet"; - default: - return "Invalid"; - } - } - - CustomizationAction::Type fromString(std::string actionType) - { - if (actionType == toString(CustomizationAction::PpmReset)) - { - return CustomizationAction::PpmReset; - } - else if (actionType == toString(CustomizationAction::PpmSet)) - { - return CustomizationAction::PpmSet; - } - else - { - return CustomizationAction::Invalid; - } - } -} diff --git a/DPTF/Sources/SharedLib/DptfTypesLib/CustomizationType.cpp b/DPTF/Sources/SharedLib/DptfTypesLib/CustomizationType.cpp deleted file mode 100644 index 385516e8..00000000 --- a/DPTF/Sources/SharedLib/DptfTypesLib/CustomizationType.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/****************************************************************************** -** Copyright (c) 2013-2022 Intel Corporation All Rights Reserved -** -** Licensed under the Apache License, Version 2.0 (the "License"); you may not -** use this file except in compliance with the License. -** -** You may obtain a copy of the License at -** http://www.apache.org/licenses/LICENSE-2.0 -** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -** WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** -** See the License for the specific language governing permissions and -** limitations under the License. -** -******************************************************************************/ - -#include "CustomizationType.h" - -namespace CustomizationType -{ - std::string toString(CustomizationType::Type CustomizationType) - { - switch (CustomizationType) - { - case PpmCustomization: - return "PpmCustomization"; - default: - return "Invalid"; - } - } - - CustomizationType::Type fromString(std::string CustomizationType) - { - if (CustomizationType == toString(CustomizationType::PpmCustomization)) - { - return CustomizationType::PpmCustomization; - } - return CustomizationType::Invalid; - } -} \ No newline at end of file diff --git a/DPTF/Sources/SharedLib/DptfTypesLib/ForegroundRatioChoice.cpp b/DPTF/Sources/SharedLib/DptfTypesLib/ForegroundRatioChoice.cpp deleted file mode 100644 index db9f2266..00000000 --- a/DPTF/Sources/SharedLib/DptfTypesLib/ForegroundRatioChoice.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/****************************************************************************** -** Copyright (c) 2013-2022 Intel Corporation All Rights Reserved -** -** Licensed under the Apache License, Version 2.0 (the "License"); you may not -** use this file except in compliance with the License. -** -** You may obtain a copy of the License at -** http://www.apache.org/licenses/LICENSE-2.0 -** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -** WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** -** See the License for the specific language governing permissions and -** limitations under the License. -** -******************************************************************************/ - -#include "ForegroundRatioChoice.h" - -namespace ForegroundRatioChoice -{ - ForegroundRatioChoice::Type fromString(std::string foregroundChoice) - { - if (foregroundChoice == toString(ForegroundRatioChoice::SingleCore)) - { - return ForegroundRatioChoice::SingleCore; - } - else if (foregroundChoice == toString(ForegroundRatioChoice::TotalPhysicalCores)) - { - return ForegroundRatioChoice::TotalPhysicalCores; - } - else if (foregroundChoice == toString(ForegroundRatioChoice::TotalLogicalProcessors)) - { - return ForegroundRatioChoice::TotalLogicalProcessors; - } - else if (foregroundChoice == toString(ForegroundRatioChoice::TotalSmtCores)) - { - return ForegroundRatioChoice::TotalSmtCores; - } - else - { - return ForegroundRatioChoice::Invalid; - } - } - - std::string toString(ForegroundRatioChoice::Type foregroundChoice) - { - switch (foregroundChoice) - { - case SingleCore: - return "SingleCore"; - case TotalPhysicalCores: - return "TotalPhysicalCores"; - case TotalLogicalProcessors: - return "TotalLogicalProcessors"; - case TotalSmtCores: - return "TotalSmtCores"; - default: - return "Invalid"; - } - } -} diff --git a/DPTF/Sources/SharedLib/DptfTypesLib/IpfAppNotificationData.h b/DPTF/Sources/SharedLib/DptfTypesLib/IpfAppNotificationData.h index f333f388..0aa1d0fb 100644 --- a/DPTF/Sources/SharedLib/DptfTypesLib/IpfAppNotificationData.h +++ b/DPTF/Sources/SharedLib/DptfTypesLib/IpfAppNotificationData.h @@ -22,12 +22,26 @@ const Guid DttToOemAppCommunicationGuid(0x8C, 0xF9, 0x06, 0x02, 0x3D, 0xB0, 0x49, 0xD0, 0xBC, 0x21, 0xFC, 0xB1, 0xC0, 0x0D, 0x0F, 0x57); // 8cf90602-3db0-49d0-bc21-fcb1c00d0f57 +namespace IpfAppNotificationData +{ + enum IpfAppNotificationDataType + { + OemVariable, + OemSwNotification, + NptWwanBand, + NdtWifiChannel, + XtuOcMode, + Max + }; +} + namespace DttToOemSwNotificationData { typedef struct OemSwNotificationData { esif_guid_t guidOemDttAppCommunication; UInt32 dataPayloadLength; + IpfAppNotificationData::IpfAppNotificationDataType dataPayloadType; UInt32 dataPayload; } OemSwNotificationData, *OemSwNotificationDataPtr; } diff --git a/DPTF/Sources/SharedLib/DptfTypesLib/MbtHint.cpp b/DPTF/Sources/SharedLib/DptfTypesLib/MbtHint.cpp index 6c6e2125..59b4b26d 100644 --- a/DPTF/Sources/SharedLib/DptfTypesLib/MbtHint.cpp +++ b/DPTF/Sources/SharedLib/DptfTypesLib/MbtHint.cpp @@ -38,30 +38,4 @@ namespace MbtHint return Constants::InvalidString; } } - - MbtHint::Type fromString(std::string mbtHint) - { - if (mbtHint == toString(MbtHint::Idle)) - { - return MbtHint::Idle; - } - else if (mbtHint == toString(MbtHint::SemiActive)) - { - return MbtHint::SemiActive; - } - else if (mbtHint == toString(MbtHint::Bursty)) - { - return MbtHint::Bursty; - } - else if (mbtHint == toString(MbtHint::Sustained)) - { - return MbtHint::Sustained; - } - else if (mbtHint == toString(MbtHint::BatteryLife)) - { - return MbtHint::BatteryLife; - } - - return MbtHint::Invalid; - } } diff --git a/DPTF/Sources/SharedLib/DptfTypesLib/MbtHint.h b/DPTF/Sources/SharedLib/DptfTypesLib/MbtHint.h index 9ce81ae7..8c7f9b4b 100644 --- a/DPTF/Sources/SharedLib/DptfTypesLib/MbtHint.h +++ b/DPTF/Sources/SharedLib/DptfTypesLib/MbtHint.h @@ -34,5 +34,4 @@ namespace MbtHint }; std::string toString(MbtHint::Type mbtHint); - MbtHint::Type fromString(std::string mbtHint); } diff --git a/DPTF/Sources/SharedLib/DptfTypesLib/SmtType.cpp b/DPTF/Sources/SharedLib/DptfTypesLib/SmtType.cpp deleted file mode 100644 index 811f361e..00000000 --- a/DPTF/Sources/SharedLib/DptfTypesLib/SmtType.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/****************************************************************************** -** Copyright (c) 2013-2022 Intel Corporation All Rights Reserved -** -** Licensed under the Apache License, Version 2.0 (the "License"); you may not -** use this file except in compliance with the License. -** -** You may obtain a copy of the License at -** http://www.apache.org/licenses/LICENSE-2.0 -** -** Unless required by applicable law or agreed to in writing, software -** distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -** WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -** -** See the License for the specific language governing permissions and -** limitations under the License. -** -******************************************************************************/ - -#include "SmtType.h" - -namespace SmtType -{ - std::string toString(SmtType::Type smtType) - { - switch (smtType) - { - case NoSmt: - return "NoSmt"; - case SymmetricSmt: - return "SymmetricSmt"; - case AsymmetricSmt: - return "AsymmetricSmt"; - default: - return "InvalidSmt"; - } - } - - SmtType::Type fromString(std::string smtType) - { - if (smtType == toString(SmtType::NoSmt)) - { - return SmtType::NoSmt; - } - else if (smtType == toString(SmtType::SymmetricSmt)) - { - return SmtType::SymmetricSmt; - } - else if (smtType == toString(SmtType::AsymmetricSmt)) - { - return SmtType::AsymmetricSmt; - } - else - { - return SmtType::InvalidSmt; - } - } -} diff --git a/DPTF/Sources/SharedLib/EventsLib/FrameworkEvent.cpp b/DPTF/Sources/SharedLib/EventsLib/FrameworkEvent.cpp index 545f5487..64baacf6 100644 --- a/DPTF/Sources/SharedLib/EventsLib/FrameworkEvent.cpp +++ b/DPTF/Sources/SharedLib/EventsLib/FrameworkEvent.cpp @@ -175,12 +175,15 @@ void FrameworkEventInfo::initializeEvents() // Policy events INIT_EVENT(PolicyCreate, 31); INIT_EVENT(PolicyDestroy, 31); + INIT_EVENT_WITH_GUID(PolicyActiveRelationshipTableChanged, 0, DTT_ACTIVE_RELATIONSHIP_TABLE_CHANGED); INIT_EVENT_WITH_GUID(PolicyCoolingModePolicyChanged, 0, DTT_SYSTEM_COOLING_POLICY_CHANGED); INIT_EVENT_WITH_GUID(PolicyForegroundApplicationChanged, 0, FOREGROUND_APP_CHANGED); INIT_EVENT(PolicyInitiatedCallback, 0); + INIT_EVENT_WITH_GUID(PolicyPassiveTableChanged, 0, DTT_PASSIVE_TABLE_CHANGED); INIT_EVENT_WITH_GUID(PolicySensorOrientationChanged, 0, DISPLAY_ORIENTATION_CHANGED); INIT_EVENT_WITH_GUID(PolicySensorMotionChanged, 0, MOTION_CHANGED); INIT_EVENT_WITH_GUID(PolicySensorSpatialOrientationChanged, 0, DEVICE_ORIENTATION_CHANGED); + INIT_EVENT_WITH_GUID(PolicyThermalRelationshipTableChanged, 0, DTT_THERMAL_RELATIONSHIP_TABLE_CHANGED); INIT_EVENT_WITH_GUID(PolicyOperatingSystemPowerSourceChanged, 0, OS_POWER_SOURCE_CHANGED); INIT_EVENT_WITH_GUID(PolicyOperatingSystemLidStateChanged, 0, OS_LID_STATE_CHANGED); INIT_EVENT_WITH_GUID(PolicyOperatingSystemBatteryPercentageChanged, 0, OS_BATTERY_PERCENT_CHANGED); @@ -194,13 +197,22 @@ void FrameworkEventInfo::initializeEvents() INIT_EVENT_WITH_GUID(PolicyOperatingSystemScreenStateChanged, 0, OS_SCREEN_STATE_CHANGED); INIT_EVENT_WITH_GUID(PolicyOperatingSystemBatteryCountChanged, 0, BATTERY_COUNT_NOTIFICATION); INIT_EVENT_WITH_GUID(PolicyOperatingSystemPowerSliderChanged, 0, OS_POWER_SLIDER_VALUE_CHANGED); + INIT_EVENT_WITH_GUID(PolicyOemVariablesChanged, 0, OEM_VARS_CHANGED); + INIT_EVENT_WITH_GUID(PolicyPowerBossConditionsTableChanged, 0, DTT_POWER_BOSS_CONDITIONS_TABLE_CHANGED); + INIT_EVENT_WITH_GUID(PolicyPowerBossActionsTableChanged, 0, DTT_POWER_BOSS_ACTIONS_TABLE_CHANGED); + INIT_EVENT_WITH_GUID(PolicyPowerBossMathTableChanged, 0, DTT_POWER_BOSS_MATH_TABLE_CHANGED); + INIT_EVENT_WITH_GUID(PolicyVoltageThresholdMathTableChanged, 0, DTT_VOLTAGE_THRESHOLD_MATH_TABLE_CHANGED); INIT_EVENT_WITH_GUID(DptfPolicyLoadedUnloadedEvent, 0, DTT_POLICY_LOADED_UNLOADED); INIT_EVENT_WITH_GUID(PolicyEmergencyCallModeTableChanged, 0, EMERGENCY_CALL_MODE_TABLE_CHANGED); + INIT_EVENT_WITH_GUID(PolicyPidAlgorithmTableChanged, 0, DTT_PID_ALGORITHM_TABLE_CHANGED); + INIT_EVENT_WITH_GUID( + PolicyActiveControlPointRelationshipTableChanged, 0, DTT_ACTIVE_CONTROL_POINT_RELATIONSHIP_TABLE_CHANGED); + INIT_EVENT_WITH_GUID(PolicyPowerShareAlgorithmTableChanged, 0, DTT_POWER_SHARING_ALGORITHM_TABLE_CHANGED); INIT_EVENT(PowerLimitChanged, 0); - INIT_EVENT(PowerLimitTimeWindowChanged, 0); INIT_EVENT(PerformanceCapabilitiesChanged, 0); INIT_EVENT_WITH_GUID(PolicyWorkloadHintConfigurationChanged, 0, DTT_WORKLOAD_HINT_CONFIGURATION_CHANGED); INIT_EVENT_WITH_GUID(PolicyOperatingSystemGameModeChanged, 0, OS_GAME_MODE_CHANGED); + INIT_EVENT_WITH_GUID(PolicyPowerShareAlgorithmTable2Changed, 0, DTT_POWER_SHARING_ALGORITHM_TABLE_2_CHANGED); INIT_EVENT_WITH_GUID(PolicyPlatformUserPresenceChanged, 0, PLATFORM_USER_PRESENCE_CHANGED); INIT_EVENT_WITH_GUID(PolicyExternalMonitorStateChanged, 0, EXTERNAL_MONITOR_CONNECTION_STATE_CHANGED); INIT_EVENT_WITH_GUID(PolicyUserInteractionChanged, 0, OS_USER_INTERACTION_CHANGED); diff --git a/DPTF/Sources/SharedLib/EventsLib/FrameworkEvent.h b/DPTF/Sources/SharedLib/EventsLib/FrameworkEvent.h index 0e241603..8bc85cb9 100644 --- a/DPTF/Sources/SharedLib/EventsLib/FrameworkEvent.h +++ b/DPTF/Sources/SharedLib/EventsLib/FrameworkEvent.h @@ -91,12 +91,15 @@ namespace FrameworkEvent // Policy events PolicyCreate, PolicyDestroy, + PolicyActiveRelationshipTableChanged, PolicyCoolingModePolicyChanged, // Active cooling mode vs. Passive cooling mode PolicyForegroundApplicationChanged, PolicyInitiatedCallback, // The policy created the event so it will get called back on a work item thread + PolicyPassiveTableChanged, PolicySensorOrientationChanged, PolicySensorMotionChanged, PolicySensorSpatialOrientationChanged, + PolicyThermalRelationshipTableChanged, PolicyOperatingSystemPowerSourceChanged, PolicyOperatingSystemLidStateChanged, PolicyOperatingSystemBatteryPercentageChanged, @@ -110,13 +113,21 @@ namespace FrameworkEvent PolicyOperatingSystemScreenStateChanged, PolicyOperatingSystemBatteryCountChanged, PolicyOperatingSystemPowerSliderChanged, + PolicyOemVariablesChanged, + PolicyPowerBossConditionsTableChanged, + PolicyPowerBossActionsTableChanged, + PolicyPowerBossMathTableChanged, + PolicyVoltageThresholdMathTableChanged, DptfPolicyLoadedUnloadedEvent, PolicyEmergencyCallModeTableChanged, + PolicyPidAlgorithmTableChanged, + PolicyActiveControlPointRelationshipTableChanged, + PolicyPowerShareAlgorithmTableChanged, PowerLimitChanged, - PowerLimitTimeWindowChanged, PerformanceCapabilitiesChanged, PolicyWorkloadHintConfigurationChanged, PolicyOperatingSystemGameModeChanged, + PolicyPowerShareAlgorithmTable2Changed, PolicyPlatformUserPresenceChanged, PolicyExternalMonitorStateChanged, PolicyUserInteractionChanged, diff --git a/DPTF/Sources/SharedLib/EventsLib/PolicyEvent.cpp b/DPTF/Sources/SharedLib/EventsLib/PolicyEvent.cpp index fa3efa88..07c101cf 100644 --- a/DPTF/Sources/SharedLib/EventsLib/PolicyEvent.cpp +++ b/DPTF/Sources/SharedLib/EventsLib/PolicyEvent.cpp @@ -74,12 +74,15 @@ namespace PolicyEvent CASE(DomainFanCapabilityChanged) CASE(DomainSocWorkloadClassificationChanged) CASE(DomainEppSensitivityHintChanged) + CASE(PolicyActiveRelationshipTableChanged) CASE(PolicyCoolingModePolicyChanged) CASE(PolicyForegroundApplicationChanged) CASE(PolicyInitiatedCallback) + CASE(PolicyPassiveTableChanged) CASE(PolicySensorOrientationChanged) CASE(PolicySensorMotionChanged) CASE(PolicySensorSpatialOrientationChanged) + CASE(PolicyThermalRelationshipTableChanged) CASE(PolicyOperatingSystemPowerSourceChanged) CASE(PolicyOperatingSystemLidStateChanged) CASE(PolicyOperatingSystemBatteryPercentageChanged) @@ -92,16 +95,24 @@ namespace PolicyEvent CASE(PolicyOperatingSystemScreenStateChanged) CASE(PolicyOperatingSystemBatteryCountChanged) CASE(PolicyOperatingSystemPowerSliderChanged) + CASE(PolicyOemVariablesChanged) + CASE(PolicyPowerBossConditionsTableChanged) + CASE(PolicyPowerBossActionsTableChanged) + CASE(PolicyPowerBossMathTableChanged) + CASE(PolicyVoltageThresholdMathTableChanged) CASE(DptfPolicyLoadedUnloadedEvent) CASE(DptfPolicyActivityLoggingEnabled) CASE(DptfPolicyActivityLoggingDisabled) CASE(PolicyOperatingSystemPowerSchemePersonalityChanged) CASE(PolicyEmergencyCallModeTableChanged) + CASE(PolicyPidAlgorithmTableChanged) + CASE(PolicyActiveControlPointRelationshipTableChanged) + CASE(PolicyPowerShareAlgorithmTableChanged) CASE(PowerLimitChanged) - CASE(PowerLimitTimeWindowChanged) CASE(PerformanceCapabilitiesChanged) CASE(PolicyWorkloadHintConfigurationChanged) CASE(PolicyOperatingSystemGameModeChanged) + CASE(PolicyPowerShareAlgorithmTable2Changed) CASE(PolicyPlatformUserPresenceChanged) CASE(PolicyExternalMonitorStateChanged) CASE(PolicyUserInteractionChanged) @@ -119,11 +130,14 @@ namespace PolicyEvent Bool RequiresEsifEventRegistration(PolicyEvent::Type policyEventType) { return ( - (policyEventType == PolicyEvent::PolicyCoolingModePolicyChanged) + (policyEventType == PolicyEvent::PolicyActiveRelationshipTableChanged) + || (policyEventType == PolicyEvent::PolicyCoolingModePolicyChanged) || (policyEventType == PolicyEvent::PolicyForegroundApplicationChanged) + || (policyEventType == PolicyEvent::PolicyPassiveTableChanged) || (policyEventType == PolicyEvent::PolicySensorOrientationChanged) || (policyEventType == PolicyEvent::PolicySensorMotionChanged) || (policyEventType == PolicyEvent::PolicySensorSpatialOrientationChanged) + || (policyEventType == PolicyEvent::PolicyThermalRelationshipTableChanged) || (policyEventType == PolicyEvent::PolicyOperatingSystemPowerSourceChanged) || (policyEventType == PolicyEvent::PolicyOperatingSystemLidStateChanged) || (policyEventType == PolicyEvent::PolicyOperatingSystemBatteryPercentageChanged) @@ -136,10 +150,19 @@ namespace PolicyEvent || (policyEventType == PolicyEvent::PolicyOperatingSystemScreenStateChanged) || (policyEventType == PolicyEvent::PolicyOperatingSystemBatteryCountChanged) || (policyEventType == PolicyEvent::PolicyOperatingSystemPowerSliderChanged) + || (policyEventType == PolicyEvent::PolicyOemVariablesChanged) + || (policyEventType == PolicyEvent::PolicyPowerBossConditionsTableChanged) + || (policyEventType == PolicyEvent::PolicyPowerBossActionsTableChanged) + || (policyEventType == PolicyEvent::PolicyPowerBossMathTableChanged) + || (policyEventType == PolicyEvent::PolicyVoltageThresholdMathTableChanged) || (policyEventType == PolicyEvent::PolicyOperatingSystemPowerSchemePersonalityChanged) || (policyEventType == PolicyEvent::PolicyEmergencyCallModeTableChanged) + || (policyEventType == PolicyEvent::PolicyPidAlgorithmTableChanged) + || (policyEventType == PolicyEvent::PolicyActiveControlPointRelationshipTableChanged) + || (policyEventType == PolicyEvent::PolicyPowerShareAlgorithmTableChanged) || (policyEventType == PolicyEvent::PolicyWorkloadHintConfigurationChanged) || (policyEventType == PolicyEvent::PolicyOperatingSystemGameModeChanged) + || (policyEventType == PolicyEvent::PolicyPowerShareAlgorithmTable2Changed) || (policyEventType == PolicyEvent::PolicyPlatformUserPresenceChanged) || (policyEventType == PolicyEvent::PolicyExternalMonitorStateChanged) || (policyEventType == PolicyEvent::PolicyUserInteractionChanged) @@ -234,6 +257,8 @@ namespace PolicyEvent return "DomainSocWorkloadClassificationChanged"; case PolicyEvent::DomainEppSensitivityHintChanged: return "DomainEppSensitivityHintChanged"; + case PolicyEvent::PolicyActiveRelationshipTableChanged: + return "PolicyActiveRelationshipTableChanged"; case PolicyEvent::PolicyCoolingModePolicyChanged: return "PolicyCoolingModePolicyChanged"; case PolicyEvent::PolicyForegroundApplicationChanged: @@ -250,8 +275,6 @@ namespace PolicyEvent return "PolicySensorSpatialOrientationChanged"; case PolicyEvent::PolicyThermalRelationshipTableChanged: return "PolicyThermalRelationshipTableChanged"; - case PolicyEvent::PolicyActiveRelationshipTableChanged: - return "PolicyActiveRelationshipTableChanged"; case PolicyEvent::PolicyAdaptivePerformanceConditionsTableChanged: return "PolicyAdaptivePerformanceConditionsTableChanged"; case PolicyEvent::PolicyAdaptivePerformanceActionsTableChanged: @@ -316,8 +339,6 @@ namespace PolicyEvent return "PolicyEnergyPerformanceOptimizerTableChanged"; case PolicyEvent::PowerLimitChanged: return "PowerLimitChanged"; - case PolicyEvent::PowerLimitTimeWindowChanged: - return "PowerLimitTimeWindowChanged"; case PolicyEvent::PerformanceCapabilitiesChanged: return "PerformanceCapabilitiesChanged"; case PolicyEvent::PolicyWorkloadHintConfigurationChanged: diff --git a/DPTF/Sources/SharedLib/EventsLib/PolicyEvent.h b/DPTF/Sources/SharedLib/EventsLib/PolicyEvent.h index d953585e..8712b281 100644 --- a/DPTF/Sources/SharedLib/EventsLib/PolicyEvent.h +++ b/DPTF/Sources/SharedLib/EventsLib/PolicyEvent.h @@ -107,7 +107,6 @@ namespace PolicyEvent PolicyPowerShareAlgorithmTableChanged, PolicyEnergyPerformanceOptimizerTableChanged, PowerLimitChanged, - PowerLimitTimeWindowChanged, PerformanceCapabilitiesChanged, PolicyWorkloadHintConfigurationChanged, PolicyOperatingSystemGameModeChanged, diff --git a/DPTF/Sources/SharedLib/FrameworkEventCreationInterface.h b/DPTF/Sources/SharedLib/FrameworkEventCreationInterface.h index 7e8bfd24..6200b334 100644 --- a/DPTF/Sources/SharedLib/FrameworkEventCreationInterface.h +++ b/DPTF/Sources/SharedLib/FrameworkEventCreationInterface.h @@ -35,5 +35,4 @@ class FrameworkEventCreationInterface virtual void createEventDomainPowerControlCapabilityChanged() = 0; virtual void createEventPowerLimitChanged() = 0; virtual void createEventPerformanceCapabilitiesChanged() = 0; - virtual void createEventPowerLimitTimeWindowChanged() = 0; }; diff --git a/DPTF/Sources/SharedLib/PlatformConfigurationDataInterface.h b/DPTF/Sources/SharedLib/PlatformConfigurationDataInterface.h index b9338152..b27a5f18 100644 --- a/DPTF/Sources/SharedLib/PlatformConfigurationDataInterface.h +++ b/DPTF/Sources/SharedLib/PlatformConfigurationDataInterface.h @@ -96,7 +96,6 @@ class PlatformConfigurationDataInterface virtual void setDynamicBoostState(UIntN participantIndex, UIntN domainIndex, UInt32 value) = 0; virtual UInt32 getTpgPowerStateWithoutCache(UIntN participantIndex, UIntN domainIndex) = 0; virtual UInt64 getPlatformCpuId() = 0; + virtual void clearPpmPackageSettings(void) = 0; - virtual UInt32 getLogicalProcessorCount(UIntN participantIndex, UIntN domainIndex) = 0; - virtual UInt32 getPhysicalCoreCount(UIntN participantIndex, UIntN domainIndex) = 0; }; diff --git a/DPTF/Sources/SharedLib/PolicyInterface.h b/DPTF/Sources/SharedLib/PolicyInterface.h index 6551c61a..0e2c1c95 100644 --- a/DPTF/Sources/SharedLib/PolicyInterface.h +++ b/DPTF/Sources/SharedLib/PolicyInterface.h @@ -194,7 +194,6 @@ class dptf_export PolicyInterface virtual void intelligentThermalManagementTableChanged(void) = 0; virtual void energyPerformanceOptimizerTableChanged(void) = 0; virtual void powerLimitChanged(void) = 0; - virtual void powerLimitTimeWindowChanged(void) = 0; virtual void performanceCapabilitiesChanged(UIntN participantIndex) = 0; virtual void workloadHintConfigurationChanged(void) = 0; virtual void operatingSystemGameModeChanged(OnOffToggle::Type osGameMode) = 0; diff --git a/DPTF/Sources/SharedLib/ResourceLib/FileIO.cpp b/DPTF/Sources/SharedLib/ResourceLib/FileIO.cpp index fdbd07f0..9939b306 100644 --- a/DPTF/Sources/SharedLib/ResourceLib/FileIO.cpp +++ b/DPTF/Sources/SharedLib/ResourceLib/FileIO.cpp @@ -17,25 +17,21 @@ ******************************************************************************/ #include "FileIO.h" -#include "esif_ccb_file.h" #include -#include using namespace std; -const string separatorForward = "/"; // accepted by both Windows and Linux -const string separatorBackward = "\\"; // used only by Windows -const string illegalFileNameCharacters = "/\\"; -const string illegalFilePathCharacters = "*<>:|?\""; +string separatorForward = "/"; // accepted by both Windows and Linux +string separatorBackward = "\\"; // used only by Windows bool hasEndingPathSeparator(const std::string& folderPath) { - if (folderPath.empty()) + if (folderPath.size() == 0) { return true; } else { - const auto lastCharacter = string(1, folderPath.at(folderPath.size() - 1)); + auto lastCharacter = string(1, folderPath.at(folderPath.size() - 1)); if ((lastCharacter == separatorForward) || (lastCharacter == separatorBackward)) { return true; @@ -63,61 +59,9 @@ std::string getCommonSeparator(const std::string& folderPath) } } -bool IFileIO::fileNameContainsIllegalCharacters(const std::string& fileName) +bool IFileIO::fileNameHasIllegalChars(const std::string& fileName) { - const auto containsIllegalFileNameCharacter = fileName.find_first_of(illegalFileNameCharacters, 0) != string::npos; - const auto containsIllegalFilePathCharacter = fileName.find_first_of(illegalFilePathCharacters, 0) != string::npos; - return (containsIllegalFileNameCharacter || containsIllegalFilePathCharacter); -} - -Bool IFileIO::filePathStartsWithIllegalCharacter(const std::string& filePath) -{ - const auto posStartChar = filePath.find_first_of(illegalFilePathCharacters); - return (posStartChar == 0); -} - -Bool IFileIO::filePathContainsColonOutsideOfDriveSection(const std::string& filePath) -{ - // 'C:' is allowed, but : outside of 2nd char is not - const auto posDrive = filePath.find_first_of(':'); - return ((posDrive != std::string::npos) && (posDrive != 1)); -} - -Bool IFileIO::filePathContainsIllegalCharacterOutsideOfDriveSection(const std::string& filePath) -{ - const auto posIllegalCharacter = filePath.find_last_of(illegalFilePathCharacters); - return ((posIllegalCharacter != std::string::npos) && (posIllegalCharacter != 1)); -} - -Bool IFileIO::filePathEndsWithOtherwiseAllowedCharacter(const std::string& filePath) -{ - return ((filePath.back() == '\\') || (filePath.back() == '/') || (filePath.back() == '.') || (filePath.back() == ' ')); -} - -Bool IFileIO::filePathContainsDoubleSlashes(const std::string& filePath) -{ - return (filePath.find("\\\\") != std::string::npos) || (filePath.find("//") != std::string::npos); -} - -Bool IFileIO::isControlCharacter(const char c) -{ - return iscntrl(c); -} - -Bool IFileIO::filePathContainsControlCharacters(const std::string& filePath) -{ - return std::any_of(filePath.cbegin(), filePath.cend(), isControlCharacter); -} - -Bool IFileIO::filePathContainsIllegalCharacters(const std::string& filePath) -{ - return - filePathStartsWithIllegalCharacter(filePath) || - filePathContainsColonOutsideOfDriveSection(filePath) || - filePathContainsIllegalCharacterOutsideOfDriveSection(filePath) || - filePathEndsWithOtherwiseAllowedCharacter(filePath) || - filePathContainsDoubleSlashes(filePath) || - filePathContainsControlCharacters(filePath); + return fileName.find_first_of("*<>:/\\|?", 0) != string::npos; } std::string IFileIO::generatePathWithTrailingSeparator(const std::string& folderPath) @@ -132,10 +76,16 @@ std::string IFileIO::generatePathWithTrailingSeparator(const std::string& folder } } +FileIO::FileIO() +{ +} + +FileIO::~FileIO() +{ +} + void FileIO::writeData(const std::string& filePath, const std::string& data) { - throwIfFilePathHasIllegalCharacters(filePath); - throwIfFilePathIsSymbolicLink(filePath); fstream fp; fp.open(filePath, ios::out); throwIfFileNotOpened(fp, filePath); @@ -145,8 +95,6 @@ void FileIO::writeData(const std::string& filePath, const std::string& data) void FileIO::writeData(const std::string& filePath, const DptfBuffer& data) { - throwIfFilePathHasIllegalCharacters(filePath); - throwIfFilePathIsSymbolicLink(filePath); fstream fp; fp.open(filePath, ios::out); throwIfFileNotOpened(fp, filePath); @@ -161,19 +109,3 @@ void FileIO::throwIfFileNotOpened(const std::fstream& fp, const std::string& fil throw file_open_create_failure(string("Failed to open path \"") + filePath + string("\"")); } } - -void FileIO::throwIfFilePathHasIllegalCharacters(const std::string& filePath) -{ - if (filePathContainsIllegalCharacters(filePath)) - { - throw file_open_create_failure(string("File path contains illegal characters.")); - } -} - -void FileIO::throwIfFilePathIsSymbolicLink(const std::string& filePath) -{ - if (esif_ccb_issymlink(filePath.c_str())) - { - throw file_open_create_failure(string("File path given is a symbolic link.")); - } -} \ No newline at end of file diff --git a/DPTF/Sources/SharedLib/ResourceLib/FileIO.h b/DPTF/Sources/SharedLib/ResourceLib/FileIO.h index 93a66763..523f5999 100644 --- a/DPTF/Sources/SharedLib/ResourceLib/FileIO.h +++ b/DPTF/Sources/SharedLib/ResourceLib/FileIO.h @@ -26,30 +26,18 @@ class dptf_export IFileIO virtual ~IFileIO(void){}; virtual void writeData(const std::string& filePath, const std::string& data) = 0; virtual void writeData(const std::string& filePath, const DptfBuffer& data) = 0; - static Bool fileNameContainsIllegalCharacters(const std::string& fileName); - static Bool filePathContainsIllegalCharacters(const std::string& filePath); + static Bool fileNameHasIllegalChars(const std::string& fileName); static std::string generatePathWithTrailingSeparator(const std::string& folderPath); - -private: - static Bool filePathStartsWithIllegalCharacter(const std::string& filePath); - static Bool filePathContainsColonOutsideOfDriveSection(const std::string& filePath); - static Bool filePathContainsIllegalCharacterOutsideOfDriveSection(const std::string& filePath); - static Bool filePathEndsWithOtherwiseAllowedCharacter(const std::string& filePath); - static Bool filePathContainsDoubleSlashes(const std::string& filePath); - static Bool isControlCharacter(const char c); - static Bool filePathContainsControlCharacters(const std::string& filePath); }; class dptf_export FileIO : public IFileIO { public: - FileIO() = default; - virtual ~FileIO() = default; + FileIO(); + virtual ~FileIO(); virtual void writeData(const std::string& filePath, const std::string& data) override; virtual void writeData(const std::string& filePath, const DptfBuffer& data) override; private: - static void throwIfFileNotOpened(const std::fstream& fp, const std::string& filePath); - static void throwIfFilePathHasIllegalCharacters(const std::string& filePath); - static void throwIfFilePathIsSymbolicLink(const std::string& filePath); + void throwIfFileNotOpened(const std::fstream& fp, const std::string& filePath); }; diff --git a/DPTF/Sources/UnifiedParticipant/DomainPerformanceControl_004.cpp b/DPTF/Sources/UnifiedParticipant/DomainPerformanceControl_004.cpp index 6bec25e0..728426d8 100644 --- a/DPTF/Sources/UnifiedParticipant/DomainPerformanceControl_004.cpp +++ b/DPTF/Sources/UnifiedParticipant/DomainPerformanceControl_004.cpp @@ -65,7 +65,7 @@ PerformanceControlStatus DomainPerformanceControl_004::getPerformanceControlStat { if (m_performanceControlStatus.isInvalid()) { - m_performanceControlStatus.set(createPerformanceControlStatus(domainIndex)); + m_performanceControlStatus.set(PerformanceControlStatus(Constants::Invalid)); } return m_performanceControlStatus.get(); } @@ -251,32 +251,6 @@ PerformanceControlStaticCaps DomainPerformanceControl_004::createPerformanceCont return PerformanceControlStaticCaps(false); // This is hard-coded to FALSE in 7.0 } -PerformanceControlStatus DomainPerformanceControl_004::createPerformanceControlStatus(UIntN domainIndex) -{ - UInt32 activeIndex = Constants::Invalid; - try - { - auto perfControlSet = getPerformanceControlSet(getParticipantIndex(), domainIndex); - auto currentControlId = getParticipantServices()->primitiveExecuteGetAsUInt32( - esif_primitive_type::GET_PARTICIPANT_PERF_PRESENT_CAPABILITY, domainIndex); - - for (UInt32 index = 0; index < perfControlSet.getCount(); ++index) { - auto entry = perfControlSet[index]; - if (currentControlId == entry.getControlId()) { - activeIndex = index; - break; - } - } - - } - catch (...) - { - PARTICIPANT_LOG_MESSAGE_DEBUG({ return "Failed to load the initial performance control status. "; }); - } - - return PerformanceControlStatus(activeIndex); -} - PerformanceControlDynamicCaps DomainPerformanceControl_004::createPerformanceControlDynamicCaps(UIntN domainIndex) { // Get dynamic caps. Set lower limit as min(ppdl value, last index) and diff --git a/DPTF/Sources/UnifiedParticipant/DomainPerformanceControl_004.h b/DPTF/Sources/UnifiedParticipant/DomainPerformanceControl_004.h index 36a93516..6ce94ec0 100644 --- a/DPTF/Sources/UnifiedParticipant/DomainPerformanceControl_004.h +++ b/DPTF/Sources/UnifiedParticipant/DomainPerformanceControl_004.h @@ -64,7 +64,6 @@ class DomainPerformanceControl_004 : public DomainPerformanceControlBase DomainPerformanceControl_004& operator=(const DomainPerformanceControl_004& rhs); PerformanceControlStaticCaps createPerformanceControlStaticCaps(); - PerformanceControlStatus createPerformanceControlStatus(UIntN domainIndex); PerformanceControlDynamicCaps createPerformanceControlDynamicCaps(UIntN domainIndex); PerformanceControlSet createPerformanceControlSet(UIntN domainIndex); UIntN snapIfPerformanceControlIndexIsOutOfBounds(UIntN domainIndex, UIntN performanceControlIndex); diff --git a/DPTF/Sources/UnifiedParticipant/DomainPowerControl_001.cpp b/DPTF/Sources/UnifiedParticipant/DomainPowerControl_001.cpp index 00b8e556..46c4f875 100644 --- a/DPTF/Sources/UnifiedParticipant/DomainPowerControl_001.cpp +++ b/DPTF/Sources/UnifiedParticipant/DomainPowerControl_001.cpp @@ -248,7 +248,6 @@ void DomainPowerControl_001::setPowerLimitTimeWindow( esif_primitive_type::SET_RAPL_POWER_LIMIT_TIME_WINDOW, timeWindow, domainIndex, (UInt8)controlType); setAndUpdateEnabled(controlType); throwIfLimitNotEnabled(controlType); - getParticipantServices()->createEventPowerLimitTimeWindowChanged(); } void DomainPowerControl_001::setPowerLimitTimeWindowIgnoringCaps( diff --git a/ESIF/Packages/DSP/dsp.dv b/ESIF/Packages/DSP/dsp.dv index d3d75e94..6b0f3595 100644 Binary files a/ESIF/Packages/DSP/dsp.dv and b/ESIF/Packages/DSP/dsp.dv differ diff --git a/ESIF/Products/ESIF_CM/Sources/esif.h b/ESIF/Products/ESIF_CM/Sources/esif.h index de6fb366..db91d690 100644 --- a/ESIF/Products/ESIF_CM/Sources/esif.h +++ b/ESIF/Products/ESIF_CM/Sources/esif.h @@ -67,9 +67,10 @@ #define ESIF_FEAT_OPT_EVENT_CACHE_ENABLED /* IPF core and IPC layer tracing support */ -#define ESIF_FEAT_OPT_IPF_CLIENT_ETW_TRACE_ENABLED +/* #define ESIF_FEAT_OPT_IPF_CLIENT_ETW_TRACE_ENABLED */ +#ifdef ESIF_ATTR_OS_LINUX /* All Linux-Derived OS */ /* * ESIF_FEAT_OPT_SYSFS exports SYSFS entries. It is defined @@ -78,21 +79,114 @@ * To enable it, it must be uncommented out in makefile. */ +#endif /* Linux Derived OS */ +#ifdef ESIF_ATTR_OS_WINDOWS +/* Build option to enable thermal interrupt support for Windows*/ +#define ESIF_FEAT_OPT_THERMAL_INTERRUPTS_ENABLED +/* Build option to enable sensor support in Windows */ +#define ESIF_FEAT_OPT_SENSOR_SUPPORT_ENABLED + +/* Build option to enable PERC support in Windows */ +#define ESIF_FEAT_OPT_PERC_SUPPORT_ENABLED + +/* Build option to enable USB-C support in Windows */ +#define ESIF_FEAT_OPT_USBC_SUPPORT_ENABLED */ + +/* Build option to provide UF support in the Windows service application */ +/*#define ESIF_FEAT_OPT_SERVICE_AS_UF*/ + +/* Build option to create the LF driver as a non-filter driver for Windows */ +/*#define ESIF_FEAT_OPT_LF_NOT_FILTER*/ + +/* Build option to create the LF driver in a configuration which is not in the INT3400 stack */ +/*#define ESIF_FEAT_OPT_BIOS_LITE_LF*/ + +/* Build option to enable creation of the PCIe participant */ +#define ESIF_FEAT_OPT_PCIE_SUPPORT_ENABLED + +/* Build option to enable creation of the VPU participant */ +#define ESIF_FEAT_OPT_VPU_SUPPORT_ENABLED /**/ + +#endif /* ESIF_ATTR_OS_WINDOWS */ + +#ifdef ESIF_ATTR_KERNEL +#include "esif_version.h" + +#ifdef ESIF_ATTR_OS_LINUX +#include /* Linux Module */ +#include /* Linux Platform Device */ +#include /* Linux ACPI Device */ +#include /* Linux PCI Device */ +#include /* Linux Thermals */ +#include /* Linux Kernel Objects */ +#include /* Linux Kernel Version */ + +/* + * Devices Are Defined To Be Opaque to allow for OS + * implementation of Pointer VS Handle Etc. Linux uses a + * a device pointer. + */ +#define esif_device_t struct device * /* opaque: use #define not typedef */ + +#define ESIF_FEAT_OPT_THERMAL_INTERRUPTS_ENABLED + +#endif /* ESIF_ATTR_KERNEL::ESIF_ATTR_OS_LINUX */ + +#ifdef ESIF_ATTR_OS_WINDOWS + #include "ntddk.h" /* The Windows DDK */ + #include "wdf.h" /* Windows Driver Framework */ + #include "INITGUID.H" /* Init GUID */ + #include "wdmguid.h" /* Windows GUIDS */ + +/* +** Suppress Windows Warnings for warn level 4. Need to find out if we can +** challenge the Windows Blue /W4 /WX with no pragramas assumption? +*/ + #pragma warning(disable : 4204) /* Non-constant aggregate initializer */ + #pragma warning(disable : 4221) /* Can't be initialized using address of + automatic variable */ +/* + * Devices Are Defined To Be Opaque to allow for OS + * implementation of Pointer VS Handle Etc. Windows uses a + * a device handle for WDF. + */ + +typedef WDFDEVICE esif_device_t; +extern WDFDEVICE g_wdf_device_handle; +extern WDFQUEUE g_wdf_ipc_queue_handle; + +/* Map Linux To Windows */ +#define __iomem /* NOOP For Windows */ +#define __le16 short int /* Add To Windows Dictionary */ + +#define EXPORT_SYMBOL_GPL(fn) extern void NOOP_##fn(void) /* NOOP for Windows */ + +#endif /* ESIF_ATTR_KERNEL:: ESIF_ATTR_OS_WINDOWS */ +#endif /* ESIF_ATTR_KERNEL */ + +#ifdef ESIF_ATTR_USER /* * OS Agnostic */ /* Linux */ +#ifdef ESIF_ATTR_OS_LINUX #include #include +#endif /* USER::ESIF_ATTR_OS_LINUX */ +#ifdef ESIF_ATTR_OS_WINDOWS +#pragma warning(disable : 4204) /* Non-constant aggregate initializer */ +#pragma warning(disable : 4221) /* Can't be init'd with addr of autos */ +#endif /* USER::ESIF_ATTR_OS_WINDOWS */ typedef esif_string EsifString; +#endif /* ESIF_ATTR_USER */ #define ESIF_PERCENT_CONV_FACTOR 100 /* Percentages are in 100ths */ @@ -105,6 +199,7 @@ typedef esif_string EsifString; */ #include "esif_ccb_rc.h" /* Return Codes */ +#ifdef ESIF_ATTR_USER #include /* Standard Library */ #include /* String Library */ @@ -112,6 +207,7 @@ typedef esif_string EsifString; #include "esif_ccb_library.h" #include "esif_ccb_file.h" +#endif /* ESIF_ATTR_USER */ #include "esif_ccb_lock.h" #include "esif_ccb_mempool.h" @@ -122,10 +218,19 @@ typedef esif_string EsifString; #include "esif_ccb_sem.h" #include "esif_ccb_timer.h" +#ifdef ESIF_ATTR_KERNEL + +#include "esif_lf_ccb_mbi.h" +#include "esif_lf_ccb_mmio.h" +#include "esif_lf_ccb_msr.h" +#include "esif_lf_ccb_acpi.h" + +#endif /* ESIF_ATTR_KERNEL */ /* * Autogenerated Data Types */ +#ifdef ESIF_ATTR_USER /* Autogen Types Required for Upper Framework */ #include "esif_enum_algorithm_type.h" @@ -149,7 +254,22 @@ typedef esif_string EsifString; #include "esif_sdk_logging_data.h" #include "esif_uf.h" +#endif /* ESIF_ATTR_USER */ + +#ifdef ESIF_ATTR_KERNEL + +/* Autogen Types Required for Lower Framework */ +#include "esif_enum_algorithm_type.h" +#include "esif_enum_acpi_device.h" +#include "esif_enum_event_group.h" +#include "esif_enum_pci_device.h" +#include "esif_sdk_action_type.h" +#include "esif_sdk_capability_type.h" +#include "esif_sdk_class_guid.h" +#include "esif_sdk_domain_type.h" +#include "esif_sdk_primitive_type.h" +#endif /* ESIF_ATTR_KERNEL */ /* OS Agnostic */ #include "esif_mempool.h" /* Memory Pool */ diff --git a/ESIF/Products/ESIF_CM/Sources/esif_ccb_mempool.h b/ESIF/Products/ESIF_CM/Sources/esif_ccb_mempool.h index 7c16536d..0c2aaf7a 100644 --- a/ESIF/Products/ESIF_CM/Sources/esif_ccb_mempool.h +++ b/ESIF/Products/ESIF_CM/Sources/esif_ccb_mempool.h @@ -67,7 +67,220 @@ extern esif_ccb_lock_t g_mempool_lock; } #endif +#ifdef ESIF_ATTR_KERNEL +#include "esif_lf_trace.h" + +#define MPOOL_DEBUG 12 + +#define MEMPOOL_DEBUG(format, ...) \ + ESIF_TRACE_DYN(ESIF_DEBUG_MOD_ELF, MPOOL_DEBUG, format, ##__VA_ARGS__) + +struct esif_ccb_mempool { +#ifdef ESIF_ATTR_OS_LINUX + struct kmem_cache *cache; +#endif /* Linux */ + +#ifdef ESIF_ATTR_OS_WINDOWS + /* TODO: Look aside List? */ +#endif /* Windows */ + esif_string name_ptr; /* Name */ + u32 pool_tag; /* Pool Tag */ + u32 object_size; /* Size Of Pool Object In Bytes */ + u32 alloc_count; /* Object Allocation Count */ + u32 free_count; /* Object Free Count */ +}; + + +/* Memory Pool Create */ +/* WARNING: This function may not be called from paged code in kernel */ +static ESIF_INLINE struct esif_ccb_mempool *esif_ccb_mempool_create( + enum esif_mempool_type pool_type, + u32 pool_tag, + u32 object_size + ) +{ + struct esif_ccb_mempool *pool_ptr = NULL; + + if (pool_type >= ESIF_MEMPOOL_TYPE_MAX) + goto exit; + + pool_ptr = (struct esif_ccb_mempool *) + esif_ccb_malloc(sizeof(*pool_ptr)); + + if (NULL == pool_ptr) + return NULL; + + pool_ptr->name_ptr = esif_mempool_str(pool_tag); + pool_ptr->pool_tag = pool_tag; + pool_ptr->alloc_count = 0; + pool_ptr->free_count = 0; + pool_ptr->object_size = object_size; + +#ifdef ESIF_ATTR_OS_LINUX + pool_ptr->cache = kmem_cache_create(pool_ptr->name_ptr, + pool_ptr->object_size, + 0, + SLAB_HWCACHE_ALIGN, + NULL); +#endif +#ifdef ESIF_ATTR_OS_WINDOWS +/* TODO Look aside List? */ +#endif + esif_ccb_write_lock(&g_mempool_lock); + + g_mempool[pool_type] = pool_ptr; + memstat_inc(&g_memstat.memPoolAllocs); + + MEMPOOL_DEBUG("Memory Pool %s Create Object Size=%d\n", + pool_ptr->name_ptr, + pool_ptr->object_size); + + esif_ccb_write_unlock(&g_mempool_lock); + +exit: + return pool_ptr; +} + + +/* Memory Pool Destroy */ +/* WARNING: This function may not be in paged code in kernel */ +static ESIF_INLINE void esif_ccb_mempool_destroy( + enum esif_mempool_type pool_type + ) +{ + struct esif_ccb_mempool *pool_ptr = NULL; + int remain = 0; + + if (pool_type >= ESIF_MEMPOOL_TYPE_MAX) + goto exit; + + esif_ccb_write_lock(&g_mempool_lock); + + pool_ptr = g_mempool[pool_type]; + + if (NULL == pool_ptr) { + esif_ccb_write_unlock(&g_mempool_lock); + goto exit; + } + + remain = pool_ptr->alloc_count - pool_ptr->free_count; + MEMPOOL_DEBUG("Memory Pool %s Destroy alloc=%d free=%d remain=%d\n", + pool_ptr->name_ptr, + pool_ptr->alloc_count, + pool_ptr->free_count, + remain); + +#ifdef ESIF_ATTR_OS_LINUX + if (NULL != pool_ptr->cache) + kmem_cache_destroy(pool_ptr->cache); +#endif +#ifdef ESIF_ATTR_OS_WINDOWS + /* Nothing To Do */ +#endif + g_mempool[pool_type] = NULL; + memstat_inc(&g_memstat.memPoolFrees); + + esif_ccb_write_unlock(&g_mempool_lock); + + esif_ccb_free(pool_ptr); +exit: + ; +} + + +/* Memory Pool Alloc */ +/* WARNING: This function may not be called from paged code in kernel */ +static ESIF_INLINE void *esif_ccb_mempool_alloc( + enum esif_mempool_type pool_type + ) +{ + struct esif_ccb_mempool *pool_ptr = NULL; + void *mem_ptr = NULL; + + if (pool_type >= ESIF_MEMPOOL_TYPE_MAX) + goto exit; + + esif_ccb_write_lock(&g_mempool_lock); + + pool_ptr = g_mempool[pool_type]; + if (NULL == pool_ptr) { + esif_ccb_write_unlock(&g_mempool_lock); + goto exit; + } + +#ifdef ESIF_ATTR_OS_LINUX + mem_ptr = kmem_cache_alloc(pool_ptr->cache, GFP_ATOMIC); +#endif +#ifdef ESIF_ATTR_OS_WINDOWS + mem_ptr = EsifExAllocatePool(ESIF_POOL_NON_PAGED, + pool_ptr->object_size, + pool_ptr->pool_tag); +#endif + + if (NULL == mem_ptr) { + esif_ccb_write_unlock(&g_mempool_lock); + goto exit; + } + + pool_ptr->alloc_count++; + memstat_inc(&g_memstat.memPoolObjAllocs); + + MEMPOOL_DEBUG("MP Entry Allocated(%d)=%p From Mempool %s\n", + pool_ptr->alloc_count, + mem_ptr, + pool_ptr->name_ptr); + + esif_ccb_write_unlock(&g_mempool_lock); +exit: + return mem_ptr; +} + + +/* Memory Pool Free */ +/* WARNING: This function may not be called from paged code in kernel */ +static ESIF_INLINE void esif_ccb_mempool_free( + enum esif_mempool_type pool_type, + void *mem_ptr + ) +{ + struct esif_ccb_mempool *pool_ptr = NULL; + + if ((NULL == mem_ptr) || (pool_type >= ESIF_MEMPOOL_TYPE_MAX)) + goto exit; + + esif_ccb_write_lock(&g_mempool_lock); + + pool_ptr = g_mempool[pool_type]; + + if (NULL == pool_ptr) { + esif_ccb_write_unlock(&g_mempool_lock); + goto exit; + } + +#ifdef ESIF_ATTR_OS_LINUX + kmem_cache_free(pool_ptr->cache, mem_ptr); +#endif +#ifdef ESIF_ATTR_OS_WINDOWS + ExFreePoolWithTag(mem_ptr, pool_ptr->pool_tag); +#endif + + pool_ptr->free_count++; + memstat_inc(&g_memstat.memPoolObjFrees); + + MEMPOOL_DEBUG("MP Entry Freed(%d)=%p From Mempool %s\n", + pool_ptr->free_count, + mem_ptr, pool_ptr->name_ptr); + + esif_ccb_write_unlock(&g_mempool_lock); +exit: + ; +} + + +#endif /* ESIF_ATTR_KERNEL */ + +#ifdef ESIF_ATTR_USER #include "esif.h" #include "esif_uf_trace.h" @@ -241,6 +454,7 @@ static ESIF_INLINE void esif_ccb_mempool_free( } +#endif /* ESIF_ATTR_USER */ /* NOTE: This function is common to user and kernel mode */ diff --git a/ESIF/Products/ESIF_CM/Sources/esif_command.h b/ESIF/Products/ESIF_CM/Sources/esif_command.h index 3bb4be62..bf8c53ef 100644 --- a/ESIF/Products/ESIF_CM/Sources/esif_command.h +++ b/ESIF/Products/ESIF_CM/Sources/esif_command.h @@ -291,6 +291,9 @@ void esif_execute_ipc_command(struct esif_ipc_command *cmd_ptr); enum esif_rc esif_command_init(void); void esif_command_exit(void); +#ifdef ESIF_ATTR_KERNEL +u32 esif_ipc_command_get_data_len(struct esif_ipc_command *cmd_ptr); +#endif #ifdef __cplusplus } diff --git a/ESIF/Products/ESIF_CM/Sources/esif_drvm.h b/ESIF/Products/ESIF_CM/Sources/esif_drvm.h index beee1161..e7131b7c 100644 --- a/ESIF/Products/ESIF_CM/Sources/esif_drvm.h +++ b/ESIF/Products/ESIF_CM/Sources/esif_drvm.h @@ -71,17 +71,6 @@ #define drvm_iterator_t struct drvm_iterator -typedef enum esif_rc(*kpe_get_handler)( /* KPE Action GET handler */ - const void *context_ptr, - const u32 p1, - const u32 p2, - const u32 p3, - const u32 p4, - const u32 p5, - const struct esif_data *request_ptr, - struct esif_data *response_ptr - ); - /* * TYPE DECLARATIONS */ @@ -149,6 +138,90 @@ struct esif_drv_to_part_binding { #ifdef __cplusplus extern "C" { #endif +#ifdef ESIF_ATTR_KERNEL + +enum esif_rc esif_drvm_init(void); +void esif_drvm_exit(void); + +/* Registers a KPE with the Driver Manager*/ +enum esif_rc esif_drvm_register_driver(struct esif_driver_iface *iface_ptr); + +/* Unregisters a KPE with the Driver Manager*/ +enum esif_rc esif_drvm_unregister_driver(struct esif_driver_iface *iface_ptr); + + +/* + * Increase the reference count on the object: + * Should be called whenever a pointer is passed to another section of code. + * When done with the object, the caller should call exif_drv_put ref. + */ +enum esif_rc esif_drv_get_ref(struct esif_drv_obj *self); + +/* + * Decreases the reference count on the object and destroys the object + * if the reference count is 0. + * After a call is made to this function, the object pointer should no + * longer be used by the code; unless additional references have been + * taken. + */ +void esif_drv_put_ref(struct esif_drv_obj *self); + +/* + * Outputs an ESIF_TRACE message with object details + */ +void esif_drv_trace_obj(struct esif_drv_obj *self); + +/* + * Used to iterate through the available drivers. + * First call esif_drvm_init_iterator to initialize the iterator + * Next, call esif_drvm_get_next_driver using the iterator + * Repeat until esif_drvm_get_next_driver fails. + * The call will release the reference of the driver from the previous call + * for you. If you stop iteration part way through all drivers, the caller + * is responsible for releasing the reference on the last driver returned + */ +enum esif_rc esif_drvm_init_iterator( + drvm_iterator_t *iterator_ptr + ); + +/* + * NOTE: User is responsible for releasing the reference on the driver if + * successful. + */ +enum esif_rc esif_drvm_get_drv_by_instance( + u32 instance, + struct esif_drv_obj **drv_ptr + ); + +enum esif_rc esif_drvm_get_next_driver( + drvm_iterator_t *iterator_ptr, + struct esif_drv_obj **drv_ptr + ); + +enum esif_rc esif_get_action_kpe( + struct esif_lp *lp_ptr, + struct esif_lp_primitive *primitive_ptr, + const struct esif_lp_action *action_ptr, + struct esif_data *req_data_ptr, + struct esif_data *rsp_data_ptr, + void *context_ptr +); + +enum esif_rc esif_set_action_kpe( + struct esif_lp *lp_ptr, + struct esif_lp_primitive *primitive_ptr, + const struct esif_lp_action *action_ptr, + struct esif_data *req_data_ptr, + void *context_ptr +); + +enum esif_rc esif_drv_send_event( + struct esif_drv_obj *self, + const enum esif_event_type event_type, + const struct esif_data *data_ptr + ); + +#endif /* ESIF_ATTR_KERNEL */ #ifdef __cplusplus } #endif diff --git a/ESIF/Products/ESIF_CM/Sources/esif_dsp.h b/ESIF/Products/ESIF_CM/Sources/esif_dsp.h index f046009e..89180ab9 100644 --- a/ESIF/Products/ESIF_CM/Sources/esif_dsp.h +++ b/ESIF/Products/ESIF_CM/Sources/esif_dsp.h @@ -78,8 +78,156 @@ enum esif_dsp_parameter_type { ESIF_DSP_PARAMETER_TYPE_ARGUMENT = 6, }; +#ifdef ESIF_ATTR_KERNEL +/* Compact Primitive Catalog */ +#include "esif.h" +#include "esif_cpc.h" + +#define THIS const struct esif_lp_dsp *THIS + +/* Lower Framework DSP + * Kernel version of DSP is a subset of the full DSP and is known as a Compact + * Primitive Catalog. The CPC contains only the abosulte essentials for the + * kernel driver. + */ +struct esif_lp_dsp { +/* private: */ + + /* Pointers Will Point Into Raw CPC Block Of Memory */ + esif_flags_t *capability_ptr; /* Enhanced Capability */ + esif_string code_ptr; /* Code Short Name */ + u8 *domain_count_ptr; /* Domain Count */ + struct domain *domains_ptr; /* Domains */ + u8 *ver_major_ptr; /* DSP Content Major */ + u8 *ver_minor_ptr; /* DSP Content Minor */ + + /* Raw Cannonical Data For DSP Pointeers */ + struct esif_lp_cpc *cpc_ptr; + /* DSP Hash Table Will Contain Pointers Into CPC */ + struct esif_ht *ht_ptr; + struct esif_link_list *algo_ptr; /* Algorithm */ + struct esif_link_list *evt_ptr; /* Event */ + + void *table; /* Add'l Static Or Dynamic Table(s) */ + u32 table_size; /* Table(s) Size Of Each */ + +/* public: */ + + esif_string (*get_code)(THIS); + u8 (*get_domain_count)(THIS); + + esif_flags_t (*get_domain_capability)( + THIS, + u8 domain_index + ); + enum esif_domain_type (*get_domain_type)( + THIS, + u8 domain_index + ); + u16 (*get_domain_id)( + THIS, + u8 domain_index + ); + esif_string (*get_domain_desc)( + THIS, + u8 domain_index + ); + esif_string (*get_domain_name)( + THIS, + u8 domain_index + ); + + u8 (*get_ver_major)(THIS); + u8 (*get_ver_minor)(THIS); + + u32 (*get_temp_tc1)( + THIS, + const enum esif_action_type action + ); + u32 (*get_percent_xform)( + THIS, + const enum esif_action_type action + ); + enum esif_rc (*insert_primitive)( + THIS, + struct esif_cpc_primitive *primitive_ptr + ); + enum esif_rc (*insert_algorithm)( + THIS, + struct esif_cpc_algorithm *algorithm_ptr + ); + enum esif_rc (*insert_event)( + THIS, + struct esif_cpc_event *event_ptr + ); + struct esif_lp_primitive *(*get_primitive)( + THIS, + const struct esif_primitive_tuple *tuple_ptr + ); + struct esif_lp_action *(*get_action)( + THIS, + struct esif_lp_primitive *primitive_ptr, + u8 index + ); + struct esif_cpc_algorithm *(*get_algorithm)( + THIS, + const enum esif_action_type action_type + ); + u32 (*dsp_has_algorithm)( + THIS, + const enum esif_algorithm_type + ); + struct esif_cpc_event *(*get_event)( + THIS, + u32 event + ); +}; + +#undef THIS + +/* Create DSP */ +enum esif_rc esif_dsp_create( + const struct esif_data *cpc_ptr, + struct esif_lp_dsp **dsp_ptr + ); + +void esif_dsp_destroy(struct esif_lp_dsp * dsp_ptr); + +/* Init / Exit */ +enum esif_rc esif_dsp_init(void); +void esif_dsp_exit(void); + +esif_flags_t get_domain_capability( + const struct esif_lp_dsp *dsp_ptr, + u8 domain_index + ); + +esif_string get_domain_desc( + const struct esif_lp_dsp *dsp_ptr, + u8 domain_index + ); + +u16 get_domain_id( + const struct esif_lp_dsp *dsp_ptr, + u8 domain_index + ); + +esif_string get_domain_name( + const struct esif_lp_dsp *dsp_ptr, + u8 domain_index + ); + +enum esif_domain_type get_domain_type( + const struct esif_lp_dsp *dsp_ptr, + u8 domain_index + ); + +#endif /* ESIF_ATTR_KERNEL */ + + +#ifdef ESIF_ATTR_USER #include "esif_primitive.h" #include "esif_uf_fpc.h" @@ -287,6 +435,7 @@ void EsifDspMgrExit (void); } #endif +#endif /* ESIF_ATTR_USER */ #endif /* _ESIF_DSP_H_ */ /******************************************************************************/ diff --git a/ESIF/Products/ESIF_CM/Sources/esif_enum_acpi_device.h b/ESIF/Products/ESIF_CM/Sources/esif_enum_acpi_device.h index 83bd065e..ece58b1c 100644 --- a/ESIF/Products/ESIF_CM/Sources/esif_enum_acpi_device.h +++ b/ESIF/Products/ESIF_CM/Sources/esif_enum_acpi_device.h @@ -75,36 +75,30 @@ #define ESIF_ACPI_DEVICE_INT340D "INT340D" /* Discrete Graphics Participant */ #define ESIF_ACPI_DEVICE_INT3530 "INT3530" /* MultiChip Package */ #define ESIF_ACPI_DEVICE_INT3532 "INT3532" /* Battery Participant */ -#define ESIF_ACPI_DEVICE_INTC1040 "INTC1040" /* Manager Participant [TGL,RKL,JSL] */ -#define ESIF_ACPI_DEVICE_INTC1041 "INTC1041" /* Manager Participant [ADL] */ -#define ESIF_ACPI_DEVICE_INTC1042 "INTC1042" /* Manager Participant [MTL] */ -#define ESIF_ACPI_DEVICE_INTC1043 "INTC1043" /* Generic Participant [TGL,RKL,JSL] */ -#define ESIF_ACPI_DEVICE_INTC1044 "INTC1044" /* Fan Participant [TGL,RKL,JSL] */ -#define ESIF_ACPI_DEVICE_INTC1045 "INTC1045" /* FIVR Participant [TGL,RKL,JSL] */ -#define ESIF_ACPI_DEVICE_INTC1046 "INTC1046" /* Generic Participant [ADL] */ -#define ESIF_ACPI_DEVICE_INTC1047 "INTC1047" /* Power Participant [TGL,RKL,JSL] */ -#define ESIF_ACPI_DEVICE_INTC1048 "INTC1048" /* Fan Participant [ADL] */ -#define ESIF_ACPI_DEVICE_INTC1049 "INTC1049" /* FIVR Participant [ADL] */ -#define ESIF_ACPI_DEVICE_INTC1050 "INTC1050" /* Battery Participant [TGL,RKL,JSL] */ -#define ESIF_ACPI_DEVICE_INTC1060 "INTC1060" /* Power Participant [ADL] */ -#define ESIF_ACPI_DEVICE_INTC1061 "INTC1061" /* Battery Participant [ADL] */ -#define ESIF_ACPI_DEVICE_INTC1062 "INTC1062" /* Generic Participant [MTL] */ -#define ESIF_ACPI_DEVICE_INTC1063 "INTC1063" /* Fan Participant [MTL] */ -#define ESIF_ACPI_DEVICE_INTC1064 "INTC1064" /* FIVR Participant [MTL] */ -#define ESIF_ACPI_DEVICE_INTC1065 "INTC1065" /* Power Participant [MTL] */ -#define ESIF_ACPI_DEVICE_INTC1066 "INTC1066" /* Battery Participant [MTL] */ -#define ESIF_ACPI_DEVICE_INTC1068 "INTC1068" /* Manager Participant [LNL] */ -#define ESIF_ACPI_DEVICE_INTC1069 "INTC1069" /* Generic Participant [LNL] */ -#define ESIF_ACPI_DEVICE_INTC106A "INTC106A" /* Fan Participant [LNL] */ -#define ESIF_ACPI_DEVICE_INTC106B "INTC106B" /* FIVR Participant [LNL] */ -#define ESIF_ACPI_DEVICE_INTC106C "INTC106C" /* Power Participant [LNL] */ -#define ESIF_ACPI_DEVICE_INTC106D "INTC106D" /* Battery Participant [LNL] */ -#define ESIF_ACPI_DEVICE_INTC10A0 "INTC10A0" /* Manager Participant [RPL] */ -#define ESIF_ACPI_DEVICE_INTC10A1 "INTC10A1" /* Generic Participant [RPL] */ -#define ESIF_ACPI_DEVICE_INTC10A2 "INTC10A2" /* Fan Participant [RPL] */ -#define ESIF_ACPI_DEVICE_INTC10A3 "INTC10A3" /* FIVR Participant [RPL] */ -#define ESIF_ACPI_DEVICE_INTC10A4 "INTC10A4" /* Power Participant [RPL] */ -#define ESIF_ACPI_DEVICE_INTC10A5 "INTC10A5" /* Battery Participant [RPL] */ +#define ESIF_ACPI_DEVICE_INTC1040 "INTC1040" /* Manager Participant */ +#define ESIF_ACPI_DEVICE_INTC1041 "INTC1041" /* Manager Participant */ +#define ESIF_ACPI_DEVICE_INTC1042 "INTC1042" /* Manager Participant */ +#define ESIF_ACPI_DEVICE_INTC1043 "INTC1043" /* Generic Participant */ +#define ESIF_ACPI_DEVICE_INTC1044 "INTC1044" /* Fan Participant */ +#define ESIF_ACPI_DEVICE_INTC1045 "INTC1045" /* FIVR Participant */ +#define ESIF_ACPI_DEVICE_INTC1046 "INTC1046" /* Generic Participant */ +#define ESIF_ACPI_DEVICE_INTC1047 "INTC1047" /* Power Participant */ +#define ESIF_ACPI_DEVICE_INTC1048 "INTC1048" /* Fan Participant */ +#define ESIF_ACPI_DEVICE_INTC1049 "INTC1049" /* FIVR Participant */ +#define ESIF_ACPI_DEVICE_INTC1050 "INTC1050" /* Battery Participant */ +#define ESIF_ACPI_DEVICE_INTC1060 "INTC1060" /* Power Participant */ +#define ESIF_ACPI_DEVICE_INTC1061 "INTC1061" /* Battery Participant */ +#define ESIF_ACPI_DEVICE_INTC1062 "INTC1062" /* Generic Participant */ +#define ESIF_ACPI_DEVICE_INTC1063 "INTC1063" /* Fan Participant */ +#define ESIF_ACPI_DEVICE_INTC1064 "INTC1064" /* FIVR Participant */ +#define ESIF_ACPI_DEVICE_INTC1065 "INTC1065" /* Power Participant */ +#define ESIF_ACPI_DEVICE_INTC1066 "INTC1066" /* Battery Participant */ +#define ESIF_ACPI_DEVICE_INTC10A0 "INTC10A0" /* Manager Participant */ +#define ESIF_ACPI_DEVICE_INTC10A1 "INTC10A1" /* Generic Participant */ +#define ESIF_ACPI_DEVICE_INTC10A2 "INTC10A2" /* Fan Participant */ +#define ESIF_ACPI_DEVICE_INTC10A3 "INTC10A3" /* FIVR Participant */ +#define ESIF_ACPI_DEVICE_INTC10A4 "INTC10A4" /* Power Participant */ +#define ESIF_ACPI_DEVICE_INTC10A5 "INTC10A5" /* Battery Participant */ static ESIF_INLINE esif_string esif_acpi_device_str(esif_string acpi_device) { @@ -181,18 +175,6 @@ static ESIF_INLINE esif_string esif_acpi_device_str(esif_string acpi_device) "Power Participant"), ESIF_MAP(ESIF_ACPI_DEVICE_INTC1066, "Battery Participant"), - ESIF_MAP(ESIF_ACPI_DEVICE_INTC1068, - "Manager Participant"), - ESIF_MAP(ESIF_ACPI_DEVICE_INTC1069, - "Generic Participant"), - ESIF_MAP(ESIF_ACPI_DEVICE_INTC106A, - "Fan Participant"), - ESIF_MAP(ESIF_ACPI_DEVICE_INTC106B, - "FIVR Participant"), - ESIF_MAP(ESIF_ACPI_DEVICE_INTC106C, - "Power Participant"), - ESIF_MAP(ESIF_ACPI_DEVICE_INTC106D, - "Battery Participant"), ESIF_MAP(ESIF_ACPI_DEVICE_INTC10A0, "Manager Participant"), ESIF_MAP(ESIF_ACPI_DEVICE_INTC10A1, @@ -215,6 +197,7 @@ static ESIF_INLINE esif_string esif_acpi_device_str(esif_string acpi_device) #if defined(ESIF_FEAT_OPT_USE_VIRT_DRVRS) +#if defined(ESIF_ATTR_OS_LINUX) #pragma pack(push, 1) @@ -253,12 +236,6 @@ const struct acpi_device_id esif_acpi_ids[] = { { ESIF_ACPI_DEVICE_INTC1064, 0 }, { ESIF_ACPI_DEVICE_INTC1065, 0 }, { ESIF_ACPI_DEVICE_INTC1066, 0 }, - { ESIF_ACPI_DEVICE_INTC1068, 0 }, - { ESIF_ACPI_DEVICE_INTC1069, 0 }, - { ESIF_ACPI_DEVICE_INTC106A, 0 }, - { ESIF_ACPI_DEVICE_INTC106B, 0 }, - { ESIF_ACPI_DEVICE_INTC106C, 0 }, - { ESIF_ACPI_DEVICE_INTC106D, 0 }, { ESIF_ACPI_DEVICE_INTC10A0, 0 }, { ESIF_ACPI_DEVICE_INTC10A1, 0 }, { ESIF_ACPI_DEVICE_INTC10A2, 0 }, @@ -270,3 +247,4 @@ const struct acpi_device_id esif_acpi_ids[] = { #pragma pack(pop) #endif +#endif diff --git a/ESIF/Products/ESIF_CM/Sources/esif_enum_ietm_hid.h b/ESIF/Products/ESIF_CM/Sources/esif_enum_ietm_hid.h index 5db49e75..b644264b 100644 --- a/ESIF/Products/ESIF_CM/Sources/esif_enum_ietm_hid.h +++ b/ESIF/Products/ESIF_CM/Sources/esif_enum_ietm_hid.h @@ -66,7 +66,6 @@ static ESIF_INLINE const char **esif_enum_ietm_hid() "INTC1040", "INTC1041", "INTC1042", - "INTC1068", "INTC10A0", NULL }; diff --git a/ESIF/Products/ESIF_CM/Sources/esif_enum_pci_device.h b/ESIF/Products/ESIF_CM/Sources/esif_enum_pci_device.h index 149bd28f..b55ec5db 100644 --- a/ESIF/Products/ESIF_CM/Sources/esif_enum_pci_device.h +++ b/ESIF/Products/ESIF_CM/Sources/esif_enum_pci_device.h @@ -66,8 +66,7 @@ typedef enum esif_pci_device_id { ESIF_PCI_DEVICE_ID_RKL = 0x4C03, ESIF_PCI_DEVICE_ID_JSL = 0x4E03, ESIF_PCI_DEVICE_ID_CNL = 0x5a03, - ESIF_PCI_DEVICE_ID_LNL = 0x641D, - ESIF_PCI_DEVICE_ID_MTL = 0x7D03, + ESIF_PCI_DEVICE_ID_MTL_MP = 0x7D03, ESIF_PCI_DEVICE_ID_ICL = 0x8a03, ESIF_PCI_DEVICE_ID_LKF = 0x9820, ESIF_PCI_DEVICE_ID_TGL = 0x9a03, @@ -90,9 +89,7 @@ static ESIF_INLINE esif_string esif_device_str(esif_pci_device_id_t device_id) "Jasper Lake"); ESIF_CASE(ESIF_PCI_DEVICE_ID_CNL, "Cannon Lake"); - ESIF_CASE(ESIF_PCI_DEVICE_ID_LNL, - "Lunar Lake"); - ESIF_CASE(ESIF_PCI_DEVICE_ID_MTL, + ESIF_CASE(ESIF_PCI_DEVICE_ID_MTL_MP, "Meteor Lake-MP"); ESIF_CASE(ESIF_PCI_DEVICE_ID_ICL, "Ice Lake"); @@ -139,6 +136,7 @@ static ESIF_INLINE esif_string esif_pci_class_str(u8 class_id) } #if defined(ESIF_FEAT_OPT_USE_VIRT_DRVRS) +#if defined(ESIF_ATTR_OS_LINUX) #pragma pack(push, 1) @@ -151,11 +149,10 @@ const struct pci_device_id esif_pci_cpu_ids[] = { { PCI_DEVICE(PCI_VENDOR_ID_INTEL, ESIF_PCI_DEVICE_ID_ADL) }, { PCI_DEVICE(PCI_VENDOR_ID_INTEL, ESIF_PCI_DEVICE_ID_RKL) }, { PCI_DEVICE(PCI_VENDOR_ID_INTEL, ESIF_PCI_DEVICE_ID_JSL) }, - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, ESIF_PCI_DEVICE_ID_MTL) }, + { PCI_DEVICE(PCI_VENDOR_ID_INTEL, ESIF_PCI_DEVICE_ID_MTL_MP) }, { PCI_DEVICE(PCI_VENDOR_ID_INTEL, ESIF_PCI_DEVICE_ID_MTL_S) }, { PCI_DEVICE(PCI_VENDOR_ID_INTEL, ESIF_PCI_DEVICE_ID_RPL) }, { PCI_DEVICE(PCI_VENDOR_ID_INTEL, ESIF_PCI_DEVICE_ID_FHF) }, - { PCI_DEVICE(PCI_VENDOR_ID_INTEL, ESIF_PCI_DEVICE_ID_LNL) }, { 0 } }; @@ -166,3 +163,4 @@ const struct pci_device_id esif_pci_pch_ids[] = { #pragma pack(pop) #endif +#endif diff --git a/ESIF/Products/ESIF_CM/Sources/esif_event.h b/ESIF/Products/ESIF_CM/Sources/esif_event.h index f27cf1bd..365288b5 100644 --- a/ESIF/Products/ESIF_CM/Sources/esif_event.h +++ b/ESIF/Products/ESIF_CM/Sources/esif_event.h @@ -61,7 +61,9 @@ #define ESIF_LF_EVENT_QUEUE_SIZE 10240 #define ESIF_LF_EVENT_QUEUE_TIMEOUT 1000 /* 1s in ms */ +#ifdef ESIF_ATTR_USER typedef enum esif_event_type eEsifEventType; +#endif #ifdef __cplusplus diff --git a/ESIF/Products/ESIF_CM/Sources/esif_hash_table.c b/ESIF/Products/ESIF_CM/Sources/esif_hash_table.c index a3810de3..464e7fd4 100644 --- a/ESIF/Products/ESIF_CM/Sources/esif_hash_table.c +++ b/ESIF/Products/ESIF_CM/Sources/esif_hash_table.c @@ -50,10 +50,23 @@ ** POSSIBILITY OF SUCH DAMAGE. ** *******************************************************************************/ +#ifdef ESIF_ATTR_USER # define ESIF_TRACE_ID ESIF_TRACEMODULE_UF +#endif #include "esif_hash_table.h" +#ifdef ESIF_ATTR_OS_WINDOWS +/* + * + * The Windows banned-API check header must be included after all other headers, + * or issues can be identified + * against Windows SDK/DDK included headers which we have no control over. + * + */ +#define _SDL_BANNED_RECOMMENDED +#include "win\banned.h" +#endif #define ESIF_DEBUG_MODULE ESIF_DEBUG_MOD_HASH diff --git a/ESIF/Products/ESIF_CM/Sources/esif_hash_table.h b/ESIF/Products/ESIF_CM/Sources/esif_hash_table.h index d5a7975e..ec0f9de8 100644 --- a/ESIF/Products/ESIF_CM/Sources/esif_hash_table.h +++ b/ESIF/Products/ESIF_CM/Sources/esif_hash_table.h @@ -111,8 +111,10 @@ void esif_ht_exit(void); #endif /* TODO */ +#ifdef ESIF_ATTR_USER typedef struct esif_ht EsifHashTable2, *EsifHashTable2Ptr, **EsifHashTable2PtrLocation; +#endif /*****************************************************************************/ /*****************************************************************************/ diff --git a/ESIF/Products/ESIF_CM/Sources/esif_ipc.c b/ESIF/Products/ESIF_CM/Sources/esif_ipc.c index 105397ef..6b243b17 100644 --- a/ESIF/Products/ESIF_CM/Sources/esif_ipc.c +++ b/ESIF/Products/ESIF_CM/Sources/esif_ipc.c @@ -51,7 +51,9 @@ ** *******************************************************************************/ +#ifdef ESIF_ATTR_USER # define ESIF_TRACE_ID ESIF_TRACEMODULE_IPC +#endif #include "esif_ipc.h" #include "esif_primitive.h" @@ -59,7 +61,136 @@ #include "esif_trace.h" #include "esif_ccb_time.h" +#ifdef ESIF_ATTR_OS_WINDOWS +/* + * + * The Windows banned-API check header must be included after all other headers, + * or issues can be identified + * against Windows SDK/DDK included headers which we have no control over. + * + */ +#define _SDL_BANNED_RECOMMENDED +#include "win\banned.h" +#endif + +#ifdef ESIF_ATTR_KERNEL + +#define ESIF_DEBUG_MODULE ESIF_DEBUG_MOD_IPC + +#define ESIF_TRACE_DYN_INIT(fmt, ...) \ + ESIF_TRACE_DYN(ESIF_DEBUG_MOD_IPC, IPC_TRACE_INIT, fmt, ##__VA_ARGS__) +#define ESIF_TRACE_DYN_IPC(fmt, ...) \ + ESIF_TRACE_DYN(ESIF_DEBUG_MOD_IPC, IPC_TRACE_DEBUG, fmt, ##__VA_ARGS__) + +/* + * Kernel Implementation + */ + +/* + ****************************************************************************** + * PUBLIC + ****************************************************************************** + */ + +/* Process IPC */ +struct esif_ipc *esif_ipc_process( + struct esif_ipc *ipc_ptr + ) +{ + struct esif_ipc *ipc_ret_ptr = ipc_ptr; + struct esif_ipc_command *cmd_ptr = NULL; + struct esif_ipc_primitive *prim_ptr = NULL; + + ESIF_TRACE_DYN_IPC("START ipc %p\n", ipc_ptr); + + if (NULL == ipc_ptr) + goto exit; + + /* + * If we got this far we are guaranteed to have a valid IPC + * header now we need to check to see if we hav enough data + * for the type specified if so process it if not return to + * avoid what would surely result in undesired behavior. + */ + + switch (ipc_ptr->type) { + /* Command e.g. Get Participants, Etc. */ + case ESIF_IPC_TYPE_COMMAND: + ESIF_TRACE_DYN_IPC("COMMAND Received\n"); + cmd_ptr = (struct esif_ipc_command *)(ipc_ptr + 1); + if ((ipc_ptr->data_len < sizeof(*cmd_ptr)) || + (ipc_ptr->data_len < (esif_ipc_command_get_data_len(cmd_ptr) + sizeof(*cmd_ptr)))) + ipc_ptr->return_code = ESIF_E_IPC_DATA_INVALID; + else + + esif_execute_ipc_command(cmd_ptr); + break; + + /* Retrieve A Signaled Event Or Check Event Queue */ + case ESIF_IPC_TYPE_EVENT: + ESIF_TRACE_DYN_IPC("EVENT Received\n"); + if (ipc_ptr->data_len < sizeof(struct esif_ipc_event)) + ipc_ptr->return_code = ESIF_E_IPC_DATA_INVALID; + else + ipc_ret_ptr = esif_event_queue_pull(); + break; + + /* Execute Primitive e.g. GET_TEMPERATURE */ + case ESIF_IPC_TYPE_PRIMITIVE: + ESIF_TRACE_DYN_IPC("PRIMITIVE Received\n"); + prim_ptr = (struct esif_ipc_primitive *)(ipc_ptr + 1); + if ((ipc_ptr->data_len < sizeof(*prim_ptr)) || + (ipc_ptr->data_len < (esif_ipc_primitive_get_data_len(prim_ptr) + sizeof(*prim_ptr)))) + ipc_ptr->return_code = ESIF_E_IPC_DATA_INVALID; + else + esif_execute_ipc_primitive(prim_ptr); + break; + + /* NOOP For Testing */ + case ESIF_IPC_TYPE_NOOP: + ESIF_TRACE_DYN_IPC("NOOP Received\n"); + ipc_ret_ptr = NULL; + break; + + /* Unsupported or Unknown IPC Type Received */ + default: + ESIF_TRACE_DYN_IPC("Unknown IPC Type Received type=%u\n", + ipc_ptr->type); + ipc_ptr->return_code = ESIF_E_IPC_DATA_INVALID; + break; + } + ESIF_TRACE_DYN_IPC("FINISH return result: %s(%u)\n", + esif_rc_str(ipc_ptr->return_code), + ipc_ptr->return_code); +exit: + return ipc_ret_ptr; +} + + +/* Init */ +enum esif_rc esif_ipc_init( + esif_device_t device + ) +{ + ESIF_TRACE_DYN_INIT("Initialize IPC\n"); + + return esif_os_ipc_init(device); +} + + +/* Exit */ +void esif_ipc_exit( + esif_device_t device + ) +{ + esif_os_ipc_exit(device); + + ESIF_TRACE_DYN_INIT("Exit IPC\n"); +} + +#endif /* ESIF_ATTR_KERNEL */ +#ifdef ESIF_ATTR_USER /* ** User Implementation @@ -96,6 +227,7 @@ enum esif_rc esif_ipc_execute( } +#endif /* ESIF_ATTR_USER */ /* diff --git a/ESIF/Products/ESIF_CM/Sources/esif_ipc.h b/ESIF/Products/ESIF_CM/Sources/esif_ipc.h index ba9cd25e..3c564cc8 100644 --- a/ESIF/Products/ESIF_CM/Sources/esif_ipc.h +++ b/ESIF/Products/ESIF_CM/Sources/esif_ipc.h @@ -73,9 +73,29 @@ /* IOCTLS May There Be Few */ +#ifdef ESIF_ATTR_OS_LINUX #define ESIF_IOCTL_IPC_NOOP _IO('A', 0) #define ESIF_IOCTL_IPC _IOWR('A', 1, u8*) +#endif + +#ifdef ESIF_ATTR_OS_WINDOWS + +#ifdef ESIF_ATTR_USER +/* Need to disable this otherwise RS4 EWDK 17074 causes warning about deprecated memcpy and RtlCopyMemory in Microsoft code (winioctl.h) */ +#pragma warning(disable:4995) +#include +#pragma warning(default:4995) +#endif + +#define ESIF_IPC_CODE(x) CTL_CODE(FILE_DEVICE_NETWORK, x, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define ESIF_IOCTL_IPC_NOOP ESIF_IPC_CODE(0) +#define ESIF_IOCTL_IPC ESIF_IPC_CODE(1) +#define ESIF_IOCTL_IPC_IPC_SUSPEND ESIF_IPC_CODE(2) +#define ESIF_IOCTL_IPC_IPC_RESUME ESIF_IPC_CODE(3) +#define ESIF_IOCTL_ENABLE_EVENT_DOORBELL ESIF_IPC_CODE(4) +#define ESIF_IOCTL_IETM_ACPI_ACCESS_INFO ESIF_IPC_CODE(5) +#endif /* IPC Types May There Be Few */ enum esif_ipc_type { @@ -107,10 +127,30 @@ struct esif_ipc { /* Data Is Here ... */ }; +#if defined(ESIF_ATTR_OS_WINDOWS) +struct esif_ipc_event_enable { + HANDLE eventDoorbell; + HANDLE eventLfExit; +}; + +struct esif_ipc_ietm_access_info { + size_t size; + size_t pdoNameOffset; + size_t pathOffset; + // PDO name and path data begins here... +}; + +#endif #pragma pack(pop) +#ifdef ESIF_ATTR_USER +#if defined(ESIF_ATTR_OS_WINDOWS) +typedef struct esif_ipc_event_enable EsifIpcEventEnable, *EsifIpcEventEnablePtr; +typedef struct esif_ipc_ietm_access_info EsifIpcIetmAccessInfo, *EsifIpcIetmAccessInfoPtr; +#endif typedef struct esif_ipc EsifIpc, *EsifIpcPtr, **EsifIpcPtrLocation; +#endif /* * IPC Primitive @@ -140,8 +180,10 @@ struct esif_ipc_primitive { #pragma pack(pop) +#ifdef ESIF_ATTR_USER typedef struct esif_ipc_primitive EsifIpcPrimitive, *EsifIpcPrimitivePtr, **EsifPrimitivePtrLoction; +#endif /* Primitive Source Is Always Upper Framework Or UNICAST */ static ESIF_INLINE esif_string esif_primitive_src_str(u8 src_id) @@ -255,6 +297,23 @@ enum esif_rc esif_os_ipc_execute(esif_os_handle_t handle, } #endif +#ifdef ESIF_ATTR_KERNEL + +/* + * Kernel Decleration + */ + +/* Receive IPC */ +struct esif_ipc *esif_ipc_process(struct esif_ipc *ipc_ptr); + +/* Init / Exit */ +enum esif_rc esif_ipc_init(esif_device_t device); +enum esif_rc esif_os_ipc_init(esif_device_t device); + +void esif_ipc_exit(esif_device_t device); +void esif_os_ipc_exit(esif_device_t device); + +#endif /* ESIF_ATTR_KERNEL */ #endif /* _ESIF_IPC_H_ */ /*****************************************************************************/ diff --git a/ESIF/Products/ESIF_CM/Sources/esif_mempool.h b/ESIF/Products/ESIF_CM/Sources/esif_mempool.h index c6646ab8..bd191bca 100644 --- a/ESIF/Products/ESIF_CM/Sources/esif_mempool.h +++ b/ESIF/Products/ESIF_CM/Sources/esif_mempool.h @@ -54,7 +54,9 @@ #ifndef _ESIF_MEMPOOL_H_ #define _ESIF_MEMPOOL_H_ +#ifdef ESIF_ATTR_USER #include "esif.h" +#endif /* Memory Pools */ enum esif_mempool_type { diff --git a/ESIF/Products/ESIF_CM/Sources/esif_nvme.h b/ESIF/Products/ESIF_CM/Sources/esif_nvme.h index b3a50081..db95287a 100644 --- a/ESIF/Products/ESIF_CM/Sources/esif_nvme.h +++ b/ESIF/Products/ESIF_CM/Sources/esif_nvme.h @@ -53,6 +53,739 @@ #pragma once +#if defined(ESIF_ATTR_OS_WINDOWS) +#include +#include + +#define STORAGE_IDENTIFY_OUTPUT_BUFFER_SIZE (4 * 1024) +#define STORAGE_DEVICE_DESCRIPTOR_OUTPUT_BUFFER_SIZE (4 * 1024) +#define LOG_PAGE_BUFFER_SIZE 512 +#define LOG_PAGE_TEMPERATURE_OFFSET 1 +#define IDENTIFY_PDL_OFFSET 263 +#define POWER_STATES_OFFSET 2048 +#define POWER_STATES_MULTIPLIER_OFFSET 3 +#define POWER_STATES_SIZE 32 +#define SATA_NUM_EFFECTIVE_STATES 3 +#define SATA_PERF_HIGH 236 +#define SATA_PERF_MEDIUM 128 +#define SATA_PERF_LOW 1 + +#define NVME_STORPORT_DRIVER 0xE000 +#define NVME_PT_TIMEOUT 40 +#define NVME_IOCTL_VENDOR_SPECIFIC_DW_SIZE 6 +#define NVME_IOCTL_CMD_DW_SIZE 16 +#define NVME_IOCTL_COMPLETE_DW_SIZE 4 +#define NVME_FROM_DEV_TO_HOST 2 +#define NVME_RETURN_TO_HOST 1 +#define NVME_PASS_THROUGH_SRB_IO_CODE \ + CTL_CODE( NVME_STORPORT_DRIVER, 0x800, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define NVME_SIG_STR "NvmeMini" +#define NVME_SIG_STR_LEN 8 +#define NVME_SET_FEATURE_OPT 9 +#define NVME_PSTATE_OPT 2 +#define NVME_DATA_VALUE_LOG_PAGE 2 +#define NVME_DATA_VALUE_NONE 0 +#define NVME_IDENTIFY_CNS_CONTROLLER 1 +#define NVME_GET_LOG_PAGE_OPT 2 +#define NVME_GET_IDENTIFY_PAGE_OPT 6 +#define NVME_NAMESPACE_NA 0xFFFFFFFF +#define NVME_LOG_PAGE_IDENTIFIER_SMART 0x00000002 +#define NVME_LOG_PAGE_IDENTIFIER_SMART_RST 0x7f0002 +#define INTEL_NVME_PASSTHROUGH_VERSION 1 +#define INTEL_NVME_PASSHTROUGH_HEADER_SIZE 28 + +#define DRIVE_HEAD_REGISTER 160 +#define DFP_SEND_DRIVE_COMMAND 0x0007c084 +#define DFP_RECEIVE_DRIVE_DATA 0x0007c088 +#define ATA_NUM_POWER_STATES 254 +#define ATA_MIN_POWER_STATE 1 +#define MAX_ATA_SMART_ATTRIBUTES 30 +#define SETFEATURES_EN_APM 0x05 + +#define NUMBER_PPSS_FIELDS 8 +#define POWER_FIELD_INDEX 5 +#define UNIT_FIELD_INDEX 7 +#define INDEX_TO_COUNT_OFFSET 1 + +#define SMART_ATTRIBUTE_TEMPERATURE 0XBE +#define ATA_SETFEATURES 0xEF +#define ATA_SET_PERFORMANCE_LEVEL 0xCF +#define ATA_SETFEATURES_TIMEOUT 2 +#define TASK_DEFINITION_INDEX 0 +#define TASK_DEFINITION_VALUE_INDEX 1 +#define TASK_DEFINITION_TARGET_INDEX 5 +#define TASK_DEFINITION_TYPE_INDEX 6 +#define INTEL_NVME_TIMEOUT 60 +#define INTELRMP_SIGNATURE "IntelRmp" +#define INTELNVM_SIGNATURE "IntelNvm" +#define IOCTL_REMAPPORT_GET_PATHIDS_IMPLEMENTED 0x80000D02 +#define IOCTL_REMAPPORT_GET_TARGETIDS_IMPLEMENTED 0x80000D03 +#define IOCTL_INTEL_NVME_PASSTHROUGH 0xF0002808 +#define TEMPERATURE_THRESHOLD 0x04 +#define IOCTL_NVME_PASS_THROUGH \ + CTL_CODE(0xF000u, 0xA02, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define AEN_MAX_EVENT_NAME_LENGTH 32 +#define NVME_GET_AER_DATA_MAX_COMPLETIONS 10 +#define IOCTL_NVME_REGISTER_AER \ + CTL_CODE(0xF000u, 0xC00, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define IOCTL_NVME_GET_AER_DATA \ + CTL_CODE(0xF000u, 0xE00, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define NVME_GLOBAL_NAMESPACE_ID (0xffffffff) +#define NVME_GLOBAL_NAMESPACE_ID_DEVICE_NAME (0x0) + +// IOCTL Control Codes (IoctlHeader.ControlCode) +// Control Codes requiring CSMI_ALL_SIGNATURE +#define CC_CSMI_SAS_GET_DRIVER_INFO 1 /**< RST SUPPORTED */ +#define CC_CSMI_SAS_GET_RAID_INFO 10 /**< RST SUPPORTED */ +#define CC_CSMI_SAS_GET_RAID_CONFIG 11 /**< RST SUPPORTED */ + +// Signature value +// (IoctlHeader.Signature) +#define CSMI_ALL_SIGNATURE "CSMIALL" /**< RST SUPPORTED - CC_CSMI_SAS_GET_DRIVER_INFO, CC_CSMI_SAS_GET_CNTLR_STATUS, CC_CSMI_SAS_GET_CNTLR_CONFIG */ +#define CSMI_RAID_SIGNATURE "CSMIARY" /**< RST SUPPORTED - CC_CSMI_SAS_GET_RAID_INFO, CC_CSMI_SAS_GET_RAID_CONFIG */ + +#pragma pack(push, 1) + +struct _pwr_flags { + unsigned int multiplier : 1; + unsigned int nops : 1; +}; + +struct _scsi_address { + unsigned long len; + unsigned char port_number; + unsigned char path_id; + unsigned char target_id; + unsigned char lun; +}; + +typedef struct NVME_PASS_THROUGH_IOCTL { + SRB_IO_CONTROL SrbIoCtrl; + DWORD VendorSpecific[NVME_IOCTL_VENDOR_SPECIFIC_DW_SIZE]; + DWORD NVMeCmd[NVME_IOCTL_CMD_DW_SIZE]; + DWORD CplEntry[NVME_IOCTL_COMPLETE_DW_SIZE]; + DWORD Direction; + DWORD QueueId; + DWORD DataBufferLen; + DWORD MetaDataLen; + DWORD ReturnBufferLen; + UCHAR DataBuffer[STORAGE_IDENTIFY_OUTPUT_BUFFER_SIZE]; +} NVMEPassThroughIOCTL, *NVMEPassThroughIOCTLPtr; + +typedef struct _SMART_READ_DATA_OUTDATA +{ + SENDCMDOUTPARAMS SendCmdOutParam; + BYTE Data[READ_ATTRIBUTE_BUFFER_SIZE - 1]; +} SMART_READ_DATA_OUTDATA, *PSMART_READ_DATA_OUTDATA; + +typedef struct _SMART_ATTRIBUTE +{ + BYTE Id; + WORD StatusFlags; + BYTE CurrentValue; + BYTE WorstValue; + BYTE RawValue[6]; + BYTE Reserved; +} SMARTAttribute; + +typedef struct _IDENTIFY_DEVICE_OUTDATA +{ + SENDCMDOUTPARAMS SendCmdOutParam; + BYTE Data[IDENTIFY_BUFFER_SIZE - 1]; +} IDENTIFY_DEVICE_OUTDATA, *PIDENTIFY_DEVICE_OUTDATA; + +typedef struct Opcode_s { + union { + struct { + UInt32 DataTransfer : 2; + UInt32 Function : 5; + UInt32 GenericCommand : 1; + }OpcodeStruct; + + UInt8 Raw; + }OpcodeUnion; +}Opcode, *OpcodePtr; + +typedef struct CommandDword0_s { + Opcode OPC; +}CommandDword0, *CommandDword0Ptr; + +struct GENERIC_COMMAND { + UInt32 CDW0; + UInt32 NSID; + UInt32 CDW2; + UInt32 CDW3; + UInt32 CDW4; + UInt32 CDW5; + UInt64 PRP1; + UInt64 PRP2; + UInt32 CDW10; + UInt32 CDW11; + UInt32 CDW12; + UInt32 CDW13; + UInt32 CDW14; + UInt32 CDW15; +}; + +struct ADMIN_ABORT { + UInt16 SQID; + UInt16 CID; + UInt32 CDW11; + UInt32 CDW12; + UInt32 CDW13; + UInt32 CDW14; + UInt32 CDW15; +}; + +struct ADMIN_ASYNCHRONOUS_EVENT_INFORMATION { + UInt32 CDW10; + UInt32 CDW11; + UInt32 CDW12; + UInt32 CDW13; + UInt32 CDW14; + UInt32 CDW15; +}; + +struct ADMIN_CREATE_IO_COMPLETION_QUEUE { + UInt16 QID; // Queue Identifier + UInt16 QSIZE; // Queue Size + + UInt32 PC : 1; // Physically Contiguous + UInt32 IEN : 1; // Interrupts Enabled + UInt32 Reserved : 14; + UInt16 IV; // Interrupt Vector + + UInt32 CDW12; + UInt32 CDW13; + UInt32 CDW14; + UInt32 CDW15; +}; + +struct ADMIN_CREATE_IO_SUBMISSION_QUEUE { + UInt16 QID; // Queue Identifier + UInt16 QSIZE; // Queue Size + + UInt32 PC : 1; // Physically Contiguous + UInt32 QPRIO : 2; // Queue Priority + UInt32 Reserved : 13; + UInt16 CQID; // Completion Queue Identifier + + UInt32 CDW12; + UInt32 CDW13; + UInt32 CDW14; + UInt32 CDW15; +}; + +struct ADMIN_DELETE_IO_COMPLETION_QUEUE { + UInt16 QID; + UInt16 Reserved; + + UInt32 CDW11; + UInt32 CDW12; + UInt32 CDW13; + UInt32 CDW14; + UInt32 CDW15; +}; + +// ********** ADMIN COMMAND SET DEFINITION **************** // +#define ADMIN_COMMAND_SET_FEATURES 0x09 +#define ADMIN_COMMAND_GET_FEATURES 0x0A +#define ADMIN_COMMAND_IDENTIFY 0x06 + +// Section 5.6 +struct ADMIN_DELETE_IO_SUBMISSION_QUEUE { + UInt16 QID; + UInt16 Reserved; + + UInt32 CDW11; + UInt32 CDW12; + UInt32 CDW13; + UInt32 CDW14; + UInt32 CDW15; +}; + +// Section 5.7 +struct ADMIN_FIRMWARE_COMMIT { + UInt32 FS : 3; // Firmware Slot + UInt32 CA : 3; // Commit Action + UInt32 Reserved : 26; + + UInt32 CDW11; + UInt32 CDW12; + UInt32 CDW13; + UInt32 CDW14; + UInt32 CDW15; +}; + +// Section 5.8 +struct ADMIN_FIRMWARE_IMAGE_DOWNLOAD { + UInt32 NUMD; + UInt32 OFST; + + UInt32 CDW12; + UInt32 CDW13; + UInt32 CDW14; + UInt32 CDW15; +}; + +// Section 5.10 +struct ADMIN_GET_LOG_PAGE { + UInt32 LID : 8; + UInt32 LSP : 4; + UInt32 Reserved : 3; + UInt32 RAE : 1; + UInt32 NUMDL : 16; + + UInt32 CDW11; + UInt32 CDW12; + UInt32 CDW13; + UInt32 CDW14; + UInt32 CDW15; +}; + +// Section 5.11 +struct ADMIN_IDENTIFY { + UInt32 CNS : 8; + UInt32 Reserved : 8; + UInt32 CNTID : 16; + + UInt32 CDW11; + UInt32 CDW12; + UInt32 CDW13; + UInt32 CDW14; + UInt32 CDW15; +}; + +#define ADMIN_IDENTIFY_CNS_CONTROLLER 0x1 + +struct ADMIN_FEATURES_ARBITRATION +{ + UInt32 AB : 3; + UInt32 Reserved : 5; + UInt32 LPW : 8; + UInt32 MPW : 8; + UInt32 HPW : 8; +}; + +struct ADMIN_FEATURES_POWER_MANAGEMENT +{ + UInt32 PS : 5; + UInt32 WH : 3; + UInt32 Reserved : 24; +}; + +struct ADMIN_FEATURES_LBA_RANGE_TYPE_COMPLETION_CDW0 +{ + UInt32 NUM : 6; + UInt32 Reserved : 26; +}; + +union ADMIN_FEATURES_TEMPERATURE_THRESHOLD +{ + struct { + UInt32 TMPTH : 16; // Temperature Threshold + UInt32 TMPSEL : 4; // Threshold Temperature Select + UInt32 THSEL : 2; // Threshold Type Select + UInt32 Reserved : 10; + }a; + UInt32 Raw; +}; + +struct ADMIN_FEATURES_ERROR_RECOVERY +{ + UInt32 TLER : 16; + UInt32 DUBLE : 1; + UInt32 Reserved : 15; +}; + +struct ADMIN_FEATURES_VOLATILE_WRITE_CACHE +{ + UInt32 WCE : 1; + UInt32 Reserved : 31; +}; + +struct ADMIN_FEATURES_NUMBER_OF_QUEUES { + UInt32 NCQR : 16; + UInt32 NSQR : 16; +}; + +struct ADMIN_FEATURES_INTERRUPT_COALESCING +{ + UInt32 THR : 8; + UInt32 Time : 8; + UInt32 Reserved : 16; +}; + +struct ADMIN_FEATURES_INTERRUPT_VECTOR_CONFIGURATION +{ + UInt32 IV : 16; + UInt32 CD : 1; + UInt32 Reserved : 15; +}; + +struct ADMIN_FEATURES_WRITE_ATOMICITY +{ + UInt32 DN : 1; + UInt32 Reserved : 31; +}; + +union ADMIN_FEATURES_ASYNCHRONOUS_EVENT_CONFIGURATION +{ + struct { + UInt32 SMART : 8; + UInt32 NamespaceAttributeNotices : 1; + UInt32 FirmwareActivationNotices : 1; + UInt32 Reserved : 22; + }a; + UInt32 Mask; +}; + +struct ADMIN_FEATURES_AUTONOMOUS_POWER_STATE_TRANSITION_CDW0 +{ + UInt32 APSTE : 1; + UInt32 Reserved : 31; +}; + +struct ADMIN_FEATURES_SOFTWARE_PROGRESS_MARKER +{ + UInt32 PBSLC : 8; + UInt32 Reserved : 24; +}; + +struct ADMIN_FEATURES_HOST_MEMORY_BUFFER { + UInt32 EHM : 1; // Enable Host Memory + UInt32 MR : 1; // Memory Return + UInt32 Reserved : 30; +}; + +struct ADMIN_SET_FEATURES { + UInt32 FID : 8; + UInt32 Reserved : 23; + UInt32 SV : 1; + + union { + struct ADMIN_FEATURES_ARBITRATION CommandArbitration; + struct ADMIN_FEATURES_POWER_MANAGEMENT PowerManagement; + struct ADMIN_FEATURES_LBA_RANGE_TYPE_COMPLETION_CDW0 LbaRangeType; + union ADMIN_FEATURES_TEMPERATURE_THRESHOLD TemperatureThreshold; + struct ADMIN_FEATURES_ERROR_RECOVERY ErrorRecovery; + struct ADMIN_FEATURES_VOLATILE_WRITE_CACHE VolatileWriteCache; + struct ADMIN_FEATURES_NUMBER_OF_QUEUES NumberOfQueues; + struct ADMIN_FEATURES_INTERRUPT_COALESCING InterruptCoalescing; + struct ADMIN_FEATURES_INTERRUPT_VECTOR_CONFIGURATION InterruptVectorConfiguration; + struct ADMIN_FEATURES_WRITE_ATOMICITY WriteAtomicity; + union ADMIN_FEATURES_ASYNCHRONOUS_EVENT_CONFIGURATION AsynchronousEventConfiguration; + struct ADMIN_FEATURES_AUTONOMOUS_POWER_STATE_TRANSITION_CDW0 AutonomousPowerStateTransition; + struct ADMIN_FEATURES_SOFTWARE_PROGRESS_MARKER SoftwareProgressMarker; + struct ADMIN_FEATURES_HOST_MEMORY_BUFFER HostMemoryBuffer; + + UInt32 CDW11; + }a; + UInt32 CDW12; + UInt32 CDW13; + UInt32 CDW14; + UInt32 CDW15; +}; + +// Section 5.9 +struct ADMIN_GET_FEATURES { + UInt32 FID : 8; + UInt32 SEL : 3; + UInt32 Reserved : 21; + + union { + struct ADMIN_FEATURES_ARBITRATION CommandArbitration; + struct ADMIN_FEATURES_POWER_MANAGEMENT PowerManagement; + struct ADMIN_FEATURES_LBA_RANGE_TYPE_COMPLETION_CDW0 LbaRangeType; + union ADMIN_FEATURES_TEMPERATURE_THRESHOLD TemperatureThreshold; + struct ADMIN_FEATURES_ERROR_RECOVERY ErrorRecovery; + struct ADMIN_FEATURES_VOLATILE_WRITE_CACHE VolatileWriteCache; + struct ADMIN_FEATURES_NUMBER_OF_QUEUES NumberOfQueues; + struct ADMIN_FEATURES_INTERRUPT_COALESCING InterruptCoalescing; + struct ADMIN_FEATURES_INTERRUPT_VECTOR_CONFIGURATION InterruptVectorConfiguration; + struct ADMIN_FEATURES_WRITE_ATOMICITY WriteAtomicity; + union ADMIN_FEATURES_ASYNCHRONOUS_EVENT_CONFIGURATION AsynchronousEventConfiguration; + struct ADMIN_FEATURES_AUTONOMOUS_POWER_STATE_TRANSITION_CDW0 AutonomousPowerStateTransition; + struct ADMIN_FEATURES_SOFTWARE_PROGRESS_MARKER SoftwareProgressMarker; + + UInt32 CDW11; + }a; + UInt32 CDW12; + UInt32 CDW13; + UInt32 CDW14; + UInt32 CDW15; +}; + +struct ADMIN_FORMAT_NVM_COMMAND { + UInt32 LBAF : 4; + UInt32 MS : 1; + UInt32 PI : 3; + UInt32 IPL : 1; + UInt32 SES : 3; + UInt32 Reserved : 20; + + UInt32 CDW11; + UInt32 CDW12; + UInt32 CDW13; + UInt32 CDW14; + UInt32 CDW15; +}; + +struct ADMIN_SECURITY_SEND_COMMAND { + UInt32 Reserved : 8; + UInt32 SPSP : 16; + UInt32 SECP : 8; + + UInt32 AL; + + UInt32 CDW12; + UInt32 CDW13; + UInt32 CDW14; + UInt32 CDW15; +}; + +struct ADMIN_SECURITY_RECEIVE_COMMAND { + UInt32 Reserved : 8; + UInt32 SPSP : 16; + UInt32 SECP : 8; + + UInt32 AL; + + UInt32 CDW12; + UInt32 CDW13; + UInt32 CDW14; + UInt32 CDW15; +}; + +// section 5.7 +struct ADMIN_DEVICE_SELF_TEST_COMMAND { + UInt32 STC : 4; + UInt32 Reserved : 28; + + UInt32 CDW11; + UInt32 CDW12; + UInt32 CDW13; + UInt32 CDW14; + UInt32 CDW15; +}; + +// Section 4.2, Figure 11 +typedef struct AdminCommand_s { + CommandDword0 CDW0; + UInt32 NSID; + UInt64 Reserved; + UInt64 MPTR; + UInt64 PRP1; + UInt64 PRP2; + + union { + struct ADMIN_ABORT AdminAbort; + struct ADMIN_ASYNCHRONOUS_EVENT_INFORMATION AsynchronousEventInformation; + struct ADMIN_CREATE_IO_COMPLETION_QUEUE CreateIoCompletionQueue; + struct ADMIN_CREATE_IO_SUBMISSION_QUEUE CreateIoSubmissionQueue; + struct ADMIN_DELETE_IO_COMPLETION_QUEUE DeleteIoCompletionQueue; + struct ADMIN_DELETE_IO_SUBMISSION_QUEUE DeleteIoSubmissionQueue; + struct ADMIN_FIRMWARE_COMMIT FirmwareCommit; + struct ADMIN_FIRMWARE_IMAGE_DOWNLOAD FirmwareImageDownload; + struct ADMIN_GET_FEATURES GetFeatures; + struct ADMIN_GET_LOG_PAGE GetLogPage; + struct ADMIN_IDENTIFY Identify; + struct ADMIN_SET_FEATURES SetFeatures; + struct ADMIN_FORMAT_NVM_COMMAND FormatNvmCommand; + struct ADMIN_SECURITY_SEND_COMMAND SecuritySendCommand; + struct ADMIN_SECURITY_RECEIVE_COMMAND SecurityReceiveCommand; + struct ADMIN_DEVICE_SELF_TEST_COMMAND DeviceSelfTest; + + struct { + UInt32 CDW10; + UInt32 CDW11; + UInt32 CDW12; + UInt32 CDW13; + UInt32 CDW14; + UInt32 CDW15; + } Raw; + }a; + +}AdminCommand, *AdminCommandPtr; + +struct COMPLETION_QUEUE_ENTRY { + u32 DW0_Command_Specific; + u32 DW1_Reserved; + u32 DW2_SQuid_SQHead; + u32 DW3_StatusField_CommmandID; +}; + +typedef struct AdminAsynchronousEventRequestCompletionDw0_s { + union { + struct { + UInt32 AsynchronousEventType : 3; + UInt32 Reserved1 : 5; + UInt32 AsynchronousEventInformation : 8; + UInt32 AssociatedLogPage : 8; + UInt32 Reserved2 : 8; + } AdminAsynchronousEventRequestCompletionDw0s; + UInt32 Raw; + } AdminAsynchronousEventRequestCompletionDw0u; +} AdminAsynchronousEventRequestCompletionDw0, *AdminAsynchronousEventRequestCompletionDw0Ptr; + +typedef struct AdminIdentifyControllerData_s { + UInt16 VID; + UInt16 SSVID; + UInt8 SN[20]; + UInt8 MN[40]; + UInt8 FR[8]; + UInt8 RAB; + UInt8 IEEE[3]; + UInt8 Data[190]; + UInt16 WCTemp; + UInt8 VS[3828]; +}AdminIdentifyControllerData, *AdminIdentifyControllerDataPtr; + +#pragma pack(pop) + +typedef struct +{ + ATA_PASS_THROUGH_EX Apt; + DWORD Filer; + BYTE Buf[512]; +} ATA_PASS_THROUGH_EX_WITH_BUFFERS; + +struct NVME_PASS_THROUGH_PARAMETERS { + struct GENERIC_COMMAND Command; + BOOLEAN IsIOCommandSet; + struct COMPLETION_QUEUE_ENTRY Completion; + ULONG DataBufferOffset; + ULONG DataBufferLength; + ULONG Reserved[10]; +}; + +struct NVME_IOCTL_PASS_THROUGH { + SRB_IO_CONTROL Header; + UCHAR Version; + UCHAR PathID; + UCHAR TargetID; + UCHAR Lun; + struct NVME_PASS_THROUGH_PARAMETERS Parameters; +}; + +struct NVME_IOCTL_PASS_THROUGH_WITH_DATA { + struct NVME_IOCTL_PASS_THROUGH Ioctl; + AdminIdentifyControllerData Data; + UCHAR Padding[4]; +}; + +typedef struct AsynchronousNotificationEventInfo_s { + HANDLE eventHandle; + esif_string eventName; + int scsiPort; + int scbl; + char *scsiPath; +}AsynchronousNotificationEventInfo, *AsynchronousNotificationEventInfoPtr; + +typedef struct RaidportRegisterSharedEvent_s { + UInt8 eventName[AEN_MAX_EVENT_NAME_LENGTH]; + UInt8 reserved; + UInt64 eventMask; +} RaidportRegisterSharedEvent, *RaidportRegisterSharedEventPtr; + +typedef struct NvmeIoctlRegisterAer_s { + SRB_IO_CONTROL Header; + RaidportRegisterSharedEvent EventData; +}NvmeIoctlRegisterAer, *NvmeIoctlRegisterAerPtr; + +typedef struct NvmeAerData_s { + UInt8 eventName[AEN_MAX_EVENT_NAME_LENGTH]; + UInt8 reserved; + AdminAsynchronousEventRequestCompletionDw0 Completions[NVME_GET_AER_DATA_MAX_COMPLETIONS]; + UInt32 CompletionsCount; +}NvmeAerData, *NvmeAerDataPtr; + +typedef struct NvmeIoctlGetAerData_s { + SRB_IO_CONTROL Header; + NvmeAerData Data; +}NvmeIoctlGetAerData, *NvmeIoctlGetAerDataPtr; + +typedef struct CsmiSasDriverInfo_s { + UInt8 szName[81]; /**< RST driver file name */ + UInt8 szDescription[81]; /**< RST driver description */ + UInt16 usMajorRevision; /**< RST driver MAJOR version - X.y.z.bbbb */ + UInt16 usMinorRevision; /**< RST driver MINOR version - x.Y.z.bbbb */ + UInt16 usBuildRevision; /**< RST driver HOT FIX number - x.y.Z.bbbb */ + UInt16 usReleaseRevision; /**< RST driver BUILD number - x.y.z.BBBB */ + UInt16 usCSMIMajorRevision; /**< RST driver supports this MAJOR revision of the CSMI specification - X.y */ + UInt16 usCSMIMinorRevision; /**< RST driver supports this MINOR revision of the CSMI specification - x.Y */ +}CsmiSasDriverInfo, *CsmiSasDriverInfoPtr; + +typedef struct CsmiSasDriverInfoBuffer_s { + SRB_IO_CONTROL Header; + CsmiSasDriverInfo Information; +}CsmiSasDriverInfoBuffer, *CsmiSasDriverInfoBufferPtr; + +typedef struct CsmiSasRaidInfo_s { + UInt32 uNumRaidSets; /**< Number of defined RST RAID volumes */ + UInt32 uMaxDrivesPerSet; /**< Maximum number of drives in a RST volume */ + UInt8 bReserved[92]; +}CsmiSasRaidInfo, *CsmiSasRaidInfoPtr; + +typedef struct CsmiSasRaidInfoBuffer_s { + SRB_IO_CONTROL Header; + CsmiSasRaidInfo Information; +}CsmiSasRaidInfoBuffer, *CsmiSasRaidInfoBufferPtr; + +typedef struct CsmiSasRaidDrives_s { + UInt8 bModel[40]; /**< Device model number */ + UInt8 bFirmware[8]; /**< Device firmware revision */ + UInt8 bSerialNumber[40]; /**< Device serial number */ + UInt8 bSASAddress[8]; /**< [0] Device lun, + [1] Device target ID, + [2] Device bus ID, + [3] Device bus ID (for legacy applications) */ + UInt8 bSASLun[8]; /**< NOT IMPLEMENTED */ + UInt8 bDriveStatus; /**< CSMI_SAS_DRIVE_STATUS_OK, CSMI_SAS_DRIVE_STATUS_REBUILDING, CSMI_SAS_DRIVE_STATUS_DEGRADED or DISK_SMART_EVENT_TRIGGERED */ + UInt8 bDriveUsage; /**< RST drive usage CSMI_SAS_DRIVE_CONFIG_NOT_USED, + CSMI_SAS_DRIVE_CONFIG_MEMBER or + CSMI_SAS_DRIVE_CONFIG_SPARE */ + UInt8 bReserved[30]; +}CsmiSasRaidDrives, *CsmiSasRaidDrivesPtr; + +typedef struct CsmiSasRaidConfig_s { + UInt32 uRaidSetIndex; /**< RST volume index requested/returned is zero based array */ + UInt32 uCapacity; /**< RST volume capacity in MB */ + UInt32 uStripeSize; /**< RST stripe size in KB */ + UInt8 bRaidType; /**< CSMI_SAS_RAID_TYPE_0, 1, 5, 10 or CSMI_SAS_RAID_TYPE_OTHER */ + UInt8 bStatus; /**< CSMI_SAS_RAID_SET_STATUS_OK if RST volume == "Normal" + CSMI_SAS_RAID_SET_STATUS_DEGRADED if RST volume == "Degraded" + CSMI_SAS_RAID_SET_STATUS_FAILED if RST volume == "Failed" + CSMI_SAS_RAID_SET_STATUS_REBUILDING if RST volume == "Initializing", "Rebuild", "Verifying" or "Migrating" */ + UInt8 bInformation; /**< No data 0x00 if RST volume == "Normal" + Drive index drive causing the degradation if RST volume == "Degraded" + Drive index of the failed drive if RST volume == "Failed" + 0-100 (percent done) if RST volume == "Initializing/Rebuilding" */ + UInt8 bDriveCount; /**< RST number of disks in the volume */ + UInt8 bReserved[20]; + CsmiSasRaidDrives Drives[5]; +}CsmiSasRaidConfig, *CsmiSasRaidConfigPtr; + +typedef struct CsmiSasRaidConfigBuffer_s { + SRB_IO_CONTROL Header; + CsmiSasRaidConfig Configuration; +}CsmiSasRaidConfigBuffer, *CsmiSasRaidConfigBufferPtr; + +typedef enum _AER_COMPLETION_EVENT_TYPES { + AE_TYPE_ERROR_STATUS = 0, + AE_TYPE_SMART_HEALTH_STATUS = 1, + AE_TYPE_NOTICE = 2, + AE_TYPE_IO_CMD_SET_SPECIFIC_STATUS = 6, + AE_TYPE_VENDOR_SPECIFIC = 7 +} AER_COMPLETION_EVENT_TYPE; + +typedef enum _AER_COMPLETION_EVENT_INFO_FOR_SMARTS { + AE_SMART_INFO_NVM_SUBSYSTEM_RELIABILITY = 0, + AE_SMART_INFO_TEMPERATURE_EXCEEDED_THRESHOLD = 1, + AE_SMART_INFO_SPARE_CAPACITY_BELOW_THRESHOLD = 2 +} AER_COMPLETION_EVENT_INFO_FOR_SMART; + +#endif // ESIF_ATTR_OS_WINDOWS diff --git a/ESIF/Products/ESIF_CM/Sources/esif_participant.h b/ESIF/Products/ESIF_CM/Sources/esif_participant.h index 9758d767..f478fbb5 100644 --- a/ESIF/Products/ESIF_CM/Sources/esif_participant.h +++ b/ESIF/Products/ESIF_CM/Sources/esif_participant.h @@ -132,6 +132,164 @@ struct esif_ipc_event_data_create_participant { #pragma pack(pop) +#ifdef ESIF_ATTR_KERNEL + +#include "esif_dsp.h" +#include "esif_temp.h" +#include "esif_power.h" +#include "esif_time.h" +#include "esif_percent.h" +#include "esif_primitive.h" +#include "esif_lf_domain.h" + +/* ESIF LF Participant State Machine Event types */ +enum esif_lp_sm_event { + ESIF_LP_SM_EVENT_DSP_LOAD = 0, + ESIF_LP_SM_EVENT_DSP_UNLOAD, + ESIF_LP_SM_EVENT_SUSPEND, + ESIF_LP_SM_EVENT_RESUME, +}; + + +/* ESIF LF Participant State Machine Event Descriptions */ +static ESIF_INLINE esif_string esif_lp_sm_event_str( + enum esif_lp_sm_event state) +{ + switch (state) { + ESIF_CASE(ESIF_LP_SM_EVENT_DSP_LOAD, "DSP_LOAD"); + ESIF_CASE(ESIF_LP_SM_EVENT_DSP_UNLOAD, "DSP_UNLOAD"); + ESIF_CASE(ESIF_LP_SM_EVENT_SUSPEND, "LP_SUSPEND"); + ESIF_CASE(ESIF_LP_SM_EVENT_RESUME, "LP_RESUME"); + } + return ESIF_NOT_AVAILABLE; +} + + +/* Lower Participant */ +#ifndef ESIF_FEAT_OPT_USE_VIRT_DRVRS +struct esif_lp { + + /* State control items */ + u8 instance; /* Lower Participant Instance */ + char pi_name[ESIF_NAME_LEN]; /* PI Name */ + enum esif_lp_state lp_state; /* Participant state */ + + enum esif_participant_enum enumerator; /* Device Enumerator */ + struct esif_participant_iface *pi_ptr; /* Particpant INTERFACE */ + + struct esif_lp_dsp *dsp_ptr; /* DSP */ + + /* Number Of Qualifiers For A Participant */ + u8 domain_count; + /* Domains For Participants */ + struct esif_lp_domain domains[ESIF_DOMAIN_MAX]; + + u32 ref_count; /* Reference count */ + u8 marked_for_delete; /* Delete pending flag */ + esif_ccb_low_priority_thread_lock_t lp_lock; /* LP Lock */ + esif_ccb_low_priority_thread_lock_t lp_sm_lock;/* For State Machine */ + + /* Signals waiters when the LP is no longer in use and may be destroyed */ + esif_ccb_event_t lp_destroy_event; +}; + +/* Takes an additional reference on an LP object */ +enum esif_rc esif_lp_get_ref( + struct esif_lp *self + ); + +/* Release a reference on an LP */ +void esif_lp_put_ref( + struct esif_lp *self + ); + +/* + * Locks the state of an LP so that it can be used with all state changes + * blocked. Must not be called by any function which will call + * esif_lp_handle_event + */ +void esif_lp_lock_state( + struct esif_lp *self + ); + +/* + * Unlocks the state of an LP after using it with the state locked by + * esif_lp_lock_state + */ +void esif_lp_unlock_state( + struct esif_lp *self + ); + +/* Get State */ +enum esif_lp_state esif_lp_get_state( + /* Lower Participant Intance */ + const struct esif_lp *self + ); + +/* Set State */ +enum esif_rc esif_lp_handle_event( + /* Lower Participant Instance */ + struct esif_lp *self, + /* Particpant State Machine Event Enumeration*/ + const enum esif_lp_sm_event state, + /* Event-dependent context data */ + void *ctx_ptr + ); + +esif_string esif_lp_get_name( + const struct esif_lp *self + ); + +enum esif_rc esif_lp_get_dmn_by_index( + const struct esif_lp *self, + const u8 index, + struct esif_lp_domain **dmn_ptr + ); + +enum esif_rc esif_lp_get_dmn_by_id( + const struct esif_lp *self, + const u16 id, + struct esif_lp_domain **dmn_ptr + ); + +enum esif_rc esif_lp_check_msr_whitelist( + const struct esif_lp *self, + const u32 msr, + const enum whitelist_access req_access + ); + +enum esif_rc esif_lp_check_ocmb_allowlist( + const struct esif_lp *self, + const u32 cmd, + const enum whitelist_access req_access + ); + +enum esif_rc esif_lp_check_mmio_whitelist( + const struct esif_lp *self, + const u32 offset, + const enum whitelist_access req_access + ); + +enum esif_rc esif_lp_load_dsp( + struct esif_lp *self, + const struct esif_data *cpc_ptr + ); + +void esif_lp_unload_dsp( + struct esif_lp *self + ); + +enum esif_rc esif_lp_suspend( + struct esif_lp *self + ); + +enum esif_rc esif_lp_resume( + struct esif_lp *self + ); + +#endif /* ESIF_FEAT_OPT_USE_VIRT_DRVRS */ +#endif /* ESIF ATTR_KERNEL */ +#ifdef ESIF_ATTR_USER #include "esif_sdk_iface_app.h" #include "esif_uf_fpc.h" @@ -390,6 +548,7 @@ static ESIF_INLINE void EsifUp_SetArbitrationContext(EsifUpPtr self, void *arbCt #ifdef __cplusplus } #endif +#endif /* ESIF_ATTR_USER */ #endif /* _ESIF_PARTICIPANT_H_ */ /******************************************************************************/ diff --git a/ESIF/Products/ESIF_CM/Sources/esif_pm.h b/ESIF/Products/ESIF_CM/Sources/esif_pm.h index 65acee86..9191d847 100644 --- a/ESIF/Products/ESIF_CM/Sources/esif_pm.h +++ b/ESIF/Products/ESIF_CM/Sources/esif_pm.h @@ -100,6 +100,100 @@ static ESIF_INLINE esif_string esif_pm_participant_state_str( ** KERNEL - Lower Framework Lower Participant (esif_lf_pm.c) ******************************************************************************* */ +#ifdef ESIF_ATTR_KERNEL + +struct lf_pm_iterator { + u8 handle; + u8 ref_taken; + u32 marker; +}; + +#define lf_pm_iterator_t struct lf_pm_iterator + +#define LF_PM_ITERATOR_MARKER 'LFPM' + +/* + * Get LP Instance By ID + * NOTE: Code should call esif_lp_put_ref after done using LP + */ +struct esif_lp *esif_lf_pm_get_lp_by_instance_id( + const u8 id + ); + +/* +* This function gets the real participant 0 and does not use symbolic linking +* to the external DPTF IETM. +*/ +struct esif_lp *esif_lf_pm_get_participant_0(void); + +/* + * Get By participant type and takes a reference to the LP + * NOTE: Code should call esif_lp_put_ref after done using LP + */ +struct esif_lp *esif_lf_pm_get_lp_by_type( + enum esif_domain_type part_type + ); + +/* + * Get LP By PI Pointer and takes a reference to the LP + * NOTE: Code should call esif_lp_put_ref after done using LP + */ +struct esif_lp *esif_lf_pm_get_lp_by_pi( + /* Participant Interface */ + const struct esif_participant_iface *pi_ptr + ); + +/* +* Get LP By Name and takes a reference to the LP +* NOTE: Code should call esif_lp_put_ref after done using LP +*/ +struct esif_lp *esif_lf_pm_get_lp_by_name( + const char *name +); + +/* + * Used to iterate through the available participants. + * First call esif_lf_pm_init_iterator to initialize the iterator. + * Next, call esif_lf_pm_get_next_lp using the iterator. Repeat until + * esif_lf_pm_get_next_lp fails. The call will release the reference of the + * participant from the previous call. If you stop iteration part way through + * all participants, the caller is responsible for releasing the reference on + * the last participant returned. Iteration is complete when + * ESIF_E_ITERATION_DONE is returned. + */ +enum esif_rc esif_lf_pm_init_iterator( + lf_pm_iterator_t *iterator_ptr + ); + +/* See esif_lf_pm_init_iterator for usage */ +enum esif_rc esif_lf_pm_get_next_lp( + lf_pm_iterator_t *iterator_ptr, + struct esif_lp **lp_ptr + ); + +/* Register Participant */ +enum esif_rc esif_lf_pm_register_participant( + /* Participant Interface */ + struct esif_participant_iface *pi_ptr, + u8 *instance_ptr + ); + +/* Unregister Participant */ +enum esif_rc esif_lf_pm_unregister_participant( + struct esif_participant_iface *pi_ptr + ); + +/* Unregister All Participants */ +void esif_lf_pm_unregister_all_participants(void); + +/* Participant Manager Init */ +enum esif_rc esif_lf_pm_init(void); + +/* Participant Manager Exit */ +void esif_lf_pm_exit(void); + + +#endif /* ESIF_ATTR_KERNEL */ /* ******************************************************************************* @@ -107,6 +201,7 @@ static ESIF_INLINE esif_string esif_pm_participant_state_str( ******************************************************************************* */ +#ifdef ESIF_ATTR_USER typedef struct UfPmIterator_s { u32 marker; @@ -225,6 +320,7 @@ eEsifError EsifUpPm_ParticipantActivityLoggingEnable(EsifUpPtr upPtr); } #endif +#endif /* ESIF_ATTR_USER */ #endif /* _ESIF_PM_H_ */ /*****************************************************************************/ diff --git a/ESIF/Products/ESIF_CM/Sources/esif_primitive.h b/ESIF/Products/ESIF_CM/Sources/esif_primitive.h index e834deb2..de189ee8 100644 --- a/ESIF/Products/ESIF_CM/Sources/esif_primitive.h +++ b/ESIF/Products/ESIF_CM/Sources/esif_primitive.h @@ -110,9 +110,11 @@ struct esif_specific_action_request { struct esif_data *rsp_ptr; }; +#ifdef ESIF_ATTR_USER typedef struct esif_primitive_tuple EsifPrimitiveTuple, *EsifPrimitiveTuplePtr; typedef struct esif_primitive_action_selector EsifPrimitiveActionSelector, *EsifPrimitiveActionSelectorPtr; typedef struct esif_specific_action_request EsifSpecificActionRequest, *EsifSpecificActionRequestPtr; +#endif #pragma pack(pop) @@ -124,12 +126,57 @@ extern "C" { struct esif_lp; struct esif_ipc_primitive; +#ifdef ESIF_ATTR_KERNEL + +void esif_execute_ipc_primitive(struct esif_ipc_primitive *prim_ptr); + +enum esif_rc esif_execute_primitive( + struct esif_lp *lp_ptr, + const struct esif_primitive_tuple *tuple_ptr, + const struct esif_data *req_data_ptr, + struct esif_data *rsp_data_ptr, + const u16 *action_index_ptr +); + +/* + * Simple helper functions to execute primitives that takes no special + * parameters. + */ +enum esif_rc esif_get_simple_primitive( + struct esif_lp *lp_ptr, + u16 id, + u16 domain, + u16 instance, + enum esif_data_type esif_type, + void *buffer_ptr, + u32 buffer_size +); + +enum esif_rc esif_set_simple_primitive( + struct esif_lp *lp_ptr, + u16 id, + u16 domain, + u16 instance, + enum esif_data_type esif_type, + void *buffer_ptr, + u32 buffer_size +); + +char *esif_primitive_domain_str( + u16 domain, + char *str_ptr + ); + +u32 esif_ipc_primitive_get_data_len(struct esif_ipc_primitive *primitive_ptr); + +#else char *esif_primitive_domain_str( u16 domain, char *str, u8 str_len ); +#endif #ifdef __cplusplus } #endif diff --git a/ESIF/Products/ESIF_CMP/Linux/Makefile b/ESIF/Products/ESIF_CMP/Linux/Makefile index c42c5b30..d35ec1f2 100644 --- a/ESIF/Products/ESIF_CMP/Linux/Makefile +++ b/ESIF/Products/ESIF_CMP/Linux/Makefile @@ -50,8 +50,6 @@ endif CFLAGS += -fno-strict-overflow CFLAGS += -fno-delete-null-pointer-checks CFLAGS += -fwrapv -#Compile with -g by default and strip it at the end -CFLAGS += -g # Linker Flags added for security purposes LDFLAGS += -z noexecstack @@ -89,9 +87,14 @@ else endif endif +ifneq ($(OS), Chrome) # make BUILD=Debug +# -s flag added for stripping the binaries ifeq ($(BUILD), Debug) - CPPFLAGS += -DESIF_ATTR_DEBUG + CFLAGS += -g +else + CFLAGS += -s +endif endif $(info ++++ ) @@ -119,15 +122,9 @@ OBJ += $(SOURCES)/esif_cmp.o $(CC) -c $(CFLAGS) $(EXTRA_CFLAGS) $(CPPFLAGS) -o $@ $< all: esif_cmp -ifeq ($(OS), Linux) - ifeq ($(BUILD), Release) - cp esif_cmp.so esif_cmp.so.debug - strip --strip-unneeded esif_cmp.so - objcopy --add-gnu-debuglink=esif_cmp.so.debug esif_cmp.so - endif -endif + esif_cmp: $(OBJ) $(CC) $(CFLAGS) -shared $(EXTRA_CFLAGS) $(LDFLAGS) -o $@.so $^ $(LDLIBS) clean: - rm -f $(OBJ) *.so *.debug + rm -f $(OBJ) *.so diff --git a/ESIF/Products/ESIF_CMP/Sources/7zTypes.h b/ESIF/Products/ESIF_CMP/Sources/7zTypes.h index 291a606e..65b3af63 100644 --- a/ESIF/Products/ESIF_CMP/Sources/7zTypes.h +++ b/ESIF/Products/ESIF_CMP/Sources/7zTypes.h @@ -4,6 +4,9 @@ #ifndef __7Z_TYPES_H #define __7Z_TYPES_H +#ifdef _WIN32 +/* #include */ +#endif #include @@ -40,12 +43,20 @@ EXTERN_C_BEGIN typedef int SRes; +#ifdef _WIN32 + +/* typedef DWORD WRes; */ +typedef unsigned WRes; +#define MY_SRes_HRESULT_FROM_WRes(x) HRESULT_FROM_WIN32(x) + +#else typedef int WRes; #define MY__FACILITY_WIN32 7 #define MY__FACILITY__WRes MY__FACILITY_WIN32 #define MY_SRes_HRESULT_FROM_WRes(x) ((HRESULT)(x) <= 0 ? ((HRESULT)(x)) : ((HRESULT) (((x) & 0x0000FFFF) | (MY__FACILITY__WRes << 16) | 0x80000000))) +#endif #ifndef RINOK @@ -98,7 +109,11 @@ typedef int BoolInt; #define False 0 +#ifdef _WIN32 +#define MY_STD_CALL __stdcall +#else #define MY_STD_CALL +#endif #ifdef _MSC_VER @@ -339,12 +354,21 @@ struct ISzAlloc +#ifdef _WIN32 + +#define CHAR_PATH_SEPARATOR '\\' +#define WCHAR_PATH_SEPARATOR L'\\' +#define STRING_PATH_SEPARATOR "\\" +#define WSTRING_PATH_SEPARATOR L"\\" + +#else #define CHAR_PATH_SEPARATOR '/' #define WCHAR_PATH_SEPARATOR L'/' #define STRING_PATH_SEPARATOR "/" #define WSTRING_PATH_SEPARATOR L"/" +#endif EXTERN_C_END diff --git a/ESIF/Products/ESIF_CMP/Sources/Alloc.c b/ESIF/Products/ESIF_CMP/Sources/Alloc.c index 4d2af21f..b5ac84b5 100644 --- a/ESIF/Products/ESIF_CMP/Sources/Alloc.c +++ b/ESIF/Products/ESIF_CMP/Sources/Alloc.c @@ -5,6 +5,9 @@ #include +#ifdef _WIN32 +#include +#endif #include #include "Alloc.h" @@ -150,6 +153,90 @@ void MyFree(void *address) free(address); } +#ifdef _WIN32 + +void *MidAlloc(size_t size) +{ + if (size == 0) + return NULL; + + PRINT_ALLOC("Alloc-Mid", g_allocCountMid, size, NULL); + + return VirtualAlloc(NULL, size, MEM_COMMIT, PAGE_READWRITE); +} + +void MidFree(void *address) +{ + PRINT_FREE("Free-Mid", g_allocCountMid, address); + + if (!address) + return; + VirtualFree(address, 0, MEM_RELEASE); +} + +#ifndef MEM_LARGE_PAGES +#undef _7ZIP_LARGE_PAGES +#endif + +#ifdef _7ZIP_LARGE_PAGES +SIZE_T g_LargePageSize = 0; +typedef SIZE_T (WINAPI *GetLargePageMinimumP)(); +#endif + +void SetLargePageSize() +{ + #ifdef _7ZIP_LARGE_PAGES + SIZE_T size; + GetLargePageMinimumP largePageMinimum = (GetLargePageMinimumP) + GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "GetLargePageMinimum"); + if (!largePageMinimum) + return; + size = largePageMinimum(); + if (size == 0 || (size & (size - 1)) != 0) + return; + g_LargePageSize = size; + #endif +} + + +void *BigAlloc(size_t size) +{ + if (size == 0) + return NULL; + + PRINT_ALLOC("Alloc-Big", g_allocCountBig, size, NULL); + + #ifdef _7ZIP_LARGE_PAGES + { + SIZE_T ps = g_LargePageSize; + if (ps != 0 && ps <= (1 << 30) && size > (ps / 2)) + { + size_t size2; + ps--; + size2 = (size + ps) & ~ps; + if (size2 >= size) + { + void *res = VirtualAlloc(NULL, size2, MEM_COMMIT | MEM_LARGE_PAGES, PAGE_READWRITE); + if (res) + return res; + } + } + } + #endif + + return VirtualAlloc(NULL, size, MEM_COMMIT, PAGE_READWRITE); +} + +void BigFree(void *address) +{ + PRINT_FREE("Free-Big", g_allocCountBig, address); + + if (!address) + return; + VirtualFree(address, 0, MEM_RELEASE); +} + +#endif static void *SzAlloc(ISzAllocPtr p, size_t size) { UNUSED_VAR(p); return MyAlloc(size); } @@ -170,10 +257,14 @@ const ISzAlloc g_BigAlloc = { SzBigAlloc, SzBigFree }; : unsupported in VS6 */ +#ifdef _WIN32 + typedef UINT_PTR UIntPtr; +#else /* typedef uintptr_t UIntPtr; */ typedef ptrdiff_t UIntPtr; +#endif #define ADJUST_ALLOC_SIZE 0 diff --git a/ESIF/Products/ESIF_CMP/Sources/Alloc.h b/ESIF/Products/ESIF_CMP/Sources/Alloc.h index cab3de60..64823764 100644 --- a/ESIF/Products/ESIF_CMP/Sources/Alloc.h +++ b/ESIF/Products/ESIF_CMP/Sources/Alloc.h @@ -11,12 +11,23 @@ EXTERN_C_BEGIN void *MyAlloc(size_t size); void MyFree(void *address); +#ifdef _WIN32 + +void SetLargePageSize(); + +void *MidAlloc(size_t size); +void MidFree(void *address); +void *BigAlloc(size_t size); +void BigFree(void *address); + +#else #define MidAlloc(size) MyAlloc(size) #define MidFree(address) MyFree(address) #define BigAlloc(size) MyAlloc(size) #define BigFree(address) MyFree(address) +#endif extern const ISzAlloc g_Alloc; extern const ISzAlloc g_BigAlloc; diff --git a/ESIF/Products/ESIF_CMP/Sources/EsifSdl.h b/ESIF/Products/ESIF_CMP/Sources/EsifSdl.h index 04d7c9cc..abb1b8b3 100644 --- a/ESIF/Products/ESIF_CMP/Sources/EsifSdl.h +++ b/ESIF/Products/ESIF_CMP/Sources/EsifSdl.h @@ -27,10 +27,19 @@ #ifndef __ESIF_SDL_H #define __ESIF_SDL_H +#ifdef _WIN32 +#include +#define _SDL_BANNED_RECOMMENDED +#include "win/banned.h" /* Flag SDL Banned Functions during Build */ +#endif /* OS Abstraction Layer and Replacements for SDL-deprecated functions */ +#ifdef _WIN32 +#define MyMemcpy(dst, src, len) memcpy_s(dst, len, src, len) +#else /* Linux-based OS*/ #include #define MyMemcpy(dst, src, len) memcpy(dst, src, len) +#endif /* Define this flag to build with optional SDL enhancements to original LZMA SDK code. * This flag is required to satisfy Intel SDL Requirements for passing Klocwork scans. diff --git a/ESIF/Products/ESIF_CMP/Sources/esif_cmp.c b/ESIF/Products/ESIF_CMP/Sources/esif_cmp.c index eb16b84f..a959a6f8 100644 --- a/ESIF/Products/ESIF_CMP/Sources/esif_cmp.c +++ b/ESIF/Products/ESIF_CMP/Sources/esif_cmp.c @@ -29,6 +29,15 @@ #include "EsifSdl.h" /* Always include last */ +#ifdef _WIN32 +BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved) +{ + UNUSED_VAR(hInstance); + UNUSED_VAR(dwReason); + UNUSED_VAR(lpReserved); + return TRUE; +} +#endif // Standard LZMA File Header #define LZMA_PROPS_SIZE 5 // [XX YY YY YY YY] Where XX = Encoded -lc -lp -pb options, YY = Encoded -d option diff --git a/ESIF/Products/ESIF_LIB/Sources/esif_lib.h b/ESIF/Products/ESIF_LIB/Sources/esif_lib.h index 3355ec27..bfb97c15 100644 --- a/ESIF/Products/ESIF_LIB/Sources/esif_lib.h +++ b/ESIF/Products/ESIF_LIB/Sources/esif_lib.h @@ -57,4 +57,4 @@ typedef unsigned char Byte, *BytePtr, **BytePtrLocation; #define IGNORE_RESULT(expr) do { if (expr) {} } while ESIF_CONSTEXPR(ESIF_ALWAYSFALSE) -#endif +#endif \ No newline at end of file diff --git a/ESIF/Products/ESIF_LIB/Sources/esif_lib_databank.c b/ESIF/Products/ESIF_LIB/Sources/esif_lib_databank.c index 614870e1..4d139963 100644 --- a/ESIF/Products/ESIF_LIB/Sources/esif_lib_databank.c +++ b/ESIF/Products/ESIF_LIB/Sources/esif_lib_databank.c @@ -37,6 +37,14 @@ # include "static_dv.h" // Static DV converted to Byte array #endif +#ifdef ESIF_ATTR_OS_WINDOWS +// +// The Windows banned-API check header must be included after all other headers, or issues can be identified +// against Windows SDK/DDK included headers which we have no control over. +// +#define _SDL_BANNED_RECOMMENDED +#include "win\banned.h" +#endif static struct { StringPtr name; diff --git a/ESIF/Products/ESIF_LIB/Sources/esif_lib_datacache.c b/ESIF/Products/ESIF_LIB/Sources/esif_lib_datacache.c index 703f4f8a..4898cb25 100644 --- a/ESIF/Products/ESIF_LIB/Sources/esif_lib_datacache.c +++ b/ESIF/Products/ESIF_LIB/Sources/esif_lib_datacache.c @@ -20,6 +20,14 @@ #define _DATACACHE_CLASS #include "esif_lib_datacache.h" +#ifdef ESIF_ATTR_OS_WINDOWS +// +// The Windows banned-API check header must be included after all other headers, or issues can be identified +// against Windows SDK/DDK included headers which we have no control over. +// +#define _SDL_BANNED_RECOMMENDED +#include "win\banned.h" +#endif /////////////////////////////////////////////////////// // DataCache Class diff --git a/ESIF/Products/ESIF_LIB/Sources/esif_lib_datacache.h b/ESIF/Products/ESIF_LIB/Sources/esif_lib_datacache.h index 43c87d38..473cfb74 100644 --- a/ESIF/Products/ESIF_LIB/Sources/esif_lib_datacache.h +++ b/ESIF/Products/ESIF_LIB/Sources/esif_lib_datacache.h @@ -82,4 +82,4 @@ eEsifError DataCache_RestoreOffsets(DataCachePtr self, DataCachePtr backup); } #endif -#endif +#endif \ No newline at end of file diff --git a/ESIF/Products/ESIF_LIB/Sources/esif_lib_datavault.c b/ESIF/Products/ESIF_LIB/Sources/esif_lib_datavault.c index 8214300b..d4dac8bf 100644 --- a/ESIF/Products/ESIF_LIB/Sources/esif_lib_datavault.c +++ b/ESIF/Products/ESIF_LIB/Sources/esif_lib_datavault.c @@ -38,6 +38,14 @@ #include #include +#ifdef ESIF_ATTR_OS_WINDOWS +// +// The Windows banned-API check header must be included after all other headers, or issues can be identified +// against Windows SDK/DDK included headers which we have no control over. +// +#define _SDL_BANNED_RECOMMENDED +#include "win\banned.h" +#endif #include "esif_sdk_sha.c" // Compile SHA code into this module @@ -1774,11 +1782,10 @@ esif_error_t DataVault_SetValue( } // Replace the File Offset stored in buf_ptr with a copy of the data for updated NOCACHE values - if ((FLAGS_TEST(keypair->flags, ESIF_SERVICE_CONFIG_NOCACHE) || (NULL == keypair->value.buf_ptr && value->data_len > 0)) && keypair->value.buf_len == 0) { + if (FLAGS_TEST(keypair->flags, ESIF_SERVICE_CONFIG_NOCACHE) && keypair->value.buf_len == 0) { keypair->value.buf_len = esif_ccb_max(1, value->data_len); keypair->value.buf_ptr = esif_ccb_malloc(value->buf_len); } - keypair->flags = flags; keypair->value.type = value->type; keypair->value.data_len = value->data_len; diff --git a/ESIF/Products/ESIF_LIB/Sources/esif_lib_esifdata.c b/ESIF/Products/ESIF_LIB/Sources/esif_lib_esifdata.c index b9d7accc..d93ef28c 100644 --- a/ESIF/Products/ESIF_LIB/Sources/esif_lib_esifdata.c +++ b/ESIF/Products/ESIF_LIB/Sources/esif_lib_esifdata.c @@ -23,6 +23,14 @@ #include "esif_sdk_iface_compress.h" +#ifdef ESIF_ATTR_OS_WINDOWS +// +// The Windows banned-API check header must be included after all other headers, or issues can be identified +// against Windows SDK/DDK included headers which we have no control over. +// +#define _SDL_BANNED_RECOMMENDED +#include "win\banned.h" +#endif #define tohexdigit(ch) ((ch) >= '0' && (ch) <= '9' ? ((ch) - '0') : (toupper(ch) - 'A' + 10)) @@ -1027,4 +1035,4 @@ esif_error_t EsifData_Decompress(EsifDataPtr self) return rc; } -#endif +#endif \ No newline at end of file diff --git a/ESIF/Products/ESIF_LIB/Sources/esif_lib_iostream.c b/ESIF/Products/ESIF_LIB/Sources/esif_lib_iostream.c index de5263aa..47dda1e0 100644 --- a/ESIF/Products/ESIF_LIB/Sources/esif_lib_iostream.c +++ b/ESIF/Products/ESIF_LIB/Sources/esif_lib_iostream.c @@ -31,6 +31,14 @@ #define MAX_OFFSET_FILESTREAM ((size_t)0x7FFFFFFF) // fseek() only accepts (long), not (size_t) #define MAX_OFFSET_MEMORYSTREAM (((size_t)(-1) >> 1) - 1) +#ifdef ESIF_ATTR_OS_WINDOWS +// +// The Windows banned-API check header must be included after all other headers, or issues can be identified +// against Windows SDK/DDK included headers which we have no control over. +// +#define _SDL_BANNED_RECOMMENDED +#include "win\banned.h" +#endif // constructor void IOStream_ctor(IOStreamPtr self) diff --git a/ESIF/Products/ESIF_LIB/Sources/esif_lib_istring.c b/ESIF/Products/ESIF_LIB/Sources/esif_lib_istring.c index de883059..1431556b 100644 --- a/ESIF/Products/ESIF_LIB/Sources/esif_lib_istring.c +++ b/ESIF/Products/ESIF_LIB/Sources/esif_lib_istring.c @@ -23,6 +23,10 @@ #include #include +#ifdef ESIF_ATTR_OS_WINDOWS +# define _SDL_BANNED_RECOMMENDED +# include "win/banned.h" +#endif #define ISTRING_AUTOGROW 0 // Autogrow IString buffer if necessary and pad with this many extra bytes (0-N). Undefine this to disable Autogrow diff --git a/ESIF/Products/ESIF_LIB/Sources/esif_lib_istringlist.c b/ESIF/Products/ESIF_LIB/Sources/esif_lib_istringlist.c index 17d12778..e0a29e06 100644 --- a/ESIF/Products/ESIF_LIB/Sources/esif_lib_istringlist.c +++ b/ESIF/Products/ESIF_LIB/Sources/esif_lib_istringlist.c @@ -20,6 +20,14 @@ #define _ISTRINGLIST_CLASS #include "esif_lib_istringlist.h" +#ifdef ESIF_ATTR_OS_WINDOWS +// +// The Windows banned-API check header must be included after all other headers, or issues can be identified +// against Windows SDK/DDK included headers which we have no control over. +// +#define _SDL_BANNED_RECOMMENDED +#include "win\banned.h" +#endif // constructor void StringList_ctor (StringListPtr self) diff --git a/ESIF/Products/ESIF_LIB/Sources/esif_lib_istringlist.h b/ESIF/Products/ESIF_LIB/Sources/esif_lib_istringlist.h index 9229cb51..c5d9aacb 100644 --- a/ESIF/Products/ESIF_LIB/Sources/esif_lib_istringlist.h +++ b/ESIF/Products/ESIF_LIB/Sources/esif_lib_istringlist.h @@ -62,4 +62,4 @@ void StringList_Add (StringListPtr self, char *str); } #endif -#endif +#endif \ No newline at end of file diff --git a/ESIF/Products/ESIF_LIB/Sources/esif_lib_json.c b/ESIF/Products/ESIF_LIB/Sources/esif_lib_json.c index 11e0c2bf..e184b5ba 100644 --- a/ESIF/Products/ESIF_LIB/Sources/esif_lib_json.c +++ b/ESIF/Products/ESIF_LIB/Sources/esif_lib_json.c @@ -21,6 +21,14 @@ #include "esif_ccb_string.h" #include "esif_lib_json.h" +#ifdef ESIF_ATTR_OS_WINDOWS +// +// The Windows banned-API check header must be included after all other headers, or issues can be identified +// against Windows SDK/DDK included headers which we have no control over. +// +#define _SDL_BANNED_RECOMMENDED +#include "win\banned.h" +#endif char *esif_shell_strtok(char *str, char *seps, char **context); void strip_illegal_chars(char *srcStringPtr, const char *illegalCharsPtr); diff --git a/ESIF/Products/ESIF_UF/Linux/Makefile b/ESIF/Products/ESIF_UF/Linux/Makefile index 5bfe555c..096123f1 100644 --- a/ESIF/Products/ESIF_UF/Linux/Makefile +++ b/ESIF/Products/ESIF_UF/Linux/Makefile @@ -41,11 +41,11 @@ CPPFLAGS += -I$(ESIF_UF_SOURCES) -I$(ESIF_CM_SOURCES) -I$(ESIF_LIB_SOURCES) -I$( CPPFLAGS += -DESIF_ATTR_USER CPPFLAGS += -DESIF_ATTR_DAEMON CPPFLAGS += -DESIF_FEAT_OPT_COMPRESS +#CPPFLAGS += -DESIF_FEAT_EPP_MAILBOX +#CPPFLAGS += -DESIF_FEAT_SYSFS_POLL CFLAGS += -Wno-multichar CFLAGS += -Werror -#Compile with -g by default and strip it at the end -CFLAGS += -g # Compile Flags added for security purposes CFLAGS += -fPIE @@ -69,9 +69,9 @@ LDFLAGS += -pie # Secure Compile options if GCC version >= 4.9 GCC_STRONG := $(shell expr `($(CC) -dumpfullversion 2>/dev/null || $(CC) -dumpversion) | cut -d'.' -f1,2,3 | sed -e 's/\.\([0-9]\)$$/0\1/' | sed -e 's/\.//g' ` \>= 409) ifeq ($(GCC_STRONG), 1) - CFLAGS += -fstack-protector-strong + CFLAGS += -fstack-protector-strong else - CFLAGS += -fstack-protector + CFLAGS += -fstack-protector endif @@ -80,12 +80,14 @@ ifeq ($(OS), Android) $(error For Android build please use Android.mk in ESIF_UF/Androidx86/jni directory) else ifeq ($(OS), Chrome) CPPFLAGS += -DESIF_ATTR_OS_CHROME + # CPPFLAGS += -DESIF_ATTR_OS_LINUX_HAVE_READLINE CPPFLAGS += -std=gnu99 ifeq ($(OPT_GMIN), 1) OPT_DBUS = 1 endif else CPPFLAGS += -DESIF_ATTR_OS_LINUX + # CPPFLAGS += -DESIF_ATTR_OS_LINUX_HAVE_READLINE CPPFLAGS += -std=gnu99 # make PLAT= @@ -111,9 +113,16 @@ ifeq ($(OPT_DBUS), 1) LDFLAGS += $(shell $(PKG_CONFIG) --libs dbus-1) endif +ifneq ($(OS), Chrome) +# make BUILD=Debug +# -s flag added for stripping the binaries ifeq ($(BUILD), Debug) + CFLAGS += -g CPPFLAGS += -DESIF_ATTR_DEBUG CPPFLAGS += -DESIF_ATTR_MEMTRACE +else + CFLAGS += -s +endif endif $(info ++++ ) @@ -190,15 +199,9 @@ OBJ += $(ESIF_LIB_SOURCES)/esif_lib_json.o $(CC) -c $(CFLAGS) $(EXTRA_CFLAGS) $(CPPFLAGS) -o $@ $< all: esif_ufd -ifeq ($(OS), Linux) - ifeq ($(BUILD), Release) - cp esif_ufd esif_ufd.debug - strip --strip-unneeded esif_ufd - objcopy --add-gnu-debuglink=esif_ufd.debug esif_ufd - endif -endif + esif_ufd: $(OBJ) $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(LDFLAGS) -o $@ $^ $(LDLIBS) clean: - rm -f $(OBJ) esif_ufd esif_ufd.debug + rm -f $(OBJ) esif_ufd diff --git a/ESIF/Products/ESIF_UF/Sources/esif_uf.c b/ESIF/Products/ESIF_UF/Sources/esif_uf.c index 9a78d5a1..d8f3c45a 100644 --- a/ESIF/Products/ESIF_UF/Sources/esif_uf.c +++ b/ESIF/Products/ESIF_UF/Sources/esif_uf.c @@ -49,6 +49,15 @@ #include "esif_ccb_timer.h" #include "esif_uf_ccb_imp_spec.h" +#ifdef ESIF_ATTR_OS_WINDOWS +#include +// +// The Windows banned-API check header must be included after all other headers, or issues can be identified +// against Windows SDK/DDK included headers which we have no control over. +// +#define _SDL_BANNED_RECOMMENDED +#include "win\banned.h" +#endif /* Native memory allocation functions for use by memtrace functions only */ #define native_malloc(siz) malloc(siz) @@ -160,7 +169,14 @@ int EsifLogFile_Open(EsifLogType type, const char *filename, int append) esif_ccb_fclose(g_EsifLogFile[type].handle); EsifLogFile_GetFullPath(fullpath, sizeof(fullpath), filename); +#ifdef ESIF_ATTR_OS_WINDOWS + mode[1] = 'c'; + g_EsifLogFile[type].handle = _fsopen(fullpath, mode, _SH_DENYWR); + if (g_EsifLogFile[type].handle == NULL) + rc = errno; +#else g_EsifLogFile[type].handle = esif_ccb_fopen(fullpath, mode, &rc); +#endif if (g_EsifLogFile[type].handle != NULL) { esif_ccb_free(g_EsifLogFile[type].filename); g_EsifLogFile[type].filename = esif_ccb_strdup((char *)fullpath); @@ -298,7 +314,12 @@ EsifLogType EsifLogType_FromString(const char *name) return result; } +#ifdef ESIF_ATTR_OS_WINDOWS +extern enum esif_rc ESIF_CALLCONV write_to_srvr_cnsl_intfc_varg(const char *pFormat, va_list args); +# define EsifConsole_vprintf(fmt, args) write_to_srvr_cnsl_intfc_varg(fmt, args) +#else # define EsifConsole_vprintf(fmt, args) vprintf(fmt, args) +#endif int EsifConsole_WriteTo(u32 writeto, const char *format, ...) { diff --git a/ESIF/Products/ESIF_UF/Sources/esif_uf_action.c b/ESIF/Products/ESIF_UF/Sources/esif_uf_action.c index 530496f4..4432c6a5 100644 --- a/ESIF/Products/ESIF_UF/Sources/esif_uf_action.c +++ b/ESIF/Products/ESIF_UF/Sources/esif_uf_action.c @@ -28,6 +28,14 @@ #include "esif_uf_eventmgr.h" #include "esif_pm.h" +#ifdef ESIF_ATTR_OS_WINDOWS +// +// The Windows banned-API check header must be included after all other headers, or issues can be identified +// against Windows SDK/DDK included headers which we have no control over. +// +#define _SDL_BANNED_RECOMMENDED +#include "win\banned.h" +#endif /* * PUBLIC FRIEND FUNCTIONS diff --git a/ESIF/Products/ESIF_UF/Sources/esif_uf_action_config.c b/ESIF/Products/ESIF_UF/Sources/esif_uf_action_config.c index 4d733eb0..5fdaa824 100644 --- a/ESIF/Products/ESIF_UF/Sources/esif_uf_action_config.c +++ b/ESIF/Products/ESIF_UF/Sources/esif_uf_action_config.c @@ -23,6 +23,14 @@ #include "esif_primitive.h" #include "esif_uf_eventmgr.h" +#ifdef ESIF_ATTR_OS_WINDOWS +// +// The Windows banned-API check header must be included after all other headers, or issues can be identified +// against Windows SDK/DDK included headers which we have no control over. +// +#define _SDL_BANNED_RECOMMENDED +#include "win\banned.h" +#endif extern char *esif_str_replace(char *orig, char *rep, char *with); diff --git a/ESIF/Products/ESIF_UF/Sources/esif_uf_action_constant.c b/ESIF/Products/ESIF_UF/Sources/esif_uf_action_constant.c index 4ded0f3b..f61073af 100644 --- a/ESIF/Products/ESIF_UF/Sources/esif_uf_action_constant.c +++ b/ESIF/Products/ESIF_UF/Sources/esif_uf_action_constant.c @@ -20,6 +20,14 @@ #include "esif_uf.h" /* Upper Framework */ #include "esif_uf_actmgr.h" /* Action Manager */ +#ifdef ESIF_ATTR_OS_WINDOWS +// +// The Windows banned-API check header must be included after all other headers, or issues can be identified +// against Windows SDK/DDK included headers which we have no control over. +// +#define _SDL_BANNED_RECOMMENDED +#include "win\banned.h" +#endif /* ** Handle ESIF Action Request diff --git a/ESIF/Products/ESIF_UF/Sources/esif_uf_action_delegate.c b/ESIF/Products/ESIF_UF/Sources/esif_uf_action_delegate.c index cf2f8f14..49e2524b 100644 --- a/ESIF/Products/ESIF_UF/Sources/esif_uf_action_delegate.c +++ b/ESIF/Products/ESIF_UF/Sources/esif_uf_action_delegate.c @@ -37,6 +37,14 @@ // Currently we do not get any of the domain/participant information as part of the interface. // !!! +#ifdef ESIF_ATTR_OS_WINDOWS +// +// The Windows banned-API check header must be included after all other headers, or issues can be identified +// against Windows SDK/DDK included headers which we have no control over. +// +#define _SDL_BANNED_RECOMMENDED +#include "win\banned.h" +#endif extern char *esif_str_replace(char *orig, char *rep, char *with); @@ -86,21 +94,6 @@ static eEsifError EsifGetActionDelegateIsBpCapableSensor( EsifDataPtr responsePtr ); -static eEsifError EsifGetActionDelegateMcppEnergy( - const EsifUpDomainPtr domainPtr, - EsifDataPtr responsePtr - ); - -static eEsifError EsifGetCpuRaplEnergy( - const EsifUpDomainPtr domainPtr, - UInt32* cpuRaplEnergy - ); - -static eEsifError EsifGetGpuRaplEnergy( - const EsifUpDomainPtr domainPtr, - UInt32* gpuRaplEnergy - ); - static eEsifError EsifGetActionDelegateBpsg(EsifDataPtr responsePtr); static eEsifError EsifSetActionDelegateBpss(const EsifDataPtr requestPtr); @@ -156,6 +149,71 @@ static eEsifError EsifSetActionDelegateScsm(EsifDataPtr requestPtr); static eEsifError EsifSetActionDelegateScas(); +#if defined(ESIF_ATTR_OS_WINDOWS) + +esif_error_t set_nv_tgp_value_win(EsifDataPtr requestPtr); +esif_error_t set_nv_power_limit_win(EsifDataPtr requestPtr); +esif_error_t set_nv_dynamic_boost_state_win(EsifDataPtr requestPtr); +esif_error_t set_nv_action_state_enable_win(); +esif_error_t set_nv_action_state_disable_win(); +esif_error_t set_display_state_win(EsifDataPtr requestPtr); +esif_error_t set_screen_autolock_state_win(EsifDataPtr requestPtr); +esif_error_t set_wake_on_approach_state_win(EsifDataPtr requestPtr); +esif_error_t set_workstation_lock_win(); +esif_error_t set_app_ratio_period_win(EsifDataPtr requestPtr); +esif_error_t get_nv_utilization_win(EsifDataPtr responsePtr); +esif_error_t get_nv_rapl_power_win(EsifDataPtr responsePtr); +esif_error_t get_nv_rapl_power_limit_win(EsifDataPtr responsePtr); +esif_error_t get_nv_temperature_win(EsifDataPtr responsePtr); +esif_error_t get_nv_dynamic_boost_state_win(EsifDataPtr responsePtr); +esif_error_t get_nv_power_state_win(EsifDataPtr responsePtr); +esif_error_t get_last_hid_input_time_win(EsifDataPtr responsePtr); +esif_error_t get_display_required_win(EsifDataPtr responsePtr); +esif_error_t get_is_ext_mon_connected_win(EsifDataPtr responsePtr); +esif_error_t get_aggregate_display_information_win(EsifDataPtr responsePtr); +esif_error_t EsifSetActionDelegatePpmParamValuesSettingWin(EsifDataPtr requestPtr); +esif_error_t EsifGetActionDelegatePpmParamValuesSettingWin(EsifDataPtr requestPtr, EsifDataPtr responsePtr); +esif_error_t EsifSetActionDelegatePowerSchemeEppWin(EsifDataPtr requestPtr); +esif_error_t EsifSetActionDelegateActivePowerSchemeWin(); +esif_error_t EsifSetActionDelegatePpmParamClearWin(); +esif_error_t EsifGetActionDelegateGurrWin(EsifDataPtr responsePtr); +esif_error_t EsifGetActionDelegateGurcWin(EsifDataPtr responsePtr); +esif_error_t EsifSetActionDelegateSurrWin(EsifDataPtr requestPtr); +esif_error_t EsifActDelegateInitOsWin(); +esif_error_t EsifActDelegateExitOsWin(); + +#define set_nv_tgp_value(reqPtr) set_nv_tgp_value_win(reqPtr) +#define set_nv_power_limit(reqPtr) set_nv_power_limit_win(reqPtr) +#define set_nv_dynamic_boost_state(reqPtr) set_nv_dynamic_boost_state_win(reqPtr) +#define set_nv_action_state_enable() set_nv_action_state_enable_win() +#define set_nv_action_state_disable() set_nv_action_state_disable_win() +#define set_display_state(reqPtr) set_display_state_win(reqPtr) +#define set_screen_autolock_state(reqPtr) set_screen_autolock_state_win(reqPtr) +#define set_wake_on_approach_state(reqPtr) set_wake_on_approach_state_win(reqPtr) +#define set_workstation_lock() set_workstation_lock_win() +#define set_app_ratio_period(reqPtr) set_app_ratio_period_win(reqPtr) +#define get_nv_utilization(rspPtr) get_nv_utilization_win(rspPtr) +#define get_nv_rapl_power(rspPtr) get_nv_rapl_power_win(rspPtr) +#define get_nv_rapl_power_limit(rspPtr) get_nv_rapl_power_limit_win(rspPtr) +#define get_nv_temperature(rspPtr) get_nv_temperature_win(rspPtr) +#define get_nv_dynamic_boost_state(rspPtr) get_nv_dynamic_boost_state_win(rspPtr) +#define get_nv_power_state(rspPtr) get_nv_power_state_win(rspPtr) +#define get_last_hid_input_time(rspPtr) get_last_hid_input_time_win(rspPtr) +#define get_display_required(rspPtr) get_display_required_win(rspPtr) +#define get_is_ext_mon_connected(rspPtr) get_is_ext_mon_connected_win(rspPtr) +#define get_aggregate_display_information(rspPtr) get_aggregate_display_information_win(rspPtr) +#define EsifSetActionDelegatePpmParamValuesSetting(requestPtr) EsifSetActionDelegatePpmParamValuesSettingWin(requestPtr) +#define EsifGetActionDelegatePpmParamValuesSetting(requestPtr, rspPtr) EsifGetActionDelegatePpmParamValuesSettingWin(requestPtr, rspPtr) +#define EsifSetActionDelegatePowerSchemeEpp(requestPtr) EsifSetActionDelegatePowerSchemeEppWin(requestPtr) +#define EsifSetActionDelegateActivePowerScheme() EsifSetActionDelegateActivePowerSchemeWin() +#define EsifSetActionDelegatePpmParamClear() EsifSetActionDelegatePpmParamClearWin() +#define EsifGetActionDelegateGurr(reqPtr) EsifGetActionDelegateGurrWin(reqPtr) +#define EsifGetActionDelegateGurc(reqPtr) EsifGetActionDelegateGurcWin(reqPtr) +#define EsifSetActionDelegateSurr(rspPtr) EsifSetActionDelegateSurrWin(rspPtr) +#define EsifActDelegateInitOs() EsifActDelegateInitOsWin() +#define EsifActDelegateExitOs() EsifActDelegateExitOsWin() + +#elif defined(ESIF_ATTR_OS_LINUX) #define set_nv_tgp_value(reqPtr) (ESIF_E_NOT_IMPLEMENTED) #define set_nv_power_limit(reqPtr) (ESIF_E_NOT_IMPLEMENTED) @@ -185,10 +243,10 @@ static eEsifError EsifSetActionDelegateScas(); #define EsifGetActionDelegateGurr(rspPtr) (ESIF_E_NOT_IMPLEMENTED) #define EsifGetActionDelegateGurc(rspPtr) (ESIF_E_NOT_IMPLEMENTED) #define EsifSetActionDelegateSurr(reqPtr) (ESIF_E_NOT_IMPLEMENTED) -#define EsifSetActionDelegateSres() (ESIF_E_NOT_IMPLEMENTED) #define EsifActDelegateInitOs() (ESIF_E_NOT_IMPLEMENTED) #define EsifActDelegateExitOs() (ESIF_E_NOT_IMPLEMENTED) +#endif // Delegate Opcodes @@ -332,10 +390,6 @@ static eEsifError ESIF_CALLCONV ActionDelegateGet( rc = EsifGetActionDelegatePpmParamValuesSetting(requestPtr, responsePtr); break; - case 'ERMG': /* GMRE - Get MCPP Rapl Energy */ - rc = EsifGetActionDelegateMcppEnergy(domainPtr, responsePtr); - break; - default: rc = ESIF_E_NOT_IMPLEMENTED; break; @@ -582,10 +636,6 @@ static eEsifError ESIF_CALLCONV ActionDelegateSet( rc = EsifSetActionDelegateSurr(requestPtr); break; - case 'SERS': /* SRES - Set User-Based Refresh Rate Reset*/ - rc = EsifSetActionDelegateSres(); - break; - default: rc = ESIF_E_NOT_IMPLEMENTED; break; @@ -1356,84 +1406,6 @@ static eEsifError EsifGetActionDelegateIsBpCapableSensor( return rc; } -static eEsifError EsifGetActionDelegateMcppEnergy( - const EsifUpDomainPtr domainPtr, - EsifDataPtr responsePtr) -{ - eEsifError rc = ESIF_OK; - UInt32 cpuRaplEnergy = 0; - UInt32 gpuRaplEnergy = 0; - - ESIF_ASSERT(NULL != domainPtr); - ESIF_ASSERT(NULL != responsePtr); - - if (responsePtr->buf_ptr == NULL) { - rc = ESIF_E_PARAMETER_IS_NULL; - goto exit; - } - - if (responsePtr->buf_len < esif_data_type_sizeof(ESIF_DATA_UINT32)) { - rc = ESIF_E_NEED_LARGER_BUFFER; - goto exit; - } - - rc = EsifGetCpuRaplEnergy(domainPtr, &cpuRaplEnergy); - if (rc != ESIF_OK) { - ESIF_TRACE_DEBUG("Failed to obtain RAPL Energy value for CPU component: %s\n", esif_rc_str(rc)); - goto exit; - } - - rc = EsifGetGpuRaplEnergy(domainPtr, &gpuRaplEnergy); - if (rc != ESIF_OK) { - ESIF_TRACE_DEBUG("Failed to obtain RAPL Energy value for GPU component, continuing w/ only CPU counters. GPU Error: %s\n", esif_rc_str(rc)); - gpuRaplEnergy = 0; - rc = ESIF_OK; - } - - *(UInt32*)responsePtr->buf_ptr = (cpuRaplEnergy + gpuRaplEnergy); -exit: - return rc; -} - -static eEsifError EsifGetCpuRaplEnergy( - const EsifUpDomainPtr domainPtr, - UInt32* cpuRaplEnergy) -{ - eEsifError rc = ESIF_OK; - EsifPrimitiveTuple energyTuple = { GET_RAPL_ENERGY_CPU_SUR, 0, 255 }; - UInt32 energyValue = 0; - EsifData energyData = { ESIF_DATA_UINT32, &energyValue, sizeof(energyValue), 0 }; - - energyTuple.domain = domainPtr->domain; - rc = EsifUp_ExecutePrimitive(domainPtr->upPtr, &energyTuple, NULL, &energyData); - if (rc != ESIF_OK) { - goto exit; - } - - *cpuRaplEnergy = energyValue; -exit: - return rc; -} - -static eEsifError EsifGetGpuRaplEnergy( - const EsifUpDomainPtr domainPtr, - UInt32* gpuRaplEnergy) -{ - eEsifError rc = ESIF_OK; - EsifPrimitiveTuple energyTuple = { GET_RAPL_ENERGY_GPU_SUR, 0, 255 }; - UInt32 energyValue = 0; - EsifData energyData = { ESIF_DATA_UINT32, &energyValue, sizeof(energyValue), 0 }; - - energyTuple.domain = domainPtr->domain; - rc = EsifUp_ExecutePrimitive(domainPtr->upPtr, &energyTuple, NULL, &energyData); - if (rc != ESIF_OK) { - goto exit; - } - - *gpuRaplEnergy = energyValue; -exit: - return rc; -} static eEsifError EsifSetActionDelegateSampleBehavior( const EsifUpDomainPtr domainPtr, diff --git a/ESIF/Products/ESIF_UF/Sources/esif_uf_action_system.c b/ESIF/Products/ESIF_UF/Sources/esif_uf_action_system.c index 1217fd24..9320a5a6 100644 --- a/ESIF/Products/ESIF_UF/Sources/esif_uf_action_system.c +++ b/ESIF/Products/ESIF_UF/Sources/esif_uf_action_system.c @@ -21,6 +21,14 @@ #include "esif_uf_actmgr.h" /* Action Manager */ #include "esif_uf_ccb_system.h" /* System Commands */ +#ifdef ESIF_ATTR_OS_WINDOWS +// +// The Windows banned-API check header must be included after all other headers, or issues can be identified +// against Windows SDK/DDK included headers which we have no control over. +// +#define _SDL_BANNED_RECOMMENDED +#include "win\banned.h" +#endif /* * Handle ESIF Action "Get" Request diff --git a/ESIF/Products/ESIF_UF/Sources/esif_uf_actmgr.c b/ESIF/Products/ESIF_UF/Sources/esif_uf_actmgr.c index 83b4f064..0a355605 100644 --- a/ESIF/Products/ESIF_UF/Sources/esif_uf_actmgr.c +++ b/ESIF/Products/ESIF_UF/Sources/esif_uf_actmgr.c @@ -24,6 +24,14 @@ #include "esif_uf_ccb_imp_spec.h" #include "esif_uf_eventmgr.h" +#ifdef ESIF_ATTR_OS_WINDOWS +// +// The Windows banned-API check header must be included after all other headers, or issues can be identified +// against Windows SDK/DDK included headers which we have no control over. +// +#define _SDL_BANNED_RECOMMENDED +#include "win\banned.h" +#endif typedef eEsifError (ESIF_CALLCONV *GetIfaceFuncPtr)(EsifActIfacePtr); diff --git a/ESIF/Products/ESIF_UF/Sources/esif_uf_app.c b/ESIF/Products/ESIF_UF/Sources/esif_uf_app.c index 7dbe7686..86246e42 100644 --- a/ESIF/Products/ESIF_UF/Sources/esif_uf_app.c +++ b/ESIF/Products/ESIF_UF/Sources/esif_uf_app.c @@ -32,6 +32,14 @@ #include "esif_uf_ccb_thermalapi.h" #include "esif_uf_handlemgr.h" +#ifdef ESIF_ATTR_OS_WINDOWS +// +// The Windows banned-API check header must be included after all other headers, or issues can be identified +// against Windows SDK/DDK included headers which we have no control over. +// +#define _SDL_BANNED_RECOMMENDED +#include "win\banned.h" +#endif #define ESIF_APP_CLIENT_INDICATOR '@' // AppNames that start with this indicate out-of-process (non-restartable) client apps diff --git a/ESIF/Products/ESIF_UF/Sources/esif_uf_appmgr.c b/ESIF/Products/ESIF_UF/Sources/esif_uf_appmgr.c index 2ffc09c5..03d3c715 100644 --- a/ESIF/Products/ESIF_UF/Sources/esif_uf_appmgr.c +++ b/ESIF/Products/ESIF_UF/Sources/esif_uf_appmgr.c @@ -22,6 +22,14 @@ #include "esif_uf_eventmgr.h" #include "esif_uf_primitive.h" +#ifdef ESIF_ATTR_OS_WINDOWS +// +// The Windows banned-API check header must be included after all other headers, or issues can be identified +// against Windows SDK/DDK included headers which we have no control over. +// +#define _SDL_BANNED_RECOMMENDED +#include "win\banned.h" +#endif // // GENERAL DEFINITIONS diff --git a/ESIF/Products/ESIF_UF/Sources/esif_uf_arbmgr.c b/ESIF/Products/ESIF_UF/Sources/esif_uf_arbmgr.c index 481fa598..bb222085 100644 --- a/ESIF/Products/ESIF_UF/Sources/esif_uf_arbmgr.c +++ b/ESIF/Products/ESIF_UF/Sources/esif_uf_arbmgr.c @@ -30,6 +30,14 @@ #include "esif_ccb_atomic.h" #include "esif_uf_primitive_type.h" +#ifdef ESIF_ATTR_OS_WINDOWS +// +// The Windows banned-API check header must be included after all other headers, or issues can be identified +// against Windows SDK/DDK included headers which we have no control over. +// +#define _SDL_BANNED_RECOMMENDED +#include "win\banned.h" +#endif /****************************************************************************** * General Definitions @@ -718,6 +726,7 @@ static EsifArbEntryParams g_wifiArbTable[] = { }; static EsifArbEntryParams g_ietmArbTable[] = { + {SET_DISPLAY_BRIGHTNESS_SOFT, ESIF_PRIMITIVE_DOMAIN_D0, 255, ESIF_ARBITRATION_UIN32_LESS_THAN, ESIF_ARB_LIMIT_MAX, ESIF_ARB_LIMIT_MIN}, {0} /* Mark end of table */ }; diff --git a/ESIF/Products/ESIF_UF/Sources/esif_uf_ccb_logging_listener.h b/ESIF/Products/ESIF_UF/Sources/esif_uf_ccb_logging_listener.h index cff266e7..c8c5f6ea 100644 --- a/ESIF/Products/ESIF_UF/Sources/esif_uf_ccb_logging_listener.h +++ b/ESIF/Products/ESIF_UF/Sources/esif_uf_ccb_logging_listener.h @@ -19,6 +19,27 @@ #pragma once #include "esif_ccb.h" +#ifdef ESIF_ATTR_OS_WINDOWS +// +// The Windows banned-API check header must be included after all other headers, or issues can be identified +// against Windows SDK/DDK included headers which we have no control over. +// +#define _SDL_BANNED_RECOMMENDED +#include "win\banned.h" + +static ESIF_INLINE eEsifError EsifLogMgr_LogToDebugger(char *outputString) +{ + OutputDebugStringA(outputString); + return ESIF_OK; +} + +static ESIF_INLINE eEsifError EsifLogMgr_LogToEvent(char *buffer) +{ + report_event_to_event_log(ESIF_TRACELEVEL_INFO, "%s", buffer); + return ESIF_OK; +} + +#else //NOT ESIF_ATTR_OS_WINDOWS static ESIF_INLINE eEsifError EsifLogMgr_LogToDebugger(char *outputString) { @@ -29,6 +50,7 @@ static ESIF_INLINE eEsifError EsifLogMgr_LogToEvent(char *buffer) { return ESIF_E_NOT_IMPLEMENTED; } +#endif /*****************************************************************************/ /*****************************************************************************/ diff --git a/ESIF/Products/ESIF_UF/Sources/esif_uf_ccb_system.h b/ESIF/Products/ESIF_UF/Sources/esif_uf_ccb_system.h index 367c3beb..b7669d30 100644 --- a/ESIF/Products/ESIF_UF/Sources/esif_uf_ccb_system.h +++ b/ESIF/Products/ESIF_UF/Sources/esif_uf_ccb_system.h @@ -22,7 +22,15 @@ #include "esif_sdk_data.h" #include "esif_uf_ccb_thermalapi.h" +#ifdef ESIF_ATTR_OS_WINDOWS +#include "powrprof.h" +#include "win\dppe.h" +#endif +#ifdef ESIF_ATTR_OS_ANDROID +#include +#include +#endif #define MAX_SYSTEM_CMD 256 @@ -38,7 +46,11 @@ static ESIF_INLINE void esif_ccb_system(const char *cmd) // Reboot static ESIF_INLINE void esif_ccb_reboot() { +#if defined(ESIF_ATTR_OS_WINDOWS) + esif_ccb_system("shutdown /r /t 0"); +#else esif_ccb_system("reboot"); +#endif } /* Convert GUID format from @@ -69,8 +81,18 @@ static ESIF_INLINE void esif_ccb_shutdown( EsifString namePtr ) { -#if defined(ESIF_ATTR_OS_CHROME) +#if defined(ESIF_ATTR_OS_WINDOWS) + esif_ccb_report_thermal_event( + ENVIRONMENTAL_EVENT_SHUTDOWN, + temperature, + tripPointTemperature, + namePtr + ); + esif_ccb_system("shutdown /s /f /t 0"); +#elif defined(ESIF_ATTR_OS_CHROME) esif_ccb_system("shutdown -P now"); +#elif defined(ESIF_ATTR_OS_ANDROID) + property_set(ANDROID_RB_PROPERTY, "thermal-shutdown"); #else esif_ccb_system("shutdown -h now"); #endif @@ -85,7 +107,21 @@ static ESIF_INLINE void esif_ccb_hibernate( EsifString namePtr ) { -#if defined(ESIF_ATTR_OS_CHROME) +#if defined(ESIF_ATTR_OS_WINDOWS) + esif_ccb_report_thermal_event( + ENVIRONMENTAL_EVENT_HIBERNATE, + temperature, + tripPointTemperature, + namePtr + ); + /* + ** TODO: Remove this code later as this is only a temporary solution for + ** problems related to attempting a hibernate too soon after a resume in + ** Windows. + */ + esif_ccb_sleep_msec(SUSPEND_DELAY_IN_MILLISECONDS); + SetSuspendState(1, 1, 0); +#elif defined(ESIF_ATTR_OS_CHROME) /* NA */ #else esif_ccb_system("pm-hibernate"); @@ -96,13 +132,37 @@ static ESIF_INLINE void esif_ccb_hibernate( // Enter S3 or CS static ESIF_INLINE void esif_ccb_suspend() { -#if defined(ESIF_ATTR_OS_CHROME) +#if defined(ESIF_ATTR_OS_WINDOWS) + /* + ** TODO: Remove this code later as this is only a temporary solution for + ** problems related to attempting a sleep too soon after a resume in + ** Windows. + */ + esif_ccb_sleep_msec(SUSPEND_DELAY_IN_MILLISECONDS); + SetSuspendState(0, 1, 0); +#elif defined(ESIF_ATTR_OS_CHROME) esif_ccb_system("powerd_dbus_suspend"); +#elif defined(ESIF_ATTR_OS_ANDROID) + esif_ccb_system("input keyevent 26"); #else esif_ccb_system("pm-suspend"); #endif } +#ifdef ESIF_ATTR_OS_WINDOWS +#define esif_ccb_disable_all_power_settings \ + esif_ccb_disable_all_power_settings_win + +#define esif_ccb_enable_power_setting(req_ptr) \ + esif_ccb_enable_power_setting_win(req_ptr) + +#define esif_ccb_disable_power_setting(req_ptr) \ + esif_ccb_disable_power_setting_win(req_ptr) + +#define esif_ccb_remove_power_setting(req_ptr) \ + esif_ccb_remove_power_setting_win(req_ptr) + +#else #define esif_ccb_disable_all_power_settings \ ESIF_E_ACTION_NOT_IMPLEMENTED @@ -115,6 +175,7 @@ static ESIF_INLINE void esif_ccb_suspend() #define esif_ccb_remove_power_setting(req_ptr) \ ESIF_E_ACTION_NOT_IMPLEMENTED +#endif /*****************************************************************************/ /*****************************************************************************/ diff --git a/ESIF/Products/ESIF_UF/Sources/esif_uf_ccb_thermalapi.h b/ESIF/Products/ESIF_UF/Sources/esif_uf_ccb_thermalapi.h index 407c9523..49858b05 100644 --- a/ESIF/Products/ESIF_UF/Sources/esif_uf_ccb_thermalapi.h +++ b/ESIF/Products/ESIF_UF/Sources/esif_uf_ccb_thermalapi.h @@ -22,6 +22,111 @@ #include "esif_uf_shell.h" #include "esif_uf_loggingmgr.h" +#ifdef ESIF_ATTR_OS_WINDOWS +// +// The Windows banned-API check header must be included after all other headers, or issues can be identified +// against Windows SDK/DDK included headers which we have no control over. +// +#define _SDL_BANNED_RECOMMENDED +#include "win\banned.h" +#include "powrprof.h" + +#define WIN10_LIMITS_MANAGEMENT_DLL "api-ms-win-power-limitsmanagement-l1-1-0.dll" +#define THERMALAPI_NO_OF_ARGUMENTS 2 + +#define POWR_PROF_DLL "powrprof.dll" +#define POWER_REPORT_THERMAL_EVENT_STR "PowerReportThermalEvent" +#define POWER_REPORT_LIMITS_EVENT_STR "PowerReportLimitsEvent" + +// +// _THERMAL_EVENT and PowerReportThermalEvent have been defined in WinBlue/Win8.1 WDK +// +#ifndef THERMAL_EVENT_VERSION + +#define THERMAL_EVENT_VERSION 1 + +typedef struct _THERMAL_EVENT { + ULONG Version; + ULONG Size; + ULONG Type; + ULONG Temperature; + ULONG TripPointTemperature; + LPWSTR Initiator; +} THERMAL_EVENT, *PTHERMAL_EVENT; + +#endif + +// +// _ENVIRONMENTAL_MANAGEMENT_EVENT and PowerReportLimitsEvent have been defined in Win10 WDK +// +#ifndef ENVIRONMENTAL_MANAGEMENT_EVENT_VERSION + +typedef struct _ENVIRONMENTAL_MANAGEMENT_EVENT { + ULONG Version; + ULONG Size; + ULONG EventType; + ULONG MonitorType; + ULONG LowerThreshold; + ULONG UpperThreshold; + ULONG Value; + LPWSTR Initiator; +} ENVIRONMENTAL_MANAGEMENT_EVENT, *PENVIRONMENTAL_MANAGEMENT_EVENT; + +#define ENVIRONMENTAL_MANAGEMENT_EVENT_VERSION 2 +#define ENVIORNMENTAL_VALUE_UNSPECIFIED 0 + +#define ENVIRONMENTAL_EVENT_SHUTDOWN 0 +#define ENVIRONMENTAL_EVENT_HIBERNATE 1 +#define ENVIRONMENTAL_EVENT_UNSPECIFIED 0xffffffff + +#endif + +typedef DWORD(WINAPI * PFNPOWERREPORTLIMITSEVENT)( + PENVIRONMENTAL_MANAGEMENT_EVENT Event); + +typedef DWORD(WINAPI * PFNPOWERREPORTTHERMALEVENT)( + PTHERMAL_EVENT Event); + +#define THERMAL_EVENT_SHUTDOWN 0 +#define THERMAL_EVENT_HIBERNATE 1 +#define THERMAL_EVENT_UNSPECIFIED 0xffffffff +// +// Externs +// +extern esif_lib_t g_thermalApiLib; + +#ifdef __cplusplus +extern "C" { +#endif + +char *EsifShellCmdThermalApi(EsifShellCmdPtr shell); +eEsifError EsifThermalApi_Init(void); +void EsifThermalApi_Exit(void); + +//Utility Functions +eEsifError ThermalApi_LoadLibrary(void); +eEsifError ThermalApi_ReleaseLibrary(void); + +void ThermalApi_ParticipantCreate(EsifUpPtr upPtr); +void ThermalApi_ParticipantDestroy(esif_handle_t participantId); + +void ThermalApi_ReportThermalEvent( + UInt32 EventFlag, + UInt32 temperature, + UInt32 tripPointTemperature, + EsifString namePtr + ); + +#ifdef __cplusplus +} +#endif + +#define esif_ccb_report_thermal_event(EventFlag, temperature, tripPointTemperature, participantName) \ + ThermalApi_ReportThermalEvent(EventFlag, temperature, tripPointTemperature, participantName) +#define EsifThermalApi_ParticipantCreate(upPtr) \ + ThermalApi_ParticipantCreate(upPtr) + +#else //NOT ESIF_ATTR_OS_WINDOWS static ESIF_INLINE char *EsifShellCmdThermalApi(EsifShellCmdPtr shell) { @@ -49,6 +154,7 @@ static ESIF_INLINE void esif_ccb_report_thermal_event( UNREFERENCED_PARAMETER(participantName); } +#endif /*****************************************************************************/ /*****************************************************************************/ diff --git a/ESIF/Products/ESIF_UF/Sources/esif_uf_ccb_timedwait.h b/ESIF/Products/ESIF_UF/Sources/esif_uf_ccb_timedwait.h index d4a344f8..8de5fdd2 100644 --- a/ESIF/Products/ESIF_UF/Sources/esif_uf_ccb_timedwait.h +++ b/ESIF/Products/ESIF_UF/Sources/esif_uf_ccb_timedwait.h @@ -21,7 +21,50 @@ #include "esif_ccb.h" #include "esif_ccb_sem.h" +#if defined(ESIF_ATTR_USER) +#if defined(ESIF_ATTR_OS_WINDOWS) + +static ESIF_INLINE eEsifError EsifTimedEventWait( + esif_ccb_event_t *waitEventPtr, + esif_ccb_time_t msDelay + ) +{ + eEsifError rc = ESIF_OK; + DWORD apiStatus = 0; + + esif_ccb_write_lock(&waitEventPtr->state_lock); + + if (waitEventPtr->signaled) { + esif_ccb_write_unlock(&waitEventPtr->state_lock); + goto exit; + } + + waitEventPtr->waiters++; + esif_ccb_write_unlock(&waitEventPtr->state_lock); + + apiStatus = WaitForSingleObject(waitEventPtr->sem_obj, (DWORD) msDelay); + // + // If thread released, but not due to signaling; decrement the waiter count + // + if (apiStatus != WAIT_OBJECT_0) { + + esif_ccb_write_lock(&waitEventPtr->state_lock); + if (waitEventPtr->waiters) { + waitEventPtr->waiters--; + } + esif_ccb_write_unlock(&waitEventPtr->state_lock); + + if (apiStatus != WAIT_TIMEOUT) { + rc = ESIF_E_UNSPECIFIED; + } + } + +exit: + return rc; +} + +#elif defined(ESIF_ATTR_OS_LINUX) #include "esif_ccb_timer.h" @@ -57,7 +100,9 @@ static ESIF_INLINE eEsifError EsifTimedEventWait( return rc; } +#endif /* LINUX */ +#endif /* USER */ diff --git a/ESIF/Products/ESIF_UF/Sources/esif_uf_cnjmgr.c b/ESIF/Products/ESIF_UF/Sources/esif_uf_cnjmgr.c index 148ebf35..27ba338d 100644 --- a/ESIF/Products/ESIF_UF/Sources/esif_uf_cnjmgr.c +++ b/ESIF/Products/ESIF_UF/Sources/esif_uf_cnjmgr.c @@ -20,6 +20,14 @@ #include "esif_uf.h" /* Upper Framework */ #include "esif_uf_cnjmgr.h" /* Application Manager */ +#ifdef ESIF_ATTR_OS_WINDOWS +// +// The Windows banned-API check header must be included after all other headers, or issues can be identified +// against Windows SDK/DDK included headers which we have no control over. +// +#define _SDL_BANNED_RECOMMENDED +#include "win\banned.h" +#endif /* Friends */ diff --git a/ESIF/Products/ESIF_UF/Sources/esif_uf_conjure.c b/ESIF/Products/ESIF_UF/Sources/esif_uf_conjure.c index 36659454..21893927 100644 --- a/ESIF/Products/ESIF_UF/Sources/esif_uf_conjure.c +++ b/ESIF/Products/ESIF_UF/Sources/esif_uf_conjure.c @@ -24,6 +24,14 @@ #include "esif_uf_cnjmgr.h" /* Conjure Manager */ #include "esif_uf_appmgr.h" +#ifdef ESIF_ATTR_OS_WINDOWS +// +// The Windows banned-API check header must be included after all other headers, or issues can be identified +// against Windows SDK/DDK included headers which we have no control over. +// +#define _SDL_BANNED_RECOMMENDED +#include "win\banned.h" +#endif /* Conjure Well Known Function */ typedef eEsifError (ESIF_CALLCONV *GetIfaceFuncPtr)(EsifConjureInterfacePtr); diff --git a/ESIF/Products/ESIF_UF/Sources/esif_uf_domain.c b/ESIF/Products/ESIF_UF/Sources/esif_uf_domain.c index d3b78a5c..0f048f61 100644 --- a/ESIF/Products/ESIF_UF/Sources/esif_uf_domain.c +++ b/ESIF/Products/ESIF_UF/Sources/esif_uf_domain.c @@ -29,6 +29,14 @@ #include "esif_lib_esifdata.h" +#ifdef ESIF_ATTR_OS_WINDOWS +// +// The Windows banned-API check header must be included after all other headers, or issues can be identified +// against Windows SDK/DDK included headers which we have no control over. +// +#define _SDL_BANNED_RECOMMENDED +#include "win\banned.h" +#endif #define PERF_STATE_POLL_PERIOD 3000 /* msec to poll perf state (will detect AC/DC change) */ diff --git a/ESIF/Products/ESIF_UF/Sources/esif_uf_dsp.c b/ESIF/Products/ESIF_UF/Sources/esif_uf_dsp.c index d20e6705..a821fedf 100644 --- a/ESIF/Products/ESIF_UF/Sources/esif_uf_dsp.c +++ b/ESIF/Products/ESIF_UF/Sources/esif_uf_dsp.c @@ -31,6 +31,14 @@ #define MAX_CPC_OFFSET 0x7ffffffd #define MAX_FPC_OFFSET 0x7ffffffd +#ifdef ESIF_ATTR_OS_WINDOWS +// +// The Windows banned-API check header must be included after all other headers, or issues can be identified +// against Windows SDK/DDK included headers which we have no control over. +// +#define _SDL_BANNED_RECOMMENDED +#include "win\banned.h" +#endif // Verify EDP Header Bool esif_verify_edp(struct edp_dir *edp, size_t size) diff --git a/ESIF/Products/ESIF_UF/Sources/esif_uf_dspmgr.c b/ESIF/Products/ESIF_UF/Sources/esif_uf_dspmgr.c index 0cf363e6..7bfbc858 100644 --- a/ESIF/Products/ESIF_UF/Sources/esif_uf_dspmgr.c +++ b/ESIF/Products/ESIF_UF/Sources/esif_uf_dspmgr.c @@ -30,6 +30,14 @@ #define MAX_MINTERM_LENGTH 256 /* Max Length for Minterm Match Lists */ +#ifdef ESIF_ATTR_OS_WINDOWS +// +// The Windows banned-API check header must be included after all other headers, or issues can be identified +// against Windows SDK/DDK included headers which we have no control over. +// +#define _SDL_BANNED_RECOMMENDED +#include "win\banned.h" +#endif // Limits #define MAX_EDP_SIZE 0x7ffffffe @@ -955,7 +963,11 @@ void esif_dsp_table_destroy() ******************************************************************************* */ +#ifdef ESIF_ATTR_OS_WINDOWS +#define DEFAULT_PROC "skl_proc" +#else #define DEFAULT_PROC "lin_proc" +#endif struct dsp_map_s { esif_string name; /* participant name or NULL for Default or end-of-list */ diff --git a/ESIF/Products/ESIF_UF/Sources/esif_uf_event.c b/ESIF/Products/ESIF_UF/Sources/esif_uf_event.c index bd637d2c..de446f9a 100644 --- a/ESIF/Products/ESIF_UF/Sources/esif_uf_event.c +++ b/ESIF/Products/ESIF_UF/Sources/esif_uf_event.c @@ -23,6 +23,15 @@ #include "esif_uf_eventmgr.h" #include "esif_ccb_socket.h" +#ifdef ESIF_ATTR_OS_WINDOWS +#include +// +// The Windows banned-API check header must be included after all other headers, or issues can be identified +// against Windows SDK/DDK included headers which we have no control over. +// +#define _SDL_BANNED_RECOMMENDED +#include "win\banned.h" +#endif void EsifEvent_GetAndSignalIpcEvent(); static eEsifError EsifEvent_InitEventWorkerThread(); @@ -44,6 +53,25 @@ extern int g_quit; extern esif_os_handle_t g_ipc_handle; int g_eventThreadExit = 0; +#ifdef ESIF_ATTR_OS_WINDOWS + +BOOL SendIpcIoctl( + DWORD ioControlCode, + LPVOID inBufferPtr, + DWORD inBufferSize, + LPVOID outBufferPtr, + DWORD outBufferSize, + LPDWORD bytesReturnedPtr + ); + +static eEsifError EsifEvent_InitEventObjects(); +static eEsifError EsifEvent_StartEventIpc(); +static eEsifError EsifEvent_HandleLfExit(); + +HANDLE g_hEventDoorbell = NULL; +HANDLE g_hEventLfExit = NULL; + +#endif // Dispatch An Event @@ -71,7 +99,21 @@ void EsifEvent_GetAndSignalIpcEvent() // // TODO: This needs to be in an OS abstraction layer // +#ifdef ESIF_ATTR_OS_LINUX r_bytes = read(g_ipc_handle, ipc_ptr, data_len); +#endif +#ifdef ESIF_ATTR_OS_WINDOWS + + rc = ipc_execute(ipc_ptr); + // + // TODO: The return size check is a W/A until a better solution is developed to determine if an event was returned. + // (The current LF code does not change the original data_len or fail the request if there are not events.) + // + r_bytes = 0; + if ((ESIF_OK == rc) && (ipc_ptr->data_len < event_len)) { + r_bytes = ipc_ptr->data_len; + } +#endif // Have Event? if (r_bytes > 0) { @@ -169,6 +211,10 @@ void *esif_event_worker_thread(void *ptr) eEsifError esifStatus = ESIF_OK; fd_set rfds = {0}; struct timeval tv = {0}; +#ifdef ESIF_ATTR_OS_WINDOWS + DWORD waitStatus = 0; + HANDLE waitHandles[2] = { 0 }; +#endif #ifdef ESIF_FEAT_OPT_ACTION_SYSFS UNREFERENCED_PARAMETER(rc); @@ -201,8 +247,26 @@ void *esif_event_worker_thread(void *ptr) tv.tv_sec = 0; tv.tv_usec = 50000; /* 50 msec */ + #ifdef ESIF_ATTR_OS_LINUX rc = select(g_ipc_handle + 1, &rfds, NULL, NULL, &tv); + #endif + #ifdef ESIF_ATTR_OS_WINDOWS + + waitHandles[0] = g_hEventDoorbell; + waitHandles[1] = g_hEventLfExit; + + waitStatus = WaitForMultipleObjects(sizeof(waitHandles) / sizeof(*waitHandles), waitHandles, FALSE, INFINITE); + if (waitStatus == (WAIT_OBJECT_0 + 1)) { + esifStatus = EsifEvent_HandleLfExit(); + if (esifStatus != ESIF_OK) { + break; + } + } else { + ResetEvent(g_hEventDoorbell); + } + rc = 1; + #endif #endif /* !ESIF_FEAT_OPT_ACTION_SYSFS */ } @@ -218,9 +282,125 @@ void *esif_event_worker_thread(void *ptr) void EsifEvent_StopEventWorkerThread() { g_eventThreadExit = 1; +#ifdef ESIF_ATTR_OS_WINDOWS + if (g_hEventDoorbell != NULL) { + SetEvent(g_hEventDoorbell); + } +#endif +} + + +#ifdef ESIF_ATTR_OS_WINDOWS + +static eEsifError EsifEvent_InitEventWorkerThread() +{ + eEsifError rc = ESIF_OK; + + rc = EsifEvent_InitEventObjects(); + if (rc != ESIF_OK) { + goto exit; + } + + rc = EsifEvent_StartEventIpc(); + if (rc != ESIF_OK) { + goto exit; + } +exit: + return rc; +} + + +static eEsifError EsifEvent_InitEventObjects() +{ + eEsifError rc = ESIF_OK; + + g_hEventDoorbell = CreateEventW(NULL, TRUE, FALSE, NULL); + if (NULL == g_hEventDoorbell) { + ESIF_TRACE_ERROR("Unable to create event doorbell\n"); + rc = ESIF_E_UNSPECIFIED; + goto exit; + } + ResetEvent(g_hEventDoorbell); + + g_hEventLfExit = CreateEventW(NULL, TRUE, FALSE, NULL); + if (NULL == g_hEventLfExit) { + ESIF_TRACE_ERROR("Unable to create LF exit event\n"); + rc = ESIF_E_UNSPECIFIED; + goto exit; + } + ResetEvent(g_hEventLfExit); +exit: + if (rc != ESIF_OK) { + if (g_hEventDoorbell != NULL) { + CloseHandle(g_hEventDoorbell); + g_hEventDoorbell = NULL; + } + if (g_hEventLfExit != NULL) { + CloseHandle(g_hEventLfExit); + g_hEventLfExit = NULL; + } + } + return rc; +} + + +static eEsifError EsifEvent_StartEventIpc() +{ + eEsifError rc = ESIF_OK; + EsifIpcEventEnable eventEnableStruct = {g_hEventDoorbell, g_hEventLfExit}; + + // Connect To Kernel IPC with infinite timeout + ipc_autoconnect(0); + + // + // If we can't notify of events + // + if (!SendIpcIoctl(ESIF_IOCTL_ENABLE_EVENT_DOORBELL, + &eventEnableStruct, sizeof(eventEnableStruct), + NULL, 0, + NULL)) { + ESIF_TRACE_ERROR("Unable to enable event doorbell\n"); + rc = ESIF_E_UNSPECIFIED; + goto exit; + } +exit: + return rc; +} + + +static void EsifEvent_CleanupEventWorkerThread() +{ + if (g_hEventDoorbell != NULL) { + CloseHandle(g_hEventDoorbell); + g_hEventDoorbell = NULL; + } + + if (g_hEventLfExit != NULL) { + CloseHandle(g_hEventLfExit); + g_hEventLfExit = NULL; + } + + if (g_ipc_handle != INVALID_HANDLE_VALUE) { + ipc_disconnect(); + } +} + + +static eEsifError EsifEvent_HandleLfExit() +{ + eEsifError rc = ESIF_OK; + + EsifEventMgr_SignalEvent(ESIF_HANDLE_PRIMARY_PARTICIPANT, EVENT_MGR_DOMAIN_D0, ESIF_EVENT_LF_UNLOADED, NULL); + + ResetEvent(g_hEventLfExit); + ipc_disconnect(); + rc = EsifEvent_StartEventIpc(); + + return rc; } +#else /* !ESIF_ATTR_OS_WINDOWS */ static eEsifError EsifEvent_InitEventWorkerThread() { @@ -238,6 +418,7 @@ static void EsifEvent_CleanupEventWorkerThread() } } +#endif /* !ESIF_ATTR_OS_WINDOWS */ /*****************************************************************************/ /*****************************************************************************/ diff --git a/ESIF/Products/ESIF_UF/Sources/esif_uf_event_cache.c b/ESIF/Products/ESIF_UF/Sources/esif_uf_event_cache.c index 211dd062..51084667 100644 --- a/ESIF/Products/ESIF_UF/Sources/esif_uf_event_cache.c +++ b/ESIF/Products/ESIF_UF/Sources/esif_uf_event_cache.c @@ -23,6 +23,14 @@ #include "esif_uf_eventmgr.h" #include "esif_pm.h" +#ifdef ESIF_ATTR_OS_WINDOWS +// +// The Windows banned-API check header must be included after all other headers, or issues can be identified +// against Windows SDK/DDK included headers which we have no control over. +// +#define _SDL_BANNED_RECOMMENDED +#include "win\banned.h" +#endif /////////////////////////////////////////////////////////////////////////////// diff --git a/ESIF/Products/ESIF_UF/Sources/esif_uf_eventmgr.c b/ESIF/Products/ESIF_UF/Sources/esif_uf_eventmgr.c index bd0b8370..86c5271f 100644 --- a/ESIF/Products/ESIF_UF/Sources/esif_uf_eventmgr.c +++ b/ESIF/Products/ESIF_UF/Sources/esif_uf_eventmgr.c @@ -26,6 +26,14 @@ #include "esif_queue.h" #include "esif_uf_sensors.h" +#ifdef ESIF_ATTR_OS_WINDOWS +// +// The Windows banned-API check header must be included after all other headers, or issues can be identified +// against Windows SDK/DDK included headers which we have no control over. +// +#define _SDL_BANNED_RECOMMENDED +#include "win\banned.h" +#endif #define NUM_EVENT_LISTS 64 #define EVENT_MGR_FILTERED_EVENTS_PER_LINE 64 diff --git a/ESIF/Products/ESIF_UF/Sources/esif_uf_eventmgr.h b/ESIF/Products/ESIF_UF/Sources/esif_uf_eventmgr.h index 82625927..a7eaa431 100644 --- a/ESIF/Products/ESIF_UF/Sources/esif_uf_eventmgr.h +++ b/ESIF/Products/ESIF_UF/Sources/esif_uf_eventmgr.h @@ -81,6 +81,23 @@ #define ESIF_UF_EVENT_QUEUE_NAME "UfQueue" #define ESIF_UF_EVENT_QUEUE_TIMEOUT ESIF_QUEUE_TIMEOUT_INFINITE /* No timeout */ +#if defined(ESIF_ATTR_OS_WINDOWS) +#include "win\dppe.h" +#include "win\cem_csensormanager.h" +#include "win\support_app.h" + +#define register_for_power_notification(guid_ptr) register_for_power_notification_win(guid_ptr) +#define unregister_power_notification(guid_ptr) unregister_power_notification_win(guid_ptr) + +#define register_for_system_metrics_notification(guid_ptr) register_for_system_metrics_notification_win(guid_ptr) +#define unregister_system_metrics_notification(guid_ptr) unregister_system_metrics_notification_win(guid_ptr) + +#define esif_enable_code_event(eventType) enable_code_event_win(eventType) +#define esif_disable_code_event(eventType) disable_code_event_win(eventType) + +#define EsifEventMgr_SendInitialEvent(participantId, domainId, eventType) esif_send_initial_event_win (participantId, domainId, eventType) + +#elif defined(ESIF_ATTR_OS_LINUX) #include "lin/esif_uf_sensor_manager_os_lin.h" #define register_for_power_notification(guid_ptr) register_for_system_metric_notification_lin(guid_ptr) @@ -93,6 +110,14 @@ #define esif_disable_code_event(eventType) (ESIF_E_NOT_IMPLEMENTED) #define EsifEventMgr_SendInitialEvent(participantId, domainId, eventType) (ESIF_E_NOT_IMPLEMENTED) +#else +#define register_for_power_notification(guid_ptr) (ESIF_E_NOT_IMPLEMENTED) +#define unregister_power_notification(guid_ptr) (ESIF_E_NOT_IMPLEMENTED) + +#define register_for_system_metrics_notification(guid_ptr) (ESIF_E_NOT_IMPLEMENTED) +#define unregister_system_metrics_notification(guid_ptr) (ESIF_E_NOT_IMPLEMENTED) + +#endif typedef eEsifError (ESIF_CALLCONV * EVENT_OBSERVER_CALLBACK)( esif_context_t context, diff --git a/ESIF/Products/ESIF_UF/Sources/esif_uf_handlemgr.c b/ESIF/Products/ESIF_UF/Sources/esif_uf_handlemgr.c index 2a68ec16..ccc9df0b 100644 --- a/ESIF/Products/ESIF_UF/Sources/esif_uf_handlemgr.c +++ b/ESIF/Products/ESIF_UF/Sources/esif_uf_handlemgr.c @@ -21,6 +21,14 @@ #include "esif_uf_handlemgr.h" /* Application Manager */ #include "esif_link_list.h" +#ifdef ESIF_ATTR_OS_WINDOWS +// +// The Windows banned-API check header must be included after all other headers, or issues can be identified +// against Windows SDK/DDK included headers which we have no control over. +// +#define _SDL_BANNED_RECOMMENDED +#include "win\banned.h" +#endif // // GLOBAL DEFINITIONS diff --git a/ESIF/Products/ESIF_UF/Sources/esif_uf_ipc.c b/ESIF/Products/ESIF_UF/Sources/esif_uf_ipc.c index d05d08d6..73823129 100644 --- a/ESIF/Products/ESIF_UF/Sources/esif_uf_ipc.c +++ b/ESIF/Products/ESIF_UF/Sources/esif_uf_ipc.c @@ -23,6 +23,14 @@ #include "esif_dsp.h" /* Device Support Package */ #include "esif_version.h" +#ifdef ESIF_ATTR_OS_WINDOWS +// +// The Windows banned-API check header must be included after all other headers, or issues can be identified +// against Windows SDK/DDK included headers which we have no control over. +// +#define _SDL_BANNED_RECOMMENDED +#include "win\banned.h" +#endif void ipc_disconnect(); @@ -263,4 +271,4 @@ enum esif_rc ipc_execute(struct esif_ipc *ipc) return rc; } -#endif +#endif \ No newline at end of file diff --git a/ESIF/Products/ESIF_UF/Sources/esif_uf_log.h b/ESIF/Products/ESIF_UF/Sources/esif_uf_log.h index 0975fb33..0c1a9ba7 100644 --- a/ESIF/Products/ESIF_UF/Sources/esif_uf_log.h +++ b/ESIF/Products/ESIF_UF/Sources/esif_uf_log.h @@ -22,8 +22,21 @@ #include #include +#ifndef ESIF_ATTR_OS_WINDOWS # include +#endif + +#ifdef ESIF_ATTR_OS_WINDOWS +#ifdef __cplusplus +extern "C" { +#endif +void report_event_to_event_log(int eventType, char *pFormat, ...); + +#ifdef __cplusplus +} +#endif +#endif #ifdef __cplusplus extern "C" { diff --git a/ESIF/Products/ESIF_UF/Sources/esif_uf_loggingmgr.c b/ESIF/Products/ESIF_UF/Sources/esif_uf_loggingmgr.c index 3161d5b2..cf5d6b8e 100644 --- a/ESIF/Products/ESIF_UF/Sources/esif_uf_loggingmgr.c +++ b/ESIF/Products/ESIF_UF/Sources/esif_uf_loggingmgr.c @@ -2220,7 +2220,7 @@ static eEsifError EsifLogMgr_ParticipantLogAddHeaderData( case ESIF_CAPABILITY_TYPE_MANAGER: esif_ccb_sprintf_concat(dataLength, logString, "OS Power Source,OS Battery Percent,OS Dock Mode,OS Game Mode,OS Lid State,OS Power Slider,OS User Interaction," "OS User Presence,OS Screen State,Device Orientation,In Motion,System Cooling Mode,OS Platform Type," - "Display Orientation,OS Power Scheme Personality,OS Mixed Reality Mode,Platform User Presence,Foreground Background Ratio,Collaboration State,"); + "Display Orientation,OS Power Scheme Personality,OS Mixed Reality Mode,Platform User Presence,Foreground Background Ratio,PPM Package,Collaboration State,"); break; case ESIF_CAPABILITY_TYPE_WORKLOAD_CLASSIFICATION: esif_ccb_sprintf_concat(dataLength, logString, "SOC Workload,"); @@ -2488,10 +2488,10 @@ static eEsifError EsifLogMgr_ParticipantLogAddCapabilityData( case ESIF_CAPABILITY_TYPE_MANAGER: { if (capabilityPtr->data.managerStatus.osPowerSource == ESIF_INVALID_DATA) { - esif_ccb_sprintf_concat(dataLength, logString, "X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,"); + esif_ccb_sprintf_concat(dataLength, logString, "X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,X,"); } else { - esif_ccb_sprintf_concat(dataLength, logString, "%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%s,%u,%u,%u,%u,", + esif_ccb_sprintf_concat(dataLength, logString, "%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%u,%s,%u,%u,%u,%u,%u,", capabilityPtr->data.managerStatus.osPowerSource, capabilityPtr->data.managerStatus.batteryPercent, capabilityPtr->data.managerStatus.dockMode, @@ -2510,6 +2510,7 @@ static eEsifError EsifLogMgr_ParticipantLogAddCapabilityData( capabilityPtr->data.managerStatus.mixedRealityMode, capabilityPtr->data.managerStatus.platformUserPresence, capabilityPtr->data.managerStatus.foregroundBackgroundRatio, + capabilityPtr->data.managerStatus.ppmPackage, capabilityPtr->data.managerStatus.collaboration ); } diff --git a/ESIF/Products/ESIF_UF/Sources/esif_uf_participant.c b/ESIF/Products/ESIF_UF/Sources/esif_uf_participant.c index 1f39a266..238adf78 100644 --- a/ESIF/Products/ESIF_UF/Sources/esif_uf_participant.c +++ b/ESIF/Products/ESIF_UF/Sources/esif_uf_participant.c @@ -25,6 +25,14 @@ #include "esif_sdk_iface_upe.h" #include "esif_uf_handlemgr.h" +#ifdef ESIF_ATTR_OS_WINDOWS +// +// The Windows banned-API check header must be included after all other headers, or issues can be identified +// against Windows SDK/DDK included headers which we have no control over. +// +#define _SDL_BANNED_RECOMMENDED +#include "win\banned.h" +#endif #define CONNECTED_STANDBY_POLLING_RATE_DEFAULT 60000 diff --git a/ESIF/Products/ESIF_UF/Sources/esif_uf_pm.c b/ESIF/Products/ESIF_UF/Sources/esif_uf_pm.c index 0fff0db0..8f027173 100644 --- a/ESIF/Products/ESIF_UF/Sources/esif_uf_pm.c +++ b/ESIF/Products/ESIF_UF/Sources/esif_uf_pm.c @@ -31,6 +31,14 @@ #include "esif_command.h" #include "esif_ccb_string.h" +#ifdef ESIF_ATTR_OS_WINDOWS +// +// The Windows banned-API check header must be included after all other headers, or issues can be identified +// against Windows SDK/DDK included headers which we have no control over. +// +#define _SDL_BANNED_RECOMMENDED +#include "win\banned.h" +#endif #define ESIF_PARTICIPANT0_INDEX 0 @@ -239,7 +247,6 @@ eEsifError EsifUpPm_ParticipantActivityLoggingEnable(EsifUpPtr upPtr) case ESIF_DOMAIN_TYPE_WWAN: case ESIF_DOMAIN_TYPE_POWER: case ESIF_DOMAIN_TYPE_CHIPSET: - case ESIF_DOMAIN_TYPE_VPU: { UInt32 capMask = EsifUp_GetDomainCapabilityMask(domainPtr); EsifData capData = { ESIF_DATA_UINT32, &capMask, sizeof(capMask), sizeof(capMask) }; diff --git a/ESIF/Products/ESIF_UF/Sources/esif_uf_primitive.c b/ESIF/Products/ESIF_UF/Sources/esif_uf_primitive.c index 027bd881..c463ada0 100644 --- a/ESIF/Products/ESIF_UF/Sources/esif_uf_primitive.c +++ b/ESIF/Products/ESIF_UF/Sources/esif_uf_primitive.c @@ -23,6 +23,14 @@ #include "esif_dsp.h" #include "esif_uf_action.h" +#ifdef ESIF_ATTR_OS_WINDOWS +// +// The Windows banned-API check header must be included after all other headers, or issues can be identified +// against Windows SDK/DDK included headers which we have no control over. +// +#define _SDL_BANNED_RECOMMENDED +#include "win\banned.h" +#endif void EsifUfDumpPrimitive( diff --git a/ESIF/Products/ESIF_UF/Sources/esif_uf_primitive_type.h b/ESIF/Products/ESIF_UF/Sources/esif_uf_primitive_type.h index ccb42af9..152a8ead 100644 --- a/ESIF/Products/ESIF_UF/Sources/esif_uf_primitive_type.h +++ b/ESIF/Products/ESIF_UF/Sources/esif_uf_primitive_type.h @@ -135,7 +135,6 @@ static ESIF_INLINE esif_primitive_type_t esif_primitive_type_set2get(esif_primit { SET_USER_BASED_REFRESH_RATE_SUR, GET_USER_BASED_REFRESH_RATE_SUR }, { SET_PERF_PREFERENCE_SUR, GET_PERF_PREFERENCE_SUR }, { SET_FAN_OPERATING_MODE, GET_FAN_OPERATING_MODE }, - { SET_DDR_DVFS_RFI_RESTRICTION_REG, GET_DDR_DVFS_RFI_RESTRICTION_REG }, }; /* Match SET using a Binary Search */ @@ -267,7 +266,6 @@ static ESIF_INLINE esif_primitive_type_t esif_primitive_type_get2set(esif_primit { GET_USER_BASED_REFRESH_RATE_SUR, SET_USER_BASED_REFRESH_RATE_SUR }, { GET_PERF_PREFERENCE_SUR, SET_PERF_PREFERENCE_SUR }, { GET_FAN_OPERATING_MODE, SET_FAN_OPERATING_MODE }, - { GET_DDR_DVFS_RFI_RESTRICTION_REG, SET_DDR_DVFS_RFI_RESTRICTION_REG }, }; /* Match Assocated GET using a Binary Search */ diff --git a/ESIF/Products/ESIF_UF/Sources/esif_uf_sensors.h b/ESIF/Products/ESIF_UF/Sources/esif_uf_sensors.h index 5279de09..a0e315e8 100644 --- a/ESIF/Products/ESIF_UF/Sources/esif_uf_sensors.h +++ b/ESIF/Products/ESIF_UF/Sources/esif_uf_sensors.h @@ -191,6 +191,19 @@ static ESIF_INLINE char* GetPlatTypeStr(PlatformType platType) return str; } +#if defined(ESIF_ATTR_OS_WINDOWS) +#include "win\dppe.h" +#include "win\cem_csensormanager.h" +#include "win\support_app.h" + +#define esif_register_sensors(eventType) esif_register_sensors_win(eventType) +#define esif_unregister_sensors(eventType) esif_unregister_sensors_win(eventType) +#define esif_is_face_detection_capable_sensor() esif_is_face_detection_capable_sensor_win() +#define esif_get_bp_sensor_instance(ret) esif_get_bp_sensor_instance_win(ret) +#define esif_set_bp_sensor_instance(arg) esif_set_bp_sensor_instance_win(arg) +#define esif_is_bp_capable_sensor() esif_is_bp_capable_sensor_win() + +#elif defined(ESIF_ATTR_OS_LINUX) #include "lin/esif_uf_sensor_manager_os_lin.h" #define esif_register_sensors(eventType) esif_register_sensor_lin(eventType) @@ -200,6 +213,7 @@ static ESIF_INLINE char* GetPlatTypeStr(PlatformType platType) #define esif_set_bp_sensor_instance(arg) (ESIF_E_NOT_IMPLEMENTED) #define esif_is_bp_capable_sensor() (ESIF_E_NOT_IMPLEMENTED) +#endif #ifdef __cplusplus extern "C" { diff --git a/ESIF/Products/ESIF_UF/Sources/esif_uf_service.c b/ESIF/Products/ESIF_UF/Sources/esif_uf_service.c index c0355311..fb2f91fd 100644 --- a/ESIF/Products/ESIF_UF/Sources/esif_uf_service.c +++ b/ESIF/Products/ESIF_UF/Sources/esif_uf_service.c @@ -30,6 +30,14 @@ #include "esif_uf_eventmgr.h" #include "esif_uf_arbmgr.h" +#ifdef ESIF_ATTR_OS_WINDOWS +// +// The Windows banned-API check header must be included after all other headers, or issues can be identified +// against Windows SDK/DDK included headers which we have no control over. +// +#define _SDL_BANNED_RECOMMENDED +#include "win\banned.h" +#endif typedef enum EventCategory_e { EVENT_CATEGORY_NONE = 0, diff --git a/ESIF/Products/ESIF_UF/Sources/esif_uf_shell.c b/ESIF/Products/ESIF_UF/Sources/esif_uf_shell.c index 48f43d58..0fcce5b0 100644 --- a/ESIF/Products/ESIF_UF/Sources/esif_uf_shell.c +++ b/ESIF/Products/ESIF_UF/Sources/esif_uf_shell.c @@ -73,6 +73,14 @@ char g_esif_kernel_version[64] = "NA"; extern struct esif_uf_dm g_dm; +#ifdef ESIF_ATTR_OS_WINDOWS +// +// The Windows banned-API check header must be included after all other headers, or issues can be identified +// against Windows SDK/DDK included headers which we have no control over. +// +#define _SDL_BANNED_RECOMMENDED +#include "win\banned.h" +#endif // Shell strings limited to current size of output buffer #define ESIF_SHELL_STRLEN(s) esif_ccb_strlen(s, OUT_BUF_LEN) @@ -3219,7 +3227,7 @@ static char *esif_shell_cmd_getp(EsifShellCmdPtr shell) rc = ESIF_E_NO_MEMORY; goto exit; } - rc = EsifData_FromString(primitiveInDataPtr, argv[opt++] + sizeof(dataIndicator) - 1, ESIF_DATA_AUTO); + rc = EsifData_FromString(primitiveInDataPtr, argv[opt++] + sizeof(dataIndicator), ESIF_DATA_AUTO); if (rc != ESIF_OK || primitiveInDataPtr->buf_ptr == NULL) { goto exit; } @@ -7019,7 +7027,9 @@ static char *esif_shell_cmd_exit(EsifShellCmdPtr shell) } g_disconnectClient = ESIF_TRUE; +#ifndef ESIF_ATTR_OS_WINDOWS g_quit = ESIF_TRUE; +#endif esif_ccb_sprintf(OUT_BUF_LEN, output, "Exiting...\n"); return output; @@ -7790,7 +7800,9 @@ static char *esif_shell_cmd_quit(EsifShellCmdPtr shell) } g_disconnectClient = ESIF_TRUE; +#ifndef ESIF_ATTR_OS_WINDOWS g_quit = ESIF_TRUE; +#endif esif_ccb_sprintf(OUT_BUF_LEN, output, "quit\n"); return output; @@ -8741,7 +8753,11 @@ static char *esif_shell_cmd_ui(EsifShellCmdPtr shell) int newargc = 0; newargv[newargc++] = "app"; newargv[newargc++] = "cmd"; +#ifdef ESIF_ATTR_OS_WINDOWS + newargv[newargc++] = "dptfui"; +#else newargv[newargc++] = ESIF_WS_LIBRARY_NAME; // TODO: Change when Linux loads dptfui.so instead of esif_ws.so +#endif newargv[newargc++] = "fetch"; newargv[newargc++] = "combined.xsl"; diff --git a/ESIF/Products/ESIF_UF/Sources/esif_uf_tableobject.c b/ESIF/Products/ESIF_UF/Sources/esif_uf_tableobject.c index 59cea264..3889d2d8 100644 --- a/ESIF/Products/ESIF_UF/Sources/esif_uf_tableobject.c +++ b/ESIF/Products/ESIF_UF/Sources/esif_uf_tableobject.c @@ -32,6 +32,14 @@ #include "esif_temp.h" #include "esif_uf_ccb_system.h" +#ifdef ESIF_ATTR_OS_WINDOWS +// +// The Windows banned-API check header must be included after all other headers, or issues can be identified +// against Windows SDK/DDK included headers which we have no control over. +// +#define _SDL_BANNED_RECOMMENDED +#include "win\banned.h" +#endif #define MAX_TABLEOBJECT_KEY_LEN 256 #define MAX_TABLEOBJECT_COLUMN_DATA_LEN 1 * 1024 @@ -2575,24 +2583,11 @@ eEsifError TableObject_LoadSchema( }; fieldlist = psha_fields; } - else if (esif_ccb_stricmp(self->name, "psh2") == 0 && self->version == 1) { - static TableField psh2_fields[] = { - { "fld1", "fld1", ESIF_DATA_STRING }, - { "fld2", "fld2", ESIF_DATA_UINT64 }, - { "fld3", "fld3", ESIF_DATA_UINT64 }, - { 0 } - }; - fieldlist = psh2_fields; - } - else if (esif_ccb_stricmp(self->name, "psh2") == 0 && self->version == 2) { + else if (esif_ccb_stricmp(self->name, "psh2") == 0) { static TableField psh2_fields[] = { { "fld1", "fld1", ESIF_DATA_STRING }, { "fld2", "fld2", ESIF_DATA_UINT64 }, { "fld3", "fld3", ESIF_DATA_UINT64 }, - { "fld4", "fld4", ESIF_DATA_UINT64 }, - { "fld5", "fld5", ESIF_DATA_UINT64 }, - { "fld6", "fld6", ESIF_DATA_UINT64 }, - { "fld7", "fld7", ESIF_DATA_UINT64 }, { 0 } }; fieldlist = psh2_fields; diff --git a/ESIF/Products/ESIF_UF/Sources/esif_uf_tableobject.h b/ESIF/Products/ESIF_UF/Sources/esif_uf_tableobject.h index 588d6950..6ed21559 100644 --- a/ESIF/Products/ESIF_UF/Sources/esif_uf_tableobject.h +++ b/ESIF/Products/ESIF_UF/Sources/esif_uf_tableobject.h @@ -98,4 +98,4 @@ eEsifError TableObject_LoadXML(TableObject *self, enum esif_temperature_type tem eEsifError TableObject_Convert(TableObject *self); eEsifError TableObject_ResetConfig(TableObject *self, UInt32 primitiveToReset, const UInt8 instance); -#endif +#endif \ No newline at end of file diff --git a/ESIF/Products/ESIF_UF/Sources/esif_uf_trace.c b/ESIF/Products/ESIF_UF/Sources/esif_uf_trace.c index 81097619..a8c320e4 100644 --- a/ESIF/Products/ESIF_UF/Sources/esif_uf_trace.c +++ b/ESIF/Products/ESIF_UF/Sources/esif_uf_trace.c @@ -19,9 +19,32 @@ #include "esif.h" #include "esif_uf_trace.h" +#ifdef ESIF_ATTR_OS_WINDOWS +/* + * + * The Windows banned-API check header must be included after all other headers, + * or issues can be identified + * against Windows SDK/DDK included headers which we have no control over. + * + */ +#define _SDL_BANNED_RECOMMENDED +#include "win\banned.h" +#endif #include "esif_uf_log.h" +#ifdef ESIF_ATTR_OS_WINDOWS +#endif +#ifdef ESIF_ATTR_OS_LINUX +# ifdef ESIF_ATTR_OS_ANDROID +# include +# define IDENT "DPTF" +# define ESIF_PRIORITY_FATAL ANDROID_LOG_FATAL +# define ESIF_PRIORITY_ERROR ANDROID_LOG_ERROR +# define ESIF_PRIORITY_WARNING ANDROID_LOG_WARN +# define ESIF_PRIORITY_INFO ANDROID_LOG_INFO +# define ESIF_PRIORITY_DEBUG ANDROID_LOG_DEBUG +# else # include # define IDENT "DPTF" # define OPTION LOG_PID @@ -31,6 +54,8 @@ # define ESIF_PRIORITY_WARNING LOG_WARNING # define ESIF_PRIORITY_INFO LOG_INFO # define ESIF_PRIORITY_DEBUG LOG_DEBUG +# endif +#endif int g_traceLevel = ESIF_TRACELEVEL_DEFAULT; @@ -197,6 +222,79 @@ int EsifUfTraceMessageArgs( } } +#ifdef ESIF_ATTR_OS_WINDOWS + if (g_traceinfo[level].routes & (ESIF_TRACEROUTE_DEBUGGER)) { + size_t msglen=0; + char *buffer=0; + int offset=0; + + va_copy(args, arglist); + msglen = esif_ccb_vscprintf(msg, args) + esif_ccb_strlen(g_traceinfo[level].label, MAX_PATH) + esif_ccb_strlen(appname, MAX_PATH) + esif_ccb_strlen(func, MAX_PATH) + esif_ccb_strlen(file, MAX_PATH) + esif_ccb_strlen(module_name, MAX_PATH) + TRACE_MESSAGE_PADDING; + va_end(args); + msglen += (detailed_message ? esif_ccb_strlen(fmtDetail, MAX_PATH) : esif_ccb_strlen(fmtInfo, MAX_PATH)); + buffer = (char *)esif_ccb_malloc(msglen); + + if (NULL != buffer) { + if (detailed_message) + rc = esif_ccb_sprintf(msglen, buffer, fmtDetail, appname, g_traceinfo[level].label, module_name, func, file, line, msec); + else + rc = esif_ccb_sprintf(msglen, buffer, fmtInfo, appname, g_traceinfo[level].label, module_name, msec); + + offset = rc; + va_copy(args, arglist); + rc += esif_ccb_vsprintf(msglen-offset, buffer+offset, msg, args); + va_end(args); + if (rc && buffer[rc-1]!='\n') + esif_ccb_strcat(buffer, "\n", msglen); + + OutputDebugStringA(buffer); + esif_ccb_free(buffer); + } + } + if (g_traceinfo[level].routes & (ESIF_TRACEROUTE_EVENTLOG)) { + size_t msglen=0; + char *buffer=0; + char *replaced=0; + int offset=0; + + appname = ""; + fmtInfo = "%sESIF(%s) TYPE: %s MODULE: %s TIME %llu ms\n\n"; + fmtDetail= "%sESIF(%s) TYPE: %s MODULE: %s FUNC: %s FILE: %s LINE: %d TIME: %llu ms\n\n"; + + va_copy(args, arglist); + msglen = esif_ccb_vscprintf(msg,args) + esif_ccb_strlen(g_traceinfo[level].label, MAX_PATH) + esif_ccb_strlen(appname, MAX_PATH) + esif_ccb_strlen(func, MAX_PATH) + esif_ccb_strlen(file, MAX_PATH) + esif_ccb_strlen(module_name, MAX_PATH) + sizeof(ESIF_UF_VERSION) + TRACE_MESSAGE_PADDING; + va_end(args); + msglen += (detailed_message ? esif_ccb_strlen(fmtDetail, MAX_PATH) : esif_ccb_strlen(fmtInfo, MAX_PATH)); + buffer = (char *)esif_ccb_malloc(msglen); + + if (NULL != buffer) { + char *alt_module_name = esif_str_replace(module_name, "><", "+"); + + if (detailed_message) + rc = esif_ccb_sprintf(msglen, buffer, fmtDetail, appname, ESIF_UF_VERSION, g_traceinfo[level].label, (alt_module_name ? alt_module_name : module_name), func, file, line, msec); + else + rc = esif_ccb_sprintf(msglen, buffer, fmtInfo, appname, ESIF_UF_VERSION, g_traceinfo[level].label, (alt_module_name ? alt_module_name : module_name), msec); + + offset = rc; + va_copy(args, arglist); + rc += esif_ccb_vsprintf(msglen-(offset), buffer+offset, msg, args); + va_end(args); + if (rc && buffer[rc-1]=='\n') + buffer[--rc] = 0; + + // Escape any "%" in message before writing to EventLog + if ((replaced = esif_str_replace(buffer, "%", "%%")) != NULL) { + esif_ccb_free(buffer); + buffer = replaced; + replaced = NULL; + } + report_event_to_event_log(g_traceinfo[level].level, buffer); + esif_ccb_free(buffer); + esif_ccb_free(alt_module_name); + } + } +#endif +#ifdef ESIF_ATTR_OS_LINUX if (g_traceinfo[level].routes & (ESIF_TRACEROUTE_EVENTLOG|ESIF_TRACEROUTE_DEBUGGER)) { size_t msglen=0; char *buffer=0; @@ -247,12 +345,17 @@ int EsifUfTraceMessageArgs( priority = ESIF_PRIORITY_DEBUG; break; } + #ifdef ESIF_ATTR_OS_ANDROID + __android_log_write(priority, IDENT, buffer); + #else openlog(IDENT, OPTION, FACILITY); syslog(priority, "%s", buffer); closelog(); + #endif esif_ccb_free(buffer); } } +#endif exit: esif_ccb_free(module_name); return rc; @@ -308,4 +411,4 @@ int EsifUfTraceMessage( va_end(args); return rc; } -#endif +#endif \ No newline at end of file diff --git a/ESIF/Products/ESIF_UF/Sources/esif_uf_trace.h b/ESIF/Products/ESIF_UF/Sources/esif_uf_trace.h index 94cd585c..7099ab09 100644 --- a/ESIF/Products/ESIF_UF/Sources/esif_uf_trace.h +++ b/ESIF/Products/ESIF_UF/Sources/esif_uf_trace.h @@ -75,11 +75,25 @@ typedef u8 esif_traceroute_t; #define ESIF_TRACEMASK_MAX 32 #define ESIF_TRACEMAPPING_MAX 256 +#ifdef ESIF_ATTR_OS_WINDOWS +/* Avoid Klocworks "suspicious semicolon" warnings */ +#define ESIF_ALWAYSFALSE (0) +#define ESIF_TRACENULL(fmt, ...) (0) +#define ESIF_TRACEFUNC(fmt, ...) CMD_OUT(fmt, ##__VA_ARGS__) +#define ESIF_FILENAME __FILE__ + +/* OS Trace is only available for Windows components */ +#define ESIF_FEAT_OPT_OS_TRACE + +#endif /* ESIF_ATTR_OS_WINDOWS */ + +#ifdef ESIF_ATTR_OS_LINUX #define ESIF_ALWAYSFALSE (0) #define ESIF_TRACENULL(fmt, ...) #define ESIF_TRACEFUNC(fmt, ...) printf(fmt, ##__VA_ARGS__) #define ESIF_FILENAME __FILE__ +#endif /* LINUX */ /* * ESIF_TRACE_ID must be #defined in each source file before any #includes diff --git a/ESIF/Products/ESIF_UF/Sources/esif_uf_xform.c b/ESIF/Products/ESIF_UF/Sources/esif_uf_xform.c index c84437fb..40747472 100644 --- a/ESIF/Products/ESIF_UF/Sources/esif_uf_xform.c +++ b/ESIF/Products/ESIF_UF/Sources/esif_uf_xform.c @@ -21,6 +21,14 @@ #include "esif_participant.h" #include "esif_uf_trace.h" +#ifdef ESIF_ATTR_OS_WINDOWS +// +// The Windows banned-API check header must be included after all other headers, or issues can be identified +// against Windows SDK/DDK included headers which we have no control over. +// +#define _SDL_BANNED_RECOMMENDED +#include "win\banned.h" +#endif #define ESIF_TRACE_DYN_TEMP(format, ...) \ ESIF_TRACE_DYN(ESIF_TRACEMODULE_DEFAULT, \ diff --git a/ESIF/Products/ESIF_UF/Sources/lin/esif_uf_action_sysfs_os_lin.c b/ESIF/Products/ESIF_UF/Sources/lin/esif_uf_action_sysfs_os_lin.c index c9c08e7e..2df1b329 100644 --- a/ESIF/Products/ESIF_UF/Sources/lin/esif_uf_action_sysfs_os_lin.c +++ b/ESIF/Products/ESIF_UF/Sources/lin/esif_uf_action_sysfs_os_lin.c @@ -252,7 +252,6 @@ enum esif_sysfs_param { ESIF_SYSFS_GET_BATTERY_HIGH_FREQUENCY_IMPEDANCE = 'FHBR', ESIF_SYSFS_GET_BATTERY_CURRENT_DISCHARGE_CAPABILITY = 'PPMC', ESIF_SYSFS_GET_BATTERY_NO_LOAD_VOLTAGE = 'LNBV', - ESIF_SYSFS_GET_PARTICIPANT_UNIQUE_ID = 'DIU_', ESIF_SYSFS_GET_RFPROFILE_SSC = 'FSRG', ESIF_SYSFS_GET_RFPROFILE_SSC_PCH = 'PSSG', ESIF_SYSFS_GET_BATTERY_MAX_PEAK_CURRENT = 'ppmc', @@ -343,6 +342,9 @@ static void UpdateFineGrainSupportedStatus(const EsifString devicePathPtr); static void UpdateStepSize(const EsifString devicePathPtr); static void UpdateFpsSupportedStatus(const EsifString devicePathPtr); +#ifdef ESIF_ATTR_OS_ANDROID +static void NotifyJhs(EsifUpPtr upPtr, const EsifDataPtr requestPtr); +#endif // Get crystal clock freq static eEsifError GetCrystalClockFrequency(UInt32 *crystalFreq) @@ -517,7 +519,6 @@ static eEsifError ESIF_CALLCONV ActionSysfsGet( size_t actionContext = 0; EsifUpDataPtr metaPtr = NULL; char batPwrSysfsPath[MAX_SYSFS_PATH] = { 0 }; - char participantUidSysfsPath[MAX_SYSFS_PATH] = { 0 }; UInt32 sscPercentage = 0; UInt32 sscRegisterValue = 0; static UInt32 raplEnergyUnit = 0; @@ -900,31 +901,12 @@ static eEsifError ESIF_CALLCONV ActionSysfsGet( goto exit; } - if (SysfsGetInt64(batPwrSysfsPath, parm2, &sysval) < SYSFS_FILE_RETRIEVAL_SUCCESS) { + if (SysfsGetInt64(batPwrSysfsPath, parm2, &sysval) < SYSFS_FILE_RETRIEVAL_SUCCESS) { rc = ESIF_E_PRIMITIVE_ACTION_FAILURE; goto exit; - } + } *(u32 *) responsePtr->buf_ptr = (u32) sysval; break; - case ESIF_SYSFS_GET_PARTICIPANT_UNIQUE_ID: - if(esif_ccb_strstr(deviceFullPathPtr, "cooling_device") || esif_ccb_strstr(deviceFullPathPtr, "thermal_zone")) - { - esif_ccb_sprintf(sizeof(participantUidSysfsPath),participantUidSysfsPath, "%s/device/%s", deviceFullPathPtr, "firmware_node"); - } - else { - esif_ccb_sprintf(sizeof(participantUidSysfsPath),participantUidSysfsPath, "%s/%s", deviceFullPathPtr, "firmware_node"); - } - if (SysfsGetString(participantUidSysfsPath, parm2, sysvalstring, sizeof(sysvalstring)) < SYSFS_FILE_RETRIEVAL_SUCCESS) { - rc = ESIF_E_PRIMITIVE_ACTION_FAILURE; - goto exit; - } - responsePtr->data_len = esif_ccb_strlen(sysvalstring, MAX_SYSFS_PATH); - if (responsePtr->buf_len < responsePtr->data_len) { - rc = ESIF_E_NEED_LARGER_BUFFER; - goto exit; - } - esif_ccb_sprintf(responsePtr->buf_len, (char *) responsePtr->buf_ptr, "%s", sysvalstring); - break; case ESIF_SYSFS_GET_RFPROFILE_SSC: if (SysfsGetInt64(parm1, "spread_spectrum_clk_enable" , &sysval) < SYSFS_FILE_RETRIEVAL_SUCCESS) { rc = ESIF_E_INVALID_HANDLE; @@ -3308,6 +3290,10 @@ static eEsifError SetOsc(EsifUpPtr upPtr, const EsifDataPtr requestPtr) char cur_node_name[MAX_SYSFS_PATH] = { 0 }; char sysvalstring[MAX_SYSFS_PATH] = { 0 }; +#ifdef ESIF_ATTR_OS_ANDROID + // Notify JHS that DPTF is up + NotifyJhs(upPtr, requestPtr); +#endif // Check validity of _OSC request if (ESIF_DATA_STRUCTURE != requestPtr->type || sizeof(struct esif_data_complex_osc) != requestPtr->buf_len) { diff --git a/ESIF/Products/ESIF_UF/Sources/lin/esif_uf_ipc_os_lin.c b/ESIF/Products/ESIF_UF/Sources/lin/esif_uf_ipc_os_lin.c index 1a3a133b..d46890ff 100644 --- a/ESIF/Products/ESIF_UF/Sources/lin/esif_uf_ipc_os_lin.c +++ b/ESIF/Products/ESIF_UF/Sources/lin/esif_uf_ipc_os_lin.c @@ -58,11 +58,17 @@ enum esif_rc esif_os_ipc_execute( ipc_ptr); /* use IOCTL or read here */ +#ifdef ESIF_ATTR_OS_ANDROID + rc = read(handle, ipc_ptr, ipc_ptr->data_len + sizeof(struct esif_ipc)); + ESIF_TRACE_DEBUG("linux_%s: READ handle = %d, IPC = %p rc = %d\n", + __func__, handle, ipc_ptr, rc); +#else rc = ioctl(handle, ESIF_IOCTL_IPC, ipc_ptr); ESIF_TRACE_DEBUG("linux_%s: IOCTL handle = %d, IPC = %p rc = %d\n", __func__, handle, ipc_ptr, rc); if (rc) return ESIF_E_UNSPECIFIED; +#endif return ESIF_OK; } diff --git a/ESIF/Products/ESIF_UF/Sources/lin/esif_uf_sensor_manager_os_lin.c b/ESIF/Products/ESIF_UF/Sources/lin/esif_uf_sensor_manager_os_lin.c index c83992bb..6df9a01c 100644 --- a/ESIF/Products/ESIF_UF/Sources/lin/esif_uf_sensor_manager_os_lin.c +++ b/ESIF/Products/ESIF_UF/Sources/lin/esif_uf_sensor_manager_os_lin.c @@ -569,6 +569,9 @@ static void *EsifIio_Poll(void *ptr) UNREFERENCED_PARAMETER(ptr); +#ifdef ESIF_ATTR_OS_ANDROID + sigusr1_enable(); +#endif while(gEsifSensorMgrStarted) { // Update sensor values @@ -641,7 +644,13 @@ static void StopEsifSensorMgr() if (gEsifSensorMgrStarted) { ESIF_TRACE_DEBUG("Stopping ESIF Sensor Manager...\n"); gEsifSensorMgrStarted = ESIF_FALSE; +#ifdef ESIF_ATTR_OS_ANDROID + // Android NDK does not support pthread_cancel() + // Use pthread_kill() to emualte + pthread_kill(gEsifSensorMgrThread, SIGUSR1); +#else pthread_cancel(gEsifSensorMgrThread); +#endif esif_ccb_thread_join(&gEsifSensorMgrThread); EsifSensorMgr_DeregisterSensors(); } diff --git a/ESIF/Products/ESIF_UF/Sources/lin/esif_uf_sysfs_enumerate_os_lin.c b/ESIF/Products/ESIF_UF/Sources/lin/esif_uf_sysfs_enumerate_os_lin.c index 4507349d..42faec7a 100644 --- a/ESIF/Products/ESIF_UF/Sources/lin/esif_uf_sysfs_enumerate_os_lin.c +++ b/ESIF/Products/ESIF_UF/Sources/lin/esif_uf_sysfs_enumerate_os_lin.c @@ -51,9 +51,6 @@ #define NUM_CPU_LOCATIONS 3 #define SIZE_OF_UINT64 (sizeof(UInt64)) -#define INTEL_VENDOR_STRING "0x8086" -#define SYSFS_VENDOR_ATTRIBUTE "vendor" - static int g_zone_count = 0; const char *CPU_location[NUM_CPU_LOCATIONS] = {"0000:00:04.0", "0000:00:0b.0", "0000:00:00.1"}; static Bool gSocParticipantFound = ESIF_FALSE; @@ -215,7 +212,36 @@ void SysfsRegisterParticipants () // Special handling for Android OS that may have Java based participants // Possibly add two more Java participants - Display and WWAN - but only if they do not exist yet +#ifdef ESIF_ATTR_OS_ANDROID + if (!EsifUpPm_DoesAvailableParticipantExistByHID(SYSFS_DISP_HID)) { + newParticipantCreate(ESIF_PARTICIPANT_VERSION, + classGuid, + ESIF_PARTICIPANT_ENUM_SYSFS, + 0x0, + "TDSP", + ESIF_PARTICIPANT_PLAT_DESC, + "N/A", + SYSFS_DISP_HID, + "N/A", + "\\_SB_.TDSP", + ESIF_PARTICIPANT_INVALID_TYPE); + } + if (!EsifUpPm_DoesAvailableParticipantExistByHID(SYSFS_WWAN_HID)) { + newParticipantCreate(ESIF_PARTICIPANT_VERSION, + classGuid, + ESIF_PARTICIPANT_ENUM_SYSFS, + 0x0, + "WWAN", + ESIF_PARTICIPANT_PLAT_DESC, + "N/A", + SYSFS_WWAN_HID, + "N/A", + "\\_SB_.WWAN", + ESIF_DOMAIN_TYPE_WWAN); + } +#else UNREFERENCED_PARAMETER(classGuid); +#endif } static eEsifError newParticipantCreate ( @@ -272,28 +298,6 @@ static Int32 PciDeviceFilter(const struct dirent *entry) return 0; }; -static Bool IsIntelDevice(const char * pciDevicePath) -{ - Bool vendorIdFound = ESIF_FALSE; - char vendorIdStr[ESIF_SCOPE_LEN] = { 0 }; - ESIF_ASSERT(NULL != pciDevicePath); - - if (SysfsGetString(pciDevicePath,SYSFS_VENDOR_ATTRIBUTE, vendorIdStr, sizeof(vendorIdStr)) < 0) { - ESIF_TRACE_ERROR("No vendor info found for PCI Device\n"); - goto exit; - } - - if (esif_ccb_strcmp(vendorIdStr, INTEL_VENDOR_STRING) != 0) { - // Not found, exiting - goto exit; - } - - // Vendor ID Found - vendorIdFound = ESIF_TRUE; -exit: - return vendorIdFound; -} - static Int32 scanPCI(void) { Int32 returnCode = 0; @@ -321,7 +325,6 @@ static Int32 scanPCI(void) // We need to iterate this loop in ascending order so that 0/0/4 will be enumerated // before 0/0/b PCI Device for (UInt32 i = 0 ; i < n ; i++) { - // We should not break out of this loop and it can result in memory leaks // we need to continue inside the loop to free each namelist entries if ( gSocParticipantFound == ESIF_TRUE ) { @@ -330,12 +333,6 @@ static Int32 scanPCI(void) } esif_ccb_sprintf(MAX_SYSFS_PATH, participant_path, "%s/%s", SYSFS_PCI,namelist[i]->d_name); - // Skip if it is not an Intel Device - if (IsIntelDevice(participant_path) == ESIF_FALSE) { - esif_ccb_free(namelist[i]); - continue; - } - esif_ccb_sprintf(MAX_SYSFS_PATH, firmware_path, "%s/firmware_node", participant_path); if (SysfsGetString(firmware_path,"path", participant_scope, sizeof(participant_scope)) < 0) { @@ -425,10 +422,6 @@ static int scanPlat(void) if (SysfsGetString(firmware_path,"hid", hid, sizeof(hid)) < 1) { esif_ccb_strncpy(hid,SYSFS_DEFAULT_HID,HID_LEN); } - // Check if it is a DTT Platform Device, If not, skip that device - if ( IsSupportedDttPlatformDevice(hid) == ESIF_FALSE ) { - goto exit_participant; - } if (SysfsGetString(firmware_path,"path", participant_scope, sizeof(participant_scope)) > -1) { int scope_len = esif_ccb_strlen(participant_scope,ESIF_SCOPE_LEN); @@ -465,7 +458,11 @@ static int scanPlat(void) ptype); } // For devices with no mapping in thermal zone, - else { + // Check if it is an Intel Device and if it is in Available DTT Participant Device List + // then , create a new participant + else if ( esif_ccb_strstr(hid, "INTC") != 0 && + IsSupportedDttPlatformDevice(hid) == ESIF_TRUE ) { + newParticipantCreate(ESIF_PARTICIPANT_VERSION, classGuid, ESIF_PARTICIPANT_ENUM_SYSFS, @@ -618,6 +615,9 @@ static enum esif_rc get_participant_name_alias(const char *ACPI_name, char *ACPI { enum esif_rc rc = ESIF_OK; struct { const char *name; const char *alias; } participant_aliases[] = { +#ifdef ESIF_ATTR_OS_ANDROID + { "TCHG", "bq25890-charger" }, +#endif { NULL, NULL } }; int j = 0; diff --git a/ESIF/Products/ESIF_UF/Sources/lin/esif_uf_sysfs_os_lin.h b/ESIF/Products/ESIF_UF/Sources/lin/esif_uf_sysfs_os_lin.h index 081b962f..aa297792 100644 --- a/ESIF/Products/ESIF_UF/Sources/lin/esif_uf_sysfs_os_lin.h +++ b/ESIF/Products/ESIF_UF/Sources/lin/esif_uf_sysfs_os_lin.h @@ -85,7 +85,7 @@ int SysfsSetString(const char *path, const char *filename, char *val); int SysfsSetStringWithError(const char *path, const char *filename, char *buffer, unsigned int length); int SysfsGetInt64Direct(int fd, Int64 *p64); int SysfsSetInt64Direct(int fd, Int32 val); -int SysfsGetString(const char *path, const char *filename, char *str, size_t buf_len); +int SysfsGetString(char *path, char *filename, char *str, size_t buf_len); int SysfsGetStringMultiline(const char *path, const char *filename, char *str); int SysfsGetInt64(const char *path, const char *filename, Int64 *p64); int SysfsSetInt64(char *path, char *filename, Int64 val); diff --git a/ESIF/Products/ESIF_UF/Sources/lin/main.c b/ESIF/Products/ESIF_UF/Sources/lin/main.c index 72018f93..17047e4a 100644 --- a/ESIF/Products/ESIF_UF/Sources/lin/main.c +++ b/ESIF/Products/ESIF_UF/Sources/lin/main.c @@ -29,7 +29,6 @@ #include "esif_uf_sysfs_os_lin.h" #include "esif_uf_sensors.h" #include "esif_sdk_data_misc.h" -#include "esif_ccb_cpuid.h" #include #include @@ -43,7 +42,15 @@ #define COPYRIGHT_NOTICE "Copyright (c) 2013-2022 Intel Corporation All Rights Reserved" /* ESIF_UF Startup Script Defaults */ +#ifdef ESIF_ATTR_OS_ANDROID +#ifdef ESIF_FEAT_OPT_ACTION_IOC +#define ESIF_STARTUP_SCRIPT_DAEMON_MODE "conjure upe_ioc && appstart dptf" +#else +#define ESIF_STARTUP_SCRIPT_DAEMON_MODE "appstart dptf" +#endif +#else #define ESIF_STARTUP_SCRIPT_DAEMON_MODE "arbitrator disable && appstart dptf" +#endif #define ESIF_STARTUP_SCRIPT_SERVER_MODE NULL #define TOTAL_PSY_PROPERTIES 10 @@ -64,7 +71,6 @@ static char *g_udev_target = NULL; static esif_thread_t gSysfsReadThread; static Bool gSysfsReadQuit = ESIF_TRUE; -static Bool IsIntelCPU(); static Bool EsifSysfsReadIsStarted(); static void EsifSysfsReadStart(); static void EsifSysfsReadStop(); @@ -120,18 +126,31 @@ static char *g_psy_val[TOTAL_PSY_PROPERTIES]; # define ARCHBITS "64" #else #define ARCHNAME "x86" +# ifdef ESIF_ATTR_OS_ANDROID +# define ARCHBITS "" // Android Libs go in /system/vendor/lib64 or lib, not lib32 +# else # define ARCHBITS "32" +# endif #endif -#define CPUID_LEAF_0_EBX (0x756E6547) //'Genu' -#define CPUID_LEAF_0_EDX (0x49656E69) //'ineI' -#define CPUID_LEAF_0_ECX (0x6C65746E) //'ntel' - - // Default ESIF Paths for each OS // Paths preceded by "$" are treated as system paths and are not auto-created or checked for symbolic links static const esif_string ESIF_PATHLIST = -#if defined(ESIF_ATTR_OS_CHROME) +#if defined(ESIF_ATTR_OS_ANDROID) + // Android + "HOME=/data/vendor/dptf/log\n" + "TEMP=/data/vendor/dptf/tmp\n" + "DV=/vendor/etc/dptf/dv\n" + "LOG=/data/vendor/dptf/log\n" + "BIN=/vendor/etc/dptf/bin\n" + "LOCK=/data/vendor/dptf/lock\n" + "EXE=$/vendor/bin\n" + "DLL=$/vendor/lib" ARCHBITS "\n" + "DLLALT=$#/vendor/lib" ARCHBITS "\n" + "DSP=/vendor/etc/dptf/dsp\n" + "CMD=/vendor/etc/dptf/cmd\n" + "DATA=/vendor/etc/dptf/ui\n" +#elif defined(ESIF_ATTR_OS_CHROME) // Chromium "HOME=/var/log/dptf\n" "TEMP=$/tmp\n" @@ -701,7 +720,11 @@ static void release_timer_thread_pool(void) * to terminate the g_sigrtmin_thread_pool now. */ for (i = 0; i < g_nproc; ++i) { +#ifdef ESIF_ATTR_OS_ANDROID + pthread_kill(g_sigrtmin_thread_pool[i], SIGRTMIN); +#else pthread_cancel(g_sigrtmin_thread_pool[i]); +#endif } for (i = 0; i < g_nproc; ++i) { pthread_join(g_sigrtmin_thread_pool[i], NULL); @@ -710,7 +733,7 @@ static void release_timer_thread_pool(void) } } -int SysfsGetString(const char *path, const char *filename, char *str, size_t buf_len) +int SysfsGetString(char *path, char *filename, char *str, size_t buf_len) { FILE *fd = NULL; int ret = -1; @@ -1124,7 +1147,13 @@ esif_error_t CreateActionAssociatedParticipants(esif_action_type_t actionType) static void esif_udev_exit() { g_udev_quit = ESIF_TRUE; +#ifdef ESIF_ATTR_OS_ANDROID + // Android NDK does not support pthread_cancel() + // Use pthread_kill() to emualte + pthread_kill(g_udev_thread, SIGUSR1); +#else pthread_cancel(g_udev_thread); +#endif esif_ccb_thread_join(&g_udev_thread); esif_ccb_free(g_udev_target); } @@ -1133,7 +1162,13 @@ static void EsifSysfsReadExit() { gSysfsReadQuit = ESIF_TRUE; +#ifdef ESIF_ATTR_OS_ANDROID + // Android NDK does not support pthread_cancel() + // Use pthread_kill() to emualte + pthread_kill(g_udev_thread, SIGUSR1); +#else pthread_cancel(gSysfsReadThread); +#endif esif_ccb_thread_join(&gSysfsReadThread); } @@ -1303,6 +1338,9 @@ static void *EsifSysfsReadListen(void *ptr) static void *esif_udev_listen(void *ptr) { UNREFERENCED_PARAMETER(ptr); +#ifdef ESIF_ATTR_OS_ANDROID + sigusr1_enable(); +#endif sock_fd = socket(PF_NETLINK, SOCK_RAW, NETLINK_KOBJECT_UEVENT); if (sock_fd < 0) { goto exit; @@ -1479,6 +1517,9 @@ void* dbus_listen() { DBusError err = {0}; +#ifdef ESIF_ATTR_OS_ANDROID + sigusr1_enable(); +#endif dbus_error_init(&err); g_dbus_conn = dbus_bus_get(DBUS_BUS_SYSTEM, &err); @@ -1819,11 +1860,6 @@ int main (int argc, char **argv) int start_as_server = ESIF_TRUE; #endif - if(IsIntelCPU() == ESIF_FALSE) { - CMD_DEBUG("Not Supported\n"); - exit(EXIT_FAILURE); - } - // Init ESIF esif_main_init(ESIF_PATHLIST); esif_ccb_sem_init(&g_sigquit); @@ -2015,7 +2051,13 @@ int main (int argc, char **argv) #ifdef ESIF_FEAT_OPT_DBUS CMD_DEBUG("Stopping D-Bus listener thread...\n"); +#ifdef ESIF_ATTR_OS_ANDROID + // Android NDK does not support pthread_cancel() + // Use pthread_kill() to emualte + pthread_kill(g_dbus_thread, SIGUSR1); +#else pthread_cancel(g_dbus_thread); +#endif esif_ccb_thread_join(&g_dbus_thread); if (g_dbus_conn) dbus_connection_unref(g_dbus_conn); @@ -2043,34 +2085,6 @@ eEsifError esif_uf_os_init () return ESIF_OK; } -static Bool IsIntelCPU() -{ - Bool intelCPUDetected = ESIF_FALSE; - esif_ccb_cpuid_t cpuInfo = { 0 }; - - cpuInfo.leaf = 0; - esif_ccb_cpuid(&cpuInfo); - // - // Check for CPUID support and verify its an Intel processor - // - if (cpuInfo.eax < 1) { - CMD_DEBUG("CPUID not supported\n"); - goto exit; - } - // - // Check for "GenuineIntel" - // - if (cpuInfo.ebx != CPUID_LEAF_0_EBX || - cpuInfo.ecx != CPUID_LEAF_0_ECX || - cpuInfo.edx != CPUID_LEAF_0_EDX) { - CMD_DEBUG("Not a genuine Intel processor\n"); - goto exit; - } - - intelCPUDetected = ESIF_TRUE; -exit: - return intelCPUDetected; -} void esif_uf_os_exit () { diff --git a/ESIF/Products/ESIF_WS/Linux/Makefile b/ESIF/Products/ESIF_WS/Linux/Makefile index 8e4b18b5..906f2f86 100644 --- a/ESIF/Products/ESIF_WS/Linux/Makefile +++ b/ESIF/Products/ESIF_WS/Linux/Makefile @@ -49,8 +49,6 @@ endif CFLAGS += -fno-strict-overflow CFLAGS += -fno-delete-null-pointer-checks CFLAGS += -fwrapv -#Compile with -g by default and strip it at the end -CFLAGS += -g # Linker Flags added for security purposes LDFLAGS += -z noexecstack @@ -87,9 +85,14 @@ else endif endif +ifneq ($(OS), Chrome) # make BUILD=Debug +# -s flag added for stripping the binaries ifeq ($(BUILD), Debug) - CPPFLAGS += -DESIF_ATTR_DEBUG + CFLAGS += -g +else + CFLAGS += -s +endif endif $(info ++++ ) @@ -118,15 +121,9 @@ OBJ += $(ESIF_LIB_SOURCES)/esif_lib_istring.o $(CC) -c $(CFLAGS) $(EXTRA_CFLAGS) $(CPPFLAGS) -o $@ $< all: esif_ws -ifeq ($(OS), Linux) - ifeq ($(BUILD), Release) - cp esif_ws.so esif_ws.so.debug - strip --strip-unneeded esif_ws.so - objcopy --add-gnu-debuglink=esif_ws.so.debug esif_ws.so - endif -endif + esif_ws: $(OBJ) $(CC) $(CFLAGS) -shared $(EXTRA_CFLAGS) $(LDFLAGS) -o $@.so $^ $(LDLIBS) clean: - rm -f $(OBJ) *.so *.debug + rm -f $(OBJ) *.so diff --git a/ESIF/Products/ESIF_WS/Sources/esif_ws.c b/ESIF/Products/ESIF_WS/Sources/esif_ws.c index dd1855bd..f93bb8c0 100644 --- a/ESIF/Products/ESIF_WS/Sources/esif_ws.c +++ b/ESIF/Products/ESIF_WS/Sources/esif_ws.c @@ -28,6 +28,18 @@ #include "esif_sdk_event_guid.h" #include "esif_lib_istring.h" +#ifdef ESIF_ATTR_OS_WINDOWS +#define _SDL_BANNED_RECOMMENDED +#include "win\banned.h" + +BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) +{ + UNREFERENCED_PARAMETER(hModule); + UNREFERENCED_PARAMETER(ul_reason_for_call); + UNREFERENCED_PARAMETER(lpReserved); + return TRUE; +} +#endif ////////////////////////////////////////////////////////////////////////////// // ESIF/App Inferface Variables @@ -465,10 +477,19 @@ static esif_error_t ESIF_CALLCONV EsifWs_AppCreate( if (rc == ESIF_OK) { if (!self->config.docRoot[0]) { // Use OS-Specific UI Document Root Path instead of fPathHome when running In-Process - #if defined(ESIF_ATTR_OS_CHROME) + #if defined(ESIF_ATTR_OS_ANDROID) + esif_ccb_strcpy(self->config.docRoot, "/vendor/etc/dptf/ui", sizeof(self->config.docRoot)); + #elif defined(ESIF_ATTR_OS_CHROME) esif_ccb_strcpy(self->config.docRoot, "/usr/share/dptf/ui", sizeof(self->config.docRoot)); - #else + #elif defined(ESIF_ATTR_OS_LINUX) esif_ccb_strcpy(self->config.docRoot, "/usr/share/dptf/ui", sizeof(self->config.docRoot)); + #elif defined(ESIF_ATTR_OS_WINDOWS) + esif_ccb_strcpy(self->config.docRoot, appDataPtr->fPathHome.buf_ptr, sizeof(self->config.docRoot)); + char *sep = esif_ccb_strrchr(self->config.docRoot, *ESIF_PATH_SEP); + if (sep) { + sep[1] = 0; + esif_ccb_strcat(self->config.docRoot, "ui", sizeof(self->config.docRoot)); + } #endif } @@ -492,6 +513,15 @@ static esif_error_t ESIF_CALLCONV EsifWs_AppCreate( if (rc == ESIF_OK) { WebServerPtr server = g_WebServer; +#ifdef ESIF_ATTR_OS_WINDOWS + // Enable Remote Connections in Win10X by default + char sysdir[MAX_PATH] = {0}; + if (GetSystemDirectoryA(sysdir, sizeof(sysdir))) { + if (esif_ccb_strnicmp(sysdir, "C:", 2) != 0 && (esif_ccb_strcmp(self->config.ipAddr, WS_DEFAULT_IPADDR) == 0 || self->config.ipAddr[0] == 0)) { + esif_ccb_strcpy(self->config.ipAddr, WS_REMOTE_IPADDR, sizeof(self->config.ipAddr)); + } + } +#endif // If in-process using legacy appname, lookup and use last known URL. Do Not Fail AppCreate on Error if (!self->config.isClient && esif_ccb_stricmp(self->config.appName, WS_APP_LEGACYNAME) == 0 && self->ifaceSet.esifIface.fSendCommandFuncPtr) { diff --git a/ESIF/Products/ESIF_WS/Sources/esif_ws_http.c b/ESIF/Products/ESIF_WS/Sources/esif_ws_http.c index cd67a8e4..41e5acf9 100644 --- a/ESIF/Products/ESIF_WS/Sources/esif_ws_http.c +++ b/ESIF/Products/ESIF_WS/Sources/esif_ws_http.c @@ -29,6 +29,10 @@ #include "esif_ws_http.h" #include "esif_ws_version.h" +#ifdef ESIF_ATTR_OS_WINDOWS +#define _SDL_BANNED_RECOMMENDED +#include "win\banned.h" +#endif #include "esif_sdk_sha.c" // Compile SHA code into this module diff --git a/ESIF/Products/ESIF_WS/Sources/esif_ws_server.c b/ESIF/Products/ESIF_WS/Sources/esif_ws_server.c index 20d3c0b2..b7aa6e79 100644 --- a/ESIF/Products/ESIF_WS/Sources/esif_ws_server.c +++ b/ESIF/Products/ESIF_WS/Sources/esif_ws_server.c @@ -28,6 +28,10 @@ #include "esif_ws_http.h" #include "esif_ws_socket.h" +#ifdef ESIF_ATTR_OS_WINDOWS +#define _SDL_BANNED_RECOMMENDED +#include "win\banned.h" +#endif // Use Non-Blocking Socket I/O #ifdef MSG_NOSIGNAL diff --git a/ESIF/Products/ESIF_WS/Sources/esif_ws_socket.c b/ESIF/Products/ESIF_WS/Sources/esif_ws_socket.c index e0a72eb4..f7feb367 100644 --- a/ESIF/Products/ESIF_WS/Sources/esif_ws_socket.c +++ b/ESIF/Products/ESIF_WS/Sources/esif_ws_socket.c @@ -22,6 +22,10 @@ #include "esif_ws_server.h" #include "esif_ws_socket.h" +#ifdef ESIF_ATTR_OS_WINDOWS +#define _SDL_BANNED_RECOMMENDED +#include "win\banned.h" +#endif // WebSocket Frame Header consists of: // 1. UInt16 header bits diff --git a/ESIF/Products/UPE_JAVA/Sources/cnjr_jhs_iface.cpp b/ESIF/Products/UPE_JAVA/Sources/cnjr_jhs_iface.cpp index 97a6531e..aaea086c 100644 --- a/ESIF/Products/UPE_JAVA/Sources/cnjr_jhs_iface.cpp +++ b/ESIF/Products/UPE_JAVA/Sources/cnjr_jhs_iface.cpp @@ -26,9 +26,22 @@ #include "esif_ccb_thread.h" #include "conjure.h" +#ifdef ESIF_ATTR_OS_ANDROID +#include "jhs_binder_service.h" +#include +using namespace jhs; +#endif using namespace std; +#ifdef ESIF_ATTR_OS_WINDOWS +// +// The Windows banned-API check header must be included after all other headers, or issues can be identified +// against Windows SDK/DDK included headers which we have no control over. +// +#define _SDL_BANNED_RECOMMENDED +#include "..\ESIF\Products\ESIF_CM\Sources\win\banned.h" +#endif // Application Description #define CONJURE_LIB_NAME "Conjure1" @@ -43,7 +56,16 @@ using namespace std; // Debug #define IFACE_TAG "esif_uf_cnj_iface -->" +#ifdef ESIF_ATTR_OS_ANDROID + #define TRACE_LEVEL_ERROR ANDROID_LOG_ERROR + #define TRACE_LEVEL_INFORMATION ANDROID_LOG_INFO + #define TRACE_LEVEL_VERBOSE ANDROID_LOG_DEBUG + #define DBG_ESIF_ACT_APP "UPE_JAVA" + #define DBG_ESIF_CNJ_LIB "UPE_JAVA" + #define ESIF_TRACE(level, type, format, ...) __android_log_print(level, type, format, ##__VA_ARGS__) +#else #define ESIF_TRACE(level, type, format, ...) +#endif static void* cjrClientService(void *ptr); @@ -120,6 +142,18 @@ static eEsifError ConjureCreate ( } static void* cjrClientService(void *ptr) { +#ifdef ESIF_ATTR_OS_ANDROID + UNREFERENCED_PARAMETER(ptr); + + sigusr1_enable(); + + sp sm = defaultServiceManager(); + ESIF_ASSERT(sm != NULL); + sm->addService(String16(JHS_CLIENT_SERVICE_NAME), new JhsClientService()); + ProcessState::self()->startThreadPool(); + ESIF_TRACE(TRACE_LEVEL_INFORMATION, DBG_ESIF_ACT_APP, "JHS client service started..."); + IPCThreadState::self()->joinThreadPool(); +#endif return NULL; } diff --git a/ESIF/Products/UPE_JAVA/Sources/upe_iface.cpp b/ESIF/Products/UPE_JAVA/Sources/upe_iface.cpp index 1fb8cba9..51c09f14 100644 --- a/ESIF/Products/UPE_JAVA/Sources/upe_iface.cpp +++ b/ESIF/Products/UPE_JAVA/Sources/upe_iface.cpp @@ -33,6 +33,18 @@ #include "esif_ccb_memory.h" #include "jhs_binder_service.h" +#ifdef ESIF_ATTR_OS_WINDOWS +/* + * TODO: The banned.h file is not included as part of the SDK sample code. + * If desired, include the file in Windows builds. The file is available from + * Microsoft at https://www.microsoft.com/en-us/download/details.aspx?id=24817 + * The Windows banned-API check header must be included after all other headers, + * or issues can be identified against Windows SDK/DDK included headers which + * we have no control over. The header is not provided with the SDK code. + */ +#define _SDL_BANNED_RECOMMENDED +/* #include "banned.h" */ +#endif using namespace jhs; diff --git a/ESIF/Products/UPE_JAVA/Sources/upe_trace.cpp b/ESIF/Products/UPE_JAVA/Sources/upe_trace.cpp index d04fd3c0..f39ef0db 100644 --- a/ESIF/Products/UPE_JAVA/Sources/upe_trace.cpp +++ b/ESIF/Products/UPE_JAVA/Sources/upe_trace.cpp @@ -34,6 +34,18 @@ #include "esif_ccb_string.h" #include "esif_ccb_file.h" +#ifdef ESIF_ATTR_OS_WINDOWS +/* + * TODO: The banned.h file is not included as part of the SDK sample code. + * If desired, include the file in Windows builds. The file is available from + * Microsoft at https://www.microsoft.com/en-us/download/details.aspx?id=24817 + * The Windows banned-API check header must be included after all other headers, + * or issues can be identified against Windows SDK/DDK included headers which + * we have no control over. The header is not provided with the SDK code, + */ +#define _SDL_BANNED_RECOMMENDED +/* #include "banned.h" */ +#endif extern "C" {