arch/ceva: Update tls handle to the latest mainline
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
parent
4bc5b246ac
commit
f8df491d5d
@ -1,74 +0,0 @@
|
||||
/****************************************************************************
|
||||
* arch/ceva/include/tls.h
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ARCH_CEVA_INCLUDE_TLS_H
|
||||
#define __ARCH_CEVA_INCLUDE_TLS_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <assert.h>
|
||||
#include <nuttx/arch.h>
|
||||
#include <nuttx/tls.h>
|
||||
|
||||
#ifdef CONFIG_TLS
|
||||
|
||||
/****************************************************************************
|
||||
* Inline Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: up_tls_info
|
||||
*
|
||||
* Description:
|
||||
* Return the TLS information structure for the currently executing thread.
|
||||
* When TLS is enabled, up_createstack() will align allocated stacks to
|
||||
* the TLS_STACK_ALIGN value. An instance of the following structure will
|
||||
* be implicitly positioned at the "lower" end of the stack. Assuming a
|
||||
* "push down" stack, this is at the "far" end of the stack (and can be
|
||||
* clobbered if the stack overflows).
|
||||
*
|
||||
* If an MCU has a "push up" then that TLS structure will lie at the top
|
||||
* of the stack and stack allocation and initialization logic must take
|
||||
* care to preserve this structure content.
|
||||
*
|
||||
* The stack memory is fully accessible to user mode threads.
|
||||
*
|
||||
* Input Parameters:
|
||||
* None
|
||||
*
|
||||
* Returned Value:
|
||||
* A pointer to TLS info structure at the beginning of the STACK memory
|
||||
* allocation. This is essentially an application of the TLS_INFO(sp)
|
||||
* macro and has a platform dependency only in the manner in which the
|
||||
* stack pointer (sp) is obtained and interpreted.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static inline FAR struct tls_info_s *up_tls_info(void)
|
||||
{
|
||||
DEBUGASSERT(!up_interrupt_context());
|
||||
return TLS_INFO((uintptr_t)up_getsp());
|
||||
}
|
||||
|
||||
#endif /* CONFIG_TLS */
|
||||
#endif /* __ARCH_CEVA_INCLUDE_TLS_H */
|
@ -38,7 +38,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
|
||||
@ -57,41 +57,12 @@ 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)
|
||||
{
|
||||
uintptr_t start;
|
||||
uintptr_t end;
|
||||
FAR uint32_t *ptr;
|
||||
size_t nwords;
|
||||
size_t mark;
|
||||
|
||||
if (size == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Get aligned addresses of the top and bottom of the stack */
|
||||
|
||||
#ifdef CONFIG_TLS
|
||||
if (!int_stack)
|
||||
{
|
||||
/* Skip over the TLS data structure at the bottom of the stack */
|
||||
|
||||
DEBUGASSERT(alloc & (TLS_STACK_ALIGN - 1) == 0);
|
||||
start = alloc + sizeof(struct tls_info_s);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
DEBUGASSERT(alloc & (sizeof(uint32_t) - 1) == 0);
|
||||
start = alloc;
|
||||
}
|
||||
|
||||
end = alloc + size;
|
||||
|
||||
/* Get the adjusted size based on the top and bottom of the stack */
|
||||
|
||||
size = end - start;
|
||||
nwords = size / sizeof(uint32_t);
|
||||
|
||||
/* The CEVA uses a push-down stack: the stack grows toward lower addresses
|
||||
@ -100,7 +71,7 @@ static size_t do_stackcheck(uintptr_t alloc, size_t size, bool int_stack)
|
||||
* that does not have the magic value is the high water mark.
|
||||
*/
|
||||
|
||||
for (ptr = (FAR uint32_t *)start, mark = nwords;
|
||||
for (ptr = (FAR uint32_t *)alloc, mark = nwords;
|
||||
*ptr == STACK_COLOR && mark > 0;
|
||||
ptr++, mark--);
|
||||
|
||||
@ -171,7 +142,7 @@ 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);
|
||||
tcb->adj_stack_size);
|
||||
}
|
||||
|
||||
ssize_t up_check_tcbstack_remain(FAR struct tcb_s *tcb)
|
||||
@ -192,8 +163,7 @@ ssize_t up_check_stack_remain(void)
|
||||
size_t up_check_intstack(void)
|
||||
{
|
||||
return do_stackcheck((uintptr_t)&g_intstackalloc,
|
||||
&g_intstackbase - &g_intstackalloc,
|
||||
true);
|
||||
&g_intstackbase - &g_intstackalloc);
|
||||
}
|
||||
|
||||
size_t up_check_intstack_remain(void)
|
||||
|
@ -97,10 +97,6 @@
|
||||
int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype)
|
||||
{
|
||||
#ifdef CONFIG_TLS
|
||||
/* Add the size of the TLS information structure */
|
||||
|
||||
stack_size += sizeof(struct tls_info_s);
|
||||
|
||||
/* The allocated stack size must not exceed the maximum possible for the
|
||||
* TLS feature.
|
||||
*/
|
||||
@ -188,9 +184,6 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype)
|
||||
|
||||
if (tcb->stack_alloc_ptr)
|
||||
{
|
||||
#if defined(CONFIG_TLS) && defined(CONFIG_STACK_COLORATION)
|
||||
FAR void *stack_base;
|
||||
#endif
|
||||
FAR void *top_of_stack;
|
||||
size_t size_of_stack;
|
||||
|
||||
@ -213,23 +206,6 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype)
|
||||
tcb->adj_stack_ptr = top_of_stack;
|
||||
tcb->adj_stack_size = size_of_stack;
|
||||
|
||||
#ifdef CONFIG_TLS
|
||||
/* Initialize the TLS data structure */
|
||||
|
||||
memset(tcb->stack_alloc_ptr, 0, sizeof(struct tls_info_s));
|
||||
|
||||
#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.
|
||||
*/
|
||||
|
||||
stack_base = tcb->stack_alloc_ptr + sizeof(struct tls_info_s);
|
||||
stack_size = tcb->adj_stack_size - sizeof(struct tls_info_s);
|
||||
up_stack_color(stack_base, stack_size);
|
||||
|
||||
#endif /* CONFIG_STACK_COLORATION */
|
||||
#else /* CONFIG_TLS */
|
||||
#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
|
||||
@ -239,7 +215,6 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype)
|
||||
up_stack_color(tcb->stack_alloc_ptr, tcb->adj_stack_size);
|
||||
|
||||
#endif /* CONFIG_STACK_COLORATION */
|
||||
#endif /* CONFIG_TLS */
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
@ -118,24 +118,12 @@ int up_use_stack(FAR struct tcb_s *tcb, FAR void *stack, size_t stack_size)
|
||||
tcb->adj_stack_ptr = top_of_stack;
|
||||
tcb->adj_stack_size = size_of_stack;
|
||||
|
||||
#ifdef CONFIG_TLS
|
||||
/* Initialize the TLS data structure */
|
||||
|
||||
memset(tcb->stack_alloc_ptr, 0, sizeof(struct tls_info_s));
|
||||
#endif
|
||||
|
||||
#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.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_TLS
|
||||
up_stack_color(
|
||||
tcb->stack_alloc_ptr + sizeof(struct tls_info_s),
|
||||
tcb->adj_stack_size - sizeof(struct tls_info_s));
|
||||
#else
|
||||
up_stack_color(tcb->stack_alloc_ptr, tcb->adj_stack_size);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
return OK;
|
||||
|
Loading…
Reference in New Issue
Block a user