SPM: Fix scheduling when NSPE was pre-empted

Commit 80326b7affe8 reversed the meaning of the configuration flag
CONFIG_TFM_SCHEDULE_WHEN_NS_INTERRUPTED, running the scheduler when the
flag was set to 0, and not running it when the flag was set to 1.

Also update the documentation to make it clear that the flag is 0/1.

Signed-off-by: Chris Brand <chris.brand@cypress.com>
Change-Id: I3723d36a00adf3641255eef22d9453c9b3688ad4
diff --git a/docs/configuration/index.rst b/docs/configuration/index.rst
index 72d48ae..2fe9f94 100644
--- a/docs/configuration/index.rst
+++ b/docs/configuration/index.rst
@@ -274,7 +274,7 @@
 +----------------------------------------+-----------+-------------+
 |CONFIG_TFM_DOORBELL_API                 | Component |   0         |
 +----------------------------------------+-----------+-------------+
-|CONFIG_TFM_SCHEDULE_WHEN_NS_INTERRUPTED | Component |   OFF       |
+|CONFIG_TFM_SCHEDULE_WHEN_NS_INTERRUPTED | Component |   0         |
 +----------------------------------------+-----------+-------------+
 
 --------------
diff --git a/secure_fw/spm/cmsis_psa/arch/tfm_arch_v8m_base.c b/secure_fw/spm/cmsis_psa/arch/tfm_arch_v8m_base.c
index 8b8657a..c6a8368 100644
--- a/secure_fw/spm/cmsis_psa/arch/tfm_arch_v8m_base.c
+++ b/secure_fw/spm/cmsis_psa/arch/tfm_arch_v8m_base.c
@@ -10,6 +10,7 @@
 
 #include <inttypes.h>
 #include "compiler_ext_defs.h"
+#include "config_spm.h"
 #include "security_defs.h"
 #include "spm.h"
 #include "svc_num.h"
@@ -104,7 +105,7 @@
 #endif
         "   movs    r0, #"M2S(EXC_RETURN_S)"            \n"
         "   mov     r1, lr                              \n"
-#if CONFIG_TFM_SCHEDULE_WHEN_NS_INTERRUPTED == 1
+#if CONFIG_TFM_SCHEDULE_WHEN_NS_INTERRUPTED == 0
         "   tst     r0, r1                              \n" /* NS interrupted */
         "   beq     v8b_pendsv_exit                     \n" /* No schedule */
 #endif
diff --git a/secure_fw/spm/cmsis_psa/arch/tfm_arch_v8m_main.c b/secure_fw/spm/cmsis_psa/arch/tfm_arch_v8m_main.c
index ce0578d..6d0c619 100644
--- a/secure_fw/spm/cmsis_psa/arch/tfm_arch_v8m_main.c
+++ b/secure_fw/spm/cmsis_psa/arch/tfm_arch_v8m_main.c
@@ -11,6 +11,7 @@
 #include <inttypes.h>
 
 #include "compiler_ext_defs.h"
+#include "config_spm.h"
 #include "security_defs.h"
 #include "region_defs.h"
 #include "spm.h"
@@ -105,7 +106,7 @@
 #endif
         "   movs    r0, #"M2S(EXC_RETURN_S)"            \n"
         "   ands    r0, lr                              \n" /* NS interrupted */
-#if CONFIG_TFM_SCHEDULE_WHEN_NS_INTERRUPTED == 1
+#if CONFIG_TFM_SCHEDULE_WHEN_NS_INTERRUPTED == 0
         "   beq     v8m_pendsv_exit                     \n" /* No schedule */
 #endif
         "   push    {r0, lr}                            \n" /* Save R0, LR */