Add initial version of c-picker

Introduce the following features to c-picker:

* Picking of the elements from C source files:
  * Include directives
  * Functions
  * Variables
* Removing 'static' keyword from declarations
* Mapping coverage to the original source
* Documentation of the system

Signed-off-by: Imre Kis <imre.kis@arm.com>
Change-Id: Ia5cb90d3096b16b15aafb86363b8cabfe7d2ab72
diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..ef89ab8
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,100 @@
+#
+# Copyright (c) 2020-2021, Arm Limited and Contributors. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+
+
+# References:
+# [LCS]         Linux Coding Style
+#                 (https://www.kernel.org/doc/html/v4.10/process/coding-style.html)
+# [PEP8]        Style Guide for Python Code
+#		          (https://www.python.org/dev/peps/pep-0008)
+
+root = true
+
+################################
+# Default settings for all files
+[*]
+# Windows .bat files may have trouble with utf8 and will fail with lf line ends.
+# Currently no plans to add .bat files, but this can be an issue in the future.
+charset = uft-8
+end_of_line = lf
+trim_trailing_whitespace = true
+indent_size = 4
+indent_style = tab
+
+################################
+#C and C++, follow LCS
+[*.{c,h,cpp,hpp}]
+
+# [LCS] Chapter 1: Indentation
+#       "Tabs are 8 characters"
+tab_width = 8
+
+# [LCS] Chapter 1: Indentation
+#       "and thus indentations are also 8 characters"
+indent_size = 8
+
+# [LCS] Chapter 1: Indentation
+#       "Outside of comments,...spaces are never used for indentation"
+indent_style = tab
+
+# [LCS] Chapter 2: Breaking long lines and strings
+#       "Statements may be up to 100 columns when appropriate."
+max_line_length = 100
+
+# [LCS] Chapter 1: Indentation
+#       "Get a decent editor and don't leave whitespace at the end of lines."
+# [LCS] Chapter 3.1: Spaces
+#       "Do not leave trailing whitespace at the ends of lines."
+trim_trailing_whitespace = true
+
+
+################################
+#CMake specific settings
+[{CMakeLists.txt,*.cmake}]
+charset = utf-8
+end_of_line = lf
+indent_size = 4
+indent_style = tab
+insert_final_newline = false
+max_line_length = 128
+trim_trailing_whitespace = true
+
+################################
+#Documentation
+[*.{rst,md}]
+charset = utf-8
+end_of_line = lf
+indent_size = 4
+indent_style = space
+insert_final_newline = false
+max_line_length = 128
+tab_width = 4
+trim_trailing_whitespace = true
+
+################################
+# Python code
+[*.py]
+# [PEP8] Indentation
+#	"Use 4 spaces per indentation level."
+indent_size = 4
+indent_style = space
+# [PEP8] Maximum Line Length
+#	"Limit all lines to a maximum of 79 characters."
+max_line_length = 79
+
+################################
+# Makefiles
+[{Makefile,*.mk}]
+indent_style = tab
+indent_size = 4
+
+################################
+# json,yaml and xml files
+[{*.json,*.yaml,*.xml}]
+indent_style = space
+indent_size = 4
+tab_width = 4
+trim_trailing_whitespace = true
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..af93826
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,20 @@
+#
+# Copyright (c) 2019-2021, Arm Limited and Contributors. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+
+#Ignore all build directoryes.
+*build*/
+
+##Python specific intermediate files
+# Byte-compiled / optimized / DLL files
+__pycache__/
+*.py[cod]
+*$py.class
+
+#Ignore Eclipse project files
+.project
+.cproject
+.settings
+.pydevproject
diff --git a/c_picker/__init__.py b/c_picker/__init__.py
new file mode 100644
index 0000000..b606582
--- /dev/null
+++ b/c_picker/__init__.py
@@ -0,0 +1,12 @@
+#!/usr/bin/env python3
+# Copyright (c) 2019-2021, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+
+"""
+Package information.
+"""
+
+__all__ = ["picker", "runner", "coverage"]
+__license__ = "BSD-3-Clause"
+__version__ = "1.0.0"
diff --git a/c_picker/coverage.py b/c_picker/coverage.py
new file mode 100644
index 0000000..1c79db0
--- /dev/null
+++ b/c_picker/coverage.py
@@ -0,0 +1,189 @@
+#!/usr/bin/env python3
+# Copyright (c) 2020-2021, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+
+"""
+This module can map the coverage of c-picker generated files to the original source files.
+"""
+
+import argparse
+import json
+import os
+import re
+import sys
+
+class MappingDescriptor:
+    """ Storage class for file-line number data """
+
+    def __init__(self, file=None, line=None):
+        self.descriptor = {"file": file, "line": line}
+
+    def get_file(self):
+        """ Queries file name """
+        return self.descriptor["file"]
+
+    def get_line(self):
+        """ Queries line number """
+        return self.descriptor["line"]
+
+    @staticmethod
+    def serialize(mapping_descriptor):
+        """ Serializes the descriptor into a C comment containing JSON. """
+        return "/* C-PICKER-MAPPING " + json.dumps(mapping_descriptor.descriptor) + " */"
+
+    @staticmethod
+    def deserialize(line):
+        """
+        Deserializes the descriptor from a C comment containing JSON.
+        It returns None if the line is not matching the required pattern.
+        """
+        match = re.match(r"/\* C-PICKER-MAPPING ({.*}) \*/", line)
+        if not match:
+            return None
+
+        mapping_descriptor = MappingDescriptor()
+        mapping_descriptor.descriptor = json.loads(match.group(1))
+        return mapping_descriptor
+
+class CoverageMapper:
+    """ The class maps the coverage of the c-picker generated source files to the original ones. """
+
+    def __init__(self):
+        self.mapping_path = None
+        self.output = sys.stdout
+
+        self.test_name = None
+        self.mapping_enabled = False
+        self.mapping_descriptors = {}
+        self.mapped_source_file = None
+
+    def read_mapping_descriptors(self, filename):
+        """ Reads the mapping descriptors from the c-picker generated file. """
+        self.mapping_enabled = True
+
+        with open(filename, "r") as source_file:
+            source_lines = source_file.read().split("\n")
+            source_line_index = 1
+
+            for source_line in source_lines:
+                mapping_descriptor = MappingDescriptor.deserialize(source_line)
+
+                if mapping_descriptor:
+                    # +1: the elements start at the following line after the descriptor comment
+                    self.mapping_descriptors[source_line_index + 1] = mapping_descriptor
+                source_line_index += 1
+
+    def clear_mapping_descriptors(self):
+        """ Resets the mapping descriptor database. """
+        self.mapping_enabled = False
+        self.mapping_descriptors = {}
+        self.mapped_source_file = None
+
+    def find_mapping(self, line_number):
+        """ Find the mapping descriptor of a line number and also returns the mapped line. """
+        mapping_descriptor_index = 0
+        for i in self.mapping_descriptors:
+            if i > line_number:
+                break
+            mapping_descriptor_index = i
+
+        if not mapping_descriptor_index:
+            raise Exception("Invalid mapping for line %d" % line_number)
+
+        mapping_descriptor = self.mapping_descriptors[mapping_descriptor_index]
+        mapped_line = line_number - mapping_descriptor_index + mapping_descriptor.get_line()
+        return mapping_descriptor, mapped_line
+
+    def output_line(self, line):
+        """ Outputs a single line to the output """
+        self.output.write(line + "\n")
+
+    def process_line(self, trace_line):
+        """
+        The function processes a single line of the trace file and maintains the internal state of
+        the state matchine.
+        """
+        if not trace_line:
+            return
+
+        if trace_line == "end_of_record":
+            # End of record, exit mapping mode
+            self.clear_mapping_descriptors()
+            self.output_line(trace_line)
+            return
+
+        command, params = trace_line.split(":", 1)
+        if command == "TN":
+            # Test name TN:<test name>
+            self.test_name = params
+        elif command == "SF" and params.startswith(self.mapping_path):
+            # Source file SF:<absolute path to the source file>
+            # Matching source file, switch into mapping mode
+            self.read_mapping_descriptors(params)
+            return
+
+        if self.mapping_enabled and (command in ("FN", "BRDA", "DA")):
+            # Function        FN:<line number of function start>,<function name>
+            # Branch coverage BRDA:<line number>,<block number>,<branch number>,<taken>
+            # Line coverage   DA:<line number>,<execution count>[,<checksum>]
+            line_number, remaining_params = params.split(",", 1)
+            mapping_descriptor, mapped_line_number = self.find_mapping(int(line_number))
+
+            if mapping_descriptor.get_file() != self.mapped_source_file:
+                # Change in the name of the mapped source file, starting new record
+                if self.mapped_source_file is not None:
+                    # No need for this part if it was the first mapped file
+                    # because TN has been alread printed
+                    self.output_line("end_of_record")
+                    self.output_line("TN:%s" % self.test_name)
+                self.mapped_source_file = mapping_descriptor.get_file()
+                self.output_line("SF:%s" % self.mapped_source_file)
+
+            self.output_line("%s:%d,%s" % (command, mapped_line_number, remaining_params))
+            return
+
+        self.output_line(trace_line)
+
+    def main(self):
+        """ Runs coverage mapper configured by the command line arguments  """
+
+        try:
+            parser = argparse.ArgumentParser(prog="c-picker-coverage-mapper", description=__doc__)
+            parser.add_argument("--input", help="Input trace file", required=True)
+            parser.add_argument("--output", help="Input file")
+            parser.add_argument("--mapping-path", help="Directory of generated files",
+                                required=True)
+            args = parser.parse_args()
+
+            output_fp = open(args.output, "w") if args.output else None
+
+            self.output = output_fp if output_fp else sys.stdout
+            self.mapping_path = os.path.abspath(args.mapping_path)
+
+            with open(args.input, "r") as tracefile:
+                trace_lines = tracefile.read().split("\n")
+                for trace_line in trace_lines:
+                    self.process_line(trace_line)
+
+            if output_fp:
+                output_fp.close()
+
+            return 0
+        except FileNotFoundError as exception:
+            print("File not found: %s" % str(exception), file=sys.stderr)
+        except ValueError as exception:
+            print("Invalid format: %s" % str(exception), file=sys.stderr)
+        except Exception as exception: # pylint: disable=broad-except
+            print("Exception: %s" % exception, file=sys.stderr)
+
+        return 1
+
+def main():
+    """ Command line main function """
+    coverage_mapper = CoverageMapper()
+    result = coverage_mapper.main()
+    sys.exit(result)
+
+if __name__ == "__main__":
+    main()
diff --git a/c_picker/picker.py b/c_picker/picker.py
new file mode 100644
index 0000000..963a313
--- /dev/null
+++ b/c_picker/picker.py
@@ -0,0 +1,194 @@
+#!/usr/bin/env python3
+# Copyright (c) 2019-2021, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+
+"""
+This module can fetch elements (include directives, functions, etc) from C source codes.
+The main purpose of this module is help unit testing by isolating functions from the
+rest of the code.
+"""
+
+import enum
+import os
+import sys
+
+# pylint exceptions are used because of the necessary Config.set_library_path call.
+from clang.cindex import Config
+if "CLANG_LIBRARY_PATH" in os.environ:
+    Config.set_library_path(os.environ["CLANG_LIBRARY_PATH"])
+import clang.cindex # pylint: disable=wrong-import-position
+
+from c_picker.coverage import MappingDescriptor # pylint: disable=wrong-import-position
+
+class CPicker:
+    """ CPicker can fetch C source element from a file matching the parameters and options. """
+
+    class Type(enum.Enum):
+        """ C source element type """
+        include = clang.cindex.CursorKind.INCLUSION_DIRECTIVE
+        function = clang.cindex.CursorKind.FUNCTION_DECL
+        variable = clang.cindex.CursorKind.VAR_DECL
+
+    class Option(enum.Enum):
+        """ Parameter for modifying the behaviour of the fetcher """
+
+        class RemoveStaticProcessor:
+            """ Removes 'static' from function declaration """
+
+            @staticmethod
+            def is_matching(node):
+                """ Checks if the storage class STATIC """
+                return node.storage_class == clang.cindex.StorageClass.STATIC
+
+            @staticmethod
+            def process(lines):
+                """ Removes 'static' before the function body """
+                processed_lines = []
+                function_body_started = False
+                for line in lines:
+                    if not function_body_started:
+                        processed_lines.append(line.replace("static ", ""))
+                        function_body_started = "{" in line
+                    else:
+                        processed_lines.append(line)
+                return processed_lines
+
+        remove_static = RemoveStaticProcessor
+
+    class ElementDescriptor:
+        """ Data structure of matching parameters """
+        def __init__(self, file_name, element_type, element_name=None):
+            self.file_name = file_name
+            self.element_type = element_type
+            self.element_name = element_name
+            self.args = None
+            self.options = None
+
+        def set_args(self, args):
+            """ Setting arguments of the parser """
+            self.args = args
+
+        def set_options(self, options):
+            """ Setting options for the fetcher """
+            self.options = options
+
+        def is_single_matching_type(self):
+            """ There's only a single matching element """
+            return bool(self.element_name)
+
+        def is_matching(self, node):
+            """ The node is matching the element defined in this instance """
+            if self.element_type == CPicker.Type.include:
+                return ((node.kind == self.element_type.value) and
+                        (str(node.location.file) == self.file_name))
+
+            if self.element_type == CPicker.Type.function:
+                return ((node.kind == self.element_type.value) and
+                        (str(node.location.file) == self.file_name) and
+                        (node.spelling == self.element_name) and
+                        node.is_definition())
+            if self.element_type == CPicker.Type.variable:
+                return ((node.kind == self.element_type.value) and
+                        (str(node.location.file) == self.file_name) and
+                        (node.spelling == self.element_name))
+            raise Exception("Invalid element type")
+
+        def get_option_processors(self, node):
+            """ Get processor function for matching options """
+            processors = []
+            for option in self.options:
+                if option.value.is_matching(node):
+                    processors.append(option.value)
+            return processors
+
+    def __init__(self, output=None, print_dependencies=False):
+        self.output = output if output else sys.stdout
+        self.print_dependencies = print_dependencies
+
+    def generate_header_comment(self):
+        """ Warning comment in the first line of the code """
+        self.output.write("/* DO NOT MODIFY! Generated by c-picker. */\n")
+
+    def generate_dependencies(self, elements):
+        """ Print the set of files included in the elements list """
+        dependencies = set()
+
+        for element in elements:
+            dependencies.add(os.path.abspath(element.file_name))
+
+        self.output.write(";".join(dependencies))
+
+    def fetch(self, element_descriptor):
+        """ Fetching C source element from the file """
+
+        # Parsing file with clang
+        try:
+            parser_options = clang.cindex.TranslationUnit.PARSE_DETAILED_PROCESSING_RECORD
+            index = clang.cindex.Index.create()
+            translation_unit = index.parse(element_descriptor.file_name,
+                                           args=element_descriptor.args,
+                                           options=parser_options)
+        except clang.cindex.TranslationUnitLoadError as exception:
+            raise Exception("Failed to parse " + element_descriptor.file_name + ": "
+                            + str(exception))
+
+        # Element comment
+        if element_descriptor.element_name:
+            element_text = element_descriptor.element_name
+        else:
+            element_text = element_descriptor.element_type.name
+
+        self.output.write("\n/* %s from %s */\n" % (element_text, element_descriptor.file_name))
+
+        # Searching for matching elements
+        for node in translation_unit.cursor.walk_preorder():
+            if element_descriptor.is_matching(node):
+                self.dump(node, element_descriptor.get_option_processors(node))
+                if element_descriptor.is_single_matching_type():
+                    break
+        else:
+            if element_descriptor.is_single_matching_type():
+                raise Exception("%s not found in %s"
+                                % (element_descriptor.element_name, element_descriptor.file_name))
+
+    def dump(self, node, options_processors):
+        """ Dump the contents of a node to the specified output """
+        with open(str(node.location.file), "r") as source_file:
+            source_lines = source_file.readlines()
+            source_lines = source_lines[node.extent.start.line - 1 : node.extent.end.line]
+
+            if len(source_lines) == 1:
+                source_lines = [source_lines[0][node.extent.start.column - 1 :
+                                                node.extent.end.column - 1]]
+            elif len(source_lines) > 1:
+                source_lines = ([source_lines[0][node.extent.start.column - 1 :]] +
+                                source_lines[1:-1] +
+                                [source_lines[-1][: node.extent.end.column - 1]])
+
+            for processor in options_processors:
+                source_lines = processor.process(source_lines)
+
+            # Mapping information of the original source
+            mapping_descriptor = MappingDescriptor(str(node.location.file), node.extent.start.line)
+            self.output.write(MappingDescriptor.serialize(mapping_descriptor) + "\n")
+
+            for source_line in source_lines:
+                self.output.write(source_line)
+            if node.kind == CPicker.Type.variable.value:
+                self.output.write(";")
+            self.output.write("\n")
+
+    def process(self, elements):
+        """ Processes element list """
+        try:
+            if not self.print_dependencies:
+                self.generate_header_comment()
+
+                for element in elements:
+                    self.fetch(element)
+            else:
+                self.generate_dependencies(elements)
+        except clang.cindex.LibclangError as _:
+            raise Exception("Please ensure you have the correct version of libclang installed" +
+                            " and the CLANG_LIBRARY_PATH environment variable set.")
diff --git a/c_picker/runner.py b/c_picker/runner.py
new file mode 100644
index 0000000..b1d02a2
--- /dev/null
+++ b/c_picker/runner.py
@@ -0,0 +1,117 @@
+#!/usr/bin/env python3
+# Copyright (c) 2020-2021, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+
+"""
+This module wraps the c-picker functionality into a command line interface.
+"""
+
+import argparse
+import json
+import sys
+import yaml
+
+from c_picker import __version__ as CPICKER_VERSION
+from c_picker.picker import CPicker
+from c_picker.picker import __doc__ as c_picker_doc
+
+class CPickerRunner:
+    """ Command line wrapper for CPicker """
+
+    def __init__(self):
+        self.root = ""
+        self.args = []
+        self.options = []
+
+        self.parser = argparse.ArgumentParser(prog="c-picker", description=c_picker_doc)
+
+        self.parser.add_argument("--root", help="Root source directory")
+        self.parser.add_argument("--config", help="Configuration file (.json|.yml)", required=True)
+        self.parser.add_argument("--output", help="Output file")
+        self.parser.add_argument("--print-dependencies", help="Print dependencies",
+                                 action="store_true")
+        self.parser.add_argument("--version", action="version", version=CPICKER_VERSION)
+        self.parser.add_argument("--args", help="clang arguments", nargs=argparse.REMAINDER)
+
+    @staticmethod
+    def error(message):
+        """ Print error message to stderr """
+        print("c-picker error\n" + message, file=sys.stderr)
+
+    def generate_element_descriptors(self, elements):
+        """ Converts the structure of the config file to a list of ElementDescriptors """
+        element_descriptors = []
+
+        for element in elements:
+            file_name = self.root + element["file"]
+            element_name = element["name"] if "name" in element else None
+            element_type = CPicker.Type[element["type"]]
+            element_args = self.args + element.get("args", [])
+            element_options = [
+                CPicker.Option[opt]
+                for opt in self.options + element.get("options", [])]
+
+            descriptor = CPicker.ElementDescriptor(file_name, element_type, element_name)
+            descriptor.set_args(element_args)
+            descriptor.set_options(element_options)
+
+            element_descriptors.append(descriptor)
+
+        return element_descriptors
+
+    @staticmethod
+    def create_config(args):
+        """ Create a configuration object from the command line arguments and config files. """
+        try:
+            if args.config.endswith(".json"):
+                with open(args.config) as json_file:
+                    return json.load(json_file)
+            elif args.config.endswith(".yml"):
+                with open(args.config) as yml_file:
+                    return yaml.safe_load(yml_file)
+            else:
+                raise Exception("Invalid configuration file %s" % args.config)
+        except json.decoder.JSONDecodeError as exception:
+            raise Exception("Invalid JSON format: " + str(exception))
+        except yaml.YAMLError as exception:
+            raise Exception("Invalid YAML format: " + str(exception))
+        except FileNotFoundError as exception:
+            raise Exception("File not found: " + str(exception))
+
+    def main(self):
+        """ Runs CPicker configured by the command line arguments  """
+        try:
+            args = self.parser.parse_args()
+            config = self.create_config(args)
+
+            output_fp = open(args.output, "w") if args.output else None
+
+            self.root = args.root + "/" if args.root else ""
+            self.args = args.args if args.args else [] + config.get("args", [])
+            self.options = config.get("options", [])
+
+            elements = self.generate_element_descriptors(config.get("elements", []))
+
+            c_picker = CPicker(output_fp, args.print_dependencies)
+            c_picker.process(elements)
+
+            if output_fp:
+                output_fp.close()
+
+            return 0
+        except KeyError as exception:
+            self.error("Key error: " + str(exception))
+        except Exception as exception: # pylint: disable=broad-except
+            self.error("Error: " + str(exception))
+
+        return 1
+
+def main():
+    """ Command line main function """
+    c_picker_runner = CPickerRunner()
+    result = c_picker_runner.main()
+    sys.exit(result)
+
+if __name__ == '__main__':
+    main()
diff --git a/dco.txt b/dco.txt
new file mode 100644
index 0000000..8201f99
--- /dev/null
+++ b/dco.txt
@@ -0,0 +1,37 @@
+Developer Certificate of Origin
+Version 1.1
+
+Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
+1 Letterman Drive
+Suite D4700
+San Francisco, CA, 94129
+
+Everyone is permitted to copy and distribute verbatim copies of this
+license document, but changing it is not allowed.
+
+
+Developer's Certificate of Origin 1.1
+
+By making a contribution to this project, I certify that:
+
+(a) The contribution was created in whole or in part by me and I
+    have the right to submit it under the open source license
+    indicated in the file; or
+
+(b) The contribution is based upon previous work that, to the best
+    of my knowledge, is covered under an appropriate open source
+    license and I have the right under that license to submit that
+    work with modifications, whether created in whole or in part
+    by me, under the same open source license (unless I am
+    permitted to submit under a different license), as indicated
+    in the file; or
+
+(c) The contribution was provided directly to me by some other
+    person who certified (a), (b) or (c) and I have not modified
+    it.
+
+(d) I understand and agree that this project and the contribution
+    are public and that a record of the contribution (including all
+    personal information I submit with it, including my sign-off) is
+    maintained indefinitely and may be redistributed consistent with
+    this project or the open source license(s) involved.
diff --git a/docs/Makefile b/docs/Makefile
new file mode 100644
index 0000000..04e3a70
--- /dev/null
+++ b/docs/Makefile
@@ -0,0 +1,25 @@
+#
+# Copyright (c) 2019-2021, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# Minimal makefile for Sphinx documentation
+#
+
+# You can set these variables from the command line, and also
+# from the environment for the first two.
+SPHINXOPTS    ?=
+SPHINXBUILD   ?= sphinx-build
+SOURCEDIR     = .
+BUILDDIR      = _build
+
+# Put it first so that "make" without argument is like "make help".
+help:
+	@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
+
+.PHONY: help Makefile
+
+# Catch-all target: route all unknown targets to Sphinx using the new
+# "make mode" option.  $(O) is meant as a shortcut for $(SPHINXOPTS).
+%: Makefile
+	@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
diff --git a/docs/SphinxBuild.cmake b/docs/SphinxBuild.cmake
new file mode 100644
index 0000000..b364813
--- /dev/null
+++ b/docs/SphinxBuild.cmake
@@ -0,0 +1,18 @@
+#
+# Copyright (c) 2019-2021, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+
+# Minimal cmake script for running sphinx. Use as:
+# cmake -P SphinxBuild.cmake
+
+# Inputs:
+#   SPHINXOPTS : extra options for sphinx
+
+set(SPHINXBUILD "sphinx-build" CACHE PATH "Location of sphinx-build executable.")
+set(SPHNIX_BUILDDIR "_build" CACHE PATH "Directory to place sphinx outpot to.")
+
+exec_program(${SPHINXBUILD} ./
+             ARGS -M html ${CMAKE_CURRENT_LIST_DIR} ${SPHNIX_BUILDDIR} ${SPHINXOPTS}
+            )
diff --git a/docs/conf.py b/docs/conf.py
new file mode 100644
index 0000000..0d1528c
--- /dev/null
+++ b/docs/conf.py
@@ -0,0 +1,106 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright (c) 2019-2021, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#
+# Configuration file for the Sphinx documentation builder.
+#
+# See the options documentation at http://www.sphinx-doc.org/en/master/config
+
+# -- Metadata about this file ------------------------------------------------
+__copyright__ = "Copyright (c) 2019-2021 Arm Limited"
+__license__ = "SPDX-License-Identifier: BSD-3-Clause"
+
+# Configuration file for the Sphinx documentation builder.
+
+# -- Path setup --------------------------------------------------------------
+
+# If extensions (or modules to document with autodoc) are in another directory,
+# add these directories to sys.path here. If the directory is relative to the
+# documentation root, use os.path.abspath to make it absolute, like shown here.
+#
+# import os
+# import sys
+# sys.path.insert(0, os.path.abspath('.'))
+
+# -- Project information -----------------------------------------------------
+project = 'c-picker'
+copyright = __copyright__
+author = 'Arm Limited'
+
+# The full version, including alpha/beta/rc tags
+from c_picker import __version__ as release
+version = release
+
+
+# -- General configuration ---------------------------------------------------
+
+# Add any Sphinx extension module names here, as strings. They can be
+# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
+# ones.
+extensions = ['sphinx.ext.autosectionlabel']
+
+# Add any paths that contain templates here, relative to this directory.
+templates_path = ['_templates']
+
+# The suffix(es) of source filenames.
+source_suffix = '.rst'
+
+# The master toctree document.
+master_doc = 'index'
+
+# The language for content autogenerated by Sphinx. Refer to documentation
+# for a list of supported languages.
+#
+# This is also used if you do content translation via gettext catalogs.
+# Usually you set "language" from the command line for these cases.
+language = None
+
+# List of patterns, relative to source directory, that match files and
+# directories to ignore when looking for source files.
+# This pattern also affects html_static_path and html_extra_path.
+exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
+
+# The name of the Pygments (syntax highlighting) style to use.
+pygments_style = 'sphinx'
+
+# Load the contents of the global substitutions file into the 'rst_prolog'
+# variable. This ensures that the substitutions are all inserted into each page.
+with open('global_substitutions.txt', 'r') as subs:
+  rst_prolog = subs.read()
+rst_prolog += "\n .. |RELEASE_NUMBER| replace:: %s" % (version)
+# Minimum version of sphinx required
+needs_sphinx = '2.0'
+
+# -- Options for HTML output -------------------------------------------------
+
+# Don't show the "Built with Sphinx" footer
+html_show_sphinx = False
+
+# Don't show copyright info in the footer (we have this content in the page)
+html_show_copyright = False
+
+# The theme to use for HTML and HTML Help pages.  See the documentation for
+# a list of builtin themes.
+html_theme = "sphinx_rtd_theme"
+
+# The logo to display in the sidebar
+html_logo = 'resources/TrustedFirmware-Logo_standard-white.png'
+
+# Options for the "sphinx-rtd-theme" theme
+html_theme_options = {
+    'collapse_navigation': False, # Can expand and collapse sidebar entries
+    'prev_next_buttons_location': 'both', # Top and bottom of the page
+    'style_external_links': True # Display an icon next to external links
+}
+
+# -- Options for autosectionlabel --------------------------------------------
+
+# Only generate automatic section labels for document titles
+autosectionlabel_maxdepth = 1
+
+# -- Options for plantuml ----------------------------------------------------
+
+plantuml_output_format = 'svg_img'
diff --git a/docs/global_substitutions.txt b/docs/global_substitutions.txt
new file mode 100644
index 0000000..da70607
--- /dev/null
+++ b/docs/global_substitutions.txt
@@ -0,0 +1,20 @@
+.. |C_PICKER| replace:: :term:`c-picker`
+.. |TFA_MAIL_LIST| replace:: `TF-A development`_
+.. |TS_MAIL_LIST| replace:: `TS Mailing List`_
+.. |TS_REPO| replace:: `TS repository`_
+.. |C_PICKER_REPO| replace:: `c-picker repository`_
+.. |REST| replace:: reST
+.. |SEMVER| replace:: `Semantic Versioning`_
+
+.. _`TF-A development`: https://lists.trustedfirmware.org/pipermail/tf-a/
+.. _`TS Mailing List`: https://lists.trustedfirmware.org/mailman/listinfo/trusted-services
+.. _`c-picker repository`: https://review.trustedfirmware.org/admin/repos/shared/c-picker
+.. _`TS repository`: https://review.trustedfirmware.org/admin/repos/TS/trusted-services
+.. _`Semantic Versioning`: https://semver.org/spec/v2.0.0.html
+
+..
+    --------------
+
+    *Copyright (c) 2019-2021, Arm Limited. All rights reserved.*
+
+    SPDX-License-Identifier: BSD-3-Clause
diff --git a/docs/index.rst b/docs/index.rst
new file mode 100644
index 0000000..0c92bb8
--- /dev/null
+++ b/docs/index.rst
@@ -0,0 +1,27 @@
+Welcome to the c-picker's documentation!
+========================================
+
+.. toctree::
+   :maxdepth: 1
+   :hidden:
+   :numbered:
+
+   Home<self>
+   user_guide
+   project/index
+
+This repository contains the c-picker-tool.
+
+Separating dependencies apart from the code under test is a crutial step in unit testing systems. In many cases this can be
+easily done by linking mocked functions to the tested code but sometimes it's difficult like when the code under test and its
+dependencies are in the same compilation unit. For separating the code under test from its dependencies the tool called c-picker
+can be used. It can pick pieces of code (functions, variables, etc.) based on descriptor files.
+
+The coverage of c-picker generated sources is mapped to the original sources files.
+
+
+--------------
+
+*Copyright (c) 2019-2021, Arm Limited. All rights reserved.*
+
+SPDX-License-Identifier: BSD-3-Clause
\ No newline at end of file
diff --git a/docs/project/change-log.rst b/docs/project/change-log.rst
new file mode 100644
index 0000000..037f6da
--- /dev/null
+++ b/docs/project/change-log.rst
@@ -0,0 +1,29 @@
+Change Log & Release Notes
+==========================
+
+This document contains a summary of the new features, changes, fixes and known issues in each release of Trusted Services.
+
+Version 1.0.0
+-------------
+
+New Features
+^^^^^^^^^^^^
+First release.
+
+Changes
+^^^^^^^
+None.
+
+Resolved Issues
+^^^^^^^^^^^^^^^
+None.
+
+Deprecations
+^^^^^^^^^^^^
+None.
+
+--------------
+
+*Copyright (c) 2020-2021, Arm Limited and Contributors. All rights reserved.*
+
+SPDX-License-Identifier: BSD-3-Clause
diff --git a/docs/project/coding-guidelines.rst b/docs/project/coding-guidelines.rst
new file mode 100644
index 0000000..2244064
--- /dev/null
+++ b/docs/project/coding-guidelines.rst
@@ -0,0 +1,40 @@
+Coding Style & Guidelines
+=========================
+
+The following sections contain |C_PICKER| coding guidelines. They are continually evolving and should not be considered "set
+in stone". Feel free to question them and provide feedback.
+
+The |C_PICKER| project uses multiple "domains" (textual content types, like programming languages) and each defines its own
+rules.
+
+To help configuring text editors the project comes with "`EditorConfig`_" file(s). (:download:`../../.editorconfig`).
+
+Shared rules
+------------
+
+The following rules are common for all domains, except where noted otherwise:
+
+#. Files shall be **UTF-8** encoded.
+#. Use **Unix** style line endings (``LF`` character)
+#. The primary language of the project is English. All comments and documentation must be in this language.
+#. Trailing whitespace is not welcome, please trim these.
+
+Python Domain
+-------------
+
+Python source code rules follow `PEP 8 -- Style Guide for Python Code`_.
+
+
+Restructured Text Domain
+------------------------
+
+Please refer to :ref:`Writing documentation`.
+
+--------------
+
+.. _`EditorConfig`: https://editorconfig.org/
+.. _`PEP 8 -- Style Guide for Python Code`: https://www.python.org/dev/peps/pep-0008/
+
+*Copyright (c) 2020-2021, Arm Limited and Contributors. All rights reserved.*
+
+SPDX-License-Identifier: BSD-3-Clause
diff --git a/docs/project/contributing.rst b/docs/project/contributing.rst
new file mode 100644
index 0000000..9ff9318
--- /dev/null
+++ b/docs/project/contributing.rst
@@ -0,0 +1,83 @@
+Contributing
+============
+
+
+Getting Started
+---------------
+
+- Make sure you have a GitHub account and you are logged on `developer.trustedfirmware.org`_.
+- Send an email to the |TS_MAIL_LIST| about your work. This gives everyone visibility of whether others are working on something
+  similar.
+- Clone the |C_PICKER_REPO| on your own machine.
+- Create a local topic branch based on ``main`` branch of the |C_PICKER_REPO|.
+
+Making Changes
+--------------
+
+- Make commits of logical units. See these general `Git guidelines`_ for contributing to a project.
+- Follow the :ref:`Coding Style & Guidelines`.
+- Keep the commits on topic. If you need to fix another bug or make another enhancement, please create a separate change.
+- Avoid long commit series. If you do have a long series, consider whether some  commits should be squashed together or
+  addressed in a separate topic.
+- Make sure your commit messages are in the proper format. Please keel the 50/72 rule (for details see `Tim Popes blog entry`_.)
+- Where appropriate, please update the documentation.
+
+   - Consider whether the this document or other in-source documentation needs updating.
+
+   - Ensure that each changed file has the correct copyright and license information. Files that entirely consist of
+     contributions to this project should have a copyright notice and BSD-3-Clause SPDX license identifier of the form as shown
+     in :ref:`license`. Files that contain changes to imported Third Party IP files should retain their original copyright and
+     license notices. For significant contributions you may add your own copyright notice in following format::
+
+        Portions copyright (c) [XXXX-]YYYY, <OWNER>. All rights reserved.
+
+     where XXXX is the year of first contribution (if different to YYYY) and YYYY is the year of most recent contribution.
+     *<OWNER>* is your name or your company name.
+   - If you are submitting new files that you intend to be the technical sub-maintainer for (for example, a new platform port),
+     then also update the :ref:`maintainers` file.
+   - For topics with multiple commits, you should make all documentation changes (and nothing else) in the last commit of the
+     series. Otherwise, include the documentation changes within the single commit.
+
+- Please test your changes.
+
+Submitting Changes
+------------------
+
+- Ensure that each commit in the series has at least one ``Signed-off-by:``line, using your real name and email address. The
+  names in the ``Signed-off-by:`` and ``Author:`` lines must match. If anyone else contributes to the commit, they must also add
+  their own ``Signed-off-by:`` line. By adding this line the contributor certifies the contribution is made under the terms of
+  the :download:`Developer Certificate of Origin <../../dco.txt>`.
+
+  More details may be found in the `Gerrit Signed-off-by Lines guidelines`_.
+
+- Ensure that each commit also has a unique ``Change-Id:`` line. If you have cloned the repository with the
+  "`Clone with commit-msg hook`" clone method, this should already be the case.
+
+  More details may be found in the `Gerrit Change-Ids documentation`_.
+
+- Submit your changes for review at https://review.trustedfirmware.org targeting the ``main`` branch.
+
+- The changes will then undergo further review and testing by the :ref:`maintainers`. Any review comments will be made
+  directly on your patch. This may require you to do some rework.
+
+  Refer to the `Gerrit Uploading Changes documentation`_ for more details.
+
+- When the changes are accepted, the :ref:`maintainers` will integrate them.
+
+  - Typically, the :ref:`maintainers` will merge the changes into the ``main`` branch.
+  - If the changes are not based on a sufficiently-recent commit, or if they cannot be automatically rebased, then the
+    :ref:`maintainers` may rebase it on the ``main`` branch or ask you to do so.
+
+--------------
+
+.. _developer.trustedfirmware.org: https://developer.trustedfirmware.org
+.. _Git guidelines: http://git-scm.com/book/ch5-2.html
+.. _Gerrit Uploading Changes documentation: https://review.trustedfirmware.org/Documentation/user-upload.html
+.. _Gerrit Signed-off-by Lines guidelines: https://review.trustedfirmware.org/Documentation/user-signedoffby.html
+.. _Gerrit Change-Ids documentation: https://review.trustedfirmware.org/Documentation/user-changeid.html
+.. _`Tim Popes blog entry`: https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
+
+
+*Copyright (c) 2019-2021, Arm Limited and Contributors. All rights reserved.*
+
+SPDX-License-Identifier: BSD-3-Clause
diff --git a/docs/project/glossary.rst b/docs/project/glossary.rst
new file mode 100644
index 0000000..d19d7b4
--- /dev/null
+++ b/docs/project/glossary.rst
@@ -0,0 +1,17 @@
+Glossary
+========
+
+This glossary provides definitions for terms and abbreviations used in the c-picker documentation.
+
+.. glossary::
+    :sorted:
+
+    c-picker
+        c-picker
+
+
+--------------
+
+*Copyright (c) 2020-2021, Arm Limited and Contributors. All rights reserved.*
+
+SPDX-License-Identifier: BSD-3-Clause
diff --git a/docs/project/index.rst b/docs/project/index.rst
new file mode 100644
index 0000000..9934ff6
--- /dev/null
+++ b/docs/project/index.rst
@@ -0,0 +1,22 @@
+About the project
+=================
+
+.. toctree::
+    :maxdepth: 1
+    :caption: Contents:
+
+    change-log
+    coding-guidelines
+    contributing
+    glossary
+    license
+    maintainers
+    versioning_policy
+    writing-documentation
+
+
+--------------
+
+*Copyright (c) 2020-2021, Arm Limited and Contributors. All rights reserved.*
+
+SPDX-License-Identifier: BSD-3-Clause
\ No newline at end of file
diff --git a/docs/project/license.rst b/docs/project/license.rst
new file mode 100644
index 0000000..ac98f00
--- /dev/null
+++ b/docs/project/license.rst
@@ -0,0 +1,37 @@
+License
+=======
+
+Copyright (c) 2019-2021, Arm Limited and Contributors. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+-  Redistributions of source code must retain the above copyright notice, this
+   list of conditions and the following disclaimer.
+-  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.
+-  Neither the name of Arm 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.
+
+--------------
+
+*Note*:
+Individual files contain the following tag instead of the full license text.
+
+    SPDX-License-Identifier:    BSD-3-Clause
+
+This enables machine processing of license information based on the SPDX
+License Identifiers that are here available: http://spdx.org/licenses/
diff --git a/docs/project/maintainers.rst b/docs/project/maintainers.rst
new file mode 100644
index 0000000..e259f77
--- /dev/null
+++ b/docs/project/maintainers.rst
@@ -0,0 +1,41 @@
+Maintainers
+===========
+
+|C_PICKER| is a trustedfirmware.org maintained component used by multiple trustedfirmware.org projects. All contributions are
+ultimately merged by the maintainers listed below. Technical ownership of some parts of the code-base is delegated to the code
+owners listed below. An acknowledgment from these code maintainers may be required before the maintainers merge a contribution.
+
+More details may be found in the `Project Maintenance Process`_ document.
+
+This file follows the format of the Linux Maintainers file. For details on the meaning of tags below please refer to the
+`Linux Maintainers file`_.
+
+Main maintainers
+----------------
+:M: György Szing <gyorgy.szing@arm.com>
+:G: `gyuri-szing`_
+:L: |TS_MAIL_LIST|
+:M: Imre Kis <imre.kis@arm.com>
+:G: `imre-kis-arm`_
+:M: Lauren Wehrmeister <Lauren.Wehrmeister@arm.com>
+:G: `laurenw-arm`_
+:L: |TFA_MAIL_LIST|
+
+Code owners
+--------------------
+
+Cyrrently there are no code owners.
+
+--------------
+
+.. _danh-arm: https://github.com/danh-arm
+.. _gyuri-szing: https://github.com/gyuri-szing
+.. _imre-kis-arm: https://github.com/imre-kis-arm
+.. _laurenw-arm: https://github.com/laurenw-arm
+
+.. _`Linux Maintainers file`: https://github.com/torvalds/linux/blob/master/MAINTAINERS#L80
+.. _Project Maintenance Process: https://developer.trustedfirmware.org/w/collaboration/project-maintenance-process/
+
+*Copyright (c) 2020-2021, Arm Limited and Contributors. All rights reserved.*
+
+SPDX-License-Identifier: BSD-3-Clause
diff --git a/docs/project/versioning_policy.rst b/docs/project/versioning_policy.rst
new file mode 100644
index 0000000..14f9637
--- /dev/null
+++ b/docs/project/versioning_policy.rst
@@ -0,0 +1,41 @@
+Versioning policy
+==================
+
+This document captures information about the version identifier used by the project. It tells the meaning of each part, where
+the version information is captured and how it is managed.
+
+Summary
+-------
+
+The version identifier identifies the feature set supported by a specific release, and captures compatibility information to
+other releases.
+
+This project uses "Semantic Versioning", for details please refer to |SEMVER|.
+
+In general the version number is constructed from three numbers. The `MAJOR` number is changed when incompatible API changes are
+introduced, the `MINOR` version when you functionality is added in a backward compatible manner, and the `PATCH` version when
+backwards compatible bug fixes are added.
+
+Each release will get a unique release id assigned. When a release is made, the version number will get incremented in
+accordance with the compatibility rules mentioned above.
+
+This project is only using the core version and will not use pre-release or build specific metadata extension.
+
+Storage and format
+------------------
+
+The version number of each release will be stored at two locations:
+  #. In a tag of the version control system in the form of "vX.Y.Z" where X Y and Z are the major, minor and patch version
+     numbers.
+  #. In a file c_picker/__init__.py as a Python variable.
+
+.. note:: The version id is independent from version identifiers of the
+          versioning system used to store the |C_PICKER| (i.e. git).
+
+--------------
+
+.. _`Semantic Versioning`: https://semver.org/spec/v2.0.0.html
+
+*Copyright (c) 2020-2021, Arm Limited and Contributors. All rights reserved.*
+
+SPDX-License-Identifier: BSD-3-Clause
diff --git a/docs/project/writing-documentation.rst b/docs/project/writing-documentation.rst
new file mode 100644
index 0000000..697013a
--- /dev/null
+++ b/docs/project/writing-documentation.rst
@@ -0,0 +1,52 @@
+Writing documentation
+=====================
+
+|C_PICKER| is documented using `Sphinx`_, which in turn uses Docutils and `Restructured Text`_ (|REST| hereafter).
+
+The source files for the documents are in the *docs* directory of the |C_PICKER_REPO|.
+
+The preferred output format is *HTML*, and other formats may or may not work.
+
+
+Section Headings
+----------------
+
+In order to avoid problems if documents include each other, it is important to follow a consistent section heading
+style. Please use at most five heading levels. Please use the following style::
+
+    First-Level Title
+    =================
+
+    Second-Level Title
+    ------------------
+
+    Third-Level Title
+    '''''''''''''''''
+
+    Forth-level Title
+    """""""""""""""""
+
+    Fifth-level Title
+    ~~~~~~~~~~~~~~~~~
+
+
+Inline documentation
+--------------------
+
+To get all information integrated into a single document the project uses Sphinx extensions to allow capturing inline
+documentation into this manual.
+
+
+CMake
+'''''
+
+Apologies, this section is not ready yet. Please check existing cmake and |REST| files to see how documentation can be added.
+
+--------------
+
+.. _`Restructured Text`: https://docutils.sourceforge.io/rst.html
+.. _`Sphinx`: https://www.sphinx-doc.org
+
+*Copyright (c) 2020-2021, Arm Limited and Contributors. All rights reserved.*
+
+SPDX-License-Identifier: BSD-3-Clause
diff --git a/docs/requirements.txt b/docs/requirements.txt
new file mode 100644
index 0000000..563c7ba
--- /dev/null
+++ b/docs/requirements.txt
@@ -0,0 +1,10 @@
+#
+# Copyright (c) 2020-2021, Arm Limited and Contributors. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+
+# Python dependencies for building the documentation.
+
+Sphinx==2.3.1
+sphinx-rtd-theme==0.4.3
diff --git a/docs/resources/TrustedFirmware-Logo_standard-white.png b/docs/resources/TrustedFirmware-Logo_standard-white.png
new file mode 100644
index 0000000..e7bff71
--- /dev/null
+++ b/docs/resources/TrustedFirmware-Logo_standard-white.png
Binary files differ
diff --git a/docs/user_guide.rst b/docs/user_guide.rst
new file mode 100644
index 0000000..bb8d004
--- /dev/null
+++ b/docs/user_guide.rst
@@ -0,0 +1,61 @@
+User guide
+==========
+
+c-picker uses ``libclang``'s Python interface for parsing source files.
+
+Command line options
+--------------------
+
+- ``-h, --help`` - Showing help message
+- ``--root ROOT`` - Root source directory
+- ``--config CONFIG`` - Configuration file (``.json|.yml``)
+- ``--output OUTPUT`` - Output file
+- ``--print-dependencies`` - Prints the dependencies
+- ``--version`` - Shows the program's version number and exit
+- ``--args ...``  - clang arguments
+
+
+Configuration file format
+-------------------------
+
+c-picker configuration can be described in ``JSON`` or ``YAML`` format using the same object structure.
+
+- ``elements`` - List of elements to pick from the original code
+
+  - ``name`` - Name of the element
+  - ``type`` - Type of the element: ``include``, ``function``, ``variable``
+  - ``args`` - Arguments for clang used during picking the element
+  - ``options`` - Currenly the only options is ``remove_static`` which removes
+    the ``static`` qualifier from the element's definition.
+
+- ``options`` - Global options for all elements
+- ``args`` - Global clang arguments for all elements
+
+YAML example
+------------
+
+YAML format is preferred because it can contain metadata like comments and licence information.
+
+.. code-block:: YAML
+
+  elements:
+  - file: bl1/bl1_fwu.c
+    type: variable
+    name: bl1_fwu_loaded_ids
+    options: [remove_static]
+  - file: bl1/bl1_fwu.c
+    type: function
+    name: bl1_fwu_add_loaded_id
+    options: [remove_static]
+  - file: bl1/bl1_fwu.c
+    type: function
+    name: bl1_fwu_remove_loaded_id
+    options: [remove_static]
+  args:
+  - -DFWU_MAX_SIMULTANEOUS_IMAGES=10
+  - -DINVALID_IMAGE_ID=0xffffffff
+
+
+--------------
+
+*Copyright (c) 2019-2021, Arm Limited. All rights reserved.*
diff --git a/license.rst b/license.rst
new file mode 100644
index 0000000..3c59fe9
--- /dev/null
+++ b/license.rst
@@ -0,0 +1,7 @@
+See `license.rst <./docs/project/license.rst>`_
+
+--------------
+
+*Copyright (c) 2019-2021, Arm Limited and Contributors. All rights reserved.*
+
+SPDX-License-Identifier: BSD-3-Clause
diff --git a/readme.rst b/readme.rst
new file mode 100644
index 0000000..4f64d8c
--- /dev/null
+++ b/readme.rst
@@ -0,0 +1,24 @@
+c-picker
+========
+
+This repository holds the tool called c-picker.
+
+The full documentation of this project is `Sphinx`_ based, lives in the *docs*
+sub-directory and is captured in reStructuredText_ format.
+
+For licensing information please refer to `license.rst`_
+
+Contributed content is accepted under the `Developer Certificate of Origin (DCO)`_
+and commit messages shall follow specific formatting  rules (for details
+please refer to the *Contributing* sections of the full documentation).
+
+.. _reStructuredText: http://docutils.sourceforge.net/rst.html
+.. _Sphinx: http://www.sphinx-doc.org/en/master/
+.. _`license.rst`: ./license.rst
+.. _`Developer Certificate of Origin (DCO)`: ./dco.txt
+
+--------------
+
+*Copyright (c) 2019-2021, Arm Limited. All rights reserved.*
+
+SPDX-License-Identifier: BSD-3-Clause
diff --git a/setup.cfg b/setup.cfg
new file mode 100644
index 0000000..31c818b
--- /dev/null
+++ b/setup.cfg
@@ -0,0 +1,6 @@
+# Copyright (c) 2021, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+
+[metadata]
+license_files = docs/project/license.rst
diff --git a/setup.py b/setup.py
new file mode 100644
index 0000000..b19958e
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,66 @@
+#!/usr/bin/env python3
+# Copyright (c) 2019-2021, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+
+"""
+Setup file for c-picker.
+"""
+
+import importlib
+import setuptools
+import pkg_resources
+from c_picker import __version__ as CPICKER_VERSION
+from c_picker import __license__ as CPICKER_LICENSE
+
+def get_install_requires():
+    """
+    Collecting dependencies on install.
+    clang module can be part of the distro's package and it should not be
+    overwritten by the clang pip package.
+    """
+
+    deps = ["pyyaml>5"]
+
+    try:
+        pkg_resources.get_distribution("clang")
+        has_clang_pip = True
+    except pkg_resources.DistributionNotFound:
+        has_clang_pip = False
+
+    clang_spec = importlib.util.find_spec("clang")
+    has_clang_module = clang_spec is not None
+
+    # Install clang Python bindings from pip if it has not been install
+    # any other way. This condition prevents overwriting clang Python
+    # modules if they were installed without pip (i.e. using the system's
+    # package manager instead of pip).
+    if not has_clang_module or has_clang_pip:
+        deps.append("clang")
+
+    return deps
+
+setuptools.setup(
+    name="c-picker",
+    version=CPICKER_VERSION,
+    author="Arm Limited",
+    author_email="imre.kis@arm.com",
+    license=CPICKER_LICENSE,
+    description="C source code picker",
+    platforms=["any"],
+    packages=[
+        "c_picker"
+    ],
+    install_requires=get_install_requires(),
+    entry_points={
+        "console_scripts": [
+            'c-picker=c_picker.runner:main',
+            'c-picker-coverage-mapper=c_picker.coverage:main'
+        ],
+    },
+    classifiers=[
+        "Programming Language :: Python :: 3",
+        "License :: OSI Approved :: BSD License",
+        "Operating System :: OS Independent",
+    ],
+)