You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by gn...@apache.org on 2020/05/07 03:56:50 UTC
[incubator-nuttx] 02/04: arch/: Implement up_tls_info() for the
rest of the architectures.
This is an automated email from the ASF dual-hosted git repository.
gnutt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit a4dd9674406545ad38e5acbfc90309fd3bdd6bcc
Author: Ouss4 <ab...@gmail.com>
AuthorDate: Thu May 7 00:32:41 2020 +0100
arch/: Implement up_tls_info() for the rest of the architectures.
---
arch/arm/include/tls.h | 6 +--
arch/avr/include/arch.h | 6 +++
arch/avr/include/avr/arch.h | 87 ++++++++++++++++++++++++++++++
arch/avr/include/avr32/arch.h | 84 +++++++++++++++++++++++++++++
arch/{arm => avr}/include/tls.h | 28 ++--------
arch/{arm => hc}/include/tls.h | 25 ++++-----
arch/{arm => mips}/include/tls.h | 21 ++++----
arch/{arm => misoc}/include/tls.h | 26 ++++-----
arch/{arm => or1k}/include/tls.h | 17 +++---
arch/renesas/include/arch.h | 6 +++
arch/renesas/include/m16c/arch.h | 86 +++++++++++++++++++++++++++++
arch/renesas/include/rx65n/arch.h | 87 ++++++++++++++++++++++++++++++
arch/renesas/include/sh1/arch.h | 86 +++++++++++++++++++++++++++++
arch/{arm => renesas}/include/tls.h | 28 ++--------
arch/risc-v/include/arch.h | 6 +++
arch/risc-v/include/rv32im/arch.h | 83 ++++++++++++++++++++++++++++
arch/risc-v/include/rv64gc/arch.h | 83 ++++++++++++++++++++++++++++
arch/{arm => risc-v}/include/tls.h | 28 ++--------
arch/risc-v/src/common/riscv_createstack.c | 9 ++--
arch/{arm => x86}/include/tls.h | 26 ++-------
arch/{arm => x86_64}/include/tls.h | 28 ++--------
arch/{arm => xtensa}/include/tls.h | 25 +++++----
arch/{arm => z16}/include/tls.h | 32 ++---------
arch/{arm => z80}/include/tls.h | 32 ++---------
24 files changed, 707 insertions(+), 238 deletions(-)
diff --git a/arch/arm/include/tls.h b/arch/arm/include/tls.h
index b96610c..49c5045 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 ccbf889..51219aa 100644
--- a/arch/avr/include/arch.h
+++ b/arch/avr/include/arch.h
@@ -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
****************************************************************************/
diff --git a/arch/avr/include/avr/arch.h b/arch/avr/include/avr/arch.h
new file mode 100644
index 0000000..d7c695a
--- /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 0000000..c765730
--- /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/arm/include/tls.h b/arch/avr/include/tls.h
similarity index 84%
copy from arch/arm/include/tls.h
copy to arch/avr/include/tls.h
index b96610c..06ed9f3 100644
--- a/arch/arm/include/tls.h
+++ b/arch/avr/include/tls.h
@@ -1,5 +1,5 @@
/****************************************************************************
- * arch/arm/include/tls.h
+ * 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
@@ -18,8 +18,8 @@
*
****************************************************************************/
-#ifndef __ARCH_ARM_INCLUDE_TLS_H
-#define __ARCH_ARM_INCLUDE_TLS_H
+#ifndef __ARCH_AVR_INCLUDE_TLS_H
+#define __ARCH_AVR_INCLUDE_TLS_H
/****************************************************************************
* Included Files
@@ -37,24 +37,6 @@
****************************************************************************/
/****************************************************************************
- * Name: up_getsp
- ****************************************************************************/
-
-/* I don't know if the builtin to get SP is enabled */
-
-static inline uint32_t up_getsp(void)
-{
- uint32_t sp;
- __asm__
- (
- "\tmov %0, sp\n\t"
- : "=r"(sp)
- );
-
- return sp;
-}
-
-/****************************************************************************
* Name: up_tls_info
*
* Description:
@@ -86,11 +68,11 @@ 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)avr_getsp());
}
#else
# define up_tls_info() tls_get_info()
#endif
#endif /* CONFIG_TLS */
-#endif /* __ARCH_ARM_INCLUDE_TLS_H */
+#endif /* __ARCH_AVR_INCLUDE_TLS_H */
diff --git a/arch/arm/include/tls.h b/arch/hc/include/tls.h
similarity index 89%
copy from arch/arm/include/tls.h
copy to arch/hc/include/tls.h
index b96610c..e7cc678 100644
--- a/arch/arm/include/tls.h
+++ b/arch/hc/include/tls.h
@@ -1,5 +1,5 @@
/****************************************************************************
- * arch/arm/include/tls.h
+ * 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
@@ -18,8 +18,8 @@
*
****************************************************************************/
-#ifndef __ARCH_ARM_INCLUDE_TLS_H
-#define __ARCH_ARM_INCLUDE_TLS_H
+#ifndef __ARCH_HC_INCLUDE_TLS_H
+#define __ARCH_HC_INCLUDE_TLS_H
/****************************************************************************
* Included Files
@@ -37,21 +37,18 @@
****************************************************************************/
/****************************************************************************
- * Name: up_getsp
+ * Name: hc_getsp
****************************************************************************/
-/* I don't know if the builtin to get SP is enabled */
-
-static inline uint32_t up_getsp(void)
+static inline uint16_t hc_getsp(void)
{
- uint32_t sp;
+ uint16_t ret;
__asm__
(
- "\tmov %0, sp\n\t"
- : "=r"(sp)
+ "\tsts %0\n"
+ : "=m"(ret) :
);
-
- return sp;
+ return ret;
}
/****************************************************************************
@@ -86,11 +83,11 @@ 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)hc_getsp());
}
#else
# define up_tls_info() tls_get_info()
#endif
#endif /* CONFIG_TLS */
-#endif /* __ARCH_ARM_INCLUDE_TLS_H */
+#endif /* __ARCH_HC_INCLUDE_TLS_H */
diff --git a/arch/arm/include/tls.h b/arch/mips/include/tls.h
similarity index 90%
copy from arch/arm/include/tls.h
copy to arch/mips/include/tls.h
index b96610c..bd88d26 100644
--- a/arch/arm/include/tls.h
+++ b/arch/mips/include/tls.h
@@ -1,5 +1,5 @@
/****************************************************************************
- * arch/arm/include/tls.h
+ * 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
@@ -18,8 +18,8 @@
*
****************************************************************************/
-#ifndef __ARCH_ARM_INCLUDE_TLS_H
-#define __ARCH_ARM_INCLUDE_TLS_H
+#ifndef __ARCH_MIPS_INCLUDE_TLS_H
+#define __ARCH_MIPS_INCLUDE_TLS_H
/****************************************************************************
* Included Files
@@ -37,20 +37,17 @@
****************************************************************************/
/****************************************************************************
- * Name: up_getsp
+ * Name: mips_getsp
****************************************************************************/
-/* I don't know if the builtin to get SP is enabled */
-
-static inline uint32_t up_getsp(void)
+static inline uint32_t mips_getsp(void)
{
- uint32_t sp;
+ register uint32_t sp;
__asm__
(
- "\tmov %0, sp\n\t"
+ "\tadd %0, $0, $29\n"
: "=r"(sp)
);
-
return sp;
}
@@ -86,11 +83,11 @@ 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)mips_getsp());
}
#else
# define up_tls_info() tls_get_info()
#endif
#endif /* CONFIG_TLS */
-#endif /* __ARCH_ARM_INCLUDE_TLS_H */
+#endif /* __ARCH_MIPS_INCLUDE_TLS_H */
diff --git a/arch/arm/include/tls.h b/arch/misoc/include/tls.h
similarity index 89%
copy from arch/arm/include/tls.h
copy to arch/misoc/include/tls.h
index b96610c..e8af51f 100644
--- a/arch/arm/include/tls.h
+++ b/arch/misoc/include/tls.h
@@ -1,5 +1,5 @@
/****************************************************************************
- * arch/arm/include/tls.h
+ * 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
@@ -18,8 +18,8 @@
*
****************************************************************************/
-#ifndef __ARCH_ARM_INCLUDE_TLS_H
-#define __ARCH_ARM_INCLUDE_TLS_H
+#ifndef __ARCH_MISOC_INCLUDE_TLS_H
+#define __ARCH_MISOC_INCLUDE_TLS_H
/****************************************************************************
* Included Files
@@ -37,23 +37,19 @@
****************************************************************************/
/****************************************************************************
- * Name: up_getsp
+ * Name: misoc_getsp
****************************************************************************/
-/* I don't know if the builtin to get SP is enabled */
-
-static inline uint32_t up_getsp(void)
+static inline uint32_t misoc_getsp(void)
{
- uint32_t sp;
- __asm__
- (
- "\tmov %0, sp\n\t"
- : "=r"(sp)
- );
+ register uint32_t sp;
+
+ __asm__ __volatile__("addi %0, sp, 0" : "=r" (sp));
return sp;
}
+
/****************************************************************************
* Name: up_tls_info
*
@@ -86,11 +82,11 @@ 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)misoc_getsp());
}
#else
# define up_tls_info() tls_get_info()
#endif
#endif /* CONFIG_TLS */
-#endif /* __ARCH_ARM_INCLUDE_TLS_H */
+#endif /* __ARCH_MISOC_INCLUDE_TLS_H */
diff --git a/arch/arm/include/tls.h b/arch/or1k/include/tls.h
similarity index 91%
copy from arch/arm/include/tls.h
copy to arch/or1k/include/tls.h
index b96610c..1b8fd22 100644
--- a/arch/arm/include/tls.h
+++ b/arch/or1k/include/tls.h
@@ -1,5 +1,5 @@
/****************************************************************************
- * arch/arm/include/tls.h
+ * 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
@@ -18,8 +18,8 @@
*
****************************************************************************/
-#ifndef __ARCH_ARM_INCLUDE_TLS_H
-#define __ARCH_ARM_INCLUDE_TLS_H
+#ifndef __ARCH_OR1K_INCLUDE_TLS_H
+#define __ARCH_OR1K_INCLUDE_TLS_H
/****************************************************************************
* Included Files
@@ -37,14 +37,13 @@
****************************************************************************/
/****************************************************************************
- * Name: up_getsp
+ * Name: or1k_getsp
****************************************************************************/
-/* I don't know if the builtin to get SP is enabled */
-
-static inline uint32_t up_getsp(void)
+static inline uint32_t or1k_getsp(void)
{
uint32_t sp;
+
__asm__
(
"\tmov %0, sp\n\t"
@@ -86,11 +85,11 @@ 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)or1k_getsp());
}
#else
# define up_tls_info() tls_get_info()
#endif
#endif /* CONFIG_TLS */
-#endif /* __ARCH_ARM_INCLUDE_TLS_H */
+#endif /* __ARCH_OR1K_INCLUDE_TLS_H */
diff --git a/arch/renesas/include/arch.h b/arch/renesas/include/arch.h
index 5bb9298..bf8973a 100644
--- a/arch/renesas/include/arch.h
+++ b/arch/renesas/include/arch.h
@@ -44,6 +44,12 @@
* Included Files
****************************************************************************/
+#include <nuttx/config.h>
+
+/* Include chip-specific definitions */
+
+#include <arch/chip/arch.h>
+
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
diff --git a/arch/renesas/include/m16c/arch.h b/arch/renesas/include/m16c/arch.h
new file mode 100644
index 0000000..f76e9c4
--- /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 0000000..e08e961
--- /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 0000000..e20826c
--- /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/arm/include/tls.h b/arch/renesas/include/tls.h
similarity index 84%
copy from arch/arm/include/tls.h
copy to arch/renesas/include/tls.h
index b96610c..8998cd8 100644
--- a/arch/arm/include/tls.h
+++ b/arch/renesas/include/tls.h
@@ -1,5 +1,5 @@
/****************************************************************************
- * arch/arm/include/tls.h
+ * 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
@@ -18,8 +18,8 @@
*
****************************************************************************/
-#ifndef __ARCH_ARM_INCLUDE_TLS_H
-#define __ARCH_ARM_INCLUDE_TLS_H
+#ifndef __ARCH_RENESAS_INCLUDE_TLS_H
+#define __ARCH_RENESAS_INCLUDE_TLS_H
/****************************************************************************
* Included Files
@@ -37,24 +37,6 @@
****************************************************************************/
/****************************************************************************
- * Name: up_getsp
- ****************************************************************************/
-
-/* I don't know if the builtin to get SP is enabled */
-
-static inline uint32_t up_getsp(void)
-{
- uint32_t sp;
- __asm__
- (
- "\tmov %0, sp\n\t"
- : "=r"(sp)
- );
-
- return sp;
-}
-
-/****************************************************************************
* Name: up_tls_info
*
* Description:
@@ -86,11 +68,11 @@ 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)renesas_getsp());
}
#else
# define up_tls_info() tls_get_info()
#endif
#endif /* CONFIG_TLS */
-#endif /* __ARCH_ARM_INCLUDE_TLS_H */
+#endif /* __ARCH_RENESAS_INCLUDE_TLS_H */
diff --git a/arch/risc-v/include/arch.h b/arch/risc-v/include/arch.h
index 970bd5b..f2c45b6 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 0000000..ff9418f
--- /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 0000000..58a7b3a
--- /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/arm/include/tls.h b/arch/risc-v/include/tls.h
similarity index 84%
copy from arch/arm/include/tls.h
copy to arch/risc-v/include/tls.h
index b96610c..70afee9 100644
--- a/arch/arm/include/tls.h
+++ b/arch/risc-v/include/tls.h
@@ -1,5 +1,5 @@
/****************************************************************************
- * arch/arm/include/tls.h
+ * 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
@@ -18,8 +18,8 @@
*
****************************************************************************/
-#ifndef __ARCH_ARM_INCLUDE_TLS_H
-#define __ARCH_ARM_INCLUDE_TLS_H
+#ifndef __ARCH_RISCV_INCLUDE_TLS_H
+#define __ARCH_RISCV_INCLUDE_TLS_H
/****************************************************************************
* Included Files
@@ -37,24 +37,6 @@
****************************************************************************/
/****************************************************************************
- * Name: up_getsp
- ****************************************************************************/
-
-/* I don't know if the builtin to get SP is enabled */
-
-static inline uint32_t up_getsp(void)
-{
- uint32_t sp;
- __asm__
- (
- "\tmov %0, sp\n\t"
- : "=r"(sp)
- );
-
- return sp;
-}
-
-/****************************************************************************
* Name: up_tls_info
*
* Description:
@@ -86,11 +68,11 @@ 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)riscv_getsp());
}
#else
# define up_tls_info() tls_get_info()
#endif
#endif /* CONFIG_TLS */
-#endif /* __ARCH_ARM_INCLUDE_TLS_H */
+#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 449fec6..472e097 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/arm/include/tls.h b/arch/x86/include/tls.h
similarity index 85%
copy from arch/arm/include/tls.h
copy to arch/x86/include/tls.h
index b96610c..fbec9a2 100644
--- a/arch/arm/include/tls.h
+++ b/arch/x86/include/tls.h
@@ -1,5 +1,5 @@
/****************************************************************************
- * arch/arm/include/tls.h
+ * 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
@@ -18,8 +18,8 @@
*
****************************************************************************/
-#ifndef __ARCH_ARM_INCLUDE_TLS_H
-#define __ARCH_ARM_INCLUDE_TLS_H
+#ifndef __ARCH_X86_INCLUDE_TLS_H
+#define __ARCH_X86_INCLUDE_TLS_H
/****************************************************************************
* Included Files
@@ -37,24 +37,6 @@
****************************************************************************/
/****************************************************************************
- * Name: up_getsp
- ****************************************************************************/
-
-/* I don't know if the builtin to get SP is enabled */
-
-static inline uint32_t up_getsp(void)
-{
- uint32_t sp;
- __asm__
- (
- "\tmov %0, sp\n\t"
- : "=r"(sp)
- );
-
- return sp;
-}
-
-/****************************************************************************
* Name: up_tls_info
*
* Description:
@@ -93,4 +75,4 @@ static inline FAR struct tls_info_s *up_tls_info(void)
#endif
#endif /* CONFIG_TLS */
-#endif /* __ARCH_ARM_INCLUDE_TLS_H */
+#endif /* __ARCH_X86_INCLUDE_TLS_H */
diff --git a/arch/arm/include/tls.h b/arch/x86_64/include/tls.h
similarity index 84%
copy from arch/arm/include/tls.h
copy to arch/x86_64/include/tls.h
index b96610c..e9462ab 100644
--- a/arch/arm/include/tls.h
+++ b/arch/x86_64/include/tls.h
@@ -1,5 +1,5 @@
/****************************************************************************
- * arch/arm/include/tls.h
+ * 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
@@ -18,8 +18,8 @@
*
****************************************************************************/
-#ifndef __ARCH_ARM_INCLUDE_TLS_H
-#define __ARCH_ARM_INCLUDE_TLS_H
+#ifndef __ARCH_X86_64_INCLUDE_TLS_H
+#define __ARCH_X86_64_INCLUDE_TLS_H
/****************************************************************************
* Included Files
@@ -37,24 +37,6 @@
****************************************************************************/
/****************************************************************************
- * Name: up_getsp
- ****************************************************************************/
-
-/* I don't know if the builtin to get SP is enabled */
-
-static inline uint32_t up_getsp(void)
-{
- uint32_t sp;
- __asm__
- (
- "\tmov %0, sp\n\t"
- : "=r"(sp)
- );
-
- return sp;
-}
-
-/****************************************************************************
* Name: up_tls_info
*
* Description:
@@ -86,11 +68,11 @@ 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)up_getrsp());
}
#else
# define up_tls_info() tls_get_info()
#endif
#endif /* CONFIG_TLS */
-#endif /* __ARCH_ARM_INCLUDE_TLS_H */
+#endif /* __ARCH_X86_64_INCLUDE_TLS_H */
diff --git a/arch/arm/include/tls.h b/arch/xtensa/include/tls.h
similarity index 89%
copy from arch/arm/include/tls.h
copy to arch/xtensa/include/tls.h
index b96610c..33735ca 100644
--- a/arch/arm/include/tls.h
+++ b/arch/xtensa/include/tls.h
@@ -1,5 +1,5 @@
/****************************************************************************
- * arch/arm/include/tls.h
+ * 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
@@ -18,8 +18,8 @@
*
****************************************************************************/
-#ifndef __ARCH_ARM_INCLUDE_TLS_H
-#define __ARCH_ARM_INCLUDE_TLS_H
+#ifndef __ARCH_XTENSA_INCLUDE_TLS_H
+#define __ARCH_XTENSA_INCLUDE_TLS_H
/****************************************************************************
* Included Files
@@ -37,18 +37,17 @@
****************************************************************************/
/****************************************************************************
- * Name: up_getsp
+ * Name: xtensa_getsp
****************************************************************************/
-/* I don't know if the builtin to get SP is enabled */
-
-static inline uint32_t up_getsp(void)
+static inline uint32_t xtensa_getsp(void)
{
- uint32_t sp;
- __asm__
+ register uint32_t sp;
+
+ __asm__ __volatile__
(
- "\tmov %0, sp\n\t"
- : "=r"(sp)
+ "mov %0, sp\n"
+ : "=r" (sp)
);
return sp;
@@ -86,11 +85,11 @@ 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)xtensa_getsp());
}
#else
# define up_tls_info() tls_get_info()
#endif
#endif /* CONFIG_TLS */
-#endif /* __ARCH_ARM_INCLUDE_TLS_H */
+#endif /* __ARCH_XTENSA_INCLUDE_TLS_H */
diff --git a/arch/arm/include/tls.h b/arch/z16/include/tls.h
similarity index 81%
copy from arch/arm/include/tls.h
copy to arch/z16/include/tls.h
index b96610c..d2a1a16 100644
--- a/arch/arm/include/tls.h
+++ b/arch/z16/include/tls.h
@@ -1,5 +1,5 @@
/****************************************************************************
- * arch/arm/include/tls.h
+ * 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
@@ -18,8 +18,8 @@
*
****************************************************************************/
-#ifndef __ARCH_ARM_INCLUDE_TLS_H
-#define __ARCH_ARM_INCLUDE_TLS_H
+#ifndef __ARCH_Z16_INCLUDE_TLS_H
+#define __ARCH_Z16_INCLUDE_TLS_H
/****************************************************************************
* Included Files
@@ -37,24 +37,6 @@
****************************************************************************/
/****************************************************************************
- * Name: up_getsp
- ****************************************************************************/
-
-/* I don't know if the builtin to get SP is enabled */
-
-static inline uint32_t up_getsp(void)
-{
- uint32_t sp;
- __asm__
- (
- "\tmov %0, sp\n\t"
- : "=r"(sp)
- );
-
- return sp;
-}
-
-/****************************************************************************
* Name: up_tls_info
*
* Description:
@@ -83,14 +65,10 @@ static inline uint32_t up_getsp(void)
****************************************************************************/
#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());
-}
+# error "Aligned TLS not supported"
#else
# define up_tls_info() tls_get_info()
#endif
#endif /* CONFIG_TLS */
-#endif /* __ARCH_ARM_INCLUDE_TLS_H */
+#endif /* __ARCH_Z16_INCLUDE_TLS_H */
diff --git a/arch/arm/include/tls.h b/arch/z80/include/tls.h
similarity index 81%
copy from arch/arm/include/tls.h
copy to arch/z80/include/tls.h
index b96610c..381a103 100644
--- a/arch/arm/include/tls.h
+++ b/arch/z80/include/tls.h
@@ -1,5 +1,5 @@
/****************************************************************************
- * arch/arm/include/tls.h
+ * 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
@@ -18,8 +18,8 @@
*
****************************************************************************/
-#ifndef __ARCH_ARM_INCLUDE_TLS_H
-#define __ARCH_ARM_INCLUDE_TLS_H
+#ifndef __ARCH_Z80_INCLUDE_TLS_H
+#define __ARCH_Z80_INCLUDE_TLS_H
/****************************************************************************
* Included Files
@@ -37,24 +37,6 @@
****************************************************************************/
/****************************************************************************
- * Name: up_getsp
- ****************************************************************************/
-
-/* I don't know if the builtin to get SP is enabled */
-
-static inline uint32_t up_getsp(void)
-{
- uint32_t sp;
- __asm__
- (
- "\tmov %0, sp\n\t"
- : "=r"(sp)
- );
-
- return sp;
-}
-
-/****************************************************************************
* Name: up_tls_info
*
* Description:
@@ -83,14 +65,10 @@ static inline uint32_t up_getsp(void)
****************************************************************************/
#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());
-}
+# error "Aligned TLS not supported"
#else
# define up_tls_info() tls_get_info()
#endif
#endif /* CONFIG_TLS */
-#endif /* __ARCH_ARM_INCLUDE_TLS_H */
+#endif /* __ARCH_Z80_INCLUDE_TLS_H */