Build: Build and arrange partition static data

- Add a template to generate partition static data into
  dedicated source files. For the ns internal partition,
  manually add a source file for it.
- Put these data into a dedicated memory section, to
  prepare for partition loading.

Change-Id: Iad988608b04d2db9f5f43e7528f3ef21c1252f31
Signed-off-by: Mingyang Sun <mingyang.sun@arm.com>
diff --git a/tools/tfm_parse_manifest_list.py b/tools/tfm_parse_manifest_list.py
index 1aea3ce..68b5979 100644
--- a/tools/tfm_parse_manifest_list.py
+++ b/tools/tfm_parse_manifest_list.py
@@ -75,6 +75,7 @@
 
     manifesttemplate = ENV.get_template('secure_fw/partitions/manifestfilename.template')
     memorytemplate = ENV.get_template('secure_fw/partitions/partition_intermedia.template')
+    infotemplate = ENV.get_template('secure_fw/partitions/partition_static_info.template')
 
     pid_list = []
     no_pid_manifest_idx = []
@@ -115,6 +116,7 @@
         context['file_name'] = outfile_name.replace('.h', '')
         outfile_name = os.path.join(manifest_dir, "psa_manifest", outfile_name).replace('\\', '/')
         intermediafile_name = os.path.join(manifest_dir, "auto_generated", 'intermedia_' + context['file_name'] + '.c').replace('\\', '/')
+        infofile_name = os.path.join(manifest_dir, "auto_generated", 'static_info_' + context['file_name'] + '.c').replace('\\', '/')
 
         """
         Remove the `source_path` portion of the filepaths, so that it can be
@@ -125,12 +127,14 @@
             source_path = os.path.expandvars(manifest_item['source_path'])
             outfile_name = os.path.relpath(outfile_name, start = source_path)
             intermediafile_name = os.path.relpath(intermediafile_name, start = source_path)
+            infofile_name = os.path.relpath(infofile_name, start = source_path)
 
         partition_db.append({"manifest": manifest, "attr": manifest_item, "header_file": outfile_name})
 
         if OUT_DIR is not None:
             outfile_name = os.path.join(OUT_DIR, outfile_name)
             intermediafile_name = os.path.join(OUT_DIR, intermediafile_name)
+            infofile_name = os.path.join(OUT_DIR, infofile_name)
 
         outfile_path = os.path.dirname(outfile_name)
         if not os.path.exists(outfile_path):
@@ -152,6 +156,16 @@
         memoutfile.write(memorytemplate.render(context))
         memoutfile.close()
 
+        infofile_path = os.path.dirname(infofile_name)
+        if not os.path.exists(infofile_path):
+            os.makedirs(infofile_path)
+
+        print ("Generating " + infofile_name)
+
+        info_outfile = io.open(infofile_name, "w", newline=None)
+        info_outfile.write(infotemplate.render(context))
+        info_outfile.close()
+
     return partition_db
 
 def gen_files(context, gen_file_lists):