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
4ac83b699a
commit
020cc2248e
@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* arch/arm/src/common/up_createstack.c
|
* 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>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* 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
|
* Name: up_create_stack
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Allocate a stack for a new thread and setup up stack-related
|
* Allocate a stack for a new thread and setup up stack-related information
|
||||||
* information in the TCB.
|
* in the TCB.
|
||||||
*
|
*
|
||||||
* The following TCB fields must be initialized:
|
* The following TCB fields must be initialized by this function:
|
||||||
* adj_stack_size: Stack size after adjustment for hardware, processor,
|
*
|
||||||
|
* - adj_stack_size: Stack size after adjustment for hardware, processor,
|
||||||
* etc. This value is retained only for debug purposes.
|
* etc. This value is retained only for debug purposes.
|
||||||
* stack_alloc_ptr: Pointer to allocated stack
|
* - stack_alloc_ptr: Pointer to allocated stack
|
||||||
* adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The initial value of
|
* - adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The initial value of
|
||||||
* the stack pointer.
|
* the stack pointer.
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Inputs:
|
||||||
* tcb: The TCB of new task
|
* - tcb: The TCB of new task
|
||||||
* stack_size: The requested stack size. At least this how much must be
|
* - stack_size: The requested stack size. At least this much
|
||||||
* allocated.
|
* 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? */
|
/* Is there already a stack allocated of a different size? */
|
||||||
|
|
||||||
|
@ -62,12 +62,34 @@
|
|||||||
* Name: up_release_stack
|
* Name: up_release_stack
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* A task has been stopped. Free all stack
|
* A task has been stopped. Free all stack related resources retained in
|
||||||
* related resources retained int the defunct TCB.
|
* 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)
|
if (dtcb->stack_alloc_ptr)
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* arch/arm/src/common/up_usestack.c
|
* 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>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@ -92,20 +92,27 @@
|
|||||||
* Name: up_use_stack
|
* Name: up_use_stack
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Setup up stack-related information in the TCB
|
* Setup up stack-related information in the TCB using pre-allocated stack
|
||||||
* 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:
|
* 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
|
* processor, etc. This value is retained only for debug
|
||||||
* purposes.
|
* purposes.
|
||||||
* stack_alloc_ptr: Pointer to allocated stack
|
* - stack_alloc_ptr: Pointer to allocated stack
|
||||||
* adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The
|
* - adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The
|
||||||
* initial value of the stack pointer.
|
* initial value of the stack pointer.
|
||||||
*
|
*
|
||||||
* Inputs:
|
* Inputs:
|
||||||
* tcb: The TCB of new task
|
* - tcb: The TCB of new task
|
||||||
* stack_size: The allocated stack size.
|
* - 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 */
|
/* 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)
|
if (ret != OK)
|
||||||
{
|
{
|
||||||
sdbg("up_create_stack failed: %d\n", ret);
|
sdbg("up_create_stack failed: %d\n", ret);
|
||||||
|
@ -70,24 +70,40 @@
|
|||||||
* Name: up_create_stack
|
* Name: up_create_stack
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Allocate a stack for a new thread and setup up stack-related
|
* Allocate a stack for a new thread and setup up stack-related information
|
||||||
* information in the TCB.
|
* in the TCB.
|
||||||
*
|
*
|
||||||
* The following TCB fields must be initialized:
|
* The following TCB fields must be initialized by this function:
|
||||||
* adj_stack_size: Stack size after adjustment for hardware, processor,
|
*
|
||||||
|
* - adj_stack_size: Stack size after adjustment for hardware, processor,
|
||||||
* etc. This value is retained only for debug purposes.
|
* etc. This value is retained only for debug purposes.
|
||||||
* stack_alloc_ptr: Pointer to allocated stack
|
* - stack_alloc_ptr: Pointer to allocated stack
|
||||||
* adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The initial value of
|
* - adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The initial value of
|
||||||
* the stack pointer.
|
* the stack pointer.
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Inputs:
|
||||||
* tcb: The TCB of new task
|
* - tcb: The TCB of new task
|
||||||
* stack_size: The requested stack size. At least this how much must be
|
* - stack_size: The requested stack size. At least this much
|
||||||
* allocated.
|
* 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? */
|
/* Is there already a stack allocated of a different size? */
|
||||||
|
|
||||||
|
@ -67,18 +67,26 @@
|
|||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Setup up stack-related information in the TCB using pre-allocated stack
|
* 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:
|
* 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.
|
* - adj_stack_size: Stack size after adjustment for hardware,
|
||||||
* stack_alloc_ptr: Pointer to allocated stack
|
* processor, etc. This value is retained only for debug
|
||||||
* adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The initial value of
|
* purposes.
|
||||||
* the stack pointer.
|
* - stack_alloc_ptr: Pointer to allocated stack
|
||||||
|
* - adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The
|
||||||
|
* initial value of the stack pointer.
|
||||||
*
|
*
|
||||||
* Inputs:
|
* Inputs:
|
||||||
* tcb: The TCB of new task
|
* - tcb: The TCB of new task
|
||||||
* stack_size: The allocated stack size.
|
* - 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
|
* Name: up_create_stack
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Allocate a stack for a new thread and setup up stack-related
|
* Allocate a stack for a new thread and setup up stack-related information
|
||||||
* information in the TCB.
|
* in the TCB.
|
||||||
*
|
*
|
||||||
* The following TCB fields must be initialized:
|
* The following TCB fields must be initialized by this function:
|
||||||
* adj_stack_size: Stack size after adjustment for hardware, processor,
|
*
|
||||||
|
* - adj_stack_size: Stack size after adjustment for hardware, processor,
|
||||||
* etc. This value is retained only for debug purposes.
|
* etc. This value is retained only for debug purposes.
|
||||||
* stack_alloc_ptr: Pointer to allocated stack
|
* - stack_alloc_ptr: Pointer to allocated stack
|
||||||
* adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The initial value of
|
* - adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The initial value of
|
||||||
* the stack pointer.
|
* the stack pointer.
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Inputs:
|
||||||
* tcb: The TCB of new task
|
* - tcb: The TCB of new task
|
||||||
* stack_size: The requested stack size. At least this how much must be
|
* - stack_size: The requested stack size. At least this much
|
||||||
* allocated.
|
* 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? */
|
/* Is there already a stack allocated of a different size? */
|
||||||
|
|
||||||
|
@ -65,20 +65,27 @@
|
|||||||
* Name: up_use_stack
|
* Name: up_use_stack
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Setup up stack-related information in the TCB
|
* Setup up stack-related information in the TCB using pre-allocated stack
|
||||||
* 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:
|
* 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
|
* processor, etc. This value is retained only for debug
|
||||||
* purposes.
|
* purposes.
|
||||||
* stack_alloc_ptr: Pointer to allocated stack
|
* - stack_alloc_ptr: Pointer to allocated stack
|
||||||
* adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The
|
* - adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The
|
||||||
* initial value of the stack pointer.
|
* initial value of the stack pointer.
|
||||||
*
|
*
|
||||||
* Inputs:
|
* Inputs:
|
||||||
* tcb: The TCB of new task
|
* - tcb: The TCB of new task
|
||||||
* stack_size: The allocated stack size.
|
* - 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
|
* Name: up_release_stack
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* A task has been stopped. Free all stack
|
* A task has been stopped. Free all stack related resources retained in
|
||||||
* related resources retained int the defunct TCB.
|
* 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)
|
if (dtcb->stack_alloc_ptr)
|
||||||
{
|
{
|
||||||
|
@ -66,24 +66,40 @@
|
|||||||
* Name: up_create_stack
|
* Name: up_create_stack
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Allocate a stack for a new thread and setup up stack-related
|
* Allocate a stack for a new thread and setup up stack-related information
|
||||||
* information in the TCB.
|
* in the TCB.
|
||||||
*
|
*
|
||||||
* The following TCB fields must be initialized:
|
* The following TCB fields must be initialized by this function:
|
||||||
* adj_stack_size: Stack size after adjustment for hardware, processor,
|
*
|
||||||
|
* - adj_stack_size: Stack size after adjustment for hardware, processor,
|
||||||
* etc. This value is retained only for debug purposes.
|
* etc. This value is retained only for debug purposes.
|
||||||
* stack_alloc_ptr: Pointer to allocated stack
|
* - stack_alloc_ptr: Pointer to allocated stack
|
||||||
* adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The initial value of
|
* - adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The initial value of
|
||||||
* the stack pointer.
|
* the stack pointer.
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Inputs:
|
||||||
* tcb: The TCB of new task
|
* - tcb: The TCB of new task
|
||||||
* stack_size: The requested stack size. At least this how much must be
|
* - stack_size: The requested stack size. At least this much
|
||||||
* allocated.
|
* 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? */
|
/* 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
|
* A task has been stopped. Free all stack related resources retained in
|
||||||
* the defunct TCB.
|
* 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)
|
if (dtcb->stack_alloc_ptr)
|
||||||
{
|
{
|
||||||
|
@ -64,19 +64,27 @@
|
|||||||
* Name: up_use_stack
|
* Name: up_use_stack
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Setup up stack-related information in the TCB using pre-allocated
|
* Setup up stack-related information in the TCB using pre-allocated stack
|
||||||
* 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:
|
* 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.
|
* - adj_stack_size: Stack size after adjustment for hardware,
|
||||||
* stack_alloc_ptr: Pointer to allocated stack
|
* processor, etc. This value is retained only for debug
|
||||||
* adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The initial value of the
|
* purposes.
|
||||||
* stack pointer.
|
* - stack_alloc_ptr: Pointer to allocated stack
|
||||||
|
* - adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The
|
||||||
|
* initial value of the stack pointer.
|
||||||
*
|
*
|
||||||
* Inputs:
|
* Inputs:
|
||||||
* tcb: The TCB of new task
|
* - tcb: The TCB of new task
|
||||||
* stack_size: The allocated stack size.
|
* - 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
|
* Name: up_create_stack
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Allocate a stack for a new thread and setup up stack-related
|
* Allocate a stack for a new thread and setup up stack-related information
|
||||||
* information in the TCB.
|
* in the TCB.
|
||||||
*
|
*
|
||||||
* The following TCB fields must be initialized:
|
* The following TCB fields must be initialized by this function:
|
||||||
* adj_stack_size: Stack size after adjustment for hardware, processor,
|
*
|
||||||
|
* - adj_stack_size: Stack size after adjustment for hardware, processor,
|
||||||
* etc. This value is retained only for debug purposes.
|
* etc. This value is retained only for debug purposes.
|
||||||
* stack_alloc_ptr: Pointer to allocated stack
|
* - stack_alloc_ptr: Pointer to allocated stack
|
||||||
* adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The initial value of
|
* - adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The initial value of
|
||||||
* the stack pointer.
|
* the stack pointer.
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Inputs:
|
||||||
* tcb: The TCB of new task
|
* - tcb: The TCB of new task
|
||||||
* stack_size: The requested stack size. At least this how much must be
|
* - stack_size: The requested stack size. At least this much
|
||||||
* allocated.
|
* 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? */
|
/* Is there already a stack allocated of a different size? */
|
||||||
|
|
||||||
|
@ -62,12 +62,34 @@
|
|||||||
* Name: up_release_stack
|
* Name: up_release_stack
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* A task has been stopped. Free all stack
|
* A task has been stopped. Free all stack related resources retained in
|
||||||
* related resources retained int the defunct TCB.
|
* 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)
|
if (dtcb->stack_alloc_ptr)
|
||||||
{
|
{
|
||||||
|
@ -65,20 +65,27 @@
|
|||||||
* Name: up_use_stack
|
* Name: up_use_stack
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Setup up stack-related information in the TCB
|
* Setup up stack-related information in the TCB using pre-allocated stack
|
||||||
* 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:
|
* 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
|
* processor, etc. This value is retained only for debug
|
||||||
* purposes.
|
* purposes.
|
||||||
* stack_alloc_ptr: Pointer to allocated stack
|
* - stack_alloc_ptr: Pointer to allocated stack
|
||||||
* adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The
|
* - adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The
|
||||||
* initial value of the stack pointer.
|
* initial value of the stack pointer.
|
||||||
*
|
*
|
||||||
* Inputs:
|
* Inputs:
|
||||||
* tcb: The TCB of new task
|
* - tcb: The TCB of new task
|
||||||
* stack_size: The allocated stack size.
|
* - 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 */
|
/* 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)
|
if (ret != OK)
|
||||||
{
|
{
|
||||||
sdbg("up_create_stack failed: %d\n", ret);
|
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;
|
*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;
|
int ret = ERROR;
|
||||||
size_t *adj_stack_ptr;
|
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;
|
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) {
|
if (dtcb->stack_alloc_ptr) {
|
||||||
kufree(dtcb->stack_alloc_ptr);
|
kufree(dtcb->stack_alloc_ptr);
|
||||||
|
@ -66,24 +66,40 @@
|
|||||||
* Name: up_create_stack
|
* Name: up_create_stack
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Allocate a stack for a new thread and setup up stack-related
|
* Allocate a stack for a new thread and setup up stack-related information
|
||||||
* information in the TCB.
|
* in the TCB.
|
||||||
*
|
*
|
||||||
* The following TCB fields must be initialized:
|
* The following TCB fields must be initialized by this function:
|
||||||
* adj_stack_size: Stack size after adjustment for hardware, processor,
|
*
|
||||||
|
* - adj_stack_size: Stack size after adjustment for hardware, processor,
|
||||||
* etc. This value is retained only for debug purposes.
|
* etc. This value is retained only for debug purposes.
|
||||||
* stack_alloc_ptr: Pointer to allocated stack
|
* - stack_alloc_ptr: Pointer to allocated stack
|
||||||
* adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The initial value of
|
* - adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The initial value of
|
||||||
* the stack pointer.
|
* the stack pointer.
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Inputs:
|
||||||
* tcb: The TCB of new task
|
* - tcb: The TCB of new task
|
||||||
* stack_size: The requested stack size. At least this how much must be
|
* - stack_size: The requested stack size. At least this much
|
||||||
* allocated.
|
* 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? */
|
/* Is there already a stack allocated of a different size? */
|
||||||
|
|
||||||
|
@ -62,12 +62,34 @@
|
|||||||
* Name: up_release_stack
|
* Name: up_release_stack
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* A task has been stopped. Free all stack
|
* A task has been stopped. Free all stack related resources retained in
|
||||||
* related resources retained int the defunct TCB.
|
* 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)
|
if (dtcb->stack_alloc_ptr)
|
||||||
{
|
{
|
||||||
|
@ -65,20 +65,27 @@
|
|||||||
* Name: up_use_stack
|
* Name: up_use_stack
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Setup up stack-related information in the TCB
|
* Setup up stack-related information in the TCB using pre-allocated stack
|
||||||
* 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:
|
* 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
|
* processor, etc. This value is retained only for debug
|
||||||
* purposes.
|
* purposes.
|
||||||
* stack_alloc_ptr: Pointer to allocated stack
|
* - stack_alloc_ptr: Pointer to allocated stack
|
||||||
* adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The
|
* - adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The
|
||||||
* initial value of the stack pointer.
|
* initial value of the stack pointer.
|
||||||
*
|
*
|
||||||
* Inputs:
|
* Inputs:
|
||||||
* tcb: The TCB of new task
|
* - tcb: The TCB of new task
|
||||||
* stack_size: The allocated stack size.
|
* - 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
|
* Name: up_create_stack
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Allocate a stack for a new thread and setup
|
* Allocate a stack for a new thread and setup up stack-related information
|
||||||
* up stack-related information in the TCB.
|
* in the TCB.
|
||||||
*
|
*
|
||||||
* The following TCB fields must be initialized:
|
* 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
|
* - adj_stack_size: Stack size after adjustment for hardware, processor,
|
||||||
* purposes.
|
* etc. This value is retained only for debug purposes.
|
||||||
* stack_alloc_ptr: Pointer to allocated stack
|
* - stack_alloc_ptr: Pointer to allocated stack
|
||||||
* adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The
|
* - adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The initial value of
|
||||||
* initial value of the stack pointer.
|
* the stack pointer.
|
||||||
*
|
*
|
||||||
* Inputs:
|
* Inputs:
|
||||||
* tcb: The TCB of new task
|
* - tcb: The TCB of new task
|
||||||
* stack_size: The requested stack size. At least this much
|
* - stack_size: The requested stack size. At least this much
|
||||||
* must be allocated.
|
* 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;
|
int ret = ERROR;
|
||||||
|
|
||||||
|
@ -64,12 +64,34 @@
|
|||||||
* Name: up_release_stack
|
* Name: up_release_stack
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* A task has been stopped. Free all stack
|
* A task has been stopped. Free all stack related resources retained in
|
||||||
* related resources retained int the defunct TCB.
|
* 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)
|
if (dtcb->stack_alloc_ptr)
|
||||||
{
|
{
|
||||||
|
@ -64,20 +64,27 @@
|
|||||||
* Name: up_use_stack
|
* Name: up_use_stack
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Setup up stack-related information in the TCB
|
* Setup up stack-related information in the TCB using pre-allocated stack
|
||||||
* 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:
|
* 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
|
* processor, etc. This value is retained only for debug
|
||||||
* purposes.
|
* purposes.
|
||||||
* stack_alloc_ptr: Pointer to allocated stack
|
* - stack_alloc_ptr: Pointer to allocated stack
|
||||||
* adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The
|
* - adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The
|
||||||
* initial value of the stack pointer.
|
* initial value of the stack pointer.
|
||||||
*
|
*
|
||||||
* Inputs:
|
* Inputs:
|
||||||
* tcb: The TCB of new task
|
* - tcb: The TCB of new task
|
||||||
* stack_size: The allocated stack size.
|
* - 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
|
* Name: up_create_stack
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Allocate a stack for a new thread and setup up stack-related
|
* Allocate a stack for a new thread and setup up stack-related information
|
||||||
* information in the TCB.
|
* in the TCB.
|
||||||
*
|
*
|
||||||
* The following TCB fields must be initialized:
|
* The following TCB fields must be initialized by this function:
|
||||||
* adj_stack_size: Stack size after adjustment for hardware, processor,
|
*
|
||||||
|
* - adj_stack_size: Stack size after adjustment for hardware, processor,
|
||||||
* etc. This value is retained only for debug purposes.
|
* etc. This value is retained only for debug purposes.
|
||||||
* stack_alloc_ptr: Pointer to allocated stack
|
* - stack_alloc_ptr: Pointer to allocated stack
|
||||||
* adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The initial value of
|
* - adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The initial value of
|
||||||
* the stack pointer.
|
* the stack pointer.
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Inputs:
|
||||||
* tcb: The TCB of new task
|
* - tcb: The TCB of new task
|
||||||
* stack_size: The requested stack size. At least this how much must be
|
* - stack_size: The requested stack size. At least this much
|
||||||
* allocated.
|
* 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? */
|
/* 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
|
* A task has been stopped. Free all stack related resources retained in
|
||||||
* the defunct TCB.
|
* 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)
|
if (dtcb->stack_alloc_ptr)
|
||||||
{
|
{
|
||||||
|
@ -66,18 +66,26 @@
|
|||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Setup up stack-related information in the TCB using pre-allocated stack
|
* 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:
|
* 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.
|
* - adj_stack_size: Stack size after adjustment for hardware,
|
||||||
* stack_alloc_ptr: Pointer to allocated stack
|
* processor, etc. This value is retained only for debug
|
||||||
* adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The initial value of
|
* purposes.
|
||||||
* the stack pointer.
|
* - stack_alloc_ptr: Pointer to allocated stack
|
||||||
|
* - adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The
|
||||||
|
* initial value of the stack pointer.
|
||||||
*
|
*
|
||||||
* Inputs:
|
* Inputs:
|
||||||
* tcb: The TCB of new task
|
* - tcb: The TCB of new task
|
||||||
* stack_size: The allocated stack size.
|
* - 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
|
* Name: up_create_stack
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Allocate a stack for a new thread and setup up stack-related
|
* Allocate a stack for a new thread and setup up stack-related information
|
||||||
* information in the TCB.
|
* in the TCB.
|
||||||
*
|
*
|
||||||
* The following TCB fields must be initialized:
|
* The following TCB fields must be initialized by this function:
|
||||||
* adj_stack_size: Stack size after adjustment for hardware, processor,
|
*
|
||||||
|
* - adj_stack_size: Stack size after adjustment for hardware, processor,
|
||||||
* etc. This value is retained only for debug purposes.
|
* etc. This value is retained only for debug purposes.
|
||||||
* stack_alloc_ptr: Pointer to allocated stack
|
* - stack_alloc_ptr: Pointer to allocated stack
|
||||||
* adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The initial value of
|
* - adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The initial value of
|
||||||
* the stack pointer.
|
* the stack pointer.
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Inputs:
|
||||||
* tcb: The TCB of new task
|
* - tcb: The TCB of new task
|
||||||
* stack_size: The requested stack size. At least this how much must be
|
* - stack_size: The requested stack size. At least this much
|
||||||
* allocated.
|
* 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? */
|
/* Is there already a stack allocated of a different size? */
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/************************************************************
|
/****************************************************************************
|
||||||
* common/up_releasestack.c
|
* common/up_releasestack.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
|
* 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
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/************************************************************
|
/****************************************************************************
|
||||||
* Included Files
|
* Included Files
|
||||||
************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
@ -46,28 +46,50 @@
|
|||||||
#include "os_internal.h"
|
#include "os_internal.h"
|
||||||
#include "up_internal.h"
|
#include "up_internal.h"
|
||||||
|
|
||||||
/************************************************************
|
/****************************************************************************
|
||||||
* Private Types
|
* Private Types
|
||||||
************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/************************************************************
|
/****************************************************************************
|
||||||
* Private Function Prototypes
|
* Private Function Prototypes
|
||||||
************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/************************************************************
|
/****************************************************************************
|
||||||
* Global Functions
|
* Global Functions
|
||||||
************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/************************************************************
|
/****************************************************************************
|
||||||
* Name: up_release_stack
|
* Name: up_release_stack
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* A task has been stopped. Free all stack
|
* A task has been stopped. Free all stack related resources retained in
|
||||||
* related resources retained int the defunct TCB.
|
* 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)
|
if (dtcb->stack_alloc_ptr)
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/************************************************************
|
/****************************************************************************
|
||||||
* arch/z16/common/up_usestack.c
|
* arch/z16/common/up_usestack.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2008-2009 Gregory Nutt. All rights reserved.
|
* 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
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/************************************************************
|
/****************************************************************************
|
||||||
* Included Files
|
* Included Files
|
||||||
************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
@ -49,38 +49,45 @@
|
|||||||
|
|
||||||
#include "up_internal.h"
|
#include "up_internal.h"
|
||||||
|
|
||||||
/************************************************************
|
/****************************************************************************
|
||||||
* Private Types
|
* Private Types
|
||||||
************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/************************************************************
|
/****************************************************************************
|
||||||
* Private Function Prototypes
|
* Private Function Prototypes
|
||||||
************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/************************************************************
|
/****************************************************************************
|
||||||
* Global Functions
|
* Global Functions
|
||||||
************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/************************************************************
|
/****************************************************************************
|
||||||
* Name: up_use_stack
|
* Name: up_use_stack
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Setup up stack-related information in the TCB
|
* Setup up stack-related information in the TCB using pre-allocated stack
|
||||||
* 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:
|
* 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
|
* processor, etc. This value is retained only for debug
|
||||||
* purposes.
|
* purposes.
|
||||||
* stack_alloc_ptr: Pointer to allocated stack
|
* - stack_alloc_ptr: Pointer to allocated stack
|
||||||
* adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The
|
* - adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The
|
||||||
* initial value of the stack pointer.
|
* initial value of the stack pointer.
|
||||||
*
|
*
|
||||||
* Inputs:
|
* Inputs:
|
||||||
* tcb: The TCB of new task
|
* - tcb: The TCB of new task
|
||||||
* stack_size: The allocated stack size.
|
* - 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)
|
int up_use_stack(struct tcb_s *tcb, void *stack, size_t stack_size)
|
||||||
{
|
{
|
||||||
|
@ -66,24 +66,40 @@
|
|||||||
* Name: up_create_stack
|
* Name: up_create_stack
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Allocate a stack for a new thread and setup up stack-related
|
* Allocate a stack for a new thread and setup up stack-related information
|
||||||
* information in the TCB.
|
* in the TCB.
|
||||||
*
|
*
|
||||||
* The following TCB fields must be initialized:
|
* The following TCB fields must be initialized by this function:
|
||||||
* adj_stack_size: Stack size after adjustment for hardware, processor,
|
*
|
||||||
|
* - adj_stack_size: Stack size after adjustment for hardware, processor,
|
||||||
* etc. This value is retained only for debug purposes.
|
* etc. This value is retained only for debug purposes.
|
||||||
* stack_alloc_ptr: Pointer to allocated stack
|
* - stack_alloc_ptr: Pointer to allocated stack
|
||||||
* adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The initial value of
|
* - adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The initial value of
|
||||||
* the stack pointer.
|
* the stack pointer.
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Inputs:
|
||||||
* tcb: The TCB of new task
|
* - tcb: The TCB of new task
|
||||||
* stack_size: The requested stack size. At least this how much must be
|
* - stack_size: The requested stack size. At least this much
|
||||||
* allocated.
|
* 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? */
|
/* Is there already a stack allocated of a different size? */
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/************************************************************
|
/****************************************************************************
|
||||||
* common/up_releasestack.c
|
* common/up_releasestack.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
|
* 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
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/************************************************************
|
/****************************************************************************
|
||||||
* Included Files
|
* Included Files
|
||||||
************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
@ -46,28 +46,50 @@
|
|||||||
#include "os_internal.h"
|
#include "os_internal.h"
|
||||||
#include "up_internal.h"
|
#include "up_internal.h"
|
||||||
|
|
||||||
/************************************************************
|
/****************************************************************************
|
||||||
* Private Types
|
* Private Types
|
||||||
************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/************************************************************
|
/****************************************************************************
|
||||||
* Private Function Prototypes
|
* Private Function Prototypes
|
||||||
************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/************************************************************
|
/****************************************************************************
|
||||||
* Global Functions
|
* Global Functions
|
||||||
************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/************************************************************
|
/****************************************************************************
|
||||||
* Name: up_release_stack
|
* Name: up_release_stack
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* A task has been stopped. Free all stack
|
* A task has been stopped. Free all stack related resources retained in
|
||||||
* related resources retained int the defunct TCB.
|
* 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)
|
if (dtcb->stack_alloc_ptr)
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/************************************************************
|
/****************************************************************************
|
||||||
* arch/z80/src/common/up_usestack.c
|
* arch/z80/src/common/up_usestack.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
|
* 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
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/************************************************************
|
/****************************************************************************
|
||||||
* Included Files
|
* Included Files
|
||||||
************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
@ -48,38 +48,45 @@
|
|||||||
|
|
||||||
#include "up_internal.h"
|
#include "up_internal.h"
|
||||||
|
|
||||||
/************************************************************
|
/****************************************************************************
|
||||||
* Private Types
|
* Private Types
|
||||||
************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/************************************************************
|
/****************************************************************************
|
||||||
* Private Function Prototypes
|
* Private Function Prototypes
|
||||||
************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/************************************************************
|
/****************************************************************************
|
||||||
* Global Functions
|
* Global Functions
|
||||||
************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/************************************************************
|
/****************************************************************************
|
||||||
* Name: up_use_stack
|
* Name: up_use_stack
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Setup up stack-related information in the TCB
|
* Setup up stack-related information in the TCB using pre-allocated stack
|
||||||
* 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:
|
* 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
|
* processor, etc. This value is retained only for debug
|
||||||
* purposes.
|
* purposes.
|
||||||
* stack_alloc_ptr: Pointer to allocated stack
|
* - stack_alloc_ptr: Pointer to allocated stack
|
||||||
* adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The
|
* - adj_stack_ptr: Adjusted stack_alloc_ptr for HW. The
|
||||||
* initial value of the stack pointer.
|
* initial value of the stack pointer.
|
||||||
*
|
*
|
||||||
* Inputs:
|
* Inputs:
|
||||||
* tcb: The TCB of new task
|
* - tcb: The TCB of new task
|
||||||
* stack_size: The allocated stack size.
|
* - 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)
|
int up_use_stack(struct tcb_s *tcb, void *stack, size_t stack_size)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user