Build: Fix library model build warnings

There are some redefination warnings when building TF_M library model.
This patch made the following changes:

- Rename "SPM_PART_FLAG_PSA_ROT" to "PARTITION_MODEL_PSA_ROT".
- Move "TFM_PARTITION_UNPRIVILEGED_MODE" and
  "TFM_PARTITION_PRIVILEGED_MODE" from partition_define.h to spm_ipc.h.

Change-Id: I2b40fdfe8c1578ca3d08145d3b834c37859efb87
Signed-off-by: Shawn Shan <Shawn.Shan@arm.com>
diff --git a/platform/ext/target/arm/mps2/an519/tfm_hal_isolation.c b/platform/ext/target/arm/mps2/an519/tfm_hal_isolation.c
index 41b4d9c..b474f40 100644
--- a/platform/ext/target/arm/mps2/an519/tfm_hal_isolation.c
+++ b/platform/ext/target/arm/mps2/an519/tfm_hal_isolation.c
@@ -174,7 +174,7 @@
 #if TFM_LVL == 1
     privileged = true;
 #else
-    privileged = !!(p_ldinf->flags & SPM_PART_FLAG_PSA_ROT);
+    privileged = !!(p_ldinf->flags & PARTITION_MODEL_PSA_ROT);
 #endif
 
     p_asset = (const struct asset_desc_t *)LOAD_INFO_ASSET(p_ldinf);
diff --git a/platform/ext/target/arm/mps2/an521/tfm_hal_isolation.c b/platform/ext/target/arm/mps2/an521/tfm_hal_isolation.c
index 795b74c..99c08c8 100644
--- a/platform/ext/target/arm/mps2/an521/tfm_hal_isolation.c
+++ b/platform/ext/target/arm/mps2/an521/tfm_hal_isolation.c
@@ -264,7 +264,7 @@
 #if TFM_LVL == 1
     privileged = true;
 #else
-    privileged = !!(p_ldinf->flags & SPM_PART_FLAG_PSA_ROT);
+    privileged = !!(p_ldinf->flags & PARTITION_MODEL_PSA_ROT);
 #endif
 
     p_asset = (const struct asset_desc_t *)LOAD_INFO_ASSET(p_ldinf);
diff --git a/platform/ext/target/arm/mps3/an524/tfm_hal_isolation.c b/platform/ext/target/arm/mps3/an524/tfm_hal_isolation.c
index b09c95b..c8f6ba0 100644
--- a/platform/ext/target/arm/mps3/an524/tfm_hal_isolation.c
+++ b/platform/ext/target/arm/mps3/an524/tfm_hal_isolation.c
@@ -193,7 +193,7 @@
 #if TFM_LVL == 1
     privileged = true;
 #else
-    privileged = !!(p_ldinf->flags & SPM_PART_FLAG_PSA_ROT);
+    privileged = !!(p_ldinf->flags & PARTITION_MODEL_PSA_ROT);
 #endif
 
     p_asset = (const struct asset_desc_t *)LOAD_INFO_ASSET(p_ldinf);
diff --git a/platform/ext/target/arm/mps3/an547/tfm_hal_isolation.c b/platform/ext/target/arm/mps3/an547/tfm_hal_isolation.c
index 98bafe4..70d41e9 100644
--- a/platform/ext/target/arm/mps3/an547/tfm_hal_isolation.c
+++ b/platform/ext/target/arm/mps3/an547/tfm_hal_isolation.c
@@ -197,7 +197,7 @@
 #if TFM_LVL == 1
     privileged = true;
 #else
-    privileged = !!(p_ldinf->flags & SPM_PART_FLAG_PSA_ROT);
+    privileged = !!(p_ldinf->flags & PARTITION_MODEL_PSA_ROT);
 #endif
 
     p_asset = (const struct asset_desc_t *)LOAD_INFO_ASSET(p_ldinf);
diff --git a/platform/ext/target/arm/musca_b1/sse_200/tfm_hal_isolation.c b/platform/ext/target/arm/musca_b1/sse_200/tfm_hal_isolation.c
index 33cf205..9d7884d 100644
--- a/platform/ext/target/arm/musca_b1/sse_200/tfm_hal_isolation.c
+++ b/platform/ext/target/arm/musca_b1/sse_200/tfm_hal_isolation.c
@@ -290,7 +290,7 @@
 #if TFM_LVL == 1
     privileged = true;
 #else
-    privileged = !!(p_ldinf->flags & SPM_PART_FLAG_PSA_ROT);
+    privileged = !!(p_ldinf->flags & PARTITION_MODEL_PSA_ROT);
 #endif
 
     p_asset = (const struct asset_desc_t *)LOAD_INFO_ASSET(p_ldinf);
diff --git a/platform/ext/target/arm/musca_s1/tfm_hal_isolation.c b/platform/ext/target/arm/musca_s1/tfm_hal_isolation.c
index 6717ee2..eaf6039 100644
--- a/platform/ext/target/arm/musca_s1/tfm_hal_isolation.c
+++ b/platform/ext/target/arm/musca_s1/tfm_hal_isolation.c
@@ -196,7 +196,7 @@
 #if TFM_LVL == 1
     privileged = true;
 #else
-    privileged = !!(p_ldinf->flags & SPM_PART_FLAG_PSA_ROT);
+    privileged = !!(p_ldinf->flags & PARTITION_MODEL_PSA_ROT);
 #endif
 
     p_asset = (const struct asset_desc_t *)LOAD_INFO_ASSET(p_ldinf);
diff --git a/platform/ext/target/cypress/psoc64/tfm_hal_isolation.c b/platform/ext/target/cypress/psoc64/tfm_hal_isolation.c
index 098e639..b83f0c0 100644
--- a/platform/ext/target/cypress/psoc64/tfm_hal_isolation.c
+++ b/platform/ext/target/cypress/psoc64/tfm_hal_isolation.c
@@ -75,7 +75,7 @@
 #if TFM_LVL == 1
     privileged = true;
 #else
-    privileged = !!(p_ldinf->flags & SPM_PART_FLAG_PSA_ROT);
+    privileged = !!(p_ldinf->flags & PARTITION_MODEL_PSA_ROT);
 #endif
 
     p_asset = (const struct asset_desc_t *)LOAD_INFO_ASSET(p_ldinf);
diff --git a/platform/ext/target/nxp/common/tfm_hal_isolation.c b/platform/ext/target/nxp/common/tfm_hal_isolation.c
index 5d94427..b6b337f 100644
--- a/platform/ext/target/nxp/common/tfm_hal_isolation.c
+++ b/platform/ext/target/nxp/common/tfm_hal_isolation.c
@@ -333,7 +333,7 @@
 #if TFM_LVL == 1
     privileged = true;
 #else
-    privileged = !!(p_ldinf->flags & SPM_PART_FLAG_PSA_ROT);
+    privileged = !!(p_ldinf->flags & PARTITION_MODEL_PSA_ROT);
 #endif
     p_asset = (const struct asset_desc_t *)LOAD_INFO_ASSET(p_ldinf);
     /*
diff --git a/platform/ext/target/stm/common/stm32l5xx/secure/tfm_hal_isolation.c b/platform/ext/target/stm/common/stm32l5xx/secure/tfm_hal_isolation.c
index cfaf05f..464d6e2 100644
--- a/platform/ext/target/stm/common/stm32l5xx/secure/tfm_hal_isolation.c
+++ b/platform/ext/target/stm/common/stm32l5xx/secure/tfm_hal_isolation.c
@@ -267,7 +267,7 @@
 #if TFM_LVL == 1
     privileged = true;
 #else
-    privileged = !!(p_ldinf->flags & SPM_PART_FLAG_PSA_ROT);
+    privileged = !!(p_ldinf->flags & PARTITION_MODEL_PSA_ROT);
 #endif
 
     p_asset = (const struct asset_desc_t *)LOAD_INFO_ASSET(p_ldinf);
diff --git a/platform/ext/target/stm/common/stm32u5xx/secure/tfm_hal_isolation.c b/platform/ext/target/stm/common/stm32u5xx/secure/tfm_hal_isolation.c
index 76e3960..dba9903 100644
--- a/platform/ext/target/stm/common/stm32u5xx/secure/tfm_hal_isolation.c
+++ b/platform/ext/target/stm/common/stm32u5xx/secure/tfm_hal_isolation.c
@@ -348,7 +348,7 @@
 #if TFM_LVL == 1
     privileged = true;
 #else
-    privileged = !!(p_ldinf->flags & SPM_PART_FLAG_PSA_ROT);
+    privileged = !!(p_ldinf->flags & PARTITION_MODEL_PSA_ROT);
 #endif
 
     p_asset = (const struct asset_desc_t *)LOAD_INFO_ASSET(p_ldinf);
diff --git a/secure_fw/partitions/idle_partition/load_info_idle_sp.c b/secure_fw/partitions/idle_partition/load_info_idle_sp.c
index d87db7b..eba22b6 100644
--- a/secure_fw/partitions/idle_partition/load_info_idle_sp.c
+++ b/secure_fw/partitions/idle_partition/load_info_idle_sp.c
@@ -38,7 +38,7 @@
         .psa_ff_ver                 = 0x0101 | PARTITION_INFO_MAGIC,
         .pid                        = TFM_SP_IDLE_ID,
         .flags                      = PARTITION_PRI_LOWEST | PARTITION_MODEL_IPC
-                                      | SPM_PART_FLAG_PSA_ROT,
+                                      | PARTITION_MODEL_PSA_ROT,
         .entry                      = ENTRY_TO_POSITION(tfm_idle_thread),
         .stack_size                 = IDLE_SP_STACK_SIZE,
         .heap_size                  = 0,
diff --git a/secure_fw/partitions/ns_agent/load_info_ns_agent.c b/secure_fw/partitions/ns_agent/load_info_ns_agent.c
index 1eb7cf5..94f7e4c 100644
--- a/secure_fw/partitions/ns_agent/load_info_ns_agent.c
+++ b/secure_fw/partitions/ns_agent/load_info_ns_agent.c
@@ -53,7 +53,7 @@
         .flags                      = (PARTITION_PRI_LOWEST - 1)
                                     | PARTITION_MODEL_IPC
 #if TFM_MULTI_CORE_TOPOLOGY
-                                    | SPM_PART_FLAG_PSA_ROT
+                                    | PARTITION_MODEL_PSA_ROT
 #endif
                                     ,
         .entry                      = ENTRY_TO_POSITION(tfm_nspm_thread_entry),
diff --git a/secure_fw/spm/cmsis_psa/spm_ipc.c b/secure_fw/spm/cmsis_psa/spm_ipc.c
index 054ee11..d78c49c 100644
--- a/secure_fw/spm/cmsis_psa/spm_ipc.c
+++ b/secure_fw/spm/cmsis_psa/spm_ipc.c
@@ -259,7 +259,7 @@
 #if TFM_LVL == 1
     return TFM_PARTITION_PRIVILEGED_MODE;
 #else /* TFM_LVL == 1 */
-    if (partition_flags & SPM_PART_FLAG_PSA_ROT) {
+    if (partition_flags & PARTITION_MODEL_PSA_ROT) {
         return TFM_PARTITION_PRIVILEGED_MODE;
     } else {
         return TFM_PARTITION_UNPRIVILEGED_MODE;
diff --git a/secure_fw/spm/cmsis_psa/spm_ipc.h b/secure_fw/spm/cmsis_psa/spm_ipc.h
index 2de04a9..cab522f 100644
--- a/secure_fw/spm/cmsis_psa/spm_ipc.h
+++ b/secure_fw/spm/cmsis_psa/spm_ipc.h
@@ -22,6 +22,10 @@
 
 #define TFM_CONN_HANDLE_MAX_NUM         16
 
+/* Privileged definitions for partition thread mode */
+#define TFM_PARTITION_UNPRIVILEGED_MODE         (0U)
+#define TFM_PARTITION_PRIVILEGED_MODE           (1U)
+
 /*
  * Set a number limit for stateless handle.
  * Valid handle must be positive, set client handle minimum value to 1.
diff --git a/secure_fw/spm/include/load/partition_defs.h b/secure_fw/spm/include/load/partition_defs.h
index a427c5b..88ca9f8 100644
--- a/secure_fw/spm/include/load/partition_defs.h
+++ b/secure_fw/spm/include/load/partition_defs.h
@@ -21,10 +21,6 @@
 #define PARTITION_INFO_MAGIC_MASK               (0xFFFF0000)
 #define PARTITION_INFO_MAGIC                    (0x5F5F0000)
 
-/* Privileged definitions for partition thread mode */
-#define TFM_PARTITION_UNPRIVILEGED_MODE         (0U)
-#define TFM_PARTITION_PRIVILEGED_MODE           (1U)
-
 /*
  * Partition load data - flags
  * bit 7-0: priority
@@ -38,9 +34,7 @@
 #define PARTITION_PRI_LOWEST                    (0xFF)
 #define PARTITION_PRI_MASK                      (0xFF)
 
-/* TODO: This def couples with library model, rename it later. */
-#define SPM_PART_FLAG_PSA_ROT                   (1U << 8)
-
+#define PARTITION_MODEL_PSA_ROT                 (1U << 8)
 #define PARTITION_MODEL_IPC                     (1U << 9)
 
 #define PARTITION_PRIORITY(flag)                ((flag) & PARTITION_PRI_MASK)
diff --git a/tools/templates/partition_load_info.template b/tools/templates/partition_load_info.template
index 87764dc..9dc43c5 100644
--- a/tools/templates/partition_load_info.template
+++ b/tools/templates/partition_load_info.template
@@ -114,7 +114,7 @@
                                     | PARTITION_MODEL_IPC
 {% endif %}
 {% if manifest.type == "PSA-ROT" %}
-                                    | SPM_PART_FLAG_PSA_ROT
+                                    | PARTITION_MODEL_PSA_ROT
 {% elif manifest.type != "APPLICATION-ROT" %}
 #error "Unsupported type '{{manifest.type}}' for partition '{{manifest.name}}'!"
 {% endif %}