summaryrefslogtreecommitdiff
path: root/nuttx/arch/avr/src
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2013-03-20 18:22:21 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2013-03-20 18:22:21 +0000
commitfce497aecaf6826d6fec3cfcb761abeac7fe72bf (patch)
tree6d2f0d4610067c2b0e4c3f831274037c9ceba91a /nuttx/arch/avr/src
parent3d7ed16eabcbea16723b66df2cd2a7d10ba22474 (diff)
downloadpx4-nuttx-fce497aecaf6826d6fec3cfcb761abeac7fe72bf.tar.gz
px4-nuttx-fce497aecaf6826d6fec3cfcb761abeac7fe72bf.tar.bz2
px4-nuttx-fce497aecaf6826d6fec3cfcb761abeac7fe72bf.zip
Change prototypes of up_create_stack and up_release_stack to include a task type parameter
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5765 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/arch/avr/src')
-rw-r--r--nuttx/arch/avr/src/avr/up_createstack.c38
-rw-r--r--nuttx/arch/avr/src/avr/up_usestack.c24
-rw-r--r--nuttx/arch/avr/src/avr32/up_createstack.c38
-rw-r--r--nuttx/arch/avr/src/avr32/up_usestack.c21
-rw-r--r--nuttx/arch/avr/src/common/up_releasestack.c28
5 files changed, 109 insertions, 40 deletions
diff --git a/nuttx/arch/avr/src/avr/up_createstack.c b/nuttx/arch/avr/src/avr/up_createstack.c
index 1eb56f918..60f6dceec 100644
--- a/nuttx/arch/avr/src/avr/up_createstack.c
+++ b/nuttx/arch/avr/src/avr/up_createstack.c
@@ -70,24 +70,40 @@
* Name: up_create_stack
*
* Description:
- * Allocate a stack for a new thread and setup up stack-related
- * information in the TCB.
+ * Allocate a stack for a new thread and setup up stack-related information
+ * in the TCB.
*
- * The following TCB fields must be initialized:
- * adj_stack_size: Stack size after adjustment for hardware, processor,
+ * The following TCB fields must be initialized by this function:
+ *
+ * - adj_stack_size: Stack size after adjustment for hardware, processor,
* etc. This value is retained only for debug purposes.
- * stack_alloc_ptr: Pointer to allocated stack
- * adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The initial value of
+ * - stack_alloc_ptr: Pointer to allocated stack
+ * - adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The initial value of
* the stack pointer.
*
- * Input Parameters:
- * tcb: The TCB of new task
- * stack_size: The requested stack size. At least this how much must be
- * allocated.
+ * Inputs:
+ * - tcb: The TCB of new task
+ * - stack_size: The requested stack size. At least this much
+ * must be allocated.
+ * - ttype: The thread type. This may be one of following (defined in
+ * include/nuttx/sched.h):
+ *
+ * TCB_FLAG_TTYPE_TASK Normal user task
+ * TCB_FLAG_TTYPE_PTHREAD User pthread
+ * TCB_FLAG_TTYPE_KERNEL Kernel thread
+ *
+ * This thread type is normally available in the flags field of the TCB,
+ * however, there are certain contexts where the TCB may not be fully
+ * initialized when up_create_stack is called.
+ *
+ * If CONFIG_NUTTX_KERNEL is defined, then this thread type may affect
+ * how the stack is allocated. For example, kernel thread stacks should
+ * be allocated from protected kernel memory. Stacks for user tasks and
+ * threads must come from memory that is accessible to user code.
*
****************************************************************************/
-int up_create_stack(struct tcb_s *tcb, size_t stack_size)
+int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype)
{
/* Is there already a stack allocated of a different size? */
diff --git a/nuttx/arch/avr/src/avr/up_usestack.c b/nuttx/arch/avr/src/avr/up_usestack.c
index 22bdcf84e..ebd911fb2 100644
--- a/nuttx/arch/avr/src/avr/up_usestack.c
+++ b/nuttx/arch/avr/src/avr/up_usestack.c
@@ -67,18 +67,26 @@
*
* Description:
* Setup up stack-related information in the TCB using pre-allocated stack
- * memory
+ * memory. This function is called only from task_init() when a task or
+ * kernel thread is started (never for pthreads).
*
* The following TCB fields must be initialized:
- * adj_stack_size: Stack size after adjustment for hardware, processor,
- * etc. This value is retained only for debug purposes.
- * stack_alloc_ptr: Pointer to allocated stack
- * adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The initial value of
- * the stack pointer.
+ *
+ * - adj_stack_size: Stack size after adjustment for hardware,
+ * processor, etc. This value is retained only for debug
+ * purposes.
+ * - stack_alloc_ptr: Pointer to allocated stack
+ * - adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The
+ * initial value of the stack pointer.
*
* Inputs:
- * tcb: The TCB of new task
- * stack_size: The allocated stack size.
+ * - tcb: The TCB of new task
+ * - stack_size: The allocated stack size.
+ *
+ * NOTE: Unlike up_stack_create() and up_stack_release, this function
+ * does not require the task type (ttype) parameter. The TCB flags will
+ * always be set to provide the task type to up_use_stack() if it needs
+ * that information.
*
****************************************************************************/
diff --git a/nuttx/arch/avr/src/avr32/up_createstack.c b/nuttx/arch/avr/src/avr32/up_createstack.c
index 5d49f4977..da7e8788c 100644
--- a/nuttx/arch/avr/src/avr32/up_createstack.c
+++ b/nuttx/arch/avr/src/avr32/up_createstack.c
@@ -69,24 +69,40 @@
* Name: up_create_stack
*
* Description:
- * Allocate a stack for a new thread and setup up stack-related
- * information in the TCB.
+ * Allocate a stack for a new thread and setup up stack-related information
+ * in the TCB.
*
- * The following TCB fields must be initialized:
- * adj_stack_size: Stack size after adjustment for hardware, processor,
+ * The following TCB fields must be initialized by this function:
+ *
+ * - adj_stack_size: Stack size after adjustment for hardware, processor,
* etc. This value is retained only for debug purposes.
- * stack_alloc_ptr: Pointer to allocated stack
- * adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The initial value of
+ * - stack_alloc_ptr: Pointer to allocated stack
+ * - adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The initial value of
* the stack pointer.
*
- * Input Parameters:
- * tcb: The TCB of new task
- * stack_size: The requested stack size. At least this how much must be
- * allocated.
+ * Inputs:
+ * - tcb: The TCB of new task
+ * - stack_size: The requested stack size. At least this much
+ * must be allocated.
+ * - ttype: The thread type. This may be one of following (defined in
+ * include/nuttx/sched.h):
+ *
+ * TCB_FLAG_TTYPE_TASK Normal user task
+ * TCB_FLAG_TTYPE_PTHREAD User pthread
+ * TCB_FLAG_TTYPE_KERNEL Kernel thread
+ *
+ * This thread type is normally available in the flags field of the TCB,
+ * however, there are certain contexts where the TCB may not be fully
+ * initialized when up_create_stack is called.
+ *
+ * If CONFIG_NUTTX_KERNEL is defined, then this thread type may affect
+ * how the stack is allocated. For example, kernel thread stacks should
+ * be allocated from protected kernel memory. Stacks for user tasks and
+ * threads must come from memory that is accessible to user code.
*
****************************************************************************/
-int up_create_stack(struct tcb_s *tcb, size_t stack_size)
+int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype)
{
/* Is there already a stack allocated of a different size? */
diff --git a/nuttx/arch/avr/src/avr32/up_usestack.c b/nuttx/arch/avr/src/avr32/up_usestack.c
index 43dc6bfe9..86cdc2de4 100644
--- a/nuttx/arch/avr/src/avr32/up_usestack.c
+++ b/nuttx/arch/avr/src/avr32/up_usestack.c
@@ -65,20 +65,27 @@
* Name: up_use_stack
*
* Description:
- * Setup up stack-related information in the TCB
- * using pre-allocated stack memory
+ * Setup up stack-related information in the TCB using pre-allocated stack
+ * memory. This function is called only from task_init() when a task or
+ * kernel thread is started (never for pthreads).
*
* The following TCB fields must be initialized:
- * adj_stack_size: Stack size after adjustment for hardware,
+ *
+ * - adj_stack_size: Stack size after adjustment for hardware,
* processor, etc. This value is retained only for debug
* purposes.
- * stack_alloc_ptr: Pointer to allocated stack
- * adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The
+ * - stack_alloc_ptr: Pointer to allocated stack
+ * - adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The
* initial value of the stack pointer.
*
* Inputs:
- * tcb: The TCB of new task
- * stack_size: The allocated stack size.
+ * - tcb: The TCB of new task
+ * - stack_size: The allocated stack size.
+ *
+ * NOTE: Unlike up_stack_create() and up_stack_release, this function
+ * does not require the task type (ttype) parameter. The TCB flags will
+ * always be set to provide the task type to up_use_stack() if it needs
+ * that information.
*
****************************************************************************/
diff --git a/nuttx/arch/avr/src/common/up_releasestack.c b/nuttx/arch/avr/src/common/up_releasestack.c
index afce3261d..7d3e6f28c 100644
--- a/nuttx/arch/avr/src/common/up_releasestack.c
+++ b/nuttx/arch/avr/src/common/up_releasestack.c
@@ -62,12 +62,34 @@
* Name: up_release_stack
*
* Description:
- * A task has been stopped. Free all stack
- * related resources retained int the defunct TCB.
+ * A task has been stopped. Free all stack related resources retained in
+ * the defunct TCB.
+ *
+ * Input Parmeters
+ * - dtcb: The TCB containing information about the stack to be released
+ * - ttype: The thread type. This may be one of following (defined in
+ * include/nuttx/sched.h):
+ *
+ * TCB_FLAG_TTYPE_TASK Normal user task
+ * TCB_FLAG_TTYPE_PTHREAD User pthread
+ * TCB_FLAG_TTYPE_KERNEL Kernel thread
+ *
+ * This thread type is normally available in the flags field of the TCB,
+ * however, there are certain error recovery contexts where the TCB may
+ * not be fully initialized when up_release_stack is called.
+ *
+ * If CONFIG_NUTTX_KERNEL is defined, then this thread type may affect
+ * how the stack is freed. For example, kernel thread stacks may have
+ * been allocated from protected kernel memory. Stacks for user tasks
+ * and threads must have come from memory that is accessible to user
+ * code.
+ *
+ * Returned Value:
+ * None
*
****************************************************************************/
-void up_release_stack(struct tcb_s *dtcb)
+void up_release_stack(FAR struct tcb_s *dtcb, uint8_t ttype)
{
if (dtcb->stack_alloc_ptr)
{