Revert "SPM: Use flag to indicate NS Agent"

This reverts commit 27f9a49508547320c50056a52a372674c27771eb.

Reason for revert: Breaks dual-core. Will re-submit it as part of agent update later.

Change-Id: I7532570476c8d543297c7f6f2e871413d5e77221
diff --git a/secure_fw/spm/cmsis_psa/spm_ipc.c b/secure_fw/spm/cmsis_psa/spm_ipc.c
index 389517a..0d8b087 100755
--- a/secure_fw/spm/cmsis_psa/spm_ipc.c
+++ b/secure_fw/spm/cmsis_psa/spm_ipc.c
@@ -520,7 +520,12 @@
 bool tfm_spm_is_ns_caller(void)
 {
     struct partition_t *partition = GET_CURRENT_COMPONENT();
-    return !!(partition->p_ldinf->flags & PARTITION_NON_SECURE_AGENT);
+
+    if (!partition) {
+        tfm_core_panic();
+    }
+
+    return (partition->p_ldinf->pid == TFM_SP_NON_SECURE_ID);
 }
 
 int32_t tfm_spm_get_client_id(bool ns_caller)
diff --git a/secure_fw/spm/ffm/backend_ipc.c b/secure_fw/spm/ffm/backend_ipc.c
index 69e956d..48c7899 100644
--- a/secure_fw/spm/ffm/backend_ipc.c
+++ b/secure_fw/spm/ffm/backend_ipc.c
@@ -116,7 +116,7 @@
               TO_THREAD_PRIORITY(PARTITION_PRIORITY(p_pldi->flags)));
 
 #if defined(CONFIG_TFM_PSA_API_CROSS_CALL) && !defined(TFM_MULTI_CORE_TOPOLOGY)
-    if (p_pldi->flags & PARTITION_NON_SECURE_AGENT) {
+    if (p_pldi->pid == TFM_SP_NON_SECURE_ID) {
         SPM_THREAD_CONTEXT = &p_pt->ctx_ctrl;
     }
 #endif
diff --git a/secure_fw/spm/ffm/backend_sfn.c b/secure_fw/spm/ffm/backend_sfn.c
index e196438..b84c307 100644
--- a/secure_fw/spm/ffm/backend_sfn.c
+++ b/secure_fw/spm/ffm/backend_sfn.c
@@ -109,7 +109,7 @@
                LOAD_ALLOCED_STACK_ADDR(p_pldi) + p_pldi->stack_size);
 
         /* SPM reuses the ns agent stack, use once only at initialization. */
-        if (p_pldi->flags & PARTITION_NON_SECURE_AGENT) {
+        if (p_pldi->pid == TFM_SP_NON_SECURE_ID) {
             spm_stack_limit = p_pt->ctx_ctrl.sp_limit;
             spm_stack_base = p_pt->ctx_ctrl.sp;
         }
diff --git a/secure_fw/spm/include/load/partition_defs.h b/secure_fw/spm/include/load/partition_defs.h
index 3ad20b1..78e2f18 100644
--- a/secure_fw/spm/include/load/partition_defs.h
+++ b/secure_fw/spm/include/load/partition_defs.h
@@ -23,10 +23,9 @@
 
 /*
  * Partition load data - flags
- * bit [7-0]: priority
- * bit   [8]: '1' for PSA RoT domain; '0' for APP RoT domain.
- * bit   [9]: '1' for IPC model partition; '0' for SFN model partition.
- * bit  [10]: '1' indicates partition accesses NSPE; '0' for common partition.
+ * bit 7-0: priority
+ * bit 8: 1 - PSA_ROT, 0 - APP_ROT
+ * bit 9: 1 - IPC model, 0 - SFN model
  */
 #define PARTITION_PRI_HIGHEST                   (0x0)
 #define PARTITION_PRI_HIGH                      (0xF)
@@ -35,11 +34,9 @@
 #define PARTITION_PRI_LOWEST                    (0xFF)
 #define PARTITION_PRI_MASK                      (0xFF)
 
-#define PARTITION_DOMAIN_PSA_ROT                (1U << 8)
+#define PARTITION_MODEL_PSA_ROT                 (1U << 8)
 #define PARTITION_MODEL_IPC                     (1U << 9)
 
-#define PARTITION_NON_SECURE_AGENT              (1U << 10)
-
 #define PARTITION_PRIORITY(flag)                ((flag) & PARTITION_PRI_MASK)
 #define TO_THREAD_PRIORITY(x)                   (x)
 
@@ -50,9 +47,9 @@
 #define REFERENCE_TO_PTR(x, t)                  (t)(x)
 
 #define IS_PARTITION_PSA_ROT(pldi)              (!!((pldi)->flags \
-                                                   & PARTITION_DOMAIN_PSA_ROT))
+                                                     & PARTITION_MODEL_PSA_ROT))
 #define IS_PARTITION_IPC_MODEL(pldi)            (!!((pldi)->flags \
-                                                   & PARTITION_MODEL_IPC))
+                                                         & PARTITION_MODEL_IPC))
 
 /*
  * Common partition structure type, the extendable data is right after it.