diff --git a/arch/arm/include/tls.h b/arch/arm/include/tls.h index b96610cbedb..49c5045415a 100644 --- a/arch/arm/include/tls.h +++ b/arch/arm/include/tls.h @@ -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() diff --git a/arch/avr/include/arch.h b/arch/avr/include/arch.h index ccbf8890ce7..51219aa2bbf 100644 --- a/arch/avr/include/arch.h +++ b/arch/avr/include/arch.h @@ -46,6 +46,12 @@ #include +#ifdef CONFIG_ARCH_FAMILY_AVR32 +# include +#else +# include +#endif + /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ diff --git a/arch/avr/include/avr/arch.h b/arch/avr/include/avr/arch.h new file mode 100644 index 00000000000..d7c695ad6b1 --- /dev/null +++ b/arch/avr/include/avr/arch.h @@ -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 */ diff --git a/arch/avr/include/avr32/arch.h b/arch/avr/include/avr32/arch.h new file mode 100644 index 00000000000..c7657306564 --- /dev/null +++ b/arch/avr/include/avr32/arch.h @@ -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 */ diff --git a/arch/avr/include/tls.h b/arch/avr/include/tls.h new file mode 100644 index 00000000000..06ed9f3fad7 --- /dev/null +++ b/arch/avr/include/tls.h @@ -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 +#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. + * + ****************************************************************************/ + +#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 */ diff --git a/arch/hc/include/tls.h b/arch/hc/include/tls.h new file mode 100644 index 00000000000..e7cc678e433 --- /dev/null +++ b/arch/hc/include/tls.h @@ -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 +#include +#include +#include + +#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 */ diff --git a/arch/mips/include/tls.h b/arch/mips/include/tls.h new file mode 100644 index 00000000000..bd88d26efe2 --- /dev/null +++ b/arch/mips/include/tls.h @@ -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 +#include +#include +#include + +#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 */ diff --git a/arch/misoc/include/tls.h b/arch/misoc/include/tls.h new file mode 100644 index 00000000000..e8af51f9b09 --- /dev/null +++ b/arch/misoc/include/tls.h @@ -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 +#include +#include +#include + +#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 */ diff --git a/arch/or1k/include/tls.h b/arch/or1k/include/tls.h new file mode 100644 index 00000000000..1b8fd221682 --- /dev/null +++ b/arch/or1k/include/tls.h @@ -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 +#include +#include +#include + +#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 */ diff --git a/arch/renesas/include/arch.h b/arch/renesas/include/arch.h index 5bb9298daca..bf8973af598 100644 --- a/arch/renesas/include/arch.h +++ b/arch/renesas/include/arch.h @@ -44,6 +44,12 @@ * Included Files ****************************************************************************/ +#include + +/* Include chip-specific definitions */ + +#include + /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ diff --git a/arch/renesas/include/m16c/arch.h b/arch/renesas/include/m16c/arch.h new file mode 100644 index 00000000000..f76e9c46ded --- /dev/null +++ b/arch/renesas/include/m16c/arch.h @@ -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 */ diff --git a/arch/renesas/include/rx65n/arch.h b/arch/renesas/include/rx65n/arch.h new file mode 100644 index 00000000000..e08e9610024 --- /dev/null +++ b/arch/renesas/include/rx65n/arch.h @@ -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 */ diff --git a/arch/renesas/include/sh1/arch.h b/arch/renesas/include/sh1/arch.h new file mode 100644 index 00000000000..e20826c58e1 --- /dev/null +++ b/arch/renesas/include/sh1/arch.h @@ -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 */ diff --git a/arch/renesas/include/tls.h b/arch/renesas/include/tls.h new file mode 100644 index 00000000000..8998cd8f696 --- /dev/null +++ b/arch/renesas/include/tls.h @@ -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 +#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. + * + ****************************************************************************/ + +#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 */ diff --git a/arch/risc-v/include/arch.h b/arch/risc-v/include/arch.h index 970bd5b6fc3..f2c45b63d41 100644 --- a/arch/risc-v/include/arch.h +++ b/arch/risc-v/include/arch.h @@ -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); diff --git a/arch/risc-v/include/rv32im/arch.h b/arch/risc-v/include/rv32im/arch.h new file mode 100644 index 00000000000..ff9418f364b --- /dev/null +++ b/arch/risc-v/include/rv32im/arch.h @@ -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 */ diff --git a/arch/risc-v/include/rv64gc/arch.h b/arch/risc-v/include/rv64gc/arch.h new file mode 100644 index 00000000000..58a7b3a245d --- /dev/null +++ b/arch/risc-v/include/rv64gc/arch.h @@ -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 */ diff --git a/arch/risc-v/include/tls.h b/arch/risc-v/include/tls.h new file mode 100644 index 00000000000..70afee99a57 --- /dev/null +++ b/arch/risc-v/include/tls.h @@ -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 +#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. + * + ****************************************************************************/ + +#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 */ diff --git a/arch/risc-v/src/common/riscv_createstack.c b/arch/risc-v/src/common/riscv_createstack.c index 449fec64f7e..472e097cf5a 100644 --- a/arch/risc-v/src/common/riscv_createstack.c +++ b/arch/risc-v/src/common/riscv_createstack.c @@ -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 */ diff --git a/arch/x86/include/tls.h b/arch/x86/include/tls.h new file mode 100644 index 00000000000..fbec9a2ef1a --- /dev/null +++ b/arch/x86/include/tls.h @@ -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 +#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. + * + ****************************************************************************/ + +#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 */ diff --git a/arch/x86_64/include/tls.h b/arch/x86_64/include/tls.h new file mode 100644 index 00000000000..e9462abb865 --- /dev/null +++ b/arch/x86_64/include/tls.h @@ -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 +#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. + * + ****************************************************************************/ + +#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 */ diff --git a/arch/xtensa/include/tls.h b/arch/xtensa/include/tls.h new file mode 100644 index 00000000000..33735ca9fcf --- /dev/null +++ b/arch/xtensa/include/tls.h @@ -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 +#include +#include +#include + +#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 */ diff --git a/arch/z16/include/tls.h b/arch/z16/include/tls.h new file mode 100644 index 00000000000..d2a1a16ecd1 --- /dev/null +++ b/arch/z16/include/tls.h @@ -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 +#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. + * + ****************************************************************************/ + +#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 */ diff --git a/arch/z80/include/tls.h b/arch/z80/include/tls.h new file mode 100644 index 00000000000..381a103c299 --- /dev/null +++ b/arch/z80/include/tls.h @@ -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 +#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. + * + ****************************************************************************/ + +#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 */