diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2013-03-21 23:37:11 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2013-03-21 23:37:11 +0000 |
commit | 7406abbc5ac56892524846c8a19d2aabfc34eef4 (patch) | |
tree | 407cb38c04306722a9e3fb6136fa4e3058e22e5c | |
parent | 7fd81076443ca5685f38f02ecd926e8bda368c9b (diff) | |
download | px4-nuttx-7406abbc5ac56892524846c8a19d2aabfc34eef4.tar.gz px4-nuttx-7406abbc5ac56892524846c8a19d2aabfc34eef4.tar.bz2 px4-nuttx-7406abbc5ac56892524846c8a19d2aabfc34eef4.zip |
Corrections needed after further test of stack-based task arguments
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5771 42af7a65-404d-4744-a932-0658087f49c3
-rw-r--r-- | nuttx/arch/arm/src/common/up_stackframe.c | 13 | ||||
-rw-r--r-- | nuttx/arch/avr/src/avr/up_stackframe.c | 14 | ||||
-rw-r--r-- | nuttx/arch/avr/src/avr32/up_stackframe.c | 13 | ||||
-rw-r--r-- | nuttx/arch/hc/src/common/up_stackframe.c | 16 | ||||
-rw-r--r-- | nuttx/arch/mips/src/common/up_stackframe.c | 12 | ||||
-rw-r--r-- | nuttx/arch/rgmp/src/nuttx.c | 6 | ||||
-rw-r--r-- | nuttx/arch/sh/src/common/up_stackframe.c | 6 | ||||
-rw-r--r-- | nuttx/arch/sim/src/up_stackframe.c | 7 | ||||
-rw-r--r-- | nuttx/arch/x86/src/i486/up_stackframe.c | 13 | ||||
-rw-r--r-- | nuttx/arch/z16/src/common/up_stackframe.c | 13 | ||||
-rw-r--r-- | nuttx/arch/z80/src/common/up_stackframe.c | 6 | ||||
-rw-r--r-- | nuttx/sched/os_start.c | 15 | ||||
-rw-r--r-- | nuttx/sched/sched_releasetcb.c | 6 | ||||
-rw-r--r-- | nuttx/sched/sig_deliver.c | 7 | ||||
-rw-r--r-- | nuttx/sched/task_setup.c | 2 |
15 files changed, 121 insertions, 28 deletions
diff --git a/nuttx/arch/arm/src/common/up_stackframe.c b/nuttx/arch/arm/src/common/up_stackframe.c index f509556af..2a38f1db8 100644 --- a/nuttx/arch/arm/src/common/up_stackframe.c +++ b/nuttx/arch/arm/src/common/up_stackframe.c @@ -45,6 +45,7 @@ #include <debug.h> #include <nuttx/arch.h> +#include <arch/irq.h> #include "up_internal.h" @@ -136,9 +137,15 @@ FAR void *up_stack_frame(FAR struct tcb_s *tcb, size_t frame_size) /* Save the adjusted stack values in the struct tcb_s */ - topaddr = (uintptr_t)tcb->adj_stack_ptr - frame_size; - tcb->adj_stack_ptr = (FAR void *)topaddr; - tcb->adj_stack_size -= frame_size; + topaddr = (uintptr_t)tcb->adj_stack_ptr - frame_size; + tcb->adj_stack_ptr = (FAR void *)topaddr; + tcb->adj_stack_size -= frame_size; + + /* Reset the initial stack pointer */ + + tcb->xcp.regs[REG_SP] = (uint32_t)tcb->adj_stack_ptr; + + /* And return the pointer to the allocated region */ return (FAR void *)(topaddr + sizeof(uint32_t)); } diff --git a/nuttx/arch/avr/src/avr/up_stackframe.c b/nuttx/arch/avr/src/avr/up_stackframe.c index f9748f2e7..2a09f0550 100644 --- a/nuttx/arch/avr/src/avr/up_stackframe.c +++ b/nuttx/arch/avr/src/avr/up_stackframe.c @@ -45,6 +45,7 @@ #include <debug.h> #include <nuttx/arch.h> +#include <arch/irq.h> #include "up_internal.h" @@ -109,9 +110,16 @@ FAR void *up_stack_frame(FAR struct tcb_s *tcb, size_t frame_size) /* Save the adjusted stack values in the struct tcb_s */ - topaddr = (uintptr_t)tcb->adj_stack_ptr - frame_size; - tcb->adj_stack_ptr = (FAR void *)topaddr; - tcb->adj_stack_size -= frame_size; + topaddr = (uintptr_t)tcb->adj_stack_ptr - frame_size; + tcb->adj_stack_ptr = (FAR void *)topaddr; + tcb->adj_stack_size -= frame_size; + + /* Set the initial stack pointer to the "base" of the allocated stack */ + + tcb->xcp.regs[REG_SPH] = (uint8_t)((uint16_t)tcb->adj_stack_ptr >> 8); + tcb->xcp.regs[REG_SPL] = (uint8_t)((uint16_t)tcb->adj_stack_ptr & 0xff); + + /* And return the pointer to the allocated region */ return (FAR void *)(topaddr + sizeof(uint8_t)); } diff --git a/nuttx/arch/avr/src/avr32/up_stackframe.c b/nuttx/arch/avr/src/avr32/up_stackframe.c index d7c0a0fc3..a38370801 100644 --- a/nuttx/arch/avr/src/avr32/up_stackframe.c +++ b/nuttx/arch/avr/src/avr32/up_stackframe.c @@ -45,6 +45,7 @@ #include <debug.h> #include <nuttx/arch.h> +#include <arch/irq.h> #include "up_internal.h" @@ -125,9 +126,15 @@ FAR void *up_stack_frame(FAR struct tcb_s *tcb, size_t frame_size) /* Save the adjusted stack values in the struct tcb_s */ - topaddr = (uintptr_t)tcb->adj_stack_ptr - frame_size; - tcb->adj_stack_ptr = (FAR void *)topaddr; - tcb->adj_stack_size -= frame_size; + topaddr = (uintptr_t)tcb->adj_stack_ptr - frame_size; + tcb->adj_stack_ptr = (FAR void *)topaddr; + tcb->adj_stack_size -= frame_size; + + /* Reset the initial stack pointer */ + + tcb->xcp.regs[REG_SP] = (uint32_t)tcb->adj_stack_ptr; + + /* And return the pointer to the allocated region */ return (FAR void *)(topaddr + sizeof(uint32_t)); } diff --git a/nuttx/arch/hc/src/common/up_stackframe.c b/nuttx/arch/hc/src/common/up_stackframe.c index 266881ec5..bc3f996b2 100644 --- a/nuttx/arch/hc/src/common/up_stackframe.c +++ b/nuttx/arch/hc/src/common/up_stackframe.c @@ -45,6 +45,7 @@ #include <debug.h> #include <nuttx/arch.h> +#include <arch/irq.h> #include "up_internal.h" @@ -125,9 +126,16 @@ FAR void *up_stack_frame(FAR struct tcb_s *tcb, size_t frame_size) /* Save the adjusted stack values in the struct tcb_s */ - topaddr = (uintptr_t)tcb->adj_stack_ptr - frame_size; - tcb->adj_stack_ptr = (FAR void *)topaddr; - tcb->adj_stack_size -= frame_size; + topaddr = (uintptr_t)tcb->adj_stack_ptr - frame_size; + tcb->adj_stack_ptr = (FAR void *)topaddr; + tcb->adj_stack_size -= frame_size; - return (FAR void *)(topaddr + sizeof(uint32_t)); + /* Reset the initial stack pointer */ + + tcb->xcp.regs[REG_SPH] = (uint16_t)tcb->adj_stack_ptr >> 8; + tcb->xcp.regs[REG_SPL] = (uint16_t)tcb->adj_stack_ptr & 0xff; + + /* And return the pointer to the allocated region */ + + return (FAR void *)(topaddr + sizeof(uint16_t)); } diff --git a/nuttx/arch/mips/src/common/up_stackframe.c b/nuttx/arch/mips/src/common/up_stackframe.c index fd055d5e6..8f0fa66cd 100644 --- a/nuttx/arch/mips/src/common/up_stackframe.c +++ b/nuttx/arch/mips/src/common/up_stackframe.c @@ -128,9 +128,15 @@ FAR void *up_stack_frame(FAR struct tcb_s *tcb, size_t frame_size) /* Save the adjusted stack values in the struct tcb_s */ - topaddr = (uintptr_t)tcb->adj_stack_ptr - frame_size; - tcb->adj_stack_ptr = (FAR void *)topaddr; - tcb->adj_stack_size -= frame_size; + topaddr = (uintptr_t)tcb->adj_stack_ptr - frame_size; + tcb->adj_stack_ptr = (FAR void *)topaddr; + tcb->adj_stack_size -= frame_size; + + /* Reset the initial stack pointer */ + + tcb->xcp.regs[REG_SP] = (uint32_t)tcb->adj_stack_ptr; + + /* And return the pointer to the allocated region */ return (FAR void *)(topaddr + sizeof(uint32_t)); } diff --git a/nuttx/arch/rgmp/src/nuttx.c b/nuttx/arch/rgmp/src/nuttx.c index f218b3f18..da67ac214 100644 --- a/nuttx/arch/rgmp/src/nuttx.c +++ b/nuttx/arch/rgmp/src/nuttx.c @@ -189,6 +189,12 @@ FAR void *up_stack_frame(FAR struct tcb_s *tcb, size_t frame_size) tcb->adj_stack_ptr = (FAR void *)topaddr; tcb->adj_stack_size -= frame_size; + /* Reset the initial state */ + + up_initial_state(tcb); + + /* And return a pointer to the allocated memory region */ + return (FAR void *)(topaddr + sizeof(uint32_t)); } #endif diff --git a/nuttx/arch/sh/src/common/up_stackframe.c b/nuttx/arch/sh/src/common/up_stackframe.c index f3e7f294a..16837f62f 100644 --- a/nuttx/arch/sh/src/common/up_stackframe.c +++ b/nuttx/arch/sh/src/common/up_stackframe.c @@ -128,5 +128,11 @@ FAR void *up_stack_frame(FAR struct tcb_s *tcb, size_t frame_size) tcb->adj_stack_ptr = (FAR void *)topaddr; tcb->adj_stack_size -= frame_size; + /* Reset the initial state */ + + up_initial_state(tcb); + + /* And return a pointer to allocated memory */ + return (FAR void *)(topaddr + sizeof(uint32_t)); } diff --git a/nuttx/arch/sim/src/up_stackframe.c b/nuttx/arch/sim/src/up_stackframe.c index f634005cb..3fc481fca 100644 --- a/nuttx/arch/sim/src/up_stackframe.c +++ b/nuttx/arch/sim/src/up_stackframe.c @@ -45,6 +45,7 @@ #include <debug.h> #include <nuttx/arch.h> +#include <arch/irq.h> #include "up_internal.h" @@ -129,5 +130,11 @@ FAR void *up_stack_frame(FAR struct tcb_s *tcb, size_t frame_size) tcb->adj_stack_ptr = (FAR void *)topaddr; tcb->adj_stack_size -= frame_size; + /* Reset the initial state */ + + tcb->xcp.regs[JB_SP] = (uint32_t)tcb->adj_stack_ptr; + + /* And return a pointer to the allocated memory */ + return (FAR void *)(topaddr + sizeof(uint32_t)); } diff --git a/nuttx/arch/x86/src/i486/up_stackframe.c b/nuttx/arch/x86/src/i486/up_stackframe.c index f2ab91f95..d8884b790 100644 --- a/nuttx/arch/x86/src/i486/up_stackframe.c +++ b/nuttx/arch/x86/src/i486/up_stackframe.c @@ -45,6 +45,7 @@ #include <debug.h> #include <nuttx/arch.h> +#include <arch/irq.h> #include "up_internal.h" @@ -126,9 +127,15 @@ FAR void *up_stack_frame(FAR struct tcb_s *tcb, size_t frame_size) /* Save the adjusted stack values in the struct tcb_s */ - topaddr = (uintptr_t)tcb->adj_stack_ptr - frame_size; - tcb->adj_stack_ptr = (FAR void *)topaddr; - tcb->adj_stack_size -= frame_size; + topaddr = (uintptr_t)tcb->adj_stack_ptr - frame_size; + tcb->adj_stack_ptr = (FAR void *)topaddr; + tcb->adj_stack_size -= frame_size; + + /* Reset the initial stack pointer */ + + tcb->xcp.regs[REG_SP] = (uint32_t)tcb->adj_stack_ptr; + + /* And return the pointer to the allocated region */ return (FAR void *)(topaddr + sizeof(uint32_t)); } diff --git a/nuttx/arch/z16/src/common/up_stackframe.c b/nuttx/arch/z16/src/common/up_stackframe.c index 11eec6c2e..ea2d696c8 100644 --- a/nuttx/arch/z16/src/common/up_stackframe.c +++ b/nuttx/arch/z16/src/common/up_stackframe.c @@ -45,6 +45,7 @@ #include <debug.h> #include <nuttx/arch.h> +#include <arch/irq.h> #include "up_internal.h" @@ -124,9 +125,15 @@ FAR void *up_stack_frame(FAR struct tcb_s *tcb, size_t frame_size) /* Save the adjusted stack values in the struct tcb_s */ - topaddr = (uintptr_t)tcb->adj_stack_ptr - frame_size; - tcb->adj_stack_ptr = (FAR void *)topaddr; - tcb->adj_stack_size -= frame_size; + topaddr = (uintptr_t)tcb->adj_stack_ptr - frame_size; + tcb->adj_stack_ptr = (FAR void *)topaddr; + tcb->adj_stack_size -= frame_size; + + /* Reset the initial stack pointer */ + + tcb->xcp.regs[REG_SP/2] = (uint32_t)tcb->adj_stack_ptr; + + /* And return a pointer to the allocated memory */ return (FAR void *)(topaddr + sizeof(uint32_t)); } diff --git a/nuttx/arch/z80/src/common/up_stackframe.c b/nuttx/arch/z80/src/common/up_stackframe.c index 228311633..fdc43a850 100644 --- a/nuttx/arch/z80/src/common/up_stackframe.c +++ b/nuttx/arch/z80/src/common/up_stackframe.c @@ -128,5 +128,11 @@ FAR void *up_stack_frame(FAR struct tcb_s *tcb, size_t frame_size) tcb->adj_stack_ptr = (FAR void *)topaddr; tcb->adj_stack_size -= frame_size; + /* Reset the initial state */ + + up_initial_state(tcb); + + /* And return a pointer to the allocated memory */ + return (FAR void *)(topaddr + sizeof(uint32_t)); } diff --git a/nuttx/sched/os_start.c b/nuttx/sched/os_start.c index fbb3b7743..100c736b2 100644 --- a/nuttx/sched/os_start.c +++ b/nuttx/sched/os_start.c @@ -286,12 +286,27 @@ void os_start(void) g_idletcb.cmn.task_state = TSTATE_TASK_RUNNING; g_idletcb.cmn.entry.main = (main_t)os_start; + /* Set the IDLE task name */ + #if CONFIG_TASK_NAME_SIZE > 0 strncpy(g_idletcb.cmn.name, g_idlename, CONFIG_TASK_NAME_SIZE-1); +#endif /* CONFIG_TASK_NAME_SIZE */ + + /* Configure the task name in the argument list. The IDLE task does + * not really have an argument list, but this name is still useful + * for things like the NSH PS command. + * + * In the kernel mode build, the arguments are saved on the task's stack + * and there is no support that yet. + */ + +#if defined(CONFIG_CUSTOM_STACK) || !defined(CONFIG_NUTTX_KERNEL) +#if CONFIG_TASK_NAME_SIZE > 0 g_idletcb.argv[0] = g_idletcb.cmn.name; #else g_idletcb.argv[0] = (char*)g_idlename; #endif /* CONFIG_TASK_NAME_SIZE */ +#endif /* CONFIG_CUSTOM_STACK || !CONFIG_NUTTX_KERNEL */ /* Then add the idle task's TCB to the head of the ready to run list */ diff --git a/nuttx/sched/sched_releasetcb.c b/nuttx/sched/sched_releasetcb.c index cbb58002d..aefc5264d 100644 --- a/nuttx/sched/sched_releasetcb.c +++ b/nuttx/sched/sched_releasetcb.c @@ -101,7 +101,9 @@ static void sched_releasepid(pid_t pid) int sched_releasetcb(FAR struct tcb_s *tcb, uint8_t ttype) { int ret = OK; +#if defined(CONFIG_CUSTOM_STACK) || !defined(CONFIG_NUTTX_KERNEL) int i; +#endif if (tcb) { @@ -156,7 +158,7 @@ int sched_releasetcb(FAR struct tcb_s *tcb, uint8_t ttype) } #endif -#if !defined(CONFIG_CUSTOM_STACK) && defined(CONFIG_NUTTX_KERNEL) +#if defined(CONFIG_CUSTOM_STACK) || !defined(CONFIG_NUTTX_KERNEL) /* Release command line arguments that were allocated for task * start/re-start. * @@ -176,7 +178,7 @@ int sched_releasetcb(FAR struct tcb_s *tcb, uint8_t ttype) } } -#endif /* !CONFIG_CUSTOM_STACK && CONFIG_NUTTX_KERNEL */ +#endif /* CONFIG_CUSTOM_STACK || !CONFIG_NUTTX_KERNEL */ /* Release this thread's reference to the address environment */ diff --git a/nuttx/sched/sig_deliver.c b/nuttx/sched/sig_deliver.c index 9b1e8cebe..0b3dc9f4c 100644 --- a/nuttx/sched/sig_deliver.c +++ b/nuttx/sched/sig_deliver.c @@ -43,6 +43,7 @@ #include <signal.h> #include <unistd.h> #include <sched.h> +#include <string.h> #include <debug.h> #include <nuttx/arch.h> @@ -137,15 +138,15 @@ void sig_deliver(FAR struct tcb_s *stcb) if ((stcb->flags & TCB_FLAG_TTYPE_MASK) != TCB_FLAG_TTYPE_KERNEL) { /* The sigq_t pointed to by sigq resides in kernel space. So we - * cannot pass a reference to sigq->info to the user space. - * Instead, we will copy the siginfo_t structure onto that stack. + * cannot pass a reference to sigq->info to the user application. + * Instead, we will copy the siginfo_t structure onto the stack. * We are currently executing on the stack of the user thread * (albeit temporarily in kernel mode), so the copy of the * siginfo_t structure will be accessible by the user thread. */ siginfo_t info; - memcpy(&info, sigq->info, sizeof(siginfo_t)); + memcpy(&info, &sigq->info, sizeof(siginfo_t)); up_signal_handler(sigq->action.sighandler, sigq->info.si_signo, &info, NULL); diff --git a/nuttx/sched/task_setup.c b/nuttx/sched/task_setup.c index 85e828fd0..bed452759 100644 --- a/nuttx/sched/task_setup.c +++ b/nuttx/sched/task_setup.c @@ -545,7 +545,7 @@ static int task_stackargsetup(FAR struct task_tcb_s *tcb, { /* A NULL argument terminates the list */ - if (!tcb->argv[argc]) + if (!argv[argc]) { break; } |