blob: ef2bd9025ebbe3059118a4ec93cd66bf40e4f74f [file] [log] [blame]
Patrick Benavoli68a91282011-08-31 11:23:23 +02001/* <auto_header>
2 * <FILENAME>
3 *
4 * INTEL CONFIDENTIAL
5 * Copyright © 2011 Intel
6 * Corporation All Rights Reserved.
7 *
8 * The source code contained or described herein and all documents related to
9 * the source code ("Material") are owned by Intel Corporation or its suppliers
10 * or licensors. Title to the Material remains with Intel Corporation or its
11 * suppliers and licensors. The Material contains trade secrets and proprietary
12 * and confidential information of Intel or its suppliers and licensors. The
13 * Material is protected by worldwide copyright and trade secret laws and
14 * treaty provisions. No part of the Material may be used, copied, reproduced,
15 * modified, published, uploaded, posted, transmitted, distributed, or
16 * disclosed in any way without Intel’s prior express written permission.
17 *
18 * No license under any patent, copyright, trade secret or other intellectual
19 * property right is granted to or conferred upon you by disclosure or delivery
20 * of the Materials, either expressly, by implication, inducement, estoppel or
21 * otherwise. Any license under such intellectual property rights must be
22 * express and approved by Intel in writing.
23 *
24 * AUTHOR: Patrick Benavoli (patrickx.benavoli@intel.com)
25 * CREATED: 2011-06-01
26 * UPDATED: 2011-07-27
27 *
28 *
29 * </auto_header>
30 */
31#pragma once
32
33#include <pthread.h>
Patrick Benavoli63499d42011-10-24 18:50:03 +020034#include "RemoteCommandHandlerTemplate.h"
Patrick Benavoli68a91282011-08-31 11:23:23 +020035#include "PathNavigator.h"
36#include "SelectionCriterionType.h"
37#include "SelectionCriterion.h"
38#include "Element.h"
Patrick Benavoli68a91282011-08-31 11:23:23 +020039#include <map>
40#include <vector>
41
Patrick Benavoli592ae562011-09-05 16:53:58 +020042
Patrick Benavoli68a91282011-08-31 11:23:23 +020043class CElementLibrarySet;
44class CSubsystemLibrary;
45class CSystemClass;
46class CSelectionCriteria;
47class CParameterFrameworkConfiguration;
48class CSystemClassConfiguration;
49class CParameterBlackboard;
50class CConfigurableDomains;
51class IRemoteProcessorServerInterface;
52class CBackSynchronizer;
53
Patrick Benavoli63499d42011-10-24 18:50:03 +020054class CParameterMgr : private CElement
Patrick Benavoli68a91282011-08-31 11:23:23 +020055{
56 enum ChildElement {
57 EFrameworkConfiguration,
58 ESelectionCriteria,
59 ESystemClass,
60 EConfigurableDomains
61 };
62 enum ElementLibrary {
63 EFrameworkConfigurationLibrary,
64 EParameterCreationLibrary,
65 EParameterConfigurationLibrary
66 };
Patrick Benavoli63499d42011-10-24 18:50:03 +020067 typedef TRemoteCommandHandlerTemplate<CParameterMgr> CCommandHandler;
Patrick Benavoli68a91282011-08-31 11:23:23 +020068
69 // Remote command parsers
Patrick Benavoli63499d42011-10-24 18:50:03 +020070 typedef CCommandHandler::CommandStatus (CParameterMgr::*RemoteCommandParser)(const IRemoteCommand& remoteCommand, string& strResult);
Patrick Benavoli68a91282011-08-31 11:23:23 +020071
72 // Parser descriptions
73 struct SRemoteCommandParserItem
74 {
75 const char* _pcCommandName;
76 CParameterMgr::RemoteCommandParser _pfnParser;
77 uint32_t _uiMinArgumentCount;
78 const char* _pcHelp;
79 const char* _pcDescription;
Patrick Benavoli68a91282011-08-31 11:23:23 +020080 };
Patrick Benavoli592ae562011-09-05 16:53:58 +020081 // Version
Patrick Benavoli63499d42011-10-24 18:50:03 +020082 static const uint32_t guiEditionMajor = 0x1;
83 static const uint32_t guiEditionMinor = 0x0;
84 static const uint32_t guiRevision = 0x0;
Patrick Benavoli68a91282011-08-31 11:23:23 +020085public:
86 // Logger interface
87 class ILogger
88 {
89 public:
90 virtual void log(const std::string& strLog) = 0;
91 };
92
93 // Construction
94 CParameterMgr(const string& strParameterFrameworkConfigurationFolderPath, const string& strSystemClassName);
95 virtual ~CParameterMgr();
96
97 // Logging
98 void setLogger(ILogger* pLogger);
99
100 // Init
101 bool load(string& strError);
102 virtual bool init(string& strError);
103
104 // Selection Criteria
105 CSelectionCriterionType* createSelectionCriterionType(bool bIsInclusive);
106 CSelectionCriterion* createSelectionCriterion(const string& strName, const CSelectionCriterionType* pSelectionCriterionType);
Patrick Benavolib71ccf72011-09-13 14:15:52 +0200107 // Selection criterion retrieval
108 CSelectionCriterion* getSelectionCriterion(const string& strName);
109
110 // Configuration application
111 bool applyConfigurations(string& strError);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200112
113 //////////// Tuning /////////////
114 // Tuning mode
115 bool setTuningMode(bool bOn, string& strError);
116 bool tuningModeOn() const;
117
118 // Current value space for user set/get value interpretation
119 void setValueSpace(bool bIsRaw);
120 bool valueSpaceIsRaw();
121
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200122 // Current Output Raw Format for user get value interpretation
123 void setOutputRawFormat(bool bIsHex);
124 bool outputRawFormatIsHex();
125
Patrick Benavoli68a91282011-08-31 11:23:23 +0200126 // Automatic hardware synchronization control (during tuning session)
127 bool setAutoSync(bool bAutoSyncOn, string& strError);
128 bool autoSyncOn() const;
129 bool sync(string& strError);
130
131 // User set/get parameters
132 bool setValue(const string& strPath, const string& strValue, string& strError);
133 bool getValue(const string& strPath, string& strValue, string& strError) const;
134
135 ////////// Configuration/Domains handling //////////////
136 // Creation/Deletion
137 bool createDomain(const string& strName, string& strError);
138 bool deleteDomain(const string& strName, string& strError);
139 bool createConfiguration(const string& strDomain, const string& strConfiguration, string& strError);
140 bool deleteConfiguration(const string& strDomain, const string& strConfiguration, string& strError);
141
142 // Save/Restore
143 bool restoreConfiguration(const string& strDomain, const string& strConfiguration, string& strError);
144 bool saveConfiguration(const string& strDomain, const string& strConfiguration, string& strError);
145
146 // Configurable element - domain association
147 bool addConfigurableElementToDomain(const string& strDomain, const string& strConfigurableElementPath, string& strError);
148 bool removeConfigurableElementFromDomain(const string& strDomain, const string& strConfigurableElementPath, string& strError);
149 bool split(const string& strDomain, const string& strConfigurableElementPath, string& strError);
150
151 // XML Import/Export
152 bool importDomainsXml(const string& strFileName, bool bWithSettings, string& strError);
153 bool exportDomainsXml(const string& strFileName, bool bWithSettings, string& strError) const;
154
155 // Binary Import/Export
156 bool importDomainsBinary(const string& strFileName, string& strError);
157 bool exportDomainsBinary(const string& strFileName, string& strError);
158
159 // Introspect
160 void logStructureContent(string& strContent) const;
161
162 // CElement
163 virtual string getKind() const;
164private:
165 // Logging (done by root)
166 virtual void doLog(const string& strLog) const;
167 virtual void nestLog() const;
168 virtual void unnestLog() const;
169
Patrick Benavoli63499d42011-10-24 18:50:03 +0200170 // Version
171 string getVersion() const;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200172
173 ////////////////:: Remote command parsers
Patrick Benavoli592ae562011-09-05 16:53:58 +0200174 /// Version
Patrick Benavoli63499d42011-10-24 18:50:03 +0200175 CCommandHandler::CommandStatus versionCommandProcess(const IRemoteCommand& remoteCommand, string& strResult);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200176 /// Status
Patrick Benavoli63499d42011-10-24 18:50:03 +0200177 CCommandHandler::CommandStatus statusCommandProcess(const IRemoteCommand& remoteCommand, string& strResult);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200178 /// Tuning Mode
Patrick Benavoli63499d42011-10-24 18:50:03 +0200179 CCommandHandler::CommandStatus setTuningModeCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult);
180 CCommandHandler::CommandStatus getTuningModeCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200181 /// Value Space
Patrick Benavoli63499d42011-10-24 18:50:03 +0200182 CCommandHandler::CommandStatus setValueSpaceCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult);
183 CCommandHandler::CommandStatus getValueSpaceCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult);
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200184 /// Output Raw Format
Patrick Benavoli63499d42011-10-24 18:50:03 +0200185 CCommandHandler::CommandStatus setOutputRawFormatCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult);
186 CCommandHandler::CommandStatus getOutputRawFormatCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200187 /// Sync
Patrick Benavoli63499d42011-10-24 18:50:03 +0200188 CCommandHandler::CommandStatus setAutoSyncCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult);
189 CCommandHandler::CommandStatus getAutoSyncCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult);
190 CCommandHandler::CommandStatus syncCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult);
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200191 /// Criteria
Patrick Benavoli63499d42011-10-24 18:50:03 +0200192 CCommandHandler::CommandStatus listCriteriaCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200193 /// Domains
Patrick Benavoli63499d42011-10-24 18:50:03 +0200194 CCommandHandler::CommandStatus listDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult);
195 CCommandHandler::CommandStatus createDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult);
196 CCommandHandler::CommandStatus deleteDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult);
197 CCommandHandler::CommandStatus renameDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult);
198 CCommandHandler::CommandStatus setSequenceAwarenessCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult);
199 CCommandHandler::CommandStatus getSequenceAwarenessCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult);
200 CCommandHandler::CommandStatus listDomainElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult);
201 CCommandHandler::CommandStatus addElementCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult);
202 CCommandHandler::CommandStatus removeElementCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult);
203 CCommandHandler::CommandStatus splitDomainCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200204 /// Configurations
Patrick Benavoli63499d42011-10-24 18:50:03 +0200205 CCommandHandler::CommandStatus listConfigurationsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult);
206 CCommandHandler::CommandStatus createConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult);
207 CCommandHandler::CommandStatus deleteConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult);
208 CCommandHandler::CommandStatus renameConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult);
209 CCommandHandler::CommandStatus saveConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult);
210 CCommandHandler::CommandStatus restoreConfigurationCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult);
211 CCommandHandler::CommandStatus setElementSequenceCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult);
212 CCommandHandler::CommandStatus getElementSequenceCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200213 /// Elements/Parameters
Patrick Benavoli63499d42011-10-24 18:50:03 +0200214 CCommandHandler::CommandStatus listElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult);
215 CCommandHandler::CommandStatus listParametersCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult);
216 CCommandHandler::CommandStatus dumpElementCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult);
217 CCommandHandler::CommandStatus getElementSizeCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult);
218 CCommandHandler::CommandStatus showPropertiesCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult);
219 CCommandHandler::CommandStatus getParameterCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult);
220 CCommandHandler::CommandStatus setParameterCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult);
221 CCommandHandler::CommandStatus listBelongingDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult);
222 CCommandHandler::CommandStatus listAssociatedDomainsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200223 /// Browse
Patrick Benavoli63499d42011-10-24 18:50:03 +0200224 CCommandHandler::CommandStatus listAssociatedElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult);
225 CCommandHandler::CommandStatus listConflictingElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult);
226 CCommandHandler::CommandStatus listRogueElementsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200227 /// Settings Import/Export
Patrick Benavoli63499d42011-10-24 18:50:03 +0200228 CCommandHandler::CommandStatus exportConfigurableDomainsToXMLCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult);
229 CCommandHandler::CommandStatus importConfigurableDomainsFromXMLCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult);
230 CCommandHandler::CommandStatus exportConfigurableDomainsWithSettingsToXMLCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult);
231 CCommandHandler::CommandStatus importConfigurableDomainsWithSettingsFromXMLCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult);
232 CCommandHandler::CommandStatus exportSettingsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult);
233 CCommandHandler::CommandStatus importSettingsCommmandProcess(const IRemoteCommand& remoteCommand, string& strResult);
Patrick Benavoli68a91282011-08-31 11:23:23 +0200234
235 // Max command usage length, use for formatting
236 void setMaxCommandUsageLength();
237
238 // For tuning, check we're in tuning mode
239 bool checkTuningModeOn(string& strError) const;
240
241 // Framework global configuration loading
242 bool loadFrameworkConfiguration(string& strError);
243
244 // System class Structure loading
245 bool loadStructure(string& strError);
246
247 // System class Structure loading
248 bool loadSettings(string& strError);
249
250 // Parse XML file into Root element
251 bool xmlParse(CXmlElementSerializingContext& elementSerializingContext, CElement* pRootElement, const string& strXmlFilePath, const string& strXmlFolder, ElementLibrary eElementLibrary, const string& strNameAttrituteName = "Name");
252
253 // Framework Configuration
254 CParameterFrameworkConfiguration* getFrameworkConfiguration();
255 const CParameterFrameworkConfiguration* getConstFrameworkConfiguration();
256
257 // Selection Criteria
258 CSelectionCriteria* getSelectionCriteria();
259 const CSelectionCriteria* getConstSelectionCriteria();
260
261 // System Class
262 CSystemClass* getSystemClass();
263 const CSystemClass* getConstSystemClass() const;
264
265 // Configurable Domains
266 CConfigurableDomains* getConfigurableDomains();
267 const CConfigurableDomains* getConstConfigurableDomains();
268 const CConfigurableDomains* getConstConfigurableDomains() const;
269
270 // Dynamic object creation libraries feeding
271 void feedElementLibraries();
272
273 // Remote Processor Server connection handling
274 bool handleRemoteProcessingInterface(string& strError);
275
276 // Back synchronization
277 CBackSynchronizer* createBackSynchronizer(string& strError) const;
278
279 // Tuning
280 bool _bTuningModeIsOn;
281
282 // Value Space
283 bool _bValueSpaceIsRaw;
284
Patrick Benavoli6ba361d2011-08-31 11:23:24 +0200285 // Output Raw Format
286 bool _bOutputRawFormatIsHex;
287
Patrick Benavoli68a91282011-08-31 11:23:23 +0200288 // Automatic synchronization to HW during Tuning session
289 bool _bAutoSyncOn;
290
291 // Current Parameter Settings
292 CParameterBlackboard* _pMainParameterBlackboard;
293
294 // Dynamic object creation
295 CElementLibrarySet* _pElementLibrarySet;
296
297 // XML parsing, object creation handling
298 string _strParameterFrameworkConfigurationFolderPath; // Root folder for framework configuration
299 string _strSchemaFolderLocation; // Place where schemas stand
300
301 // Subsystem plugin location
302 vector<string> _astrPluginFolderPaths;
303
304 // System Class Configuration
305 const CSystemClassConfiguration* _pSystemClassConfiguration;
306
307 // Whole system structure checksum
308 uint8_t _uiStructureChecksum;
309
Patrick Benavoli63499d42011-10-24 18:50:03 +0200310 // Command Handler
311 CCommandHandler* _pCommandHandler;
312
Patrick Benavoli68a91282011-08-31 11:23:23 +0200313 // Remote Processor Server
314 IRemoteProcessorServerInterface* _pRemoteProcessorServer;
315
316 // Parser description array
Patrick Benavoli592ae562011-09-05 16:53:58 +0200317 static const SRemoteCommandParserItem gastRemoteCommandParserItems[];
Patrick Benavoli68a91282011-08-31 11:23:23 +0200318
319 // Parser description array size
320 static const uint32_t guiNbRemoteCommandParserItems;
321
322 // Maximum command usage length
323 uint32_t _uiMaxCommandUsageLength;
324
325 // Tuning mode mutex
326 pthread_mutex_t _tuningModeMutex;
327
328 // Logging
329 ILogger* _pLogger;
Patrick Benavoli592ae562011-09-05 16:53:58 +0200330 mutable uint32_t _uiLogDepth;
Patrick Benavoli68a91282011-08-31 11:23:23 +0200331};
332