From f8df491d5dd7414233260025a6f6416c85e07dc4 Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Thu, 17 Feb 2022 01:55:21 +0800 Subject: [PATCH] arch/ceva: Update tls handle to the latest mainline Signed-off-by: Xiang Xiao --- arch/ceva/include/tls.h | 74 --------------------------- arch/ceva/src/common/up_checkstack.c | 40 ++------------- arch/ceva/src/common/up_createstack.c | 25 --------- arch/ceva/src/common/up_usestack.c | 12 ----- 4 files changed, 5 insertions(+), 146 deletions(-) delete mode 100644 arch/ceva/include/tls.h diff --git a/arch/ceva/include/tls.h b/arch/ceva/include/tls.h deleted file mode 100644 index fbf14953d1..0000000000 --- a/arch/ceva/include/tls.h +++ /dev/null @@ -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 -#include -#include -#include - -#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 */ diff --git a/arch/ceva/src/common/up_checkstack.c b/arch/ceva/src/common/up_checkstack.c index f7450b3da2..c3f5c782b3 100644 --- a/arch/ceva/src/common/up_checkstack.c +++ b/arch/ceva/src/common/up_checkstack.c @@ -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) diff --git a/arch/ceva/src/common/up_createstack.c b/arch/ceva/src/common/up_createstack.c index 9b4626bc20..fd4288d2a1 100644 --- a/arch/ceva/src/common/up_createstack.c +++ b/arch/ceva/src/common/up_createstack.c @@ -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; } diff --git a/arch/ceva/src/common/up_usestack.c b/arch/ceva/src/common/up_usestack.c index 47bfb915dd..6fc4b780cc 100644 --- a/arch/ceva/src/common/up_usestack.c +++ b/arch/ceva/src/common/up_usestack.c @@ -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;