Zephyr API Documentation 4.0.0-rc2
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
thread_stack.h File Reference

Macros for declaring thread stacks. More...

#include <zephyr/arch/cpu.h>
#include <zephyr/sys/util.h>

Go to the source code of this file.

Macros

#define K_KERNEL_STACK_RESERVED   ((size_t)0)
 
#define K_KERNEL_STACK_LEN(size)
 
#define K_KERNEL_STACK_DECLARE(sym, size)
 Declare a reference to a thread stack.
 
#define K_KERNEL_STACK_ARRAY_DECLARE(sym, nmemb, size)
 Declare a reference to a thread stack array.
 
#define K_KERNEL_PINNED_STACK_ARRAY_DECLARE(sym, nmemb, size)
 Declare a reference to a pinned thread stack array.
 
#define K_KERNEL_STACK_DEFINE(sym, size)
 Define a toplevel kernel stack memory region.
 
#define K_KERNEL_PINNED_STACK_DEFINE(sym, size)
 Define a toplevel kernel stack memory region in pinned section.
 
#define K_KERNEL_STACK_ARRAY_DEFINE(sym, nmemb, size)
 Define a toplevel array of kernel stack memory regions.
 
#define K_KERNEL_PINNED_STACK_ARRAY_DEFINE(sym, nmemb, size)
 Define a toplevel array of kernel stack memory regions in pinned section.
 
#define K_KERNEL_STACK_MEMBER(sym, size)
 Define an embedded stack memory region.
 
#define K_KERNEL_STACK_SIZEOF(sym)
 
#define K_THREAD_STACK_RESERVED   ((size_t)0U)
 Indicate how much additional memory is reserved for stack objects.
 
#define K_THREAD_STACK_DECLARE(sym, size)
 Declare a reference to a thread stack.
 
#define K_THREAD_STACK_ARRAY_DECLARE(sym, nmemb, size)
 Declare a reference to a thread stack array.
 
#define K_THREAD_STACK_SIZEOF(sym)
 Return the size in bytes of a stack memory region.
 
#define K_THREAD_STACK_DEFINE(sym, size)
 Define a toplevel thread stack memory region.
 
#define K_THREAD_PINNED_STACK_DEFINE(sym, size)
 Define a toplevel thread stack memory region in pinned section.
 
#define K_THREAD_STACK_LEN(size)
 Calculate size of stacks to be allocated in a stack array.
 
#define K_THREAD_STACK_ARRAY_DEFINE(sym, nmemb, size)
 Define a toplevel array of thread stack memory regions.
 
#define K_THREAD_PINNED_STACK_ARRAY_DEFINE(sym, nmemb, size)
 Define a toplevel array of thread stack memory regions in pinned section.
 

Functions

static char * K_KERNEL_STACK_BUFFER (k_thread_stack_t *sym)
 
static char * K_THREAD_STACK_BUFFER (k_thread_stack_t *sym)
 Get a pointer to the physical stack buffer.
 

Detailed Description

Macros for declaring thread stacks.

Macro Definition Documentation

◆ K_KERNEL_STACK_LEN

#define K_KERNEL_STACK_LEN ( size)
Value:
ROUND_UP(Z_KERNEL_STACK_SIZE_ADJUST(size), Z_KERNEL_STACK_OBJ_ALIGN)
#define ROUND_UP(x, align)
Value of x rounded up to the next multiple of align.
Definition util.h:322

◆ K_KERNEL_STACK_RESERVED

#define K_KERNEL_STACK_RESERVED   ((size_t)0)

◆ K_THREAD_STACK_RESERVED

#define K_THREAD_STACK_RESERVED   ((size_t)0U)

Indicate how much additional memory is reserved for stack objects.

Any given stack declaration may have additional memory in it for guard areas, supervisor mode stacks, or platform-specific data. This macro indicates how much space is reserved for this.

This value only indicates memory that is permanently reserved in the stack object. Memory that is "borrowed" from the thread's stack buffer is never accounted for here.

Reserved memory is at the beginning of the stack object. The reserved area must be appropriately sized such that the stack buffer immediately following it is correctly aligned.

Function Documentation

◆ K_KERNEL_STACK_BUFFER()

static char * K_KERNEL_STACK_BUFFER ( k_thread_stack_t * sym)
inlinestatic

◆ K_THREAD_STACK_BUFFER()

static char * K_THREAD_STACK_BUFFER ( k_thread_stack_t * sym)
inlinestatic

Get a pointer to the physical stack buffer.

Obtain a pointer to the non-reserved area of a stack object. This is not guaranteed to be the beginning of the thread-writable region; this does not account for any memory carved-out for MPU stack overflow guards.

Use with care. The true bounds of the stack buffer are available in the stack_info member of its associated thread.

Parameters
symdefined stack symbol name
Returns
The buffer itself, a char *