kernel: align kernel stack size declaration
When kernel stack is defined as an array, K_KERNEL_STACK_LEN() is used to calculate the size for each stack in the array. However, standalone kernel stack has its size calculated by Z_KERNEL_STACK_SIZE_ADJUST() instead. Depending on the arch alignment requirement, they may not be the same... which could cause some confusions. So align them both to use K_KERNEL_STACK_LEN(). Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This commit is contained in:
parent
b9f66b26f8
commit
6cd7936f57
8 changed files with 11 additions and 11 deletions
|
@ -107,9 +107,9 @@ struct x86_cpuboot x86_cpuboot[] = {
|
||||||
.tr = X86_KERNEL_CPU0_TR,
|
.tr = X86_KERNEL_CPU0_TR,
|
||||||
.gs_base = &tss0,
|
.gs_base = &tss0,
|
||||||
.sp = (uint64_t) z_interrupt_stacks[0] +
|
.sp = (uint64_t) z_interrupt_stacks[0] +
|
||||||
Z_KERNEL_STACK_SIZE_ADJUST(CONFIG_ISR_STACK_SIZE),
|
K_KERNEL_STACK_LEN(CONFIG_ISR_STACK_SIZE),
|
||||||
.stack_size =
|
.stack_size =
|
||||||
Z_KERNEL_STACK_SIZE_ADJUST(CONFIG_ISR_STACK_SIZE),
|
K_KERNEL_STACK_LEN(CONFIG_ISR_STACK_SIZE),
|
||||||
.fn = z_prep_c,
|
.fn = z_prep_c,
|
||||||
.arg = &x86_cpu_boot_arg,
|
.arg = &x86_cpu_boot_arg,
|
||||||
},
|
},
|
||||||
|
|
|
@ -123,7 +123,7 @@ static inline char *z_stack_ptr_align(char *ptr)
|
||||||
*/
|
*/
|
||||||
#define K_KERNEL_STACK_DECLARE(sym, size) \
|
#define K_KERNEL_STACK_DECLARE(sym, size) \
|
||||||
extern struct z_thread_stack_element \
|
extern struct z_thread_stack_element \
|
||||||
sym[Z_KERNEL_STACK_SIZE_ADJUST(size)]
|
sym[K_KERNEL_STACK_LEN(size)]
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Declare a reference to a thread stack array
|
* @brief Declare a reference to a thread stack array
|
||||||
|
@ -175,7 +175,7 @@ static inline char *z_stack_ptr_align(char *ptr)
|
||||||
#define Z_KERNEL_STACK_DEFINE_IN(sym, size, lsect) \
|
#define Z_KERNEL_STACK_DEFINE_IN(sym, size, lsect) \
|
||||||
struct z_thread_stack_element lsect \
|
struct z_thread_stack_element lsect \
|
||||||
__aligned(Z_KERNEL_STACK_OBJ_ALIGN) \
|
__aligned(Z_KERNEL_STACK_OBJ_ALIGN) \
|
||||||
sym[Z_KERNEL_STACK_SIZE_ADJUST(size)]
|
sym[K_KERNEL_STACK_LEN(size)]
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Define a toplevel array of kernel stack memory regions in specified section
|
* @brief Define a toplevel array of kernel stack memory regions in specified section
|
||||||
|
|
|
@ -49,7 +49,7 @@ extern "C" {
|
||||||
#define PTHREAD_ONCE_INIT {0}
|
#define PTHREAD_ONCE_INIT {0}
|
||||||
|
|
||||||
/* The minimum allowable stack size */
|
/* The minimum allowable stack size */
|
||||||
#define PTHREAD_STACK_MIN Z_KERNEL_STACK_SIZE_ADJUST(0)
|
#define PTHREAD_STACK_MIN K_KERNEL_STACK_LEN(0)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Declare a condition variable as initialized
|
* @brief Declare a condition variable as initialized
|
||||||
|
|
|
@ -75,7 +75,7 @@ static k_thread_stack_t *stack_alloc_dyn(size_t size, int flags)
|
||||||
}
|
}
|
||||||
|
|
||||||
return z_thread_stack_alloc_dyn(Z_KERNEL_STACK_OBJ_ALIGN,
|
return z_thread_stack_alloc_dyn(Z_KERNEL_STACK_OBJ_ALIGN,
|
||||||
Z_KERNEL_STACK_SIZE_ADJUST(size));
|
K_KERNEL_STACK_LEN(size));
|
||||||
}
|
}
|
||||||
|
|
||||||
k_thread_stack_t *z_impl_k_thread_stack_alloc(size_t size, int flags)
|
k_thread_stack_t *z_impl_k_thread_stack_alloc(size_t size, int flags)
|
||||||
|
|
|
@ -391,7 +391,7 @@ static char *setup_thread_stack(struct k_thread *new_thread,
|
||||||
#endif /* CONFIG_USERSPACE */
|
#endif /* CONFIG_USERSPACE */
|
||||||
{
|
{
|
||||||
/* Object cannot host a user mode thread */
|
/* Object cannot host a user mode thread */
|
||||||
stack_obj_size = Z_KERNEL_STACK_SIZE_ADJUST(stack_size);
|
stack_obj_size = K_KERNEL_STACK_LEN(stack_size);
|
||||||
stack_buf_start = K_KERNEL_STACK_BUFFER(stack);
|
stack_buf_start = K_KERNEL_STACK_BUFFER(stack);
|
||||||
stack_buf_size = stack_obj_size - K_KERNEL_STACK_RESERVED;
|
stack_buf_size = stack_obj_size - K_KERNEL_STACK_RESERVED;
|
||||||
|
|
||||||
|
|
|
@ -122,7 +122,7 @@ cy_rslt_t cy_rtos_create_thread(cy_thread_t *thread, cy_thread_entry_fn_t entry_
|
||||||
/* Allocate stack if NULL was passed */
|
/* Allocate stack if NULL was passed */
|
||||||
if ((uint32_t *)stack == NULL) {
|
if ((uint32_t *)stack == NULL) {
|
||||||
stack_alloc = k_aligned_alloc(Z_KERNEL_STACK_OBJ_ALIGN,
|
stack_alloc = k_aligned_alloc(Z_KERNEL_STACK_OBJ_ALIGN,
|
||||||
Z_KERNEL_STACK_SIZE_ADJUST(stack_size));
|
K_KERNEL_STACK_LEN(stack_size));
|
||||||
|
|
||||||
/* Store pointer to allocated stack,
|
/* Store pointer to allocated stack,
|
||||||
* NULL if not allocated by cy_rtos_thread_create (passed by application).
|
* NULL if not allocated by cy_rtos_thread_create (passed by application).
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
#ifdef CONFIG_USERSPACE
|
#ifdef CONFIG_USERSPACE
|
||||||
#define STACK_OBJ_SIZE Z_THREAD_STACK_SIZE_ADJUST(CONFIG_DYNAMIC_THREAD_STACK_SIZE)
|
#define STACK_OBJ_SIZE Z_THREAD_STACK_SIZE_ADJUST(CONFIG_DYNAMIC_THREAD_STACK_SIZE)
|
||||||
#else
|
#else
|
||||||
#define STACK_OBJ_SIZE Z_KERNEL_STACK_SIZE_ADJUST(CONFIG_DYNAMIC_THREAD_STACK_SIZE)
|
#define STACK_OBJ_SIZE K_KERNEL_STACK_LEN(CONFIG_DYNAMIC_THREAD_STACK_SIZE)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define MAX_HEAP_STACKS (POOL_SIZE / STACK_OBJ_SIZE)
|
#define MAX_HEAP_STACKS (POOL_SIZE / STACK_OBJ_SIZE)
|
||||||
|
|
|
@ -235,7 +235,7 @@ void stack_buffer_scenarios(void)
|
||||||
* K_THREAD_STACK_SIZEOF(my_stack)
|
* K_THREAD_STACK_SIZEOF(my_stack)
|
||||||
*
|
*
|
||||||
* K_KERNEL_STACK_DEFINE(my_kern_stack, Y):
|
* K_KERNEL_STACK_DEFINE(my_kern_stack, Y):
|
||||||
* Z_KERNEL_STACK_SIZE_ADJUST(Y) - K_KERNEL_STACK_RESERVED ==
|
* K_KERNEL_STACK_LEN(Y) - K_KERNEL_STACK_RESERVED ==
|
||||||
* K_KERNEL_STACK_SIZEOF(my_stack)
|
* K_KERNEL_STACK_SIZEOF(my_stack)
|
||||||
*/
|
*/
|
||||||
#ifdef CONFIG_USERSPACE
|
#ifdef CONFIG_USERSPACE
|
||||||
|
@ -245,7 +245,7 @@ void stack_buffer_scenarios(void)
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
adjusted = Z_KERNEL_STACK_SIZE_ADJUST(scenario_data.declared_size);
|
adjusted = K_KERNEL_STACK_LEN(scenario_data.declared_size);
|
||||||
}
|
}
|
||||||
adjusted -= reserved;
|
adjusted -= reserved;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue