Resource Tuner
Loading...
Searching...
No Matches
Common.h
1// Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
2// SPDX-License-Identifier: BSD-3-Clause-Clear
3
4#ifndef COMMON_UTILS_H
5#define COMMON_UTILS_H
6
7#ifdef __cplusplus
8#include <cstdint>
9#else
10#include <stdint.h>
11#endif
12
18typedef struct {
25 uint32_t mResCode;
31 int32_t mResInfo;
32 int32_t mOptionalInfo;
37 int32_t mNumValues;
38
39 union {
40 int32_t value;
41 int32_t* values;
42 } mResValue;
44
49enum RequestPriority {
50 REQ_PRIORITY_HIGH = 0,
51 REQ_PRIORITY_LOW,
52 NUMBER_OF_RQUEST_PRIORITIES
53};
54
62enum Modes {
63 MODE_RESUME = 0x01,
64 MODE_SUSPEND = 0x02,
65 MODE_DOZE = 0x04
66};
67
68#define SET_REQUEST_PRIORITY(properties, priority)({ \
69 int32_t retVal; \
70 if(properties < 0 || priority < 0 || priority >= NUMBER_OF_RQUEST_PRIORITIES) { \
71 retVal = -1; \
72 } else { \
73 retVal = (int32_t) ((properties | priority)); \
74 } \
75 retVal; \
76}) \
77
78#define ADD_ALLOWED_MODE(properties, mode)({ \
79 int32_t retVal; \
80 if(properties < 0 || mode < MODE_RESUME || mode > MODE_DOZE) { \
81 retVal = -1; \
82 } else { \
83 retVal = (int32_t) (properties | (((properties >> 8) | mode) << 8)); \
84 } \
85 retVal; \
86}) \
87
88#define EXTRACT_REQUEST_PRIORITY(properties)({ \
89 (int8_t) ((properties) & ((1 << 8) - 1)); \
90})
91
92#define EXTRACT_ALLOWED_MODES(properties)({ \
93 (int8_t) ((properties >> 8) & ((1 << 8) - 1)); \
94}) \
95
96// Define Utilities to parse and set the mResInfo field in Resource struct.
97#define EXTRACT_RESOURCE_CORE_VALUE(resInfo)({ \
98 (int8_t) ((resInfo) & ((1 << 8) - 1)); \
99}) \
100
101#define EXTRACT_RESOURCE_CLUSTER_VALUE(resInfo)({ \
102 (int8_t) ((resInfo >> 8) & ((1 << 8) - 1)); \
103}) \
104
105#define EXTRACT_RESOURCE_MPAM_VALUE(resInfo)({ \
106 (int8_t) ((resInfo >> 16) & ((1 << 8) - 1)); \
107}) \
108
109#define SET_RESOURCE_CORE_VALUE(resInfo, newValue)({ \
110 (int32_t) ((resInfo ^ EXTRACT_RESOURCE_CORE_VALUE(resInfo)) | newValue); \
111}) \
112
113#define SET_RESOURCE_CLUSTER_VALUE(resInfo, newValue)({ \
114 (int32_t) ((resInfo ^ (EXTRACT_RESOURCE_CLUSTER_VALUE(resInfo) << 8)) | (newValue << 8)); \
115}) \
116
117#define SET_RESOURCE_MPAM_VALUE(resInfo, newValue)({ \
118 (int32_t) ((resInfo ^ (EXTRACT_RESOURCE_MPAM_VALUE(resInfo) << 16)) | (newValue << 16)); \
119}) \
120
121#endif
Used to store information regarding Resources / Tunables which need to be Provisioned as part of the ...
Definition Common.h:18
int32_t value
Use this field for single Valued Resources.
Definition Common.h:40
uint32_t mResCode
A uniqued 32-bit (unsigned) identifier for the Resource.
Definition Common.h:25
int32_t mNumValues
Number of values to be configured for the Resource, both single-valued and multi-valued Resources are...
Definition Common.h:37
int32_t mResInfo
Holds Logical Core and Cluster Information:
Definition Common.h:31
int32_t mOptionalInfo
Field to hold optional information for Request Processing.
Definition Common.h:32
int32_t * values
Use this field for Multi Valued Resources.
Definition Common.h:41