arm_xxxxstack.c: small style fixes, changed calculation of stack start for checkstack.

This commit is contained in:
Johannes Schock 2020-08-13 18:04:48 +02:00 committed by patacongo
parent 87614e2efd
commit 01715e4566
3 changed files with 9 additions and 26 deletions

View File

@ -59,7 +59,7 @@
* Private Function Prototypes
****************************************************************************/
static size_t do_stackcheck(uintptr_t alloc, size_t size, bool int_stack);
static size_t do_stackcheck(uintptr_t alloc, size_t size);
/****************************************************************************
* Name: do_stackcheck
@ -78,7 +78,7 @@ static size_t do_stackcheck(uintptr_t alloc, size_t size, bool int_stack);
*
****************************************************************************/
static size_t do_stackcheck(uintptr_t alloc, size_t size, bool int_stack)
static size_t do_stackcheck(uintptr_t alloc, size_t size)
{
FAR uintptr_t start;
FAR uintptr_t end;
@ -92,20 +92,7 @@ static size_t do_stackcheck(uintptr_t alloc, size_t size, bool int_stack)
/* Get aligned addresses of the top and bottom of the stack */
if (!int_stack)
{
/* Skip over the TLS data structure at the bottom of the stack */
#ifdef CONFIG_TLS_ALIGNED
DEBUGASSERT((alloc & TLS_STACK_MASK) == 0);
#endif
start = alloc + sizeof(struct tls_info_s);
}
else
{
start = alloc & ~3;
}
start = alloc & ~3;
end = (alloc + size + 3) & ~3;
/* Get the adjusted size based on the top and bottom of the stack */
@ -188,8 +175,8 @@ static size_t do_stackcheck(uintptr_t alloc, size_t size, bool int_stack)
size_t up_check_tcbstack(FAR struct tcb_s *tcb)
{
return do_stackcheck((uintptr_t)tcb->stack_alloc_ptr, tcb->adj_stack_size,
false);
return do_stackcheck((uintptr_t)tcb->adj_stack_ptr - tcb->adj_stack_size,
tcb->adj_stack_size);
}
ssize_t up_check_tcbstack_remain(FAR struct tcb_s *tcb)
@ -212,12 +199,10 @@ size_t up_check_intstack(void)
{
#ifdef CONFIG_SMP
return do_stackcheck(arm_intstack_base(),
(CONFIG_ARCH_INTERRUPTSTACK & ~3),
true);
(CONFIG_ARCH_INTERRUPTSTACK & ~3));
#else
return do_stackcheck((uintptr_t)&g_intstackalloc,
(CONFIG_ARCH_INTERRUPTSTACK & ~3),
true);
(CONFIG_ARCH_INTERRUPTSTACK & ~3));
#endif
}

View File

@ -218,7 +218,6 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype)
arm_stack_color((FAR void *)((uintptr_t)tcb->adj_stack_ptr -
tcb->adj_stack_size), tcb->adj_stack_size);
#endif /* CONFIG_STACK_COLORATION */
board_autoled_on(LED_STACKCREATED);

View File

@ -137,7 +137,7 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t stack_size)
memset(tcb->stack_alloc_ptr, 0, sizeof(struct tls_info_s));
#ifdef CONFIG_STACK_COLORATION
#ifdef CONFIG_STACK_COLORATION
/* If stack debug is enabled, then fill the stack with a
* recognizable value that we can use later to test for high
* water marks.
@ -145,8 +145,7 @@ int up_use_stack(struct tcb_s *tcb, void *stack, size_t stack_size)
arm_stack_color((FAR void *)((uintptr_t)tcb->adj_stack_ptr -
tcb->adj_stack_size), tcb->adj_stack_size);
#endif /* CONFIG_STACK_COLORATION */
#endif /* CONFIG_STACK_COLORATION */
return OK;
}