This is an automated email from the ASF dual-hosted git repository.
hartmannathan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new c82798c66a arch/arm: change context switch to macro
c82798c66a is described below
commit c82798c66a0c9cdb0def74edd4ee0b3939a78973
Author: zhangyuan21 <[email protected]>
AuthorDate: Wed Aug 31 17:31:45 2022 +0800
arch/arm: change context switch to macro
---
arch/arm/src/common/Make.defs | 4 +--
arch/arm/src/common/arm_exit.c | 6 ++++
arch/arm/src/common/arm_fullcontextrestore.c | 49 ----------------------------
arch/arm/src/common/arm_internal.h | 11 +++++--
arch/arm/src/common/arm_switchcontext.c | 47 --------------------------
5 files changed, 17 insertions(+), 100 deletions(-)
diff --git a/arch/arm/src/common/Make.defs b/arch/arm/src/common/Make.defs
index 4d5061fa06..cbd3054948 100644
--- a/arch/arm/src/common/Make.defs
+++ b/arch/arm/src/common/Make.defs
@@ -21,12 +21,12 @@
# Common ARM files
CMN_CSRCS += arm_allocateheap.c arm_assert.c arm_blocktask.c
-CMN_CSRCS += arm_createstack.c arm_exit.c arm_fullcontextrestore.c
+CMN_CSRCS += arm_createstack.c arm_exit.c
CMN_CSRCS += arm_initialize.c arm_lowputs.c
CMN_CSRCS += arm_modifyreg16.c arm_modifyreg32.c
CMN_CSRCS += arm_modifyreg8.c arm_nputs.c arm_releasepending.c
CMN_CSRCS += arm_releasestack.c arm_reprioritizertr.c arm_saveusercontext.c
-CMN_CSRCS += arm_stackframe.c arm_switchcontext.c
+CMN_CSRCS += arm_stackframe.c
CMN_CSRCS += arm_vfork.c arm_unblocktask.c arm_usestack.c
ifneq ($(CONFIG_ALARM_ARCH),y)
diff --git a/arch/arm/src/common/arm_exit.c b/arch/arm/src/common/arm_exit.c
index 972db8d265..a8689672ea 100644
--- a/arch/arm/src/common/arm_exit.c
+++ b/arch/arm/src/common/arm_exit.c
@@ -139,4 +139,10 @@ void up_exit(int status)
/* Then switch contexts */
arm_fullcontextrestore(tcb->xcp.regs);
+
+ /* arm_fullcontextrestore() should not return but could if the software
+ * interrupts are disabled.
+ */
+
+ PANIC();
}
diff --git a/arch/arm/src/common/arm_fullcontextrestore.c
b/arch/arm/src/common/arm_fullcontextrestore.c
deleted file mode 100644
index 4ed95305b9..0000000000
--- a/arch/arm/src/common/arm_fullcontextrestore.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/****************************************************************************
- * arch/arm/src/common/arm_fullcontextrestore.c
- *
- * 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.
- *
- ****************************************************************************/
-
-/****************************************************************************
- * Included Files
- ****************************************************************************/
-
-#include <nuttx/config.h>
-
-#include <arch/syscall.h>
-
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Name: arm_fullcontextrestore
- *
- * Description:
- * Restore the current thread context. Full prototype is:
- *
- * void arm_fullcontextrestore(uint32_t *restoreregs) noreturn_function;
- *
- * Returned Value:
- * None
- *
- ****************************************************************************/
-
-void arm_fullcontextrestore(uint32_t *restoreregs)
-{
- sys_call1(SYS_restore_context, (uintptr_t)restoreregs);
-}
diff --git a/arch/arm/src/common/arm_internal.h
b/arch/arm/src/common/arm_internal.h
index 02c0b53852..4130043bd9 100644
--- a/arch/arm/src/common/arm_internal.h
+++ b/arch/arm/src/common/arm_internal.h
@@ -32,6 +32,7 @@
# include <nuttx/arch.h>
# include <sys/types.h>
# include <stdint.h>
+# include <syscall.h>
#endif
/****************************************************************************
@@ -139,6 +140,14 @@
#define modreg16(v,m,a) putreg16((getreg16(a) & ~(m)) | ((v) & (m)), (a))
#define modreg32(v,m,a) putreg32((getreg32(a) & ~(m)) | ((v) & (m)), (a))
+/* Context switching */
+
+#define arm_fullcontextrestore(restoreregs) \
+ sys_call1(SYS_restore_context, (uintptr_t)restoreregs);
+
+#define arm_switchcontext(saveregs, restoreregs) \
+ sys_call2(SYS_switch_context, (uintptr_t)saveregs, (uintptr_t)restoreregs);
+
/****************************************************************************
* Public Types
****************************************************************************/
@@ -258,8 +267,6 @@ void arm_boot(void);
/* Context switching */
uint32_t *arm_decodeirq(uint32_t *regs);
-void arm_fullcontextrestore(uint32_t *restoreregs) noreturn_function;
-void arm_switchcontext(uint32_t **saveregs, uint32_t *restoreregs);
/* Signal handling **********************************************************/
diff --git a/arch/arm/src/common/arm_switchcontext.c
b/arch/arm/src/common/arm_switchcontext.c
deleted file mode 100644
index 1cf965f7dd..0000000000
--- a/arch/arm/src/common/arm_switchcontext.c
+++ /dev/null
@@ -1,47 +0,0 @@
-/****************************************************************************
- * arch/arm/src/common/arm_switchcontext.c
- *
- * 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.
- *
- ****************************************************************************/
-
-/****************************************************************************
- * Included Files
- ****************************************************************************/
-
-#include <nuttx/config.h>
-
-#include <arch/syscall.h>
-
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Name: arm_switchcontext
- *
- * Description:
- * Save the current thread context and restore the specified context.
- *
- * Returned Value:
- * None
- *
- ****************************************************************************/
-
-void arm_switchcontext(uint32_t **saveregs, uint32_t *restoreregs)
-{
- sys_call2(SYS_switch_context, (uintptr_t)saveregs, (uintptr_t)restoreregs);
-}