summaryrefslogtreecommitdiffstats
path: root/skeleton-subsystem
diff options
context:
space:
mode:
Diffstat (limited to 'skeleton-subsystem')
-rw-r--r--skeleton-subsystem/README.md12
-rw-r--r--skeleton-subsystem/SkeletonMappingKeys.h39
-rw-r--r--skeleton-subsystem/SkeletonSubsystem.cpp47
-rw-r--r--skeleton-subsystem/SkeletonSubsystem.h40
-rw-r--r--skeleton-subsystem/SkeletonSubsystemBuilder.cpp41
-rw-r--r--skeleton-subsystem/SkeletonSubsystemObject.cpp132
-rw-r--r--skeleton-subsystem/SkeletonSubsystemObject.h58
7 files changed, 369 insertions, 0 deletions
diff --git a/skeleton-subsystem/README.md b/skeleton-subsystem/README.md
new file mode 100644
index 0000000..0d90f30
--- /dev/null
+++ b/skeleton-subsystem/README.md
@@ -0,0 +1,12 @@
+# Skeleton plugin
+
+This is a skeleton plugin i.e. the minimal plugin boilerplate.
+
+It adds an owner and message mapping key and print it when reading or writing
+the parameter.
+
+## Usage
+
+It has no purpose: it only serves as a template and the `make install` target
+does not install it. If you want to see a real-life plugin and makefiles, see
+<https://github.com/01org/parameter-framework-plugins-alsa> instead.
diff --git a/skeleton-subsystem/SkeletonMappingKeys.h b/skeleton-subsystem/SkeletonMappingKeys.h
new file mode 100644
index 0000000..19caa4c
--- /dev/null
+++ b/skeleton-subsystem/SkeletonMappingKeys.h
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2011-2014, Intel Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation and/or
+ * other materials provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors
+ * may be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#pragma once
+
+// Mapping item types
+enum SkeletonItemType {
+ ESkeletonOwner,
+ EAmend1,
+ EAmend2,
+ EAmendEnd = EAmend2,
+ ENbSkeletonItemTypes
+};
diff --git a/skeleton-subsystem/SkeletonSubsystem.cpp b/skeleton-subsystem/SkeletonSubsystem.cpp
new file mode 100644
index 0000000..3d7f8fb
--- /dev/null
+++ b/skeleton-subsystem/SkeletonSubsystem.cpp
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2011-2014, Intel Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation and/or
+ * other materials provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors
+ * may be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "SkeletonSubsystem.h"
+#include "SkeletonMappingKeys.h"
+#include "SubsystemObjectFactory.h"
+#include "SkeletonSubsystemObject.h"
+
+#define base CSubsystem
+
+// Implementation
+CSkeletonSubsystem::CSkeletonSubsystem(const string& strName) : base(strName)
+{
+ // Provide mapping keys to upper layer
+ addContextMappingKey("Owner");
+ addContextMappingKey("Amend1");
+ addContextMappingKey("Amend2");
+
+ // Provide creators to upper layer
+ addSubsystemObjectFactory(new TSubsystemObjectFactory<CSkeletonSubsystemObject>("Message", 1 << ESkeletonOwner));
+}
diff --git a/skeleton-subsystem/SkeletonSubsystem.h b/skeleton-subsystem/SkeletonSubsystem.h
new file mode 100644
index 0000000..6f1af19
--- /dev/null
+++ b/skeleton-subsystem/SkeletonSubsystem.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2011-2014, Intel Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation and/or
+ * other materials provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors
+ * may be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#pragma once
+
+#include "Subsystem.h"
+
+class CSkeletonSubsystem : public CSubsystem
+{
+public:
+ CSkeletonSubsystem(const string& strName);
+
+};
+
diff --git a/skeleton-subsystem/SkeletonSubsystemBuilder.cpp b/skeleton-subsystem/SkeletonSubsystemBuilder.cpp
new file mode 100644
index 0000000..4193460
--- /dev/null
+++ b/skeleton-subsystem/SkeletonSubsystemBuilder.cpp
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2011-2014, Intel Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation and/or
+ * other materials provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors
+ * may be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "SubsystemLibrary.h"
+#include "NamedElementBuilderTemplate.h"
+#include "SkeletonSubsystem.h"
+
+
+extern "C"
+{
+void getSkeletonSusbystemBuilder(CSubsystemLibrary* pSubsystemLibrary)
+{
+ pSubsystemLibrary->addElementBuilder("Skeleton", new TNamedElementBuilderTemplate<CSkeletonSubsystem>());
+}
+}
diff --git a/skeleton-subsystem/SkeletonSubsystemObject.cpp b/skeleton-subsystem/SkeletonSubsystemObject.cpp
new file mode 100644
index 0000000..5c251db
--- /dev/null
+++ b/skeleton-subsystem/SkeletonSubsystemObject.cpp
@@ -0,0 +1,132 @@
+/*
+ * Copyright (c) 2011-2014, Intel Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation and/or
+ * other materials provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors
+ * may be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include <fstream>
+#include <string>
+#include <sstream>
+#include <cstdlib>
+#include <cassert>
+#include <iostream>
+#include "ParameterType.h"
+#include "MappingContext.h"
+#include "SkeletonMappingKeys.h"
+#include "InstanceConfigurableElement.h"
+#include "SkeletonSubsystemObject.h"
+
+#define STR_FORMAT_LENGTH 32
+
+#define base CFormattedSubsystemObject
+
+CSkeletonSubsystemObject::CSkeletonSubsystemObject(
+ const string& strMappingValue,
+ CInstanceConfigurableElement* pInstanceConfigurableElement,
+ const CMappingContext& context
+ ) :
+ base(pInstanceConfigurableElement,
+ strMappingValue,
+ EAmend1,
+ EAmendEnd - EAmend1 + 1,
+ context),
+ _bWrongElementTypeError(false)
+{
+ // Get actual element type
+ const CParameterType* pParameterType = static_cast<const CParameterType*>(pInstanceConfigurableElement->getTypeElement());
+
+ // Retrieve sizes
+ _uiScalarSize = pParameterType->getSize();
+ _uiArraySize = pInstanceConfigurableElement->getFootPrint() / _uiScalarSize;
+
+ // Construct message
+ _strMessage = context.getItem(ESkeletonOwner) + ":" + strMappingValue ;
+
+ // Handle types
+ // Check we are able to handle elements (no exception support, defer the error)
+ switch(pInstanceConfigurableElement->getType()) {
+
+ case CInstanceConfigurableElement::EParameter:
+ break;
+ default:
+ _bWrongElementTypeError = true;
+ break;
+ }
+
+}
+// Sync to/from HW
+bool CSkeletonSubsystemObject::accessHW(bool bReceive, string& strError)
+{
+ // Check parameter type is ok (deferred error, no exceptions available :-()
+ if (_bWrongElementTypeError) {
+
+ strError = "Unsupported parameter type";
+
+ return false;
+ }
+
+ return base::accessHW(bReceive, strError);
+}
+
+bool CSkeletonSubsystemObject::sendToHW(string& strError)
+{
+ (void) strError;
+
+ uint32_t uiIndex;
+
+ void* pvValue = alloca(_uiScalarSize);
+
+ for (uiIndex = 0 ; uiIndex < _uiArraySize ; uiIndex++) {
+
+ // Read Value in BlackBoard
+ blackboardRead(pvValue, _uiScalarSize);
+
+ // Send here the value
+ cout << "Sending to HW: " << _strMessage << endl;
+ }
+
+ return true;
+}
+
+bool CSkeletonSubsystemObject::receiveFromHW(string& strError)
+{
+ (void) strError;
+
+ uint32_t uiIndex;
+
+ void* pvValue = alloca(_uiScalarSize);
+
+ for (uiIndex = 0 ; uiIndex < _uiArraySize ; uiIndex++) {
+
+ // Retreive here the value
+ cout << "Retreive from HW: " << _strMessage << endl;
+
+ // Write Value in Blackboard
+ blackboardWrite(pvValue, _uiScalarSize);
+ }
+
+ return true;
+}
diff --git a/skeleton-subsystem/SkeletonSubsystemObject.h b/skeleton-subsystem/SkeletonSubsystemObject.h
new file mode 100644
index 0000000..e561fc7
--- /dev/null
+++ b/skeleton-subsystem/SkeletonSubsystemObject.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2011-2014, Intel Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation and/or
+ * other materials provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors
+ * may be used to endorse or promote products derived from this software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#pragma once
+
+#include "FormattedSubsystemObject.h"
+
+class CMappingContext;
+
+class CSkeletonSubsystemObject : public CFormattedSubsystemObject
+{
+public:
+ CSkeletonSubsystemObject(const string& strMappingValue, CInstanceConfigurableElement* pInstanceConfigurableElement, const CMappingContext& context);
+
+protected:
+ // from CSubsystemObject
+ // Sync to/from HW
+ virtual bool sendToHW(string& strError);
+ virtual bool receiveFromHW(string& strError);
+
+private:
+ // Sync to/from HW
+ virtual bool accessHW(bool bReceive, string& strError);
+
+protected:
+ // Scalar parameter size for elementary access
+ uint32_t _uiScalarSize;
+ uint32_t _uiArraySize;
+ string _strMessage;
+ // Delayed error about supported parameter types (always false in this example)
+ bool _bWrongElementTypeError;
+};