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
This commit is contained in:
parent
d5d9fa89ab
commit
3bf2c1b355
12
ChangeLog
12
ChangeLog
@ -4392,6 +4392,14 @@
|
||||
* fs/fat: Create an error in FAT file creation. The FAT logic was
|
||||
not making a distinction between directory non-existence and file
|
||||
non-existence so when it you try to create a file in a non-existent
|
||||
directory, it would create a file with the nameof the missing
|
||||
directory. Reported by Andrew Tridgell.
|
||||
directory, it would create a file with the name of the missing
|
||||
directory. Reported by Andrew Tridgell (2013-03-30).
|
||||
* Numerous files: Changed the protoypes of up_create_stack() and
|
||||
up_release_stack() so that is includes a task type. Normally you
|
||||
can get this type from the TCB parameter, but there are certain
|
||||
conditions when the task type is not valid in the TCB when these
|
||||
functions are called. Only the prototypes were changed on this
|
||||
big, initial checkin. The next step will be to add logic to
|
||||
allocate stacks for kernel threads from protected kernel memory
|
||||
and all other task types from unprotected user memory (2013-03-20).
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
<h1><big><font color="#3c34ec">
|
||||
<i>NuttX RTOS Porting Guide</i>
|
||||
</font></big></h1>
|
||||
<p>Last Updated: February 4, 2013</p>
|
||||
<p>Last Updated: March 20, 2013</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
@ -1613,11 +1613,10 @@ The system can be re-made subsequently by just typing <code>make</code>.
|
||||
</p>
|
||||
|
||||
<h3><a name="upcreatestack">4.1.4 <code>up_create_stack()</code></a></h3>
|
||||
<p><b>Prototype</b>: <code>STATUS up_create_stack(FAR struct tcb_s *tcb, size_t stack_size);</code></p>
|
||||
<p><b>Prototype</b>: <code>STATUS up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype);</code></p>
|
||||
|
||||
<p><b>Description</b>.
|
||||
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.
|
||||
</p>
|
||||
<p>
|
||||
The following TCB fields must be initialized:
|
||||
@ -1631,18 +1630,37 @@ The system can be re-made subsequently by just typing <code>make</code>.
|
||||
initial value of the stack pointer.
|
||||
</ul>
|
||||
<p>
|
||||
This API is <i>NOT</i> required if <code>CONFIG_CUSTOM_STACK</code>
|
||||
is defined.
|
||||
This API is <i>NOT</i> required if <code>CONFIG_CUSTOM_STACK</code> is defined.
|
||||
</p>
|
||||
|
||||
<p><b>Input Parameters</b>:</p>
|
||||
<ul>
|
||||
<li>
|
||||
<code>tcb</code>: The TCB of new task.
|
||||
<p>
|
||||
<code>tcb</code>: The TCB of new task.
|
||||
</p>
|
||||
</li>
|
||||
<li>
|
||||
<code>stack_size</code>: The requested stack size. At least this much
|
||||
must be allocated.
|
||||
<p>
|
||||
<code>stack_size</code>: The requested stack size. At least this much must be allocated.
|
||||
</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>
|
||||
<code>ttype</code>: The thread type.
|
||||
This may be one of following (defined in <code>include/nuttx/sched.h</code>):
|
||||
</p>
|
||||
<ul>
|
||||
<li><code>TCB_FLAG_TTYPE_TASK</code>: Normal user task</li>
|
||||
<li><code>TCB_FLAG_TTYPE_PTHREAD</code>: User pthread</li>
|
||||
<li><code>TCB_FLAG_TTYPE_KERNEL</code>: Kernel thread</li>
|
||||
</ul>
|
||||
<p>
|
||||
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.
|
||||
</p>
|
||||
<p>
|
||||
If <code>CONFIG_NUTTX_KERNEL</code> 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.
|
||||
</p>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@ -1652,8 +1670,8 @@ The system can be re-made subsequently by just typing <code>make</code>.
|
||||
</p>
|
||||
|
||||
<p><b>Description</b>.
|
||||
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 <code>task_init()</code> when a task or kernel thread is started (never for pthreads).
|
||||
</p>
|
||||
<p>
|
||||
The following TCB fields must be initialized:
|
||||
@ -1667,8 +1685,7 @@ The system can be re-made subsequently by just typing <code>make</code>.
|
||||
initial value of the stack pointer.
|
||||
</ul>
|
||||
<p>
|
||||
This API is <i>NOT</i> required if <code>CONFIG_CUSTOM_STACK</code>
|
||||
is defined.
|
||||
This API is <i>NOT</i> required if <code>CONFIG_CUSTOM_STACK</code> is defined.
|
||||
</p>
|
||||
|
||||
<p><b>Input Parameters:</b></p>
|
||||
@ -1680,18 +1697,48 @@ The system can be re-made subsequently by just typing <code>make</code>.
|
||||
<code>stack_size</code>: The allocated stack size.
|
||||
</li>
|
||||
</ul>
|
||||
<p>
|
||||
NOTE: Unlike <code>up_stack_create()</code> and <code>up_stack_release</code>, this function does not require the task type (<code>ttype</code>) parameter.
|
||||
The TCB flags will always be set to provide the task type to <code>up_use_stack()</code> if the information needs that information.
|
||||
</p>
|
||||
|
||||
<h3><a name="upreleasestack">4.1.6 <code>up_release_stack()</code></a></h3>
|
||||
<p><b>Prototype</b>: <code>void up_release_stack(FAR struct tcb_s *dtcb);</code></p>
|
||||
|
||||
<p><b>Description</b>.
|
||||
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 int the defunct TCB.
|
||||
</p>
|
||||
<p>
|
||||
This API is <i>NOT</i> required if <code>CONFIG_CUSTOM_STACK</code>
|
||||
is defined.
|
||||
This API is <i>NOT</i> required if <code>CONFIG_CUSTOM_STACK</code> is defined.
|
||||
</p>
|
||||
<p><b>Input Parameters:</b></p>
|
||||
<ul>
|
||||
<li>
|
||||
<p>
|
||||
<code>dtcb</code>:
|
||||
The TCB containing information about the stack to be released.
|
||||
</li>
|
||||
<li>
|
||||
<p>
|
||||
<code>ttype</code>: The thread type.
|
||||
This may be one of following (defined in <code>include/nuttx/sched.h</code>):
|
||||
</p>
|
||||
<ul>
|
||||
<li><code>TCB_FLAG_TTYPE_TASK</code>: Normal user task</li>
|
||||
<li><code>TCB_FLAG_TTYPE_PTHREAD</code>: User pthread</li>
|
||||
<li><code>TCB_FLAG_TTYPE_KERNEL</code>: Kernel thread</li>
|
||||
</ul>
|
||||
<p>
|
||||
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.
|
||||
</p>
|
||||
<p>
|
||||
If <code>CONFIG_NUTTX_KERNEL</code> 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
|
||||
</p>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3><a name="upunblocktask">4.1.7 <code>up_unblock_task()</code></a></h3>
|
||||
<p><b>Prototype</b>: <code>void up_unblock_task(FAR struct tcb_s *tcb);</code></p>
|
||||
|
@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* arch/arm/src/common/up_createstack.c
|
||||
*
|
||||
* Copyright (C) 2007-2012 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007-2013 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -111,24 +111,40 @@ static void *memset32(void *s, uint32_t c, size_t n)
|
||||
* 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? */
|
||||
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* arch/arm/src/common/up_usestack.c
|
||||
*
|
||||
* Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007-2009, 2013 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -92,20 +92,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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
@ -162,7 +162,8 @@ pid_t up_vfork(const struct vfork_s *context)
|
||||
|
||||
/* Allocate the stack for the TCB */
|
||||
|
||||
ret = up_create_stack((FAR struct tcb_s *)child, stacksize);
|
||||
ret = up_create_stack((FAR struct tcb_s *)child, stacksize,
|
||||
parent->flags & TCB_FLAG_TTYPE_MASK);
|
||||
if (ret != OK)
|
||||
{
|
||||
sdbg("up_create_stack failed: %d\n", ret);
|
||||
|
@ -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? */
|
||||
|
||||
|
@ -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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
@ -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? */
|
||||
|
||||
|
@ -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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -66,24 +66,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? */
|
||||
|
||||
|
@ -66,9 +66,31 @@
|
||||
* 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)
|
||||
{
|
||||
|
@ -64,19 +64,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, 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
@ -87,24 +87,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? */
|
||||
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
@ -167,7 +167,8 @@ pid_t up_vfork(const struct vfork_s *context)
|
||||
|
||||
/* Allocate the stack for the TCB */
|
||||
|
||||
ret = up_create_stack((FAR struct tcb_s *)child, stacksize);
|
||||
ret = up_create_stack((FAR struct tcb_s *)child, stacksize,
|
||||
parent->flags & TCB_FLAG_TTYPE_MASK);
|
||||
if (ret != OK)
|
||||
{
|
||||
sdbg("up_create_stack failed: %d\n", ret);
|
||||
|
@ -111,7 +111,7 @@ void up_allocate_heap(void **heap_start, size_t *heap_size)
|
||||
*heap_size = KERNBASE + kmem_size - (uint32_t)boot_freemem;
|
||||
}
|
||||
|
||||
int up_create_stack(struct tcb_s *tcb, size_t stack_size)
|
||||
int up_create_stack(struct tcb_s *tcb, size_t stack_size, uint8_t ttype)
|
||||
{
|
||||
int ret = ERROR;
|
||||
size_t *adj_stack_ptr;
|
||||
@ -158,7 +158,7 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t stack_size)
|
||||
return OK;
|
||||
}
|
||||
|
||||
void up_release_stack(struct tcb_s *dtcb)
|
||||
void up_release_stack(struct tcb_s *dtcb, uint8_t ttype)
|
||||
{
|
||||
if (dtcb->stack_alloc_ptr) {
|
||||
kufree(dtcb->stack_alloc_ptr);
|
||||
|
@ -66,24 +66,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? */
|
||||
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
@ -67,25 +67,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, 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.
|
||||
* 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
|
||||
* the stack pointer.
|
||||
*
|
||||
* Inputs:
|
||||
* tcb: The TCB of new task
|
||||
* stack_size: The requested stack size. At least this much
|
||||
* - 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)
|
||||
{
|
||||
int ret = ERROR;
|
||||
|
||||
|
@ -64,12 +64,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)
|
||||
{
|
||||
|
@ -64,20 +64,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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
@ -68,24 +68,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? */
|
||||
|
||||
|
@ -65,9 +65,31 @@
|
||||
* 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)
|
||||
{
|
||||
|
@ -66,18 +66,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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
@ -67,24 +67,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? */
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* common/up_releasestack.c
|
||||
*
|
||||
* Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
|
||||
@ -31,11 +31,11 @@
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
@ -46,28 +46,50 @@
|
||||
#include "os_internal.h"
|
||||
#include "up_internal.h"
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Global Functions
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* 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)
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* arch/z16/common/up_usestack.c
|
||||
*
|
||||
* Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
|
||||
@ -31,11 +31,11 @@
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
@ -49,38 +49,45 @@
|
||||
|
||||
#include "up_internal.h"
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Global Functions
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int up_use_stack(struct tcb_s *tcb, void *stack, size_t stack_size)
|
||||
{
|
||||
|
@ -66,24 +66,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? */
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* common/up_releasestack.c
|
||||
*
|
||||
* Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
|
||||
@ -31,11 +31,11 @@
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
@ -46,28 +46,50 @@
|
||||
#include "os_internal.h"
|
||||
#include "up_internal.h"
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Global Functions
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* 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)
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* arch/z80/src/common/up_usestack.c
|
||||
*
|
||||
* Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
|
||||
@ -31,11 +31,11 @@
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
@ -48,38 +48,45 @@
|
||||
|
||||
#include "up_internal.h"
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Private Function Prototypes
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* Global Functions
|
||||
************************************************************/
|
||||
****************************************************************************/
|
||||
|
||||
/************************************************************
|
||||
/****************************************************************************
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int up_use_stack(struct tcb_s *tcb, void *stack, size_t stack_size)
|
||||
{
|
||||
|
@ -163,7 +163,7 @@ int exec_module(FAR const struct binary_s *binp)
|
||||
goto errout;
|
||||
}
|
||||
|
||||
/* Allocate the stack for the new task */
|
||||
/* Allocate the stack for the new task (always from the user heap) */
|
||||
|
||||
#ifndef CONFIG_CUSTOM_STACK
|
||||
stack = (FAR uint32_t*)kumalloc(binp->stacksize);
|
||||
|
@ -2344,14 +2344,14 @@ int fat_finddirentry(struct fat_mountpt_s *fs, struct fat_dirinfo_s *dirinfo,
|
||||
if (ret < 0)
|
||||
{
|
||||
/* A return value of -ENOENT would mean that the path segement
|
||||
* was not found. Let's distinguish to cases: (1) the final
|
||||
* was not found. Let's distinguish two cases: (1) the final
|
||||
* file was not found in the directory (-ENOENT), or (2) one
|
||||
* of the directory path segments does not exist (-ENOTDIR)
|
||||
*/
|
||||
|
||||
if (ret == -ENOENT && terminator != '\0')
|
||||
{
|
||||
return -ENOTDIR;
|
||||
ret = -ENOTDIR;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -149,46 +149,68 @@ void up_initial_state(FAR struct tcb_s *tcb);
|
||||
* 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, 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.
|
||||
* 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
|
||||
* the stack pointer.
|
||||
*
|
||||
* Inputs:
|
||||
* tcb: The TCB of new task
|
||||
* stack_size: The requested stack size. At least this much
|
||||
* - 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CONFIG_CUSTOM_STACK
|
||||
int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size);
|
||||
int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
@ -200,13 +222,35 @@ int up_use_stack(FAR struct tcb_s *tcb, FAR void *stack, size_t stack_size);
|
||||
* 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
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CONFIG_CUSTOM_STACK
|
||||
void up_release_stack(FAR struct tcb_s *dtcb);
|
||||
void up_release_stack(FAR struct tcb_s *dtcb, uint8_t ttype);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -290,6 +290,6 @@ int sched_reprioritize(FAR struct tcb_s *tcb, int sched_priority);
|
||||
FAR struct tcb_s *sched_gettcb(pid_t pid);
|
||||
bool sched_verifytcb(FAR struct tcb_s *tcb);
|
||||
|
||||
int sched_releasetcb(FAR struct tcb_s *tcb);
|
||||
int sched_releasetcb(FAR struct tcb_s *tcb, uint8_t ttype);
|
||||
|
||||
#endif /* __SCHED_OS_INTERNAL_H */
|
||||
|
@ -294,7 +294,8 @@ int pthread_create(FAR pthread_t *thread, FAR pthread_attr_t *attr,
|
||||
|
||||
/* Allocate the stack for the TCB */
|
||||
|
||||
ret = up_create_stack((FAR struct tcb_s *)ptcb, attr->stacksize);
|
||||
ret = up_create_stack((FAR struct tcb_s *)ptcb, attr->stacksize,
|
||||
TCB_FLAG_TTYPE_PTHREAD);
|
||||
if (ret != OK)
|
||||
{
|
||||
errcode = ENOMEM;
|
||||
@ -308,9 +309,10 @@ int pthread_create(FAR pthread_t *thread, FAR pthread_attr_t *attr,
|
||||
|
||||
if (attr->inheritsched == PTHREAD_INHERIT_SCHED)
|
||||
{
|
||||
struct sched_param param;
|
||||
|
||||
/* Get the priority for this thread. */
|
||||
|
||||
struct sched_param param;
|
||||
ret = sched_getparam(0, ¶m);
|
||||
if (ret == OK)
|
||||
{
|
||||
@ -448,6 +450,6 @@ errout_with_join:
|
||||
ptcb->joininfo = NULL;
|
||||
|
||||
errout_with_tcb:
|
||||
sched_releasetcb((FAR struct tcb_s *)ptcb);
|
||||
sched_releasetcb((FAR struct tcb_s *)ptcb, TCB_FLAG_TTYPE_PTHREAD);
|
||||
return errcode;
|
||||
}
|
||||
|
@ -83,7 +83,12 @@ static void sched_releasepid(pid_t pid)
|
||||
* Free all resources contained in a TCB
|
||||
*
|
||||
* Parameters:
|
||||
* None
|
||||
* tcb - The TCB to be released
|
||||
* ttype - The type of the TCB to be released
|
||||
*
|
||||
* This thread type is normally available in the flags field of the TCB,
|
||||
* however, there are certain error recovery contexts where the TCB my
|
||||
* not be fully initialized when sched_releasetcb is called.
|
||||
*
|
||||
* Return Value:
|
||||
* OK on success; ERROR on failure
|
||||
@ -93,7 +98,7 @@ static void sched_releasepid(pid_t pid)
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
int sched_releasetcb(FAR struct tcb_s *tcb)
|
||||
int sched_releasetcb(FAR struct tcb_s *tcb, uint8_t ttype)
|
||||
{
|
||||
int ret = OK;
|
||||
int i;
|
||||
@ -131,7 +136,7 @@ int sched_releasetcb(FAR struct tcb_s *tcb)
|
||||
#ifndef CONFIG_CUSTOM_STACK
|
||||
if (tcb->stack_alloc_ptr)
|
||||
{
|
||||
up_release_stack(tcb);
|
||||
up_release_stack(tcb, ttype);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -99,10 +99,10 @@
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CONFIG_CUSTOM_STACK
|
||||
static int thread_create(const char *name, uint8_t ttype, int priority,
|
||||
static int thread_create(FAR const char *name, uint8_t ttype, int priority,
|
||||
int stack_size, main_t entry, FAR char * const argv[])
|
||||
#else
|
||||
static int thread_create(const char *name, uint8_t ttype, int priority,
|
||||
static int thread_create(FAR const char *name, uint8_t ttype, int priority,
|
||||
main_t entry, FAR char * const argv[])
|
||||
#endif
|
||||
{
|
||||
@ -146,7 +146,7 @@ static int thread_create(const char *name, uint8_t ttype, int priority,
|
||||
/* Allocate the stack for the TCB */
|
||||
|
||||
#ifndef CONFIG_CUSTOM_STACK
|
||||
ret = up_create_stack((FAR struct tcb_s *)tcb, stack_size);
|
||||
ret = up_create_stack((FAR struct tcb_s *)tcb, stack_size, ttype);
|
||||
if (ret < OK)
|
||||
{
|
||||
errcode = -ret;
|
||||
@ -198,7 +198,7 @@ static int thread_create(const char *name, uint8_t ttype, int priority,
|
||||
return pid;
|
||||
|
||||
errout_with_tcb:
|
||||
sched_releasetcb((FAR struct tcb_s *)tcb);
|
||||
sched_releasetcb((FAR struct tcb_s *)tcb, ttype);
|
||||
|
||||
errout:
|
||||
set_errno(errcode);
|
||||
@ -244,10 +244,10 @@ errout:
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CONFIG_CUSTOM_STACK
|
||||
int task_create(const char *name, int priority,
|
||||
int task_create(FAR const char *name, int priority,
|
||||
int stack_size, main_t entry, FAR char * const argv[])
|
||||
#else
|
||||
int task_create(const char *name, int priority,
|
||||
int task_create(FAR const char *name, int priority,
|
||||
main_t entry, FAR char * const argv[])
|
||||
#endif
|
||||
{
|
||||
@ -275,10 +275,10 @@ int task_create(const char *name, int priority,
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CONFIG_CUSTOM_STACK
|
||||
int kernel_thread(const char *name, int priority,
|
||||
int kernel_thread(FAR const char *name, int priority,
|
||||
int stack_size, main_t entry, FAR char * const argv[])
|
||||
#else
|
||||
int kernel_thread(const char *name, int priority,
|
||||
int kernel_thread(FAR const char *name, int priority,
|
||||
main_t entry, FAR char * const argv[])
|
||||
#endif
|
||||
{
|
||||
|
@ -188,7 +188,7 @@ int task_delete(pid_t pid)
|
||||
|
||||
/* Deallocate its TCB */
|
||||
|
||||
sched_releasetcb(dtcb);
|
||||
sched_releasetcb(dtcb, dtcb->flags & TCB_FLAG_TTYPE_MASK);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -112,11 +112,27 @@ FAR struct task_tcb_s *task_vforksetup(start_t retaddr)
|
||||
{
|
||||
struct tcb_s *parent = (FAR struct tcb_s *)g_readytorun.head;
|
||||
struct task_tcb_s *child;
|
||||
uint8_t ttype;
|
||||
int priority;
|
||||
int ret;
|
||||
|
||||
DEBUGASSERT(retaddr);
|
||||
|
||||
/* Get the type of the fork'ed task (kernel or user) */
|
||||
|
||||
if ((parent->flags & TCB_FLAG_TTYPE_MASK) == TCB_FLAG_TTYPE_KERNEL)
|
||||
{
|
||||
/* Fork'ed from a kernel thread */
|
||||
|
||||
ttype = TCB_FLAG_TTYPE_KERNEL;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Fork'ed from a user task or pthread */
|
||||
|
||||
ttype = TCB_FLAG_TTYPE_TASK;
|
||||
}
|
||||
|
||||
/* Allocate a TCB for the child task. */
|
||||
|
||||
child = (FAR struct task_tcb_s *)kzalloc(sizeof(struct task_tcb_s));
|
||||
@ -158,8 +174,7 @@ FAR struct task_tcb_s *task_vforksetup(start_t retaddr)
|
||||
/* Initialize the task control block. This calls up_initial_state() */
|
||||
|
||||
svdbg("Child priority=%d start=%p\n", priority, retaddr);
|
||||
ret = task_schedsetup(child, priority, retaddr, parent->entry.main,
|
||||
TCB_FLAG_TTYPE_TASK);
|
||||
ret = task_schedsetup(child, priority, retaddr, parent->entry.main, ttype);
|
||||
if (ret < OK)
|
||||
{
|
||||
goto errout_with_tcb;
|
||||
@ -169,7 +184,7 @@ FAR struct task_tcb_s *task_vforksetup(start_t retaddr)
|
||||
return child;
|
||||
|
||||
errout_with_tcb:
|
||||
sched_releasetcb((FAR struct tcb_s *)child);
|
||||
sched_releasetcb((FAR struct tcb_s *)child, ttype);
|
||||
set_errno(-ret);
|
||||
return NULL;
|
||||
}
|
||||
@ -321,7 +336,8 @@ void task_vforkabort(FAR struct task_tcb_s *child, int errcode)
|
||||
|
||||
/* Release the TCB */
|
||||
|
||||
sched_releasetcb((FAR struct tcb_s *)child);
|
||||
sched_releasetcb((FAR struct tcb_s *)child,
|
||||
child->cmn.flags & TCB_FLAG_TTYPE_MASK);
|
||||
set_errno(errcode);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user