4#ifndef RESOURCE_REGISTRY_H
5#define RESOURCE_REGISTRY_H
9#include <unordered_map>
15#include "UrmSettings.h"
16#include "AuxRoutines.h"
17#include "Extensions.h"
102 static std::shared_ptr<ResourceRegistry> resourceRegistryInstance;
103 int32_t mTotalResources;
105 std::vector<ResConfInfo*> mResourceConfigs;
106 std::unordered_map<uint32_t, int32_t> mSystemIndependentLayerMappings;
107 std::unordered_map<std::string, std::string> mDefaultValueStore;
111 int8_t isResourceConfigMalformed(
ResConfInfo* resourceConfigInfo);
112 void setLifeCycleCallbacks(
ResConfInfo* resourceConfigInfo);
113 void fetchAndStoreDefaults(
ResConfInfo* resourceConfigInfo);
126 std::vector<ResConfInfo*> getRegisteredResources();
137 int32_t getResourceTableIndex(uint32_t resourceId);
138 int32_t getTotalResourcesCount();
139 std::string getDefaultValue(
const std::string& fileName);
141 void addDefaultValue(
const std::string& key,
const std::string& value);
142 void restoreResourcesToDefaultValues();
143 void displayResources();
146 void pluginModifications();
148 static std::shared_ptr<ResourceRegistry> getInstance() {
149 if(resourceRegistryInstance ==
nullptr) {
150 resourceRegistryInstance = std::shared_ptr<ResourceRegistry>(
new ResourceRegistry());
152 return resourceRegistryInstance;
156class ResourceConfigInfoBuilder {
161 int32_t mTargetRefCount;
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 setTranslationUnit(
const std::string& unitString);
177 ErrCode setApplyType(
const std::string& applyTypeString);
178 ErrCode addTargetEnabled(
const std::string& target);
179 ErrCode addTargetDisabled(
const std::string& target);
184void defaultClusterLevelApplierCb(
void* context);
185void defaultClusterLevelTearCb(
void* context);
186void defaultCoreLevelApplierCb(
void* context);
187void defaultCoreLevelTearCb(
void* context);
188void defaultCGroupLevelApplierCb(
void* context);
189void defaultCGroupLevelTearCb(
void* context);
190void defaultGlobalLevelApplierCb(
void* context);
191void 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.
void registerResource(ResConfInfo *resourceConfigInfo, int8_t isBuSpecified=false)
Used to register a Config specified (through YAML) Resource with Resource Tuner.
ResConfInfo * getResConf(uint32_t resourceId)
Get the ResConfInfo object corresponding to the given Resource ID.
Representation of a single Resource Configuration.
int32_t mHighThreshold
Max Possible Value which can be configured for this 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...
ResourceLifecycleCallback mResourceTearCallback
Optional Custom Resource Tear Callback, it needs to be supplied by the BU via the Extension Interface...
enum Policy mPolicy
Policy by which the resource is governed, for example Higher is Better.
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,...
std::string mResourceName
Name of the Resource (Placeholder).
uint8_t mModes
Specify the mode (ex: Display on, display off, doze) under which the Resource can be provisioned.
enum TranslationUnit mUnit
Translation Unit for the Resource, for example KB, MB, MHz etc.
int32_t mLowThreshold
Min Possible Value which can be configured for this Resource.
uint16_t mResourceResID
Unique Resource ID associated with the resource.
std::string mResourcePath
Path to the Sysfs node, CGroup controller file or as applicable.
Application type or level for a Resource.