Revert "Android.mk: Remove the libparameter_includes hack"

This reverts commit 34e90ae1c744e1de6547e014326ef54f516439c8.

libparameter_includes and libparameter_includes_host are used to build
the parameter-framework plugins. They were removed by error.

We need to revert this patch since we still use those make targets.

Signed-off-by: Mattijs Korpershoek <mattijsx.korpershoek@intel.com>
Fix hostDomainGenerator.sh error about localhost socket creation

BZ: 171573

If localhost is not bound to 127.0.0.1, socket creation fails in the
portAllocator.py script. This error is not well catched in the main
tool hostDomainGenerator.sh.

This patch updates portAllocator.py so that the IP address 127.0.0.1
is used instead of localhost. In addition, the potential error messages
raised by portAllocator.py are now correctly taken into account by
hostDomainGenerator.sh. HostDomainGenerator.sh has also been updated
to replace all instances of 'localhost' by '127.0.0.1'.

Change-Id: I7ed6ede7a1148360efac4bf38f49054066a50a29
Signed-off-by: Frédéric Boisnard <fredericx.boisnard@intel.com>
Fix "Argument list too long" bug during XML generation

BZ: 177060

When the initial XML file for tuning is too big, the XML generation
fails with the message: "Argument list too long". This is because the
generation relies on the PFW command "setDomainsWithSettingsXML", which
takes XML data as string argument. There is a limitation concerning
the size of this string, leading to the current issue.

This patch replaces the call to "setDomainsWithSettingsXML" by
"importDomainsWithSettingsXML", which takes a file as argument instead
of a string. There is no limitation on the file size.

Change-Id: Ieb12e6ba1391545021cd3f1e867dee0d28425d19
Signed-off-by: Frédéric Boisnard <fredericx.boisnard@intel.com>
Support context mapping at Subsystem level

BZ: 176942

Add a class (ConfigurableMappingElement) handling the mapping; to be derived by
all classes that can contain mapping.  ConfigurableMappingElement derives from
ConfigurableElement.  Until now, the only child of ConfigurableElement that
could have mapping was InstanceConfigurableElement (through TypeElement, that
contains all information related to its type).

Now, both InstanceConfigurableElement and Subsystem derive from
ConfigurableMappingElement.  That way, Subsystem XML elements can now have a
"Mapping" attribute, propagated to all Elements in the tree.  The Subsystem.xsd
schema is updated in that regard.

Only context mapping is relevant at the Subsystem-level (as opposed to
instantiation mapping).  If an instantiation mapping is set in the Subsystem,
it is silently ignored.

Change-Id: I3c09959bc5e3d18c5a4d354e498d69cc5489a247
Signed-off-by: David Wagner <david.wagner@intel.com>
Signed-off-by: Mattijs Korpershoek <mattijsx.korpershoek@intel.com>
Restore autosync of string parameter

BZ: 183857

Sync for String parameter accessed from parameter handle API
does not work.

This patch allows synchronisation for string parameter accessed
from parameter handle APIs.

Change-Id: If738402f4c0fcb0bb51bd2515e46f3ac36a361dd
Signed-off-by: Francois Gaffie <francois.gaffie@intel.com>
Signed-off-by: Mattijs Korpershoek <mattijsx.korpershoek@intel.com>
Add explicit API to append parameter path to error log

BZ: 183857

Explicit API names makes the code easier to read, allowing even
to remove some comments.
This patch adds an API to append the parameter path to the error log.

Change-Id: Id136497072e53c8dd0ea3d95354e1dfe6193f771
Signed-off-by: Francois Gaffie <francois.gaffie@intel.com>
Signed-off-by: Mattijs Korpershoek <mattijsx.korpershoek@intel.com>
Local .xsd files for config validation

BZ: 184054

In order to verify that xml files are valid, the parameter framework
check them with .xsd files.
In those files, there are references towards base schemas on the
internet. Which means that every validation downloads a copy of
the base file via http.

To avoid doing http requests, we can use the file locally.
This patchs changes from remote file to local.

Change-Id: Ide48dba0000db7c97e1d269ee5573ac8afe7e4d4
Signed-off-by: Mattijs Korpershoek <mattijsx.korpershoek@intel.com>
Added possibility to toggle xml validation

BZ: 184054

It was not possible to enable/disable xml file validation.
The parameter framework only relied on the LIBXML_SCHEMAS flag.

This patchs implements a new constructor for XmlFiles
which allows enabling/disabling xml/xsd check.

Change-Id: I32d220a42bb27f4ce685f07cb194e78e76f44a5d
Signed-off-by: Mattijs Korpershoek <mattijsx.korpershoek@intel.com>
Test-platform enable/disable xml validation

BZ: 184054

test-platform has no way to tell to the parameter
framework that it wants the parameter framework to
validate xmls on loading.

New command added to test-platform executable.
setValidateSchemasOnStart true|false
    If set to true, the parameter framework will try
    to validate the .xmls with the .xsds located next to them.
    If set to false, it will never attempt to validate.

SetValidateSchemas is false by default to allow backward compatibility.

Note(a): This assumes that the script is able to
find the .xsd files (which should be in /tmp/Schemas/).

Change-Id: I7a5b0bc09d31e6647d8c631380d31503666e7e7b
Signed-off-by: Mattijs Korpershoek <mattijsx.korpershoek@intel.com>
Fix KW10 issues

BZ: 186081

Due to upgrade klocwork (KW version from 9.6 to 10.0)
new issues have been raised.

This patch fix the new issues raised in PFW.

Change-Id: I54c14e4d6da1c9a5f8d82aec1769a9e7e948db50
Signed-off-by: Eduardo Mendi <eduardox.mendi@intel.com>
Add log in case of failure

BZ: 189977

The hostDomainGenerator.sh script generates xml files a build time.
Sometimes it fails but the log information are no sufficient to found
the root cause.

Add some log information in order to be able to find it.

Change-Id: I505577ee30503dccf25375b0ea262461ec4cce14
Signed-off-by: Kevin Rocard <kevinx.rocard@intel.com>
Signed-off-by: Mattijs Korpershoek <mattijsx.korpershoek@intel.com>
Added copying of xsd files to host build output

BZ: 188323

In order to validate the .xml parameter framework files, we use XSDs.
Those must be in the same directory as the .xml files when they
are validated.

This patch copies the .xsd files towards a directory that
hostDomainGenerator knows, so that he can use the files and
copy them towards /tmp.

Change-Id: I938fc3791006777ff65c96d4259596111f93d7b8
Signed-off-by: Mattijs Korpershoek <mattijsx.korpershoek@intel.com>
Fix xmlserializer makefile for schema validation

BZ: 188323

For schema validation features, we are using a special version of libxml2 called
libxml2-schemas (which contains the SCHEMAS feature).
This is just a different static library build with that feature only for
the parameter-framework.
The problem with that, is that the include/xmlversion.h does not
define the #LIBXML_SCHEMAS_ENABLED flag.
So when including it in our project, the flag is not defined.
This results in unexpected behaviour since validation was active in the
static library, but never called because the flag was not defined.

As a fix, we are defining the LIBXML_SCHEMAS_ENABLED flag in the makefile.

Change-Id: Id56ae5b668e587171b11e7607f2603ab5e3341a1
Signed-off-by: Mattijs Korpershoek <mattijsx.korpershoek@intel.com>
Updated hostDomainGenerator.sh schema validation

BZ: 188323

In order to validate xml files, we need the corresponding schemas to be
next to the xml files. Those are put by the script in /tmp.

This patch add the copying of the schema files to /tmp.
I also adds an optional command line argument to disable/enable validation.
This is useful for platform specific enabling/disabling validation.
It can be used by calling hostDomainGenerator.sh --validate.

Change-Id: I7da65f230e5abf5b1d18c5cd6cf11b67dae5ed76
Signed-off-by: Mattijs Korpershoek <mattijsx.korpershoek@intel.com>
FixedPointParameterType: fix potential compilation issue

BZ: 176178

The isEncodable() method has several prototypes and some compilers are not able
to decide which version to use and produce a compilation error.

Remove unnecessary casts and make the code simpler by using a template-based
conversion library from string to various numeric types instead of using
strtoll and strtod.

Change-Id: I53d0b4ebd12f2cbb315bb52d98365a35876b5aef
Signed-off-by: David Wagner <david.wagner@intel.com>
Signed-off-by: Mattijs Korpershoek <mattijsx.korpershoek@intel.com>
Correct FixedPointParameter display precision

BZ: 176178

Explain the precision computation (m * log10(2)):

  For a Qn.m number, the step between each storable number is 2^(-m).
  Hence, on a decimal representation, the Dth digit after the decimal
  point can take all possible values (1..9) - meaning that it is
  significant - only if

          2^(-m) <= 10^(-D)
              -m <= log2(10^(-D))
              -m <= log10(10^(-D)) / log10(2)
              -m <= -D / log10(2)
    m * log10(2) >= D

  Conversly, the Dth digit can be represented if

    D <= m * log10(2)

We add 1 to the precision in order to display the digit right after the last
significant digit.  This will lead to oddities such as:

    $ setParameter /Test/test/f32_Q8.23 0.1234569
    $ getParameter /Test/test/f32_Q8.23
    > 0.1234570

but it will avoid modifying raw values when converting from string to Q-format
and back to string.

Also, use std::setprecision() on the stream instead of manually truncating the
displayed number.

Change-Id: Ief2a7daabf4505ae4312e79036b0374f53368cac
Signed-off-by: David Wagner <david.wagner@intel.com>
Fix Fixed Point convert issue.

BZ: 185336

Convert is failing when trying to convert the string value
to integer value within FixedPointParameterType class.

This patch fixes the issue by requesting to convert the string
into a signed type.

Change-Id: I77987eb1564292bd6dcdd0da4db52c4b4f92818f
Signed-off-by: Francois Gaffie <francois.gaffie@intel.com>
Signed-off-by: Mattijs Korpershoek <mattijsx.korpershoek@intel.com>
Remote-processor send returning 0 is not an error

BZ: 190038

Send can return a 0 size, it is normal.

Does not consider send return value 0 as an error.

Change-Id: Ic4801908b0771d5e0aba8c090fb9e9949d6e16fc
Signed-off-by: Kevin Rocard <kevinx.rocard@intel.com>
Remote-processor continue on EINTR

BZ: 190038

EINTR is a normal error and should not fail recv or send.

Continue if those errors are received.

Change-Id: I66416153eb432b8f7daf97119c7c59c87e88da08
Signed-off-by: Kevin Rocard <kevinx.rocard@intel.com>
Signed-off-by: Mattijs Korpershoek <mattijsx.korpershoek@intel.com>
[remote-processor] Add context information on failure

BZ: 190038

Remote processor was not displaying information in case of network
read/write error.

Add some error messages to ease debug.

Change-Id: I465062e8cf77f94b3d4d4d0c71338c4630aac276
Signed-off-by: Kevin Rocard <kevinx.rocard@intel.com>
Signed-off-by: Mattijs Korpershoek <mattijsx.korpershoek@intel.com>