4#ifndef RESOURCE_REGISTRY_H
5#define RESOURCE_REGISTRY_H
10#include <unordered_map>
16#include "ResourceTunerSettings.h"
17#include "AuxRoutines.h"
104 static std::shared_ptr<ResourceRegistry> resourceRegistryInstance;
105 int32_t mTotalResources;
107 std::vector<ResourceConfigInfo*> mResourceConfig;
108 std::unordered_map<uint32_t, int32_t> mSystemIndependentLayerMappings;
109 std::unordered_map<std::string, std::string> mDefaultValueStore;
128 std::vector<ResourceConfigInfo*> getRegisteredResources();
139 int32_t getResourceTableIndex(uint32_t resourceId);
140 int32_t getTotalResourcesCount();
141 std::string getDefaultValue(
const std::string& fileName);
143 void addDefaultValue(
const std::string& key,
const std::string& value);
144 void restoreResourcesToDefaultValues();
145 void displayResources();
148 void pluginModifications();
150 static std::shared_ptr<ResourceRegistry> getInstance() {
151 if(resourceRegistryInstance ==
nullptr) {
152 resourceRegistryInstance = std::shared_ptr<ResourceRegistry>(
new ResourceRegistry());
154 return resourceRegistryInstance;
158class ResourceConfigInfoBuilder {
163 ResourceConfigInfoBuilder();
164 ~ResourceConfigInfoBuilder();
166 ErrCode setName(
const std::string& resourceName);
167 ErrCode setPath(
const std::string& resourcePath);
168 ErrCode setResType(
const std::string& resTypeString);
169 ErrCode setResID(
const std::string& resIDString);
170 ErrCode setHighThreshold(
const std::string& highThreshold);
171 ErrCode setLowThreshold(
const std::string& lowThreshold);
172 ErrCode setPermissions(
const std::string& permissionString);
173 ErrCode setModes(
const std::string& modeString);
174 ErrCode setSupported(
const std::string& supported);
175 ErrCode setPolicy(
const std::string& policyString);
176 ErrCode setApplyType(
const std::string& applyTypeString);
181void defaultClusterLevelApplierCb(
void* context);
182void defaultClusterLevelTearCb(
void* context);
183void defaultCoreLevelApplierCb(
void* context);
184void defaultCoreLevelTearCb(
void* context);
185void defaultCGroupLevelApplierCb(
void* context);
186void defaultCGroupLevelTearCb(
void* context);
187void defaultGlobalLevelApplierCb(
void* context);
188void defaultGlobalLevelTearCb(
void* context);
ErrCode
Custom Error Codes used by Resource Tuner APIs and Internal Functions.
Permissions
Certain resources can be accessed only by system clients and some which have no such restrictions and...
Policy
Different Resource Policies supported by Resource Tuner.
ResourceConfigInfo * getResourceById(uint32_t resourceId)
Get the ResourceConfigInfo object corresponding to the given Resource ID.
void registerResource(ResourceConfigInfo *resourceConfigInfo, int8_t isBuSpecified=false)
Used to register a Config specified (through YAML) Resource with Resource Tuner.
Application type or level for a Resource.
Representation of a single Resource Configuration.
ResourceLifecycleCallback mResourceTearCallback
Optional Custom Resource Tear Callback, it needs to be supplied by the BU via the Extension Interface...
enum Permissions mPermissions
The Permission Level needed by a client in order to tune this Resource.
enum ResourceApplyType mApplyType
Application Type Enum, indicating whether the specified value for the Resource by a Request,...
int32_t mLowThreshold
Min Possible Value which can be configured for this Resource.
uint16_t mResourceResID
Unique Resource ID associated with the resource.
uint8_t mResourceResType
Type of the Resource, for example: LPM, CPU_DCVS, GPU etc.
ResourceLifecycleCallback mResourceApplierCallback
Optional Custom Resource Applier Callback, it needs to be supplied by the BU via the Extension Interf...
uint8_t mModes
Specify the mode (ex: Display on, display off, doze) under which the Resource can be provisioned.
std::string mResourceName
Name of the Resource (Placeholder).
int8_t mSupported
boolean flag which is set if node is available for Tuning.
int32_t mHighThreshold
Max Possible Value which can be configured for this Resource.
enum Policy mPolicy
Policy by which the resource is governed, for example Higher is Better.
std::string mResourcePath
Path to the Sysfs node, CGroup controller file or as applicable.