summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2014-09-11 18:42:52 -0600
committerGregory Nutt <gnutt@nuttx.org>2014-09-11 18:42:52 -0600
commit3b02f22d162819dd4027ec7c7fa3b77790315cb3 (patch)
treeb2bd5e0f1ec6a57b62cc484ce2d38c19a87a1b3b
parente896f974831f25d7994cf12a2170c68a63879c4c (diff)
downloadnuttx-3b02f22d162819dd4027ec7c7fa3b77790315cb3.tar.gz
nuttx-3b02f22d162819dd4027ec7c7fa3b77790315cb3.tar.bz2
nuttx-3b02f22d162819dd4027ec7c7fa3b77790315cb3.zip
All tasks, even user mode tasks, must start in supervisor mode until they get past the start-up trampoline
-rw-r--r--nuttx/arch/arm/src/armv7-a/arm_initialstate.c27
1 files changed, 5 insertions, 22 deletions
diff --git a/nuttx/arch/arm/src/armv7-a/arm_initialstate.c b/nuttx/arch/arm/src/armv7-a/arm_initialstate.c
index 74205394c..c43e12d67 100644
--- a/nuttx/arch/arm/src/armv7-a/arm_initialstate.c
+++ b/nuttx/arch/arm/src/armv7-a/arm_initialstate.c
@@ -110,30 +110,14 @@ void up_initial_state(struct tcb_s *tcb)
}
#endif
- /* Set supervisor- or user-mode, depending on how NuttX is configured and
- * what kind of thread is being started. Disable FIQs in any event
- */
-
-#ifdef CONFIG_BUILD_KERNEL
- if ((tcb->flags & TCB_FLAG_TTYPE_MASK) == TCB_FLAG_TTYPE_KERNEL)
- {
- /* It is a kernel thread.. set supervisor mode */
-
- cpsr = PSR_MODE_SVC;
- }
- else
- {
- /* It is a normal task or a pthread. Set user mode */
-
- cpsr = PSR_MODE_USR;
- }
-#else
- /* If the kernel build is not selected, then all threads run in
- * supervisor-mode.
+ /* Set supervisor-mode and disable FIQs, regardless of how NuttX is
+ * configured and of what kind of thread is being started. That is
+ * because all threads, even user-mode threads will start in kernel
+ * trampoline at task_start() or pthread_start(). The thread's
+ * privileges will be dropped before transitioning to user code.
*/
cpsr = PSR_MODE_SVC;
-#endif
/* Enable or disable interrupts, based on user configuration */
@@ -154,4 +138,3 @@ void up_initial_state(struct tcb_s *tcb)
xcp->regs[REG_CPSR] = cpsr;
}
-