Platform: Set PPC privilege based on RoT flags

Set 'privileged' attribute of PPC of peripherals used by secure
partitions based on Partition flags (e.g. App RoT / PSA RoT).

Change-Id: I2baf3a24f7c8c614630d3bc2f9e2fd24c6f46975
Signed-off-by: Mate Toth-Pal <mate.toth-pal@arm.com>
diff --git a/secure_fw/spm/spm_api.c b/secure_fw/spm/spm_api.c
index eda2ae3..f162890 100644
--- a/secure_fw/spm/spm_api.c
+++ b/secure_fw/spm/spm_api.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017-2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2017-2020, Arm Limited. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  *
@@ -89,6 +89,23 @@
             partition_flags;
 }
 
+uint32_t tfm_spm_partition_get_privileged_mode(uint32_t partition_flags)
+{
+    if (partition_flags & SPM_PART_FLAG_PSA_ROT) {
+        return TFM_PARTITION_PRIVILEGED_MODE;
+    } else {
+        return TFM_PARTITION_UNPRIVILEGED_MODE;
+    }
+}
+
+bool tfm_is_partition_privileged(uint32_t partition_idx)
+{
+    uint32_t flags = tfm_spm_partition_get_flags(partition_idx);
+
+    return tfm_spm_partition_get_privileged_mode(flags) ==
+        TFM_PARTITION_PRIVILEGED_MODE;
+}
+
 __attribute__((section("SFN")))
 void tfm_spm_partition_change_privilege(uint32_t privileged)
 {