Build: Create pid.h file

- Create the partition ID header file by tools, which is used for macro
  definitions that map from Secure Partition names to Secure Partition
  IDs.
- The partition ID is added to the "tfm_manifest_list.yaml" manually so
  that the values will keep the same if the build sequence of secure
  partition is changed.
- The "short_name" in "tfm_manifest_list.yaml" should be the same as the
  "name" in the related manifest.

Change-Id: I0955a700e2a0c195f97c38c3ceb29f3b8c237674
Signed-off-by: Edison Ai <edison.ai@arm.com>
diff --git a/interface/include/psa_manifest/pid.h b/interface/include/psa_manifest/pid.h
new file mode 100644
index 0000000..42eeab3
--- /dev/null
+++ b/interface/include/psa_manifest/pid.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2019, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+/*********** WARNING: This is an auto-generated file. Do not edit! ***********/
+
+#ifndef __PSA_MANIFEST_PID_H__
+#define __PSA_MANIFEST_PID_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define TFM_SP_STORAGE                                                 (256)
+#define TFM_SP_ITS                                                     (257)
+#define TFM_SP_AUDIT_LOG                                               (258)
+#define TFM_SP_CRYPTO                                                  (259)
+#define TFM_SP_PLATFORM                                                (260)
+#define TFM_SP_INITIAL_ATTESTATION                                     (261)
+#define TFM_SP_CORE_TEST                                               (262)
+#define TFM_SP_CORE_TEST_2                                             (263)
+#define TFM_SP_SECURE_TEST_PARTITION                                   (264)
+#define TFM_SP_IPC_SERVICE_TEST                                        (265)
+#define TFM_SP_IPC_CLIENT_TEST                                         (266)
+#define TFM_IRQ_TEST_1                                                 (267)
+
+#define TFM_MAX_USER_PARTITIONS                                        (12)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __PSA_MANIFEST_PID_H__ */
diff --git a/interface/include/psa_manifest/pid.h.template b/interface/include/psa_manifest/pid.h.template
new file mode 100644
index 0000000..f5381f6
--- /dev/null
+++ b/interface/include/psa_manifest/pid.h.template
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2019, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+{{utilities.donotedit_warning}}
+
+#ifndef __PSA_MANIFEST_PID_H__
+#define __PSA_MANIFEST_PID_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+{% for manifest in manifests %}
+    {% if manifest.attr.pid - 256 < 0 %}
+#error "Partition ID for '{{manifest.manifest.name}}' have to be at least TFM_SP_BASE"
+    {% else %}
+#define {{"%-62s"|format(manifest.manifest.name)}} ({{manifest.attr.pid}})
+    {% endif %}
+{% endfor %}
+
+#define {{"%-62s"|format("TFM_MAX_USER_PARTITIONS")}} ({{manifests | length()}})
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __PSA_MANIFEST_PID_H__ */
diff --git a/tools/tfm_generated_file_list.yaml b/tools/tfm_generated_file_list.yaml
index 1f0f491..bef79e9 100644
--- a/tools/tfm_generated_file_list.yaml
+++ b/tools/tfm_generated_file_list.yaml
@@ -60,6 +60,11 @@
         "name": "SID H file",
         "short_name": "sid.h",
         "output": "interface/include/psa_manifest/sid.h"
+    },
+    {
+        "name": "PID H file",
+        "short_name": "pid.h",
+        "output": "interface/include/psa_manifest/pid.h"
     }
   ]
 }
diff --git a/tools/tfm_manifest_list.yaml b/tools/tfm_manifest_list.yaml
index 833fef6..c9432c7 100644
--- a/tools/tfm_manifest_list.yaml
+++ b/tools/tfm_manifest_list.yaml
@@ -13,119 +13,131 @@
   "manifest_list": [
     {
       "name": "Secure Storage Service",
-      "short_name": "SST",
+      "short_name": "TFM_SP_STORAGE",
       "manifest": "secure_fw/services/secure_storage/tfm_secure_storage.yaml",
       "tfm_extensions": true,
       "tfm_partition_ipc": true,
       "version_major": 0,
-      "version_minor": 1
+      "version_minor": 1,
+      "pid": 256
     },
     {
       "name": "TF-M Internal Trusted Storage Service",
-      "short_name": "TFM_ITS",
+      "short_name": "TFM_SP_ITS",
       "manifest": "secure_fw/services/internal_trusted_storage/tfm_internal_trusted_storage.yaml",
       "tfm_extensions": true,
       "tfm_partition_ipc": true,
       "version_major": 0,
-      "version_minor": 1
+      "version_minor": 1,
+      "pid": 257
     },
     {
       "name": "TFM Audit Log Service",
-      "short_name": "TFM_Audit_Log",
+      "short_name": "TFM_SP_AUDIT_LOG",
       "manifest": "secure_fw/services/audit_logging/tfm_audit_logging.yaml",
       "conditional": "TFM_PARTITION_AUDIT_LOG",
       "tfm_extensions": true,
       "tfm_partition_ipc": false,
       "version_major": 0,
-      "version_minor": 1
+      "version_minor": 1,
+      "pid": 258
     },
     {
       "name": "TFM Crypto Service",
-      "short_name": "TFM_Crypto",
+      "short_name": "TFM_SP_CRYPTO",
       "manifest": "secure_fw/services/crypto/tfm_crypto.yaml",
       "tfm_extensions": true,
       "tfm_partition_ipc": true,
       "version_major": 0,
-      "version_minor": 1
+      "version_minor": 1,
+      "pid": 259
     },
     {
       "name": "TFM Platform Service",
-      "short_name": "TFM_SP_Platform",
+      "short_name": "TFM_SP_PLATFORM",
       "manifest": "secure_fw/services/platform/tfm_platform.yaml",
       "tfm_extensions": true,
       "tfm_partition_ipc": false,
       "conditional": "TFM_PARTITION_PLATFORM",
       "version_major": 0,
-      "version_minor": 1
+      "version_minor": 1,
+      "pid": 260
     },
     {
       "name": "TFM Initial Attestation Service",
-      "short_name": "TFM_Init_Attest",
+      "short_name": "TFM_SP_INITIAL_ATTESTATION",
       "manifest": "secure_fw/services/initial_attestation/tfm_initial_attestation.yaml",
       "tfm_extensions": true,
       "tfm_partition_ipc": true,
       "version_major": 0,
-      "version_minor": 1
+      "version_minor": 1,
+      "pid": 261
     },
     {
       "name": "TFM Core Test Service",
-      "short_name": "TFM_Core_Test",
+      "short_name": "TFM_SP_CORE_TEST",
       "manifest": "test/test_services/tfm_core_test/tfm_test_core.yaml",
       "tfm_extensions": true,
       "tfm_partition_ipc": true,
       "conditional": "TFM_PARTITION_TEST_CORE",
       "version_major": 0,
-      "version_minor": 1
+      "version_minor": 1,
+      "pid": 262
     },
     {
       "name": "TFM Core Test Service 2",
-      "short_name": "TFM_Core_Test_2",
+      "short_name": "TFM_SP_CORE_TEST_2",
       "manifest": "test/test_services/tfm_core_test_2/tfm_test_core_2.yaml",
       "tfm_extensions": true,
       "tfm_partition_ipc": true,
       "conditional": "TFM_PARTITION_TEST_CORE",
       "version_major": 0,
-      "version_minor": 1
+      "version_minor": 1,
+      "pid": 263
     },
     {
       "name": "TFM Secure Client Service",
-      "short_name": "TFM_Secure_Client",
+      "short_name": "TFM_SP_SECURE_TEST_PARTITION",
       "manifest": "test/test_services/tfm_secure_client_service/tfm_test_client_service.yaml",
       "tfm_extensions": true,
       "tfm_partition_ipc": true,
       "conditional": "TFM_PARTITION_TEST_SECURE_SERVICES",
       "version_major": 0,
-      "version_minor": 1
+      "version_minor": 1,
+      "pid": 264
     },
     {
       "name": "TFM IPC Service Test",
-      "short_name": "TFM_IPC_Service",
+      "short_name": "TFM_SP_IPC_SERVICE_TEST",
       "manifest": "test/test_services/tfm_ipc_service/tfm_ipc_service_partition.yaml",
       "tfm_extensions": true,
       "tfm_partition_ipc": true,
       "conditional": "TFM_PARTITION_TEST_CORE_IPC",
       "version_major": 0,
-      "version_minor": 1
+      "version_minor": 1,
+      "pid": 265
     },
     {
       "name": "TFM IPC Client Service",
-      "short_name": "TFM_IPC_Client",
+      "short_name": "TFM_SP_IPC_CLIENT_TEST",
       "manifest": "test/test_services/tfm_ipc_client/tfm_ipc_client_partition.yaml",
       "tfm_extensions": true,
       "tfm_partition_ipc": true,
       "conditional": "TFM_PARTITION_TEST_CORE_IPC",
       "version_major": 0,
-      "version_minor": 1
+      "version_minor": 1,
+      "pid": 266
     },
     {
       "name": "TFM IRQ Test Service 1",
-      "short_name": "TFM_IRQ_Test_1",
+      "short_name": "TFM_IRQ_TEST_1",
       "manifest": "test/test_services/tfm_irq_test_service_1/tfm_irq_test_service_1.yaml",
       "tfm_extensions": true,
       "tfm_partition_ipc": true,
       "conditional": "TFM_ENABLE_IRQ_TEST",
       "version_major": 0,
-      "version_minor": 1
+      "version_minor": 1,
+      "pid": 267
     }
   ]
 }