From 6ba361d96bc2581667b3400f87ff89fae6449e1f Mon Sep 17 00:00:00 2001 From: Patrick Benavoli Date: Wed, 31 Aug 2011 11:23:24 +0200 Subject: parameter-framework: improvements and corrections BZ: 6721 - Bug correction concerning selection criteria display (inclusive type) - Adapted XML format to allow for only on parameter to be associated to a domain - Removed unused files in parameter project Change-Id: I9f42d08ff8cb60354714fe3d6b0f0b321ad0a7bf Orig-Change-Id: I837e553070f5acf2d275082c986ba29433493e31 Signed-off-by: Patrick Benavoli Reviewed-on: http://android.intel.com:8080/16878 Reviewed-by: Mahe, Erwan Tested-by: Barthes, FabienX Reviewed-by: buildbot Tested-by: buildbot --- parameter/SubsystemObject.cpp | 95 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 80 insertions(+), 15 deletions(-) (limited to 'parameter/SubsystemObject.cpp') diff --git a/parameter/SubsystemObject.cpp b/parameter/SubsystemObject.cpp index fb53520..f0f1985 100644 --- a/parameter/SubsystemObject.cpp +++ b/parameter/SubsystemObject.cpp @@ -32,9 +32,15 @@ #include "InstanceConfigurableElement.h" #include "ParameterBlackboard.h" #include +#include +#include +#include CSubsystemObject::CSubsystemObject(CInstanceConfigurableElement* pInstanceConfigurableElement) - : _pInstanceConfigurableElement(pInstanceConfigurableElement), _uiDataSize(pInstanceConfigurableElement->getFootPrint()), _pvSynchronizedLocation(NULL) + : _pInstanceConfigurableElement(pInstanceConfigurableElement), + _uiDataSize(pInstanceConfigurableElement->getFootPrint()), + _pucBlackboardLocation(NULL), + _uiAccessedIndex(0) { // Syncer _pInstanceConfigurableElement->setSyncer(this); @@ -45,10 +51,10 @@ CSubsystemObject::~CSubsystemObject() _pInstanceConfigurableElement->unsetSyncer(); } -// Synchronized location -void CSubsystemObject::setSynchronizedLocation(void* pvSynchronizedLocation) +// Blackboard data location +uint8_t* CSubsystemObject::getBlackboardLocation() const { - _pvSynchronizedLocation = pvSynchronizedLocation; + return _pucBlackboardLocation; } // Size @@ -57,10 +63,28 @@ uint32_t CSubsystemObject::getSize() const return _uiDataSize; } +// Conversion utility +uint32_t CSubsystemObject::asInteger(const string& strValue) +{ + return strtoul(strValue.c_str(), NULL, 0); +} + +string CSubsystemObject::asString(uint32_t uiValue) +{ + ostringstream ostr; + + ostr << uiValue; + + return ostr.str(); +} + // Synchronization bool CSubsystemObject::sync(CParameterBlackboard& parameterBlackboard, bool bBack, string& strError) { - assert(_pvSynchronizedLocation); + // Get blackboard location + _pucBlackboardLocation = parameterBlackboard.getLocation(_pInstanceConfigurableElement->getOffset()); + // Access index init + _uiAccessedIndex = 0; #ifdef SIMULATION return true; @@ -70,28 +94,69 @@ bool CSubsystemObject::sync(CParameterBlackboard& parameterBlackboard, bool bBac if (bBack) { // Read from HW - if (!receiveFromHW()) { + if (!accessHW(true, strError)) { - strError = "Unable to back synchronize configurable element " + _pInstanceConfigurableElement->getPath(); + strError = "Unable to back synchronize configurable element " + _pInstanceConfigurableElement->getPath() + ": " + strError; return false; } - // Write parameter block data - parameterBlackboard.rawWrite(_pvSynchronizedLocation, _uiDataSize, _pInstanceConfigurableElement->getOffset()); - } else { - // Read parameter block data - parameterBlackboard.rawRead(_pvSynchronizedLocation, _uiDataSize, _pInstanceConfigurableElement->getOffset()); - // Send to HW - if (!sendToHW()) { + if (!accessHW(false, strError)) { - strError = "Unable to synchronize configurable element " + _pInstanceConfigurableElement->getPath(); + strError = "Unable to synchronize configurable element " + _pInstanceConfigurableElement->getPath() + ": " + strError; return false; } } return true; } + +// Sync to/from HW +bool CSubsystemObject::sendToHW(string& strError) +{ + strError = "Send to HW interface not implemented at subsystsem level!"; + + return false; +} + +bool CSubsystemObject::receiveFromHW(string& strError) +{ + strError = "Receive from HW interface not implemented at subsystsem level!"; + + return false; +} + +// Fall back HW access +bool CSubsystemObject::accessHW(bool bReceive, string& strError) +{ + // Default access falls back + if (bReceive) { + + return receiveFromHW(strError); + } else { + + return sendToHW(strError); + } +} + +// Blackboard access from subsystems +void CSubsystemObject::blackboardRead(void* pvData, uint32_t uiSize) +{ + assert(_uiAccessedIndex + uiSize <= _uiDataSize); + + memcpy(pvData, _pucBlackboardLocation + _uiAccessedIndex, uiSize); + + _uiAccessedIndex += uiSize; +} + +void CSubsystemObject::blackboardWrite(const void* pvData, uint32_t uiSize) +{ + assert(_uiAccessedIndex + uiSize <= _uiDataSize); + + memcpy(_pucBlackboardLocation + _uiAccessedIndex, pvData, uiSize); + + _uiAccessedIndex += uiSize; +} -- cgit v1.1