diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2013-03-19 00:16:27 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2013-03-19 00:16:27 +0000 |
commit | da460d18fab3e9e8c864aae340ef4867d90483d6 (patch) | |
tree | 9e6d4ed7b2c9df8ce74d65a5ddc00114477adca9 /nuttx/arch/arm/src/sam3u | |
parent | c3998d2feead04441a90dcd45c6a35f8477b7fd6 (diff) | |
download | px4-nuttx-da460d18fab3e9e8c864aae340ef4867d90483d6.tar.gz px4-nuttx-da460d18fab3e9e8c864aae340ef4867d90483d6.tar.bz2 px4-nuttx-da460d18fab3e9e8c864aae340ef4867d90483d6.zip |
In KERNEL mode, need to explicitly set the privilege in the CONTROL register on return from exceptions
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5757 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/arch/arm/src/sam3u')
-rw-r--r-- | nuttx/arch/arm/src/sam3u/sam3u_vectors.S | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/nuttx/arch/arm/src/sam3u/sam3u_vectors.S b/nuttx/arch/arm/src/sam3u/sam3u_vectors.S index eba6edd3a..baaeb54b9 100644 --- a/nuttx/arch/arm/src/sam3u/sam3u_vectors.S +++ b/nuttx/arch/arm/src/sam3u/sam3u_vectors.S @@ -42,6 +42,8 @@ #include <arch/irq.h> +#include "exc_return.h" + /************************************************************************************************ * Preprocessor Definitions ************************************************************************************************/ @@ -236,7 +238,7 @@ sam3u_common: #ifdef CONFIG_NUTTX_KERNEL /* The EXC_RETURN value will be 0xfffffff9 (privileged thread) or 0xfffffff1 - * (handler mode) if the state is on the MSP. It can only be on the PSP if + * (handler mode) if the stack is on the MSP. It can only be on the PSP if * EXC_RETURN is 0xfffffffd (unprivileged thread) */ @@ -378,16 +380,25 @@ sam3u_common: * r4-r11 = restored register values */ 2: + #ifdef CONFIG_NUTTX_KERNEL /* The EXC_RETURN value will be 0xfffffff9 (privileged thread) or 0xfffffff1 - * (handler mode) if the state is on the MSP. It can only be on the PSP if + * (handler mode) if the stack is on the MSP. It can only be on the PSP if * EXC_RETURN is 0xfffffffd (unprivileged thread) */ - adds r0, r14, #3 /* If R14=0xfffffffd, then r0 == 0 */ - ite ne /* Next two instructions are condition */ - msrne msp, r1 /* R1=The main stack pointer */ - msreq psp, r1 /* R1=The process stack pointer */ + mrs r2, control /* R2=Contents of the control register */ + tst r14, #EXC_RETURN_PROCESS_STACK /* nonzero if context on process stack */ + beq 3f /* Branch if privileged */ + + orr r2, r2, #1 /* Unprivileged mode */ + msr psp, r1 /* R1=The process stack pointer */ + b 4f +3: + bic r2, r2, #1 /* Privileged mode */ + msr msp, r1 /* R1=The main stack pointer */ +4: + msr control, r2 /* Save the updated control register */ #else msr msp, r1 /* Recover the return MSP value */ |