arch/: Implement up_tls_info() for the rest of the architectures.

This commit is contained in:
Ouss4 2020-05-07 00:32:41 +01:00 committed by patacongo
parent 1e3ec6ecd0
commit a4dd967440
24 changed files with 1628 additions and 7 deletions

View file

@ -37,12 +37,12 @@
****************************************************************************/
/****************************************************************************
* Name: up_getsp
* Name: arm_getsp
****************************************************************************/
/* I don't know if the builtin to get SP is enabled */
static inline uint32_t up_getsp(void)
static inline uint32_t arm_getsp(void)
{
uint32_t sp;
__asm__
@ -86,7 +86,7 @@ static inline uint32_t up_getsp(void)
static inline FAR struct tls_info_s *up_tls_info(void)
{
DEBUGASSERT(!up_interrupt_context());
return TLS_INFO((uintptr_t)up_getsp());
return TLS_INFO((uintptr_t)arm_getsp());
}
#else
# define up_tls_info() tls_get_info()

View file

@ -46,6 +46,12 @@
#include <nuttx/config.h>
#ifdef CONFIG_ARCH_FAMILY_AVR32
# include <arch/avr32/arch.h>
#else
# include <arch/avr/arch.h>
#endif
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/

View file

@ -0,0 +1,87 @@
/****************************************************************************
* arch/avr/include/avr/arch.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.
*
****************************************************************************/
/* This file should never be included directly but, rather,
* only indirectly through nuttx/arch.h
*/
#ifndef __ARCH_AVR_INCLUDE_AVR_ARCH_H
#define __ARCH_AVR_INCLUDE_AVR_ARCH_H
/****************************************************************************
* Included Files
****************************************************************************/
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Public Types
****************************************************************************/
#ifndef __ASSEMBLY__
/****************************************************************************
* Inline functions
****************************************************************************/
/****************************************************************************
* Name: avr_getsp
****************************************************************************/
static inline uint16_t avr_getsp(void)
{
uint8_t spl;
uint8_t sph;
__asm__ __volatile__
(
"in %0, __SP_L__\n\t"
"in %1, __SP_H__\n"
: "=r" (spl), "=r" (sph)
:
);
return (uint16_t)sph << 8 | spl;
}
/****************************************************************************
* Public Variables
****************************************************************************/
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
#ifdef __cplusplus
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
#undef EXTERN
#ifdef __cplusplus
}
#endif
#endif /* __ASSEMBLY__ */
#endif /* __ARCH_AVR_INCLUDE_AVR_ARCH_H */

View file

@ -0,0 +1,84 @@
/****************************************************************************
* arch/avr/include/avr32/arch.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.
*
****************************************************************************/
/* This file should never be included directly but, rather,
* only indirectly through nuttx/arch.h
*/
#ifndef __ARCH_AVR_INCLUDE_AVR32_ARCH_H
#define __ARCH_AVR_INCLUDE_AVR32_ARCH_H
/****************************************************************************
* Included Files
****************************************************************************/
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Public Types
****************************************************************************/
#ifndef __ASSEMBLY__
/****************************************************************************
* Inline functions
****************************************************************************/
/****************************************************************************
* Name: avr_getsp
****************************************************************************/
static inline uint32_t avr_getsp(void)
{
uint32_t retval;
__asm__ __volatile__
(
"mov\t%0,sp\n\t"
: "=r" (retval)
:
);
return retval;
}
/****************************************************************************
* Public Variables
****************************************************************************/
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
#ifdef __cplusplus
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
#undef EXTERN
#ifdef __cplusplus
}
#endif
#endif /* __ASSEMBLY__ */
#endif /* __ARCH_AVR_INCLUDE_AVR32_ARCH_H */

78
arch/avr/include/tls.h Normal file
View file

@ -0,0 +1,78 @@
/****************************************************************************
* arch/avr/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_AVR_INCLUDE_TLS_H
#define __ARCH_AVR_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.
*
****************************************************************************/
#ifdef CONFIG_TLS_ALIGNED
static inline FAR struct tls_info_s *up_tls_info(void)
{
DEBUGASSERT(!up_interrupt_context());
return TLS_INFO((uintptr_t)avr_getsp());
}
#else
# define up_tls_info() tls_get_info()
#endif
#endif /* CONFIG_TLS */
#endif /* __ARCH_AVR_INCLUDE_TLS_H */

93
arch/hc/include/tls.h Normal file
View file

@ -0,0 +1,93 @@
/****************************************************************************
* arch/hc/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_HC_INCLUDE_TLS_H
#define __ARCH_HC_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: hc_getsp
****************************************************************************/
static inline uint16_t hc_getsp(void)
{
uint16_t ret;
__asm__
(
"\tsts %0\n"
: "=m"(ret) :
);
return ret;
}
/****************************************************************************
* 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.
*
****************************************************************************/
#ifdef CONFIG_TLS_ALIGNED
static inline FAR struct tls_info_s *up_tls_info(void)
{
DEBUGASSERT(!up_interrupt_context());
return TLS_INFO((uintptr_t)hc_getsp());
}
#else
# define up_tls_info() tls_get_info()
#endif
#endif /* CONFIG_TLS */
#endif /* __ARCH_HC_INCLUDE_TLS_H */

93
arch/mips/include/tls.h Normal file
View file

@ -0,0 +1,93 @@
/****************************************************************************
* arch/mips/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_MIPS_INCLUDE_TLS_H
#define __ARCH_MIPS_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: mips_getsp
****************************************************************************/
static inline uint32_t mips_getsp(void)
{
register uint32_t sp;
__asm__
(
"\tadd %0, $0, $29\n"
: "=r"(sp)
);
return sp;
}
/****************************************************************************
* 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.
*
****************************************************************************/
#ifdef CONFIG_TLS_ALIGNED
static inline FAR struct tls_info_s *up_tls_info(void)
{
DEBUGASSERT(!up_interrupt_context());
return TLS_INFO((uintptr_t)mips_getsp());
}
#else
# define up_tls_info() tls_get_info()
#endif
#endif /* CONFIG_TLS */
#endif /* __ARCH_MIPS_INCLUDE_TLS_H */

92
arch/misoc/include/tls.h Normal file
View file

@ -0,0 +1,92 @@
/****************************************************************************
* arch/misoc/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_MISOC_INCLUDE_TLS_H
#define __ARCH_MISOC_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: misoc_getsp
****************************************************************************/
static inline uint32_t misoc_getsp(void)
{
register uint32_t sp;
__asm__ __volatile__("addi %0, sp, 0" : "=r" (sp));
return sp;
}
/****************************************************************************
* 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.
*
****************************************************************************/
#ifdef CONFIG_TLS_ALIGNED
static inline FAR struct tls_info_s *up_tls_info(void)
{
DEBUGASSERT(!up_interrupt_context());
return TLS_INFO((uintptr_t)misoc_getsp());
}
#else
# define up_tls_info() tls_get_info()
#endif
#endif /* CONFIG_TLS */
#endif /* __ARCH_MISOC_INCLUDE_TLS_H */

95
arch/or1k/include/tls.h Normal file
View file

@ -0,0 +1,95 @@
/****************************************************************************
* arch/or1k/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_OR1K_INCLUDE_TLS_H
#define __ARCH_OR1K_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: or1k_getsp
****************************************************************************/
static inline uint32_t or1k_getsp(void)
{
uint32_t sp;
__asm__
(
"\tmov %0, sp\n\t"
: "=r"(sp)
);
return sp;
}
/****************************************************************************
* 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.
*
****************************************************************************/
#ifdef CONFIG_TLS_ALIGNED
static inline FAR struct tls_info_s *up_tls_info(void)
{
DEBUGASSERT(!up_interrupt_context());
return TLS_INFO((uintptr_t)or1k_getsp());
}
#else
# define up_tls_info() tls_get_info()
#endif
#endif /* CONFIG_TLS */
#endif /* __ARCH_OR1K_INCLUDE_TLS_H */

View file

@ -44,6 +44,12 @@
* Included Files
****************************************************************************/
#include <nuttx/config.h>
/* Include chip-specific definitions */
#include <arch/chip/arch.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/

View file

@ -0,0 +1,86 @@
/****************************************************************************
* arch/renesas/include/m16c/arch.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.
*
****************************************************************************/
/* This file should never be included directly but, rather,
* only indirectly through nuttx/arch.h
*/
#ifndef __ARCH_RENESAS_INCLUDE_M16C_ARCH_H
#define __ARCH_RENESAS_INCLUDE_M16C_ARCH_H
/****************************************************************************
* Included Files
****************************************************************************/
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Public Types
****************************************************************************/
#ifndef __ASSEMBLY__
/****************************************************************************
* Inline functions
****************************************************************************/
/****************************************************************************
* Name: renesas_getsp
****************************************************************************/
static inline uint16_t renesas_getsp(void)
{
uint16_t sp;
__asm__ __volatile__
(
"\tstc sp, %0\n\t"
: "=r" (sp)
:
: "memory"
);
return sp;
}
/****************************************************************************
* Public Variables
****************************************************************************/
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
#ifdef __cplusplus
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
#undef EXTERN
#ifdef __cplusplus
}
#endif
#endif /* __ASSEMBLY__ */
#endif /* __ARCH_RENESAS_INCLUDE_M16C_ARCH_H */

View file

@ -0,0 +1,87 @@
/****************************************************************************
* arch/renesas/include/rx65n/arch.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.
*
****************************************************************************/
/* This file should never be included directly but, rather,
* only indirectly through nuttx/arch.h
*/
#ifndef __ARCH_RENESAS_INCLUDE_RX65N_ARCH_H
#define __ARCH_RENESAS_INCLUDE_RX65N_ARCH_H
/****************************************************************************
* Included Files
****************************************************************************/
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Public Types
****************************************************************************/
#ifndef __ASSEMBLY__
/****************************************************************************
* Inline functions
****************************************************************************/
/****************************************************************************
* Name: renesas_getsp
****************************************************************************/
static inline uint16_t renesas_getsp(void)
{
uint16_t sp;
__asm__ __volatile__
(
"\tmvfc usp, %0\n\t"
: "=r" (sp)
:
:"memory"
);
return sp;
}
/****************************************************************************
* Public Variables
****************************************************************************/
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
#ifdef __cplusplus
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
#undef EXTERN
#ifdef __cplusplus
}
#endif
#endif /* __ASSEMBLY__ */
#endif /* __ARCH_RENESAS_INCLUDE_RX65N_ARCH_H */

View file

@ -0,0 +1,86 @@
/****************************************************************************
* arch/renesas/include/sh1/arch.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.
*
****************************************************************************/
/* This file should never be included directly but, rather,
* only indirectly through nuttx/arch.h
*/
#ifndef __ARCH_RENESAS_INCLUDE_SHA1_ARCH_H
#define __ARCH_RENESAS_INCLUDE_SHA1_ARCH_H
/****************************************************************************
* Included Files
****************************************************************************/
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Public Types
****************************************************************************/
#ifndef __ASSEMBLY__
/****************************************************************************
* Inline functions
****************************************************************************/
/****************************************************************************
* Name: renesas_getsp
****************************************************************************/
static inline uint32_t renesas_getsp(void)
{
uint32_t sp;
__asm__ __volatile__
(
"mov r15, %0\n\t"
: "=&z" (sp)
:
: "memory"
);
return sp;
}
/****************************************************************************
* Public Variables
****************************************************************************/
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
#ifdef __cplusplus
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
#undef EXTERN
#ifdef __cplusplus
}
#endif
#endif /* __ASSEMBLY__ */
#endif /* __ARCH_RENESAS_INCLUDE_SHA1_ARCH_H */

View file

@ -0,0 +1,78 @@
/****************************************************************************
* arch/renesas/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_RENESAS_INCLUDE_TLS_H
#define __ARCH_RENESAS_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.
*
****************************************************************************/
#ifdef CONFIG_TLS_ALIGNED
static inline FAR struct tls_info_s *up_tls_info(void)
{
DEBUGASSERT(!up_interrupt_context());
return TLS_INFO((uintptr_t)renesas_getsp());
}
#else
# define up_tls_info() tls_get_info()
#endif
#endif /* CONFIG_TLS */
#endif /* __ARCH_RENESAS_INCLUDE_TLS_H */

View file

@ -49,6 +49,11 @@
#ifdef CONFIG_ARCH_RV32IM
# include "rv32im/csr.h"
# include "rv32im/arch.h"
#endif
#ifdef CONFIG_ARCH_RV64GC
# include "rv64gc/arch.h"
#endif
/****************************************************************************
@ -57,6 +62,7 @@
/* Macros to get the core and vendor ID, HART, arch and ISA codes, etc.
*/
#ifdef CONFIG_RV32IM_SYSTEM_CSRRS_SUPPORT
uint32_t up_getmisa(void);

View file

@ -0,0 +1,83 @@
/****************************************************************************
* arch/risc-v/include/rv32im/arch.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.
*
****************************************************************************/
/* This file should never be included directly but, rather,
* only indirectly through nuttx/arch.h
*/
#ifndef __ARCH_RISCV_INCLUDE_RV32IM_ARCH_H
#define __ARCH_RISCV_INCLUDE_RV32IM_ARCH_H
/****************************************************************************
* Included Files
****************************************************************************/
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Public Types
****************************************************************************/
#ifndef __ASSEMBLY__
/****************************************************************************
* Inline functions
****************************************************************************/
/****************************************************************************
* Name: riscv_getsp
****************************************************************************/
static inline uint32_t riscv_getsp(void)
{
register uint32_t sp;
__asm__
(
"\tadd %0, x0, x2\n"
: "=r"(sp)
);
return sp;
}
/****************************************************************************
* Public Variables
****************************************************************************/
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
#ifdef __cplusplus
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
#undef EXTERN
#ifdef __cplusplus
}
#endif
#endif /* __ASSEMBLY__ */
#endif /* __ARCH_RISCV_INCLUDE_RV32IM_ARCH_H */

View file

@ -0,0 +1,83 @@
/****************************************************************************
* arch/risc-v/include/rv64gc/arch.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.
*
****************************************************************************/
/* This file should never be included directly but, rather,
* only indirectly through nuttx/arch.h
*/
#ifndef __ARCH_RISCV_INCLUDE_RV64GC_ARCH_H
#define __ARCH_RISCV_INCLUDE_RV64GC_ARCH_H
/****************************************************************************
* Included Files
****************************************************************************/
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Public Types
****************************************************************************/
#ifndef __ASSEMBLY__
/****************************************************************************
* Inline functions
****************************************************************************/
/****************************************************************************
* Name: riscv_getsp
****************************************************************************/
static inline uint64_t riscv_getsp(void)
{
register uint64_t sp;
__asm__
(
"\tadd %0, x0, x2\n"
: "=r"(sp)
);
return sp;
}
/****************************************************************************
* Public Variables
****************************************************************************/
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
#ifdef __cplusplus
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
#undef EXTERN
#ifdef __cplusplus
}
#endif
#endif /* __ASSEMBLY__ */
#endif /* __ARCH_RISCV_INCLUDE_RV64GC_ARCH_H */

78
arch/risc-v/include/tls.h Normal file
View file

@ -0,0 +1,78 @@
/****************************************************************************
* arch/riscv/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_RISCV_INCLUDE_TLS_H
#define __ARCH_RISCV_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.
*
****************************************************************************/
#ifdef CONFIG_TLS_ALIGNED
static inline FAR struct tls_info_s *up_tls_info(void)
{
DEBUGASSERT(!up_interrupt_context());
return TLS_INFO((uintptr_t)riscv_getsp());
}
#else
# define up_tls_info() tls_get_info()
#endif
#endif /* CONFIG_TLS */
#endif /* __ARCH_RISCV_INCLUDE_TLS_H */

View file

@ -265,8 +265,9 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype)
* water marks.
*/
riscv_stack_color(tcb->stack_alloc_ptr, tcb->adj_stack_size);
#endif
up_stack_color(tcb->stack_alloc_ptr, tcb->adj_stack_size);
#endif /* CONFIG_STACK_COLORATION */
#endif /* CONFIG_TLS */
board_autoled_on(LED_STACKCREATED);
return OK;
@ -276,7 +277,7 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype)
}
/****************************************************************************
* Name: riscv_stack_color
* Name: up_stack_color
*
* Description:
* Write a well know value into the stack
@ -284,7 +285,7 @@ int up_create_stack(FAR struct tcb_s *tcb, size_t stack_size, uint8_t ttype)
****************************************************************************/
#ifdef CONFIG_STACK_COLORATION
void riscv_stack_color(FAR void *stackbase, size_t nbytes)
void up_stack_color(FAR void *stackbase, size_t nbytes)
{
/* Take extra care that we do not write outsize the stack boundaries */

78
arch/x86/include/tls.h Normal file
View file

@ -0,0 +1,78 @@
/****************************************************************************
* arch/x86/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_X86_INCLUDE_TLS_H
#define __ARCH_X86_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.
*
****************************************************************************/
#ifdef CONFIG_TLS_ALIGNED
static inline FAR struct tls_info_s *up_tls_info(void)
{
DEBUGASSERT(!up_interrupt_context());
return TLS_INFO((uintptr_t)up_getsp());
}
#else
# define up_tls_info() tls_get_info()
#endif
#endif /* CONFIG_TLS */
#endif /* __ARCH_X86_INCLUDE_TLS_H */

78
arch/x86_64/include/tls.h Normal file
View file

@ -0,0 +1,78 @@
/****************************************************************************
* arch/x86_64/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_X86_64_INCLUDE_TLS_H
#define __ARCH_X86_64_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.
*
****************************************************************************/
#ifdef CONFIG_TLS_ALIGNED
static inline FAR struct tls_info_s *up_tls_info(void)
{
DEBUGASSERT(!up_interrupt_context());
return TLS_INFO((uintptr_t)up_getrsp());
}
#else
# define up_tls_info() tls_get_info()
#endif
#endif /* CONFIG_TLS */
#endif /* __ARCH_X86_64_INCLUDE_TLS_H */

95
arch/xtensa/include/tls.h Normal file
View file

@ -0,0 +1,95 @@
/****************************************************************************
* arch/xtensa/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_XTENSA_INCLUDE_TLS_H
#define __ARCH_XTENSA_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: xtensa_getsp
****************************************************************************/
static inline uint32_t xtensa_getsp(void)
{
register uint32_t sp;
__asm__ __volatile__
(
"mov %0, sp\n"
: "=r" (sp)
);
return sp;
}
/****************************************************************************
* 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.
*
****************************************************************************/
#ifdef CONFIG_TLS_ALIGNED
static inline FAR struct tls_info_s *up_tls_info(void)
{
DEBUGASSERT(!up_interrupt_context());
return TLS_INFO((uintptr_t)xtensa_getsp());
}
#else
# define up_tls_info() tls_get_info()
#endif
#endif /* CONFIG_TLS */
#endif /* __ARCH_XTENSA_INCLUDE_TLS_H */

74
arch/z16/include/tls.h Normal file
View file

@ -0,0 +1,74 @@
/****************************************************************************
* arch/z16/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_Z16_INCLUDE_TLS_H
#define __ARCH_Z16_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.
*
****************************************************************************/
#ifdef CONFIG_TLS_ALIGNED
# error "Aligned TLS not supported"
#else
# define up_tls_info() tls_get_info()
#endif
#endif /* CONFIG_TLS */
#endif /* __ARCH_Z16_INCLUDE_TLS_H */

74
arch/z80/include/tls.h Normal file
View file

@ -0,0 +1,74 @@
/****************************************************************************
* arch/z80/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_Z80_INCLUDE_TLS_H
#define __ARCH_Z80_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.
*
****************************************************************************/
#ifdef CONFIG_TLS_ALIGNED
# error "Aligned TLS not supported"
#else
# define up_tls_info() tls_get_info()
#endif
#endif /* CONFIG_TLS */
#endif /* __ARCH_Z80_INCLUDE_TLS_H */