You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ar...@apache.org on 2024/11/11 11:56:19 UTC
(nuttx) branch master updated: arm_svcall: fix the naked_function function non-compatible issue
This is an automated email from the ASF dual-hosted git repository.
archer pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new a044e1896f arm_svcall: fix the naked_function function non-compatible issue
a044e1896f is described below
commit a044e1896f74344874342a24d7d98afb99283be2
Author: guoshichao <gu...@xiaomi.com>
AuthorDate: Sat Oct 19 20:36:13 2024 +0800
arm_svcall: fix the naked_function function non-compatible issue
when build with greenhills_202354, the naked_function should only
contains the basic asm statements, so if the naked_function contains the
statements that using to accept params from C lang runtime, then build
error will reported:
error #101112: Only basic asm expressions are allowed for functions
with __attribute__((naked)): dispatch_syscall
Signed-off-by: guoshichao <gu...@xiaomi.com>
---
arch/arm/src/armv6-m/arm_svcall.c | 34 +++++++++++++++++-----------------
arch/arm/src/armv7-a/arm_syscall.c | 29 ++++++++++++++---------------
arch/arm/src/armv7-m/arm_svcall.c | 32 ++++++++++++++++----------------
arch/arm/src/armv7-r/arm_syscall.c | 28 ++++++++++++++--------------
arch/arm/src/armv8-m/arm_svcall.c | 32 ++++++++++++++++----------------
arch/arm/src/armv8-r/arm_syscall.c | 28 ++++++++++++++--------------
6 files changed, 91 insertions(+), 92 deletions(-)
diff --git a/arch/arm/src/armv6-m/arm_svcall.c b/arch/arm/src/armv6-m/arm_svcall.c
index f78f3a8a2e..90d07eae60 100644
--- a/arch/arm/src/armv6-m/arm_svcall.c
+++ b/arch/arm/src/armv6-m/arm_svcall.c
@@ -32,6 +32,7 @@
#include <syscall.h>
#include <arch/irq.h>
+#include <nuttx/macro.h>
#include <nuttx/sched.h>
#include "sched/sched.h"
@@ -82,23 +83,22 @@ static void dispatch_syscall(void)
{
__asm__ __volatile__
(
- " push {r4, r5}\n" /* Save R4 and R5 */
- " sub sp, sp, #12\n" /* Create a stack frame to hold 3 parms */
- " str r4, [sp, #0]\n" /* Move parameter 4 (if any) into position */
- " str r5, [sp, #4]\n" /* Move parameter 5 (if any) into position */
- " str r6, [sp, #8]\n" /* Move parameter 6 (if any) into position */
- " mov r5, lr\n" /* Save lr in R5 */
- " ldr r4, =g_stublookup\n" /* R4=The base of the stub lookup table */
- " lsl r0, r0, #2\n" /* R0=Offset of the stub for this syscall */
- " ldr r4, [r4, r0]\n" /* R4=Address of the stub for this syscall */
- " blx r5\n" /* Call the stub (modifies lr) */
- " mov lr, r5\n" /* Restore lr */
- " add sp, sp, #12\n" /* Destroy the stack frame */
- " pop {r4, r5}\n" /* Recover R4 and R5 */
- " mov r2, r0\n" /* R2=Save return value in R2 */
- " mov r0, %0\n" /* R0=SYS_syscall_return */
- " svc %1\n"::"i"(SYS_syscall_return),
- "i"(SYS_syscall) /* Return from the SYSCALL */
+ " push {r4, r5}\n" /* Save R4 and R5 */
+ " sub sp, sp, #12\n" /* Create a stack frame to hold 3 parms */
+ " str r4, [sp, #0]\n" /* Move parameter 4 (if any) into position */
+ " str r5, [sp, #4]\n" /* Move parameter 5 (if any) into position */
+ " str r6, [sp, #8]\n" /* Move parameter 6 (if any) into position */
+ " mov r5, lr\n" /* Save lr in R5 */
+ " ldr r4, =g_stublookup\n" /* R4=The base of the stub lookup table */
+ " lsl r0, r0, #2\n" /* R0=Offset of the stub for this syscall */
+ " ldr r4, [r4, r0]\n" /* R4=Address of the stub for this syscall */
+ " blx r5\n" /* Call the stub (modifies lr) */
+ " mov lr, r5\n" /* Restore lr */
+ " add sp, sp, #12\n" /* Destroy the stack frame */
+ " pop {r4, r5}\n" /* Recover R4 and R5 */
+ " mov r2, r0\n" /* R2=Save return value in R2 */
+ " mov r0, #" STRINGIFY(SYS_syscall_return) "\n" /* R0=SYS_syscall_return */
+ " svc #" STRINGIFY(SYS_syscall) "\n" /* Return from the SYSCALL */
);
}
#endif
diff --git a/arch/arm/src/armv7-a/arm_syscall.c b/arch/arm/src/armv7-a/arm_syscall.c
index 8ad689db5a..93167f2a39 100644
--- a/arch/arm/src/armv7-a/arm_syscall.c
+++ b/arch/arm/src/armv7-a/arm_syscall.c
@@ -33,8 +33,8 @@
#include <nuttx/addrenv.h>
#include <nuttx/arch.h>
+#include <nuttx/macro.h>
#include <nuttx/sched.h>
-#include <nuttx/addrenv.h>
#include "addrenv.h"
#include "arm.h"
@@ -124,20 +124,19 @@ static void dispatch_syscall(void)
{
__asm__ __volatile__
(
- " sub sp, sp, #16\n" /* Create a stack frame to hold 3 parms + lr */
- " str r4, [sp, #0]\n" /* Move parameter 4 (if any) into position */
- " str r5, [sp, #4]\n" /* Move parameter 5 (if any) into position */
- " str r6, [sp, #8]\n" /* Move parameter 6 (if any) into position */
- " str lr, [sp, #12]\n" /* Save lr in the stack frame */
- " ldr ip, =g_stublookup\n" /* R12=The base of the stub lookup table */
- " ldr ip, [ip, r0, lsl #2]\n" /* R12=The address of the stub for this SYSCALL */
- " blx ip\n" /* Call the stub (modifies lr) */
- " ldr lr, [sp, #12]\n" /* Restore lr */
- " add sp, sp, #16\n" /* Destroy the stack frame */
- " mov r2, r0\n" /* R2=Save return value in R2 */
- " mov r0, %0\n" /* R0=SYS_syscall_return */
- " svc %1\n"::"i"(SYS_syscall_return),
- "i"(SYS_syscall) /* Return from the SYSCALL */
+ " sub sp, sp, #16\n" /* Create a stack frame to hold 3 parms + lr */
+ " str r4, [sp, #0]\n" /* Move parameter 4 (if any) into position */
+ " str r5, [sp, #4]\n" /* Move parameter 5 (if any) into position */
+ " str r6, [sp, #8]\n" /* Move parameter 6 (if any) into position */
+ " str lr, [sp, #12]\n" /* Save lr in the stack frame */
+ " ldr ip, =g_stublookup\n" /* R12=The base of the stub lookup table */
+ " ldr ip, [ip, r0, lsl #2]\n" /* R12=The address of the stub for this SYSCALL */
+ " blx ip\n" /* Call the stub (modifies lr) */
+ " ldr lr, [sp, #12]\n" /* Restore lr */
+ " add sp, sp, #16\n" /* Destroy the stack frame */
+ " mov r2, r0\n" /* R2=Save return value in R2 */
+ " mov r0, #" STRINGIFY(SYS_syscall_return) "\n" /* R0=SYS_syscall_return */
+ " svc #" STRINGIFY(SYS_syscall) "\n" /* Return from the SYSCALL */
);
}
#endif
diff --git a/arch/arm/src/armv7-m/arm_svcall.c b/arch/arm/src/armv7-m/arm_svcall.c
index 3560a2ef26..4d3e59bed5 100644
--- a/arch/arm/src/armv7-m/arm_svcall.c
+++ b/arch/arm/src/armv7-m/arm_svcall.c
@@ -32,6 +32,7 @@
#include <syscall.h>
#include <arch/irq.h>
+#include <nuttx/macro.h>
#include <nuttx/sched.h>
#include <nuttx/userspace.h>
@@ -87,26 +88,25 @@ static void dispatch_syscall(void)
* = orig_SP - 20 - ((orig_SP - 20) & ~7)
*/
- " mov ip, sp\n" /* Calculate (orig_SP - new_SP) */
+ " mov ip, sp\n" /* Calculate (orig_SP - new_SP) */
" sub ip, ip, #20\n"
" and ip, ip, #7\n"
" add ip, ip, #20\n"
" sub sp, sp, ip\n"
- " str r4, [sp, #0]\n" /* Move parameter 4 (if any) into position */
- " str r5, [sp, #4]\n" /* Move parameter 5 (if any) into position */
- " str r6, [sp, #8]\n" /* Move parameter 6 (if any) into position */
- " str lr, [sp, #12]\n" /* Save lr in the stack frame */
- " str ip, [sp, #16]\n" /* Save (orig_SP - new_SP) value */
- " ldr ip, =g_stublookup\n" /* R12=The base of the stub lookup table */
- " ldr ip, [ip, r0, lsl #2]\n" /* R12=The address of the stub for this syscall */
- " blx ip\n" /* Call the stub (modifies lr) */
- " ldr lr, [sp, #12]\n" /* Restore lr */
- " ldr r2, [sp, #16]\n" /* Restore (orig_SP - new_SP) value */
- " add sp, sp, r2\n" /* Restore SP */
- " mov r2, r0\n" /* R2=Save return value in R2 */
- " mov r0, %0\n" /* R0=SYS_syscall_return */
- " svc %1\n"::"i"(SYS_syscall_return),
- "i"(SYS_syscall) /* Return from the SYSCALL */
+ " str r4, [sp, #0]\n" /* Move parameter 4 (if any) into position */
+ " str r5, [sp, #4]\n" /* Move parameter 5 (if any) into position */
+ " str r6, [sp, #8]\n" /* Move parameter 6 (if any) into position */
+ " str lr, [sp, #12]\n" /* Save lr in the stack frame */
+ " str ip, [sp, #16]\n" /* Save (orig_SP - new_SP) value */
+ " ldr ip, =g_stublookup\n" /* R12=The base of the stub lookup table */
+ " ldr ip, [ip, r0, lsl #2]\n" /* R12=The address of the stub for this syscall */
+ " blx ip\n" /* Call the stub (modifies lr) */
+ " ldr lr, [sp, #12]\n" /* Restore lr */
+ " ldr r2, [sp, #16]\n" /* Restore (orig_SP - new_SP) value */
+ " add sp, sp, r2\n" /* Restore SP */
+ " mov r2, r0\n" /* R2=Save return value in R2 */
+ " mov r0, #" STRINGIFY(SYS_syscall_return) "\n" /* R0=SYS_syscall_return */
+ " svc #" STRINGIFY(SYS_syscall) "\n" /* Return from the SYSCALL */
);
}
#endif
diff --git a/arch/arm/src/armv7-r/arm_syscall.c b/arch/arm/src/armv7-r/arm_syscall.c
index aa01170622..12cc3d161f 100644
--- a/arch/arm/src/armv7-r/arm_syscall.c
+++ b/arch/arm/src/armv7-r/arm_syscall.c
@@ -31,6 +31,7 @@
#include <syscall.h>
#include <nuttx/arch.h>
+#include <nuttx/macro.h>
#include <nuttx/sched.h>
#include "arm.h"
@@ -120,20 +121,19 @@ static void dispatch_syscall(void)
{
__asm__ __volatile__
(
- " sub sp, sp, #16\n" /* Create a stack frame to hold 3 parms + lr */
- " str r4, [sp, #0]\n" /* Move parameter 4 (if any) into position */
- " str r5, [sp, #4]\n" /* Move parameter 5 (if any) into position */
- " str r6, [sp, #8]\n" /* Move parameter 6 (if any) into position */
- " str lr, [sp, #12]\n" /* Save lr in the stack frame */
- " ldr ip, =g_stublookup\n" /* R12=The base of the stub lookup table */
- " ldr ip, [ip, r0, lsl #2]\n" /* R12=The address of the stub for this SYSCALL */
- " blx ip\n" /* Call the stub (modifies lr) */
- " ldr lr, [sp, #12]\n" /* Restore lr */
- " add sp, sp, #16\n" /* Destroy the stack frame */
- " mov r2, r0\n" /* R2=Save return value in R2 */
- " mov r0, %0\n" /* R0=SYS_syscall_return */
- " svc %1\n"::"i"(SYS_syscall_return),
- "i"(SYS_syscall) /* Return from the SYSCALL */
+ " sub sp, sp, #16\n" /* Create a stack frame to hold 3 parms + lr */
+ " str r4, [sp, #0]\n" /* Move parameter 4 (if any) into position */
+ " str r5, [sp, #4]\n" /* Move parameter 5 (if any) into position */
+ " str r6, [sp, #8]\n" /* Move parameter 6 (if any) into position */
+ " str lr, [sp, #12]\n" /* Save lr in the stack frame */
+ " ldr ip, =g_stublookup\n" /* R12=The base of the stub lookup table */
+ " ldr ip, [ip, r0, lsl #2]\n" /* R12=The address of the stub for this SYSCALL */
+ " blx ip\n" /* Call the stub (modifies lr) */
+ " ldr lr, [sp, #12]\n" /* Restore lr */
+ " add sp, sp, #16\n" /* Destroy the stack frame */
+ " mov r2, r0\n" /* R2=Save return value in R2 */
+ " mov r0, #" STRINGIFY(SYS_syscall_return) "\n" /* R0=SYS_syscall_return */
+ " svc #" STRINGIFY(SYS_syscall) "\n" /* Return from the SYSCALL */
);
}
#endif
diff --git a/arch/arm/src/armv8-m/arm_svcall.c b/arch/arm/src/armv8-m/arm_svcall.c
index b6b1af67b8..4c470957ec 100644
--- a/arch/arm/src/armv8-m/arm_svcall.c
+++ b/arch/arm/src/armv8-m/arm_svcall.c
@@ -32,6 +32,7 @@
#include <syscall.h>
#include <arch/irq.h>
+#include <nuttx/macro.h>
#include <nuttx/sched.h>
#include <nuttx/userspace.h>
@@ -87,26 +88,25 @@ static void dispatch_syscall(void)
* = orig_SP - 20 - ((orig_SP - 20) & ~7)
*/
- " mov ip, sp\n" /* Calculate (orig_SP - new_SP) */
+ " mov ip, sp\n" /* Calculate (orig_SP - new_SP) */
" sub ip, ip, #20\n"
" and ip, ip, #7\n"
" add ip, ip, #20\n"
" sub sp, sp, ip\n"
- " str r4, [sp, #0]\n" /* Move parameter 4 (if any) into position */
- " str r5, [sp, #4]\n" /* Move parameter 5 (if any) into position */
- " str r6, [sp, #8]\n" /* Move parameter 6 (if any) into position */
- " str lr, [sp, #12]\n" /* Save lr in the stack frame */
- " str ip, [sp, #16]\n" /* Save (orig_SP - new_SP) value */
- " ldr ip, =g_stublookup\n" /* R12=The base of the stub lookup table */
- " ldr ip, [ip, r0, lsl #2]\n" /* R12=The address of the stub for this syscall */
- " blx ip\n" /* Call the stub (modifies lr) */
- " ldr lr, [sp, #12]\n" /* Restore lr */
- " ldr r2, [sp, #16]\n" /* Restore (orig_SP - new_SP) value */
- " add sp, sp, r2\n" /* Restore SP */
- " mov r2, r0\n" /* R2=Save return value in R2 */
- " mov r0, %0\n" /* R0=SYS_syscall_return */
- " svc %1\n"::"i"(SYS_syscall_return),
- "i"(SYS_syscall) /* Return from the SYSCALL */
+ " str r4, [sp, #0]\n" /* Move parameter 4 (if any) into position */
+ " str r5, [sp, #4]\n" /* Move parameter 5 (if any) into position */
+ " str r6, [sp, #8]\n" /* Move parameter 6 (if any) into position */
+ " str lr, [sp, #12]\n" /* Save lr in the stack frame */
+ " str ip, [sp, #16]\n" /* Save (orig_SP - new_SP) value */
+ " ldr ip, =g_stublookup\n" /* R12=The base of the stub lookup table */
+ " ldr ip, [ip, r0, lsl #2]\n" /* R12=The address of the stub for this syscall */
+ " blx ip\n" /* Call the stub (modifies lr) */
+ " ldr lr, [sp, #12]\n" /* Restore lr */
+ " ldr r2, [sp, #16]\n" /* Restore (orig_SP - new_SP) value */
+ " add sp, sp, r2\n" /* Restore SP */
+ " mov r2, r0\n" /* R2=Save return value in R2 */
+ " mov r0, #" STRINGIFY(SYS_syscall_return) "\n" /* R0=SYS_syscall_return */
+ " svc #" STRINGIFY(SYS_syscall) "\n" /* Return from the SYSCALL */
);
}
#endif
diff --git a/arch/arm/src/armv8-r/arm_syscall.c b/arch/arm/src/armv8-r/arm_syscall.c
index abf3b191f4..0c796bf1b1 100644
--- a/arch/arm/src/armv8-r/arm_syscall.c
+++ b/arch/arm/src/armv8-r/arm_syscall.c
@@ -31,6 +31,7 @@
#include <syscall.h>
#include <nuttx/arch.h>
+#include <nuttx/macro.h>
#include <nuttx/sched.h>
#include "arm.h"
@@ -120,20 +121,19 @@ static void dispatch_syscall(void)
{
__asm__ __volatile__
(
- " sub sp, sp, #16\n" /* Create a stack frame to hold 3 parms + lr */
- " str r4, [sp, #0]\n" /* Move parameter 4 (if any) into position */
- " str r5, [sp, #4]\n" /* Move parameter 5 (if any) into position */
- " str r6, [sp, #8]\n" /* Move parameter 6 (if any) into position */
- " str lr, [sp, #12]\n" /* Save lr in the stack frame */
- " ldr ip, =g_stublookup\n" /* R12=The base of the stub lookup table */
- " ldr ip, [ip, r0, lsl #2]\n" /* R12=The address of the stub for this SYSCALL */
- " blx ip\n" /* Call the stub (modifies lr) */
- " ldr lr, [sp, #12]\n" /* Restore lr */
- " add sp, sp, #16\n" /* Destroy the stack frame */
- " mov r2, r0\n" /* R2=Save return value in R2 */
- " mov r0, %0\n" /* R0=SYS_syscall_return */
- " svc %1\n"::"i"(SYS_syscall_return),
- "i"(SYS_syscall) /* Return from the SYSCALL */
+ " sub sp, sp, #16\n" /* Create a stack frame to hold 3 parms + lr */
+ " str r4, [sp, #0]\n" /* Move parameter 4 (if any) into position */
+ " str r5, [sp, #4]\n" /* Move parameter 5 (if any) into position */
+ " str r6, [sp, #8]\n" /* Move parameter 6 (if any) into position */
+ " str lr, [sp, #12]\n" /* Save lr in the stack frame */
+ " ldr ip, =g_stublookup\n" /* R12=The base of the stub lookup table */
+ " ldr ip, [ip, r0, lsl #2]\n" /* R12=The address of the stub for this SYSCALL */
+ " blx ip\n" /* Call the stub (modifies lr) */
+ " ldr lr, [sp, #12]\n" /* Restore lr */
+ " add sp, sp, #16\n" /* Destroy the stack frame */
+ " mov r2, r0\n" /* R2=Save return value in R2 */
+ " mov r0, #" STRINGIFY(SYS_syscall_return) "\n" /* R0=SYS_syscall_return */
+ " svc #" STRINGIFY(SYS_syscall) "\n" /* Return from the SYSCALL */
);
}
#endif