Core: Create the privileged mode change function

Create the privileged mode change function to change the
privileged status for partition thread mode.

Change-Id: I68698bb99ef063655b70817364a0c60c19d5e5d0
Signed-off-by: Edison Ai <edison.ai@arm.com>
diff --git a/secure_fw/spm/spm_api.c b/secure_fw/spm/spm_api.c
index 02b3f07..a1ee127 100644
--- a/secure_fw/spm/spm_api.c
+++ b/secure_fw/spm/spm_api.c
@@ -388,3 +388,19 @@
     partition->runtime_data.orig_outvec = 0;
     partition->runtime_data.iovec_api = 0;
 }
+
+__attribute__((section("SFN")))
+void tfm_spm_partition_change_privilege(uint32_t privileged)
+{
+    CONTROL_Type ctrl;
+
+    ctrl.w = __get_CONTROL();
+
+    if (privileged == TFM_PARTITION_PRIVILEGED_MODE) {
+        ctrl.b.nPRIV = 0;
+    } else {
+        ctrl.b.nPRIV = 1;
+    }
+
+    __set_CONTROL(ctrl.w);
+}