summaryrefslogtreecommitdiff
path: root/nuttx
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2010-10-31 17:08:05 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2010-10-31 17:08:05 +0000
commitd4f68df6c899491fe189a1761cb247cbcc3b45da (patch)
tree7f0639c4e1ddc2606a42280e4f950a66fd118122 /nuttx
parentd340df87111d2c9ba81ec5c9773d481896717c51 (diff)
downloadpx4-nuttx-d4f68df6c899491fe189a1761cb247cbcc3b45da.tar.gz
px4-nuttx-d4f68df6c899491fe189a1761cb247cbcc3b45da.tar.bz2
px4-nuttx-d4f68df6c899491fe189a1761cb247cbcc3b45da.zip
Some context switch fixes
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3066 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx')
-rwxr-xr-xnuttx/arch/avr/src/avr32/up_fullcontextrestore.S53
-rw-r--r--nuttx/arch/avr/src/avr32/up_initialstate.c4
-rw-r--r--nuttx/sched/task_create.c2
-rw-r--r--nuttx/sched/task_setup.c2
4 files changed, 38 insertions, 23 deletions
diff --git a/nuttx/arch/avr/src/avr32/up_fullcontextrestore.S b/nuttx/arch/avr/src/avr32/up_fullcontextrestore.S
index 02c33adfd..c40239307 100755
--- a/nuttx/arch/avr/src/avr32/up_fullcontextrestore.S
+++ b/nuttx/arch/avr/src/avr32/up_fullcontextrestore.S
@@ -67,43 +67,52 @@
up_fullcontextrestore:
/* Initially, r12 points to the r7 save area. Restore r0-r7. */
- /* 07 06 05 04 03 02 01 00 xx xx xx xx xx xx xx xx xx */
- /* ^r12 */
+ /* regs: 07 06 05 04 03 02 01 00 xx xx xx xx xx xx xx xx xx */
+ /* ^r12 */
ldm r12++, r0-r7
/* Now, r12 points to the SP (r13) save area. Recover the value of */
/* the stack pointer (r13). We will need to save some temporaries on */
/* the final stack. */
- /* 07 06 05 04 03 02 01 00 SP xx xx xx xx xx xx xx xx */
- /* ^r12 */
+ /* regs: 07 06 05 04 03 02 01 00 SP xx xx xx xx xx xx xx xx */
+ /* ^r12 */
ld.w sp, r12++
/* Now r12 points to the SR save area. Skip over the SR for now. */
- /* 07 06 05 04 03 02 01 00 SP xx xx xx xx xx xx xx xx */
- /* ^r12 */
+ /* regs: 07 06 05 04 03 02 01 00 SP xx xx xx xx xx xx xx xx */
+ /* ^r12 */
- sub r12, -2*4
+ sub r12, -1*4
- /* Get the pc, lr, and r12 (in r8, r9, and r10) and move them to the */
+ /* Get the pc, lr, and r12 (in r10, r9, and r8) and move them to the */
/* stack. We can now use r12 and lr as scratch registers. */
- /* 07 06 05 04 03 02 01 00 SP xx PC LR 12 xx xx xx xx */
- /* ^r12 */
+ /* regs: 07 06 05 04 03 02 01 00 SP xx PC LR 12 xx xx xx xx */
+ /* ^r12 */
+ /* stack: lr, r12, pc */
+ /* ^sp */
- ldm r12++, r8-r10
- stm --sp, r8-r10
+ ldm r12++, r8-r10 /* Get r10=pc, r9=lr, r8=r12 */
+
+#if 0 /* See comments below */
+ stm --sp, r8-r10 /* Save r12, lr, and pc from the stack */
+#else
+ st.w --sp, r10 /* Save R10=PC on the stack */
+ st.w --sp, r8 /* Save R8=r12 on the stack */
+ st.w --sp, r9 /* Save R9=lr on the stack */
+#endif
/* Now r12 now points to the r11 save area. Restore r8-r11. */
- /* 07 06 05 04 03 02 01 00 SP xx PC LR 12 11 10 09 08 */
- /* ^r12 */
+ /* regs: 07 06 05 04 03 02 01 00 SP xx PC LR 12 11 10 09 08 */
+ /* ^r12 */
ldm r12++, r8-r11
/* r12 now points +4 beyond the end of the register save area. Restore */
/* SR. NOTE: This may enable interrupts! */
- /* 07 06 05 04 03 02 01 00 SP SR PC LR 12 11 10 09 08 */
- /* ^r12-4*8 ^r12 */
+ /* regs: 07 06 05 04 03 02 01 00 SP SR PC LR 12 11 10 09 08 */
+ /* ^r12-4*8 ^r12 */
ld.w lr, r12[-4*8]
mtsr AVR32_SR, lr
@@ -111,8 +120,14 @@ up_fullcontextrestore:
/* Restore PC, LR and r12. Hmmm.. I need to study the behaviour of ldm */
/* when r12,lr, and pc on in ldm reglist16. I'm not sure that I want */
/* that behavior. */
+ /* stack: lr, r12, pc */
+ /* ^sp */
-/* ldm sp++, r12, lr, pc */
- ldm sp++, r12, lr
- ld.w pc, sp++
+#if 0
+ ldm sp++, r12, lr, pc /* Restore r12, lr, and pc from the stack */
+#else
+ ld.w lr, sp++ /* Recover lr from the stack */
+ ld.w r12, sp++ /* Recover r12 from the stack */
+ ld.w pc, sp++ /* Jump to the address on the stack */
+#endif
.end
diff --git a/nuttx/arch/avr/src/avr32/up_initialstate.c b/nuttx/arch/avr/src/avr32/up_initialstate.c
index a9bf1a3ac..c160270d9 100644
--- a/nuttx/arch/avr/src/avr32/up_initialstate.c
+++ b/nuttx/arch/avr/src/avr32/up_initialstate.c
@@ -111,9 +111,9 @@ void up_initial_state(_TCB *tcb)
/* Enable or disable interrupts, based on user configuration */
# ifdef CONFIG_SUPPRESS_INTERRUPTS
- xcp->regs[REG_SR] = ;
+ xcp->regs[REG_SR] = avr32_sr() | AVR32_SR_GM_MASK;
# else
- xcp->regs[REG_SR] = 0;
+ xcp->regs[REG_SR] = avr32_sr() & ~AVR32_SR_GM_MASK;
# endif
}
diff --git a/nuttx/sched/task_create.c b/nuttx/sched/task_create.c
index 247183eca..d70f337c0 100644
--- a/nuttx/sched/task_create.c
+++ b/nuttx/sched/task_create.c
@@ -1,7 +1,7 @@
/****************************************************************************
* sched/task_create.c
*
- * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007-2010 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
diff --git a/nuttx/sched/task_setup.c b/nuttx/sched/task_setup.c
index 61ca424f0..217bdc892 100644
--- a/nuttx/sched/task_setup.c
+++ b/nuttx/sched/task_setup.c
@@ -1,7 +1,7 @@
/****************************************************************************
* sched/task_setup.c
*
- * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007-2010 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without