Tools: Update manifest parse tools for SFN

Change-Id: I50ea7e21cec5ab39c262827c0b3e15bc2603fce6
Signed-off-by: Shawn Shan <Shawn.Shan@arm.com>
diff --git a/secure_fw/partitions/manifestfilename.template b/secure_fw/partitions/manifestfilename.template
index d0b2e9a..a1a5f15 100644
--- a/secure_fw/partitions/manifestfilename.template
+++ b/secure_fw/partitions/manifestfilename.template
@@ -16,10 +16,22 @@
 
 {% if attr.tfm_partition_ipc %}
     {% set ns = namespace(iterator_counter=0) %}
+    {% if manifest.psa_framework_version == 1.1 and manifest.model == "SFN" %}
+#define {{"%-55s"|format(manifest.name + "_MODEL_IPC")}} 0
+#define {{"%-55s"|format(manifest.name + "_MODEL_SFN")}} 1
+    {% else %}
+#define {{"%-55s"|format(manifest.name + "_MODEL_IPC")}} 1
+#define {{"%-55s"|format(manifest.name + "_MODEL_SFN")}} 0
+    {% endif %}
+
     {% if manifest.services %}
         {% for service in manifest.services %}
+            {% if manifest.psa_framework_version == 1.1 and manifest.model == "SFN" %}
+psa_status_t {{service.name|lower}}_sfn(const psa_msg_t* msg);
+            {% else %}
 #define {{"%-55s"|format(service.name + "_SIGNAL")}} (1U << ({{"%d"|format(ns.iterator_counter)}} + 4))
-            {% set ns.iterator_counter = ns.iterator_counter + 1 %}
+                {% set ns.iterator_counter = ns.iterator_counter + 1 %}
+            {% endif %}
         {% endfor %}
     {% endif %}
     {% if ns.iterator_counter > 28 %}
diff --git a/secure_fw/partitions/partition_load_info.template b/secure_fw/partitions/partition_load_info.template
index 6c40c55..54f9257 100644
--- a/secure_fw/partitions/partition_load_info.template
+++ b/secure_fw/partitions/partition_load_info.template
@@ -56,8 +56,19 @@
 #endif
 extern uint8_t {{manifest.name|lower}}_stack[];
 
+{% if manifest.entry_init and manifest.entry_point %}
+#error "Both manifest.entry_init and manifest.entry_point exist, unsupported!"
+{% elif (manifest.model == "IPC" or manifest.psa_framework_version == 1.0) and (not manifest.entry_point) %}
+#error "The entry_point attribute is required, it should not be empty!"
+{% elif manifest.model == "SFN" and manifest.entry_point %}
+#error "The entry_point attribute should not be exist in SFN mode!"
+{% endif %}
 /* Entrypoint function declaration */
+{% if manifest.entry_point %}
 extern void {{manifest.entry_point}}(void);
+{% elif manifest.entry_init %}
+extern psa_status_t {{manifest.entry_init}}(void);
+{% endif %}
 
 /* partition load info type definition */
 struct partition_{{manifest.name|lower}}_load_info_t {
@@ -97,9 +108,7 @@
 {% endif %}
         .pid                        = {{manifest.name}},
         .flags                      = 0
-{% if manifest.psa_framework_version == 1.0 and attr.tfm_partition_ipc is sameas true %}
-                                    | SPM_PART_FLAG_IPC
-{% elif manifest.psa_framework_version == 1.1 and manifest.model == "IPC" %}
+{% if (manifest.psa_framework_version == 1.1 and manifest.model == "IPC") or manifest.psa_framework_version == 1.0 %}
                                     | SPM_PART_FLAG_IPC
 {% endif %}
 {% if manifest.type == "PSA-ROT" %}
@@ -108,7 +117,13 @@
 #error "Unsupported type '{{manifest.type}}' for partition '{{manifest.name}}'!"
 {% endif %}
                                     | PARTITION_PRI_{{manifest.priority}},
+{% if manifest.entry_point %}
         .entry                      = ENTRY_TO_POSITION({{manifest.entry_point}}),
+{% elif manifest.entry_init %}
+        .entry                      = ENTRY_TO_POSITION({{manifest.entry_init}}),
+{% else %}
+        .entry                      = NULL,
+{% endif %}
         .stack_size                 = {{manifest.stack_size}},
         .heap_size                  = 0,
         .ndeps                      = {{(manifest.name|upper + "_NDEPS")}},
@@ -130,7 +145,11 @@
     {% for service in manifest.services %}
         {
             .name_strid             = STRING_PTR_TO_STRID("{{service.name}}"),
+{% if manifest.psa_framework_version == 1.1 and manifest.model == "SFN" %}
+            .sfn                    = ENTRY_TO_POSITION({{service.name|lower}}_sfn),
+{% else %}
             .signal                 = {{service.name}}_SIGNAL,
+{% endif %}
             .sid                    = {{service.sid}},
             .flags                  = 0
         {% if service.non_secure_clients is sameas true %}
diff --git a/secure_fw/spm/include/load/service_defs.h b/secure_fw/spm/include/load/service_defs.h
index 0dac420..6c97793 100644
--- a/secure_fw/spm/include/load/service_defs.h
+++ b/secure_fw/spm/include/load/service_defs.h
@@ -41,7 +41,10 @@
 /* Common service structure type */
 struct service_load_info_t {
     uintptr_t       name_strid;         /* String ID for name               */
-    psa_signal_t    signal;             /* Service signal                   */
+    union {
+        psa_signal_t    signal;         /* Service signal                   */
+        uintptr_t       sfn;            /* Secure Function                  */
+    };
     uint32_t        sid;                /* Service ID                       */
     uint32_t        flags;              /* Flags                            */
     uint32_t        version;            /* Service version                  */