From 1320e5add4771718c6da3fdd850583a2b2694ddb Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Mon, 18 Apr 2022 02:31:08 +0800 Subject: [PATCH] arch/arm: Move the duplicated assembly code to common folder Signed-off-by: Xiang Xiao --- arch/arm/src/Makefile | 4 +- arch/arm/src/arm/vfork.S | 124 --------- arch/arm/src/armv6-m/arm_signal_handler.S | 103 -------- arch/arm/src/armv7-a/arm_fetchadd.S | 240 ----------------- arch/arm/src/armv7-a/arm_testset.S | 106 -------- arch/arm/src/armv7-a/vfork.S | 124 --------- .../arm/src/armv7-m/{gnu => }/arm_exception.S | 2 +- arch/arm/src/armv7-m/gnu/arm_fetchadd.S | 242 ------------------ arch/arm/src/armv7-m/gnu/arm_signal_handler.S | 102 -------- arch/arm/src/armv7-m/gnu/arm_testset.S | 108 -------- arch/arm/src/armv7-m/gnu/vfork.S | 127 --------- arch/arm/src/armv7-r/arm_fetchadd.S | 240 ----------------- arch/arm/src/armv7-r/arm_signal_handler.S | 99 ------- arch/arm/src/armv7-r/arm_testset.S | 106 -------- arch/arm/src/armv7-r/vfork.S | 124 --------- arch/arm/src/armv8-m/vfork.S | 127 --------- .../{armv8-m => common/gnu}/arm_fetchadd.S | 3 +- .../gnu}/arm_signal_handler.S | 3 +- .../src/{armv8-m => common/gnu}/arm_testset.S | 3 +- arch/arm/src/{armv6-m => common/gnu}/vfork.S | 17 +- .../{armv7-m => common}/iar/arm_fetchadd.S | 2 +- .../src/{armv7-m => common}/iar/arm_testset.S | 2 +- arch/arm/src/{armv7-m => common}/iar/vfork.S | 2 +- 23 files changed, 13 insertions(+), 1997 deletions(-) delete mode 100644 arch/arm/src/arm/vfork.S delete mode 100644 arch/arm/src/armv6-m/arm_signal_handler.S delete mode 100644 arch/arm/src/armv7-a/arm_fetchadd.S delete mode 100644 arch/arm/src/armv7-a/arm_testset.S delete mode 100644 arch/arm/src/armv7-a/vfork.S rename arch/arm/src/armv7-m/{gnu => }/arm_exception.S (99%) delete mode 100644 arch/arm/src/armv7-m/gnu/arm_fetchadd.S delete mode 100644 arch/arm/src/armv7-m/gnu/arm_signal_handler.S delete mode 100644 arch/arm/src/armv7-m/gnu/arm_testset.S delete mode 100644 arch/arm/src/armv7-m/gnu/vfork.S delete mode 100644 arch/arm/src/armv7-r/arm_fetchadd.S delete mode 100644 arch/arm/src/armv7-r/arm_signal_handler.S delete mode 100644 arch/arm/src/armv7-r/arm_testset.S delete mode 100644 arch/arm/src/armv7-r/vfork.S delete mode 100644 arch/arm/src/armv8-m/vfork.S rename arch/arm/src/{armv8-m => common/gnu}/arm_fetchadd.S (99%) rename arch/arm/src/{armv8-m => common/gnu}/arm_signal_handler.S (98%) rename arch/arm/src/{armv8-m => common/gnu}/arm_testset.S (98%) rename arch/arm/src/{armv6-m => common/gnu}/vfork.S (90%) rename arch/arm/src/{armv7-m => common}/iar/arm_fetchadd.S (99%) rename arch/arm/src/{armv7-m => common}/iar/arm_testset.S (98%) rename arch/arm/src/{armv7-m => common}/iar/vfork.S (99%) diff --git a/arch/arm/src/Makefile b/arch/arm/src/Makefile index fc92b6ff32..61c70659a4 100644 --- a/arch/arm/src/Makefile +++ b/arch/arm/src/Makefile @@ -109,9 +109,9 @@ VPATH += common VPATH += $(ARCH_SUBDIR) ifeq ($(CONFIG_ARCH_TOOLCHAIN_IAR),y) - VPATH += $(ARCH_SUBDIR)$(DELIM)iar + VPATH += common$(DELIM)iar else # ifeq ($(CONFIG_ARCH_TOOLCHAIN_GNU),y) - VPATH += $(ARCH_SUBDIR)$(DELIM)gnu + VPATH += common$(DELIM)gnu endif all: $(HEAD_OBJ) $(BIN) diff --git a/arch/arm/src/arm/vfork.S b/arch/arm/src/arm/vfork.S deleted file mode 100644 index 4abdf511bf..0000000000 --- a/arch/arm/src/arm/vfork.S +++ /dev/null @@ -1,124 +0,0 @@ -/**************************************************************************** - * arch/arm/src/arm/vfork.S - * - * 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 - -#include "arm_vfork.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Public Symbols - ****************************************************************************/ - - .file "vfork.S" - .globl up_vfork - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: vfork - * - * Description: - * The vfork() function has the same effect as fork(), except that the - * behavior is undefined if the process created by vfork() either modifies - * any data other than a variable of type pid_t used to store the return - * value from vfork(), or returns from the function in which vfork() was - * called, or calls any other function before successfully calling _exit() - * or one of the exec family of functions. - * - * This thin layer implements vfork by simply calling up_vfork() with the - * vfork() context as an argument. The overall sequence is: - * - * 1) User code calls vfork(). vfork() collects context information and - * transfers control up up_vfork(). - * 2) up_vfork() and calls nxtask_setup_vfork(). - * 3) nxtask_setup_vfork() allocates and configures the child task's TCB. - * This consists of: - * - Allocation of the child task's TCB. - * - Initialization of file descriptors and streams - * - Configuration of environment variables - * - Allocate and initialize the stack - * - Setup the input parameters for the task. - * - Initialization of the TCB (including call to up_initial_state()) - * 4) up_vfork() provides any additional operating context. up_vfork must: - * - Initialize special values in any CPU registers that were not - * already configured by up_initial_state() - * 5) up_vfork() then calls nxtask_start_vfork() - * 6) nxtask_start_vfork() then executes the child thread. - * - * Input Parameters: - * None - * - * Returned Value: - * Upon successful completion, vfork() returns 0 to the child process and - * returns the process ID of the child process to the parent process. - * Otherwise, -1 is returned to the parent, no child process is created, - * and errno is set to indicate the error. - * - ****************************************************************************/ - - .globl vfork - .type vfork, function -vfork: - /* Create a stack frame */ - - mov r0, sp /* Save the value of the stack on entry */ - sub sp, sp, #VFORK_SIZEOF /* Allocate the structure on the stack */ - - /* CPU registers */ - /* Save the volatile registers */ - - str r4, [sp, #VFORK_R4_OFFSET] - str r5, [sp, #VFORK_R5_OFFSET] - str r6, [sp, #VFORK_R6_OFFSET] - str r7, [sp, #VFORK_R7_OFFSET] - str r8, [sp, #VFORK_R8_OFFSET] - str r9, [sp, #VFORK_R9_OFFSET] - str r10, [sp, #VFORK_R10_OFFSET] - - /* Save the frame pointer, stack pointer, and return address */ - - str fp, [sp, #VFORK_FP_OFFSET] - str r0, [sp, #VFORK_SP_OFFSET] - str lr, [sp, #VFORK_LR_OFFSET] - - /* Floating point registers (not yet) */ - - /* Then, call up_vfork(), passing it a pointer to the stack structure */ - - mov r0, sp - bl up_vfork - - /* Release the stack data and return the value returned by up_vfork */ - - ldr lr, [sp, #VFORK_LR_OFFSET] - add sp, sp, #VFORK_SIZEOF - bx lr - .size vfork, .-vfork - .end diff --git a/arch/arm/src/armv6-m/arm_signal_handler.S b/arch/arm/src/armv6-m/arm_signal_handler.S deleted file mode 100644 index 1f76daa2f7..0000000000 --- a/arch/arm/src/armv6-m/arm_signal_handler.S +++ /dev/null @@ -1,103 +0,0 @@ -/**************************************************************************** - * arch/arm/srcm/armv6-m/arm_signal_handler.S - * - * 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 - -#include - -#if defined(CONFIG_BUILD_PROTECTED) && !defined(__KERNEL__) - -/**************************************************************************** - * File info - ****************************************************************************/ - - .file "arm_signal_handler.S" - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: up_signal_handler - * - * Description: - * This function is the user-space, signal handler trampoline function. It - * is called from up_signal_dispatch() in user-mode. - * - * R0-R3, R11 - volatile registers need not be preserved. - * R4-R10 - static registers must be preserved - * R12-R14 - LR and SP must be preserved - * - * Input Parameters: - * R0 = sighand - * The address user-space signal handling function - * R1-R3 = signo, info, and ucontext - * Standard arguments to be passed to the signal handling function. - * - * Returned Value: - * None. This function does not return in the normal sense. It returns - * via the SYS_signal_handler_return (see syscall.h) - * - ****************************************************************************/ - - .text - .align 2 - .code 16 - .thumb_func - .globl up_signal_handler - .type up_signal_handler, function -up_signal_handler: - - /* Save some register */ - - push {r4, r5} /* Save R4 and R5 on the stack */ - mov r5, lr /* Save LR in R5 */ - - /* Call the signal handler */ - - mov r4, r0 /* R4=sighand */ - mov r0, r1 /* R0=signo */ - mov r1, r2 /* R1=info */ - mov r2, r3 /* R2=ucontext */ - blx r4 /* Call the signal handler */ - - /* Restore the registers */ - - mov lr, r5 /* Restore LR */ - pop {r4, r5} /* Restore R4 and R5 */ - - /* Execute the SYS_signal_handler_return SVCall (will not return) */ - - mov r0, #SYS_signal_handler_return - svc #SYS_syscall - nop - - .size up_signal_handler, .-up_signal_handler - .end - -#endif /* CONFIG_BUILD_PROTECTED && !__KERNEL__ */ diff --git a/arch/arm/src/armv7-a/arm_fetchadd.S b/arch/arm/src/armv7-a/arm_fetchadd.S deleted file mode 100644 index 930b048895..0000000000 --- a/arch/arm/src/armv7-a/arm_fetchadd.S +++ /dev/null @@ -1,240 +0,0 @@ -/**************************************************************************** - * arch/arm/src/armv7-a/arm_fetchadd.S - * - * 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 - - .file "arm_fetchadd.S" - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - - .text - -/**************************************************************************** - * Name: up_fetchadd32 - * - * Description: - * Perform an atomic fetch add operation on the provided 32-bit value. - * - * This function must be provided via the architecture-specific logic. - * - * Input Parameters: - * addr - The address of 32-bit value to be incremented. - * value - The 32-bit addend - * - * Returned Value: - * The incremented value (volatile!) - * - ****************************************************************************/ - - .globl up_fetchadd32 - .type up_fetchadd32, %function - -up_fetchadd32: - -1: - ldrex r2, [r0] /* Fetch the value to be incremented */ - add r2, r2, r1 /* Add the addend */ - - strex r3, r2, [r0] /* Attempt to save the result */ - teq r3, #0 /* r3 will be 1 if strex failed */ - bne 1b /* Failed to lock... try again */ - - mov r0, r2 /* Return the incremented value */ - bx lr /* Successful! */ - .size up_fetchadd32, . - up_fetchadd32 - -/**************************************************************************** - * Name: up_fetchsub32 - * - * Description: - * Perform an atomic fetch subtract operation on the provided 32-bit value. - * - * This function must be provided via the architecture-specific logic. - * - * Input Parameters: - * addr - The address of 32-bit value to be decremented. - * value - The 32-bit subtrahend - * - * Returned Value: - * The decremented value (volatile!) - * - ****************************************************************************/ - - .globl up_fetchsub32 - .type up_fetchsub32, %function - -up_fetchsub32: - -1: - ldrex r2, [r0] /* Fetch the value to be decremented */ - sub r2, r2, r1 /* Subtract the subtrahend */ - - strex r3, r2, [r0] /* Attempt to save the result */ - teq r3, #0 /* r3 will be 1 if strex failed */ - bne 1b /* Failed to lock... try again */ - - mov r0, r2 /* Return the decremented value */ - bx lr /* Successful! */ - .size up_fetchsub32, . - up_fetchsub32 - -/**************************************************************************** - * Name: up_fetchadd16 - * - * Description: - * Perform an atomic fetch add operation on the provided 16-bit value. - * - * This function must be provided via the architecture-specific logic. - * - * Input Parameters: - * addr - The address of 16-bit value to be incremented. - * value - The 16-bit addend - * - * Returned Value: - * The incremented value (volatile!) - * - ****************************************************************************/ - - .globl up_fetchadd16 - .type up_fetchadd16, %function - -up_fetchadd16: - -1: - ldrexh r2, [r0] /* Fetch the value to be incremented */ - add r2, r2, r1 /* Add the addend */ - - strexh r3, r2, [r0] /* Attempt to save the result */ - teq r3, #0 /* r3 will be 1 if strexh failed */ - bne 1b /* Failed to lock... try again */ - - mov r0, r2 /* Return the incremented value */ - bx lr /* Successful! */ - .size up_fetchadd16, . - up_fetchadd16 - -/**************************************************************************** - * Name: up_fetchsub16 - * - * Description: - * Perform an atomic fetch subtract operation on the provided 16-bit value. - * - * This function must be provided via the architecture-specific logic. - * - * Input Parameters: - * addr - The address of 16-bit value to be decremented. - * value - The 16-bit subtrahend - * - * Returned Value: - * The decremented value (volatile!) - * - ****************************************************************************/ - - .globl up_fetchsub16 - .type up_fetchsub16, %function - -up_fetchsub16: - -1: - ldrexh r2, [r0] /* Fetch the value to be decremented */ - sub r2, r2, r1 /* Subtract the subtrahend */ - - /* Attempt to save the decremented value */ - - strexh r3, r2, [r0] /* Attempt to save the result */ - teq r3, #0 /* r3 will be 1 if strexh failed */ - bne 1b /* Failed to lock... try again */ - - mov r0, r2 /* Return the decremented value */ - bx lr /* Successful! */ - .size up_fetchsub16, . - up_fetchsub16 - -/**************************************************************************** - * Name: up_fetchadd8 - * - * Description: - * Perform an atomic fetch add operation on the provided 8-bit value. - * - * This function must be provided via the architecture-specific logic. - * - * Input Parameters: - * addr - The address of 8-bit value to be incremented. - * value - The 8-bit addend - * - * Returned Value: - * The incremented value (volatile!) - * - ****************************************************************************/ - - .globl up_fetchadd8 - .type up_fetchadd8, %function - -up_fetchadd8: - -1: - ldrexb r2, [r0] /* Fetch the value to be incremented */ - add r2, r2, r1 /* Add the addend */ - - strexb r3, r2, [r0] /* Attempt to save the result */ - teq r3, #0 /* r3 will be 1 if strexb failed */ - bne 1b /* Failed to lock... try again */ - - mov r0, r2 /* Return the incremented value */ - bx lr /* Successful! */ - .size up_fetchadd8, . - up_fetchadd8 - -/**************************************************************************** - * Name: up_fetchsub8 - * - * Description: - * Perform an atomic fetch subtract operation on the provided 8-bit value. - * - * This function must be provided via the architecture-specific logic. - * - * Input Parameters: - * addr - The address of 8-bit value to be decremented. - * value - The 8-bit subtrahend - * - * Returned Value: - * The decremented value (volatile!) - * - ****************************************************************************/ - - .globl up_fetchsub8 - .type up_fetchsub8, %function - -up_fetchsub8: - -1: - ldrexb r2, [r0] /* Fetch the value to be decremented */ - sub r2, r2, r1 /* Subtract the subtrahend */ - - strexb r3, r2, [r0] /* Attempt to save the result */ - teq r3, #0 /* r3 will be 1 if strexb failed */ - bne 1b /* Failed to lock... try again */ - - mov r0, r2 /* Return the decremented value */ - bx lr /* Successful! */ - .size up_fetchsub8, . - up_fetchsub8 - .end diff --git a/arch/arm/src/armv7-a/arm_testset.S b/arch/arm/src/armv7-a/arm_testset.S deleted file mode 100644 index 822c5d7c48..0000000000 --- a/arch/arm/src/armv7-a/arm_testset.S +++ /dev/null @@ -1,106 +0,0 @@ -/**************************************************************************** - * arch/arm/src/armv7-a/arm_testset.S - * - * 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 -#include - - .file "arm_testset.S" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Public Symbols - ****************************************************************************/ - - .globl up_testset - -/**************************************************************************** - * Assembly Macros - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - - .text - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: up_testset - * - * Description: - * Perform an atomic test and set operation on the provided spinlock. - * - * This function must be provided via the architecture-specific logic. - * - * Input Parameters: - * lock - A reference to the spinlock object. - * - * Returned Value: - * The spinlock is always locked upon return. The previous value of the - * spinlock variable is returned, either SP_LOCKED if the spinlock was - * previously locked (meaning that the test-and-set operation failed to - * obtain the lock) or SP_UNLOCKED if the spinlock was previously unlocked - * (meaning that we successfully obtained the lock). - * - ****************************************************************************/ - - .globl up_testset - .type up_testset, %function - -up_testset: - - mov r1, #SP_LOCKED - - /* Test if the spinlock is locked or not */ - -1: - ldrexb r2, [r0] /* Test if spinlock is locked or not */ - cmp r2, r1 /* Already locked? */ - beq 2f /* If already locked, return SP_LOCKED */ - - /* Not locked ... attempt to lock it */ - - strexb r2, r1, [r0] /* Attempt to set the locked state */ - cmp r2, r1 /* r2 will be 1 is strexb failed */ - beq 1b /* Failed to lock... try again */ - - /* Lock acquired -- return SP_UNLOCKED */ - - dmb /* Required before accessing protected resource */ - mov r0, #SP_UNLOCKED - bx lr - - /* Lock not acquired -- return SP_LOCKED */ - -2: - mov r0, #SP_LOCKED - bx lr - .size up_testset, . - up_testset - .end diff --git a/arch/arm/src/armv7-a/vfork.S b/arch/arm/src/armv7-a/vfork.S deleted file mode 100644 index 9524c07b25..0000000000 --- a/arch/arm/src/armv7-a/vfork.S +++ /dev/null @@ -1,124 +0,0 @@ -/**************************************************************************** - * arch/arm/src/armv7-a/vfork.S - * - * 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 - -#include "arm_vfork.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Public Symbols - ****************************************************************************/ - - .file "vfork.S" - .globl up_vfork - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: vfork - * - * Description: - * The vfork() function has the same effect as fork(), except that the - * behavior is undefined if the process created by vfork() either modifies - * any data other than a variable of type pid_t used to store the return - * value from vfork(), or returns from the function in which vfork() was - * called, or calls any other function before successfully calling _exit() - * or one of the exec family of functions. - * - * This thin layer implements vfork by simply calling up_vfork() with the - * vfork() context as an argument. The overall sequence is: - * - * 1) User code calls vfork(). vfork() collects context information and - * transfers control up up_vfork(). - * 2) up_vfork() and calls nxtask_setup_vfork(). - * 3) nxtask_setup_vfork() allocates and configures the child task's TCB. - * This consists of: - * - Allocation of the child task's TCB. - * - Initialization of file descriptors and streams - * - Configuration of environment variables - * - Allocate and initialize the stack - * - Setup the input parameters for the task. - * - Initialization of the TCB (including call to up_initial_state()) - * 4) up_vfork() provides any additional operating context. up_vfork must: - * - Initialize special values in any CPU registers that were not - * already configured by up_initial_state() - * 5) up_vfork() then calls nxtask_start_vfork() - * 6) nxtask_start_vfork() then executes the child thread. - * - * Input Parameters: - * None - * - * Returned Value: - * Upon successful completion, vfork() returns 0 to the child process and - * returns the process ID of the child process to the parent process. - * Otherwise, -1 is returned to the parent, no child process is created, - * and errno is set to indicate the error. - * - ****************************************************************************/ - - .globl vfork - .type vfork, function -vfork: - /* Create a stack frame */ - - mov r0, sp /* Save the value of the stack on entry */ - sub sp, sp, #VFORK_SIZEOF /* Allocate the structure on the stack */ - - /* CPU registers */ - /* Save the volatile registers */ - - str r4, [sp, #VFORK_R4_OFFSET] - str r5, [sp, #VFORK_R5_OFFSET] - str r6, [sp, #VFORK_R6_OFFSET] - str r7, [sp, #VFORK_R7_OFFSET] - str r8, [sp, #VFORK_R8_OFFSET] - str r9, [sp, #VFORK_R9_OFFSET] - str r10, [sp, #VFORK_R10_OFFSET] - - /* Save the frame pointer, stack pointer, and return address */ - - str fp, [sp, #VFORK_FP_OFFSET] - str r0, [sp, #VFORK_SP_OFFSET] - str lr, [sp, #VFORK_LR_OFFSET] - - /* Floating point registers (not yet) */ - - /* Then, call up_vfork(), passing it a pointer to the stack structure */ - - mov r0, sp - bl up_vfork - - /* Release the stack data and return the value returned by up_vfork */ - - ldr lr, [sp, #VFORK_LR_OFFSET] - add sp, sp, #VFORK_SIZEOF - bx lr - .size vfork, .-vfork - .end diff --git a/arch/arm/src/armv7-m/gnu/arm_exception.S b/arch/arm/src/armv7-m/arm_exception.S similarity index 99% rename from arch/arm/src/armv7-m/gnu/arm_exception.S rename to arch/arm/src/armv7-m/arm_exception.S index 2d4fb860e4..cc4b59ad8a 100644 --- a/arch/arm/src/armv7-m/gnu/arm_exception.S +++ b/arch/arm/src/armv7-m/arm_exception.S @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/arm/src/armv7-m/gnu/arm_exception.S + * arch/arm/src/armv7-m/arm_exception.S * * Copyright (C) 2009-2013, 2015-2016, 2018 Gregory Nutt. * All rights reserved. diff --git a/arch/arm/src/armv7-m/gnu/arm_fetchadd.S b/arch/arm/src/armv7-m/gnu/arm_fetchadd.S deleted file mode 100644 index ed7591d4bc..0000000000 --- a/arch/arm/src/armv7-m/gnu/arm_fetchadd.S +++ /dev/null @@ -1,242 +0,0 @@ -/**************************************************************************** - * arch/arm/src/armv7-m/gnu/arm_fetchadd.S - * - * 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 - - .syntax unified - .thumb - .file "arm_fetchadd.S" - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - - .text - -/**************************************************************************** - * Name: up_fetchadd32 - * - * Description: - * Perform an atomic fetch add operation on the provided 32-bit value. - * - * This function must be provided via the architecture-specific logic. - * - * Input Parameters: - * addr - The address of 32-bit value to be incremented. - * value - The 32-bit addend - * - * Returned Value: - * The incremented value (volatile!) - * - ****************************************************************************/ - - .globl up_fetchadd32 - .type up_fetchadd32, %function - -up_fetchadd32: - -1: - ldrex r2, [r0] /* Fetch the value to be incremented */ - add r2, r2, r1 /* Add the addend */ - - strex r3, r2, [r0] /* Attempt to save the result */ - teq r3, #0 /* r3 will be 1 if strex failed */ - bne 1b /* Failed to lock... try again */ - - mov r0, r2 /* Return the incremented value */ - bx lr /* Successful! */ - .size up_fetchadd32, . - up_fetchadd32 - -/**************************************************************************** - * Name: up_fetchsub32 - * - * Description: - * Perform an atomic fetch subtract operation on the provided 32-bit value. - * - * This function must be provided via the architecture-specific logic. - * - * Input Parameters: - * addr - The address of 32-bit value to be decremented. - * value - The 32-bit subtrahend - * - * Returned Value: - * The decremented value (volatile!) - * - ****************************************************************************/ - - .globl up_fetchsub32 - .type up_fetchsub32, %function - -up_fetchsub32: - -1: - ldrex r2, [r0] /* Fetch the value to be decremented */ - sub r2, r2, r1 /* Subtract the subtrahend */ - - strex r3, r2, [r0] /* Attempt to save the result */ - teq r3, #0 /* r3 will be 1 if strex failed */ - bne 1b /* Failed to lock... try again */ - - mov r0, r2 /* Return the decremented value */ - bx lr /* Successful! */ - .size up_fetchsub32, . - up_fetchsub32 - -/**************************************************************************** - * Name: up_fetchadd16 - * - * Description: - * Perform an atomic fetch add operation on the provided 16-bit value. - * - * This function must be provided via the architecture-specific logic. - * - * Input Parameters: - * addr - The address of 16-bit value to be incremented. - * value - The 16-bit addend - * - * Returned Value: - * The incremented value (volatile!) - * - ****************************************************************************/ - - .globl up_fetchadd16 - .type up_fetchadd16, %function - -up_fetchadd16: - -1: - ldrexh r2, [r0] /* Fetch the value to be incremented */ - add r2, r2, r1 /* Add the addend */ - - strexh r3, r2, [r0] /* Attempt to save the result */ - teq r3, #0 /* r3 will be 1 if strexh failed */ - bne 1b /* Failed to lock... try again */ - - mov r0, r2 /* Return the incremented value */ - bx lr /* Successful! */ - .size up_fetchadd16, . - up_fetchadd16 - -/**************************************************************************** - * Name: up_fetchsub16 - * - * Description: - * Perform an atomic fetch subtract operation on the provided 16-bit value. - * - * This function must be provided via the architecture-specific logic. - * - * Input Parameters: - * addr - The address of 16-bit value to be decremented. - * value - The 16-bit subtrahend - * - * Returned Value: - * The decremented value (volatile!) - * - ****************************************************************************/ - - .globl up_fetchsub16 - .type up_fetchsub16, %function - -up_fetchsub16: - -1: - ldrexh r2, [r0] /* Fetch the value to be decremented */ - sub r2, r2, r1 /* Subtract the subtrahend */ - - /* Attempt to save the decremented value */ - - strexh r3, r2, [r0] /* Attempt to save the result */ - teq r3, #0 /* r3 will be 1 if strexh failed */ - bne 1b /* Failed to lock... try again */ - - mov r0, r2 /* Return the decremented value */ - bx lr /* Successful! */ - .size up_fetchsub16, . - up_fetchsub16 - -/**************************************************************************** - * Name: up_fetchadd8 - * - * Description: - * Perform an atomic fetch add operation on the provided 8-bit value. - * - * This function must be provided via the architecture-specific logic. - * - * Input Parameters: - * addr - The address of 8-bit value to be incremented. - * value - The 8-bit addend - * - * Returned Value: - * The incremented value (volatile!) - * - ****************************************************************************/ - - .globl up_fetchadd8 - .type up_fetchadd8, %function - -up_fetchadd8: - -1: - ldrexb r2, [r0] /* Fetch the value to be incremented */ - add r2, r2, r1 /* Add the addend */ - - strexb r3, r2, [r0] /* Attempt to save the result */ - teq r3, #0 /* r3 will be 1 if strexb failed */ - bne 1b /* Failed to lock... try again */ - - mov r0, r2 /* Return the incremented value */ - bx lr /* Successful! */ - .size up_fetchadd8, . - up_fetchadd8 - -/**************************************************************************** - * Name: up_fetchsub8 - * - * Description: - * Perform an atomic fetch subtract operation on the provided 8-bit value. - * - * This function must be provided via the architecture-specific logic. - * - * Input Parameters: - * addr - The address of 8-bit value to be decremented. - * value - The 8-bit subtrahend - * - * Returned Value: - * The decremented value (volatile!) - * - ****************************************************************************/ - - .globl up_fetchsub8 - .type up_fetchsub8, %function - -up_fetchsub8: - -1: - ldrexb r2, [r0] /* Fetch the value to be decremented */ - sub r2, r2, r1 /* Subtract the subtrahend */ - - strexb r3, r2, [r0] /* Attempt to save the result */ - teq r3, #0 /* r3 will be 1 if strexb failed */ - bne 1b /* Failed to lock... try again */ - - mov r0, r2 /* Return the decremented value */ - bx lr /* Successful! */ - .size up_fetchsub8, . - up_fetchsub8 - .end diff --git a/arch/arm/src/armv7-m/gnu/arm_signal_handler.S b/arch/arm/src/armv7-m/gnu/arm_signal_handler.S deleted file mode 100644 index fa83e6c605..0000000000 --- a/arch/arm/src/armv7-m/gnu/arm_signal_handler.S +++ /dev/null @@ -1,102 +0,0 @@ -/**************************************************************************** - * arch/arm/src/armv7-m/gnu/arm_signal_handler.S - * - * 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 - -#include - -#if defined(CONFIG_BUILD_PROTECTED) && !defined(__KERNEL__) - -/**************************************************************************** - * File info - ****************************************************************************/ - - .syntax unified - .thumb - .file "arm_signal_handler.S" - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: up_signal_handler - * - * Description: - * This function is the user-space, signal handler trampoline function. It - * is called from up_signal_dispatch() in user-mode. - * - * R0-R3, R11 - volatile registers need not be preserved. - * R4-R10 - static registers must be preserved - * R12-R14 - LR and SP must be preserved - * - * Input Parameters: - * R0 = sighand - * The address user-space signal handling function - * R1-R3 = signo, info, and ucontext - * Standard arguments to be passed to the signal handling function. - * - * Returned Value: - * None. This function does not return in the normal sense. It returns - * via the SYS_signal_handler_return (see syscall.h) - * - ****************************************************************************/ - - .text - .thumb_func - .globl up_signal_handler - .type up_signal_handler, function -up_signal_handler: - - /* Save some register */ - - push {lr} /* Save LR on the stack */ - - /* Call the signal handler */ - - mov ip, r0 /* IP=sighand */ - mov r0, r1 /* R0=signo */ - mov r1, r2 /* R1=info */ - mov r2, r3 /* R2=ucontext */ - blx ip /* Call the signal handler */ - - /* Restore the registers */ - - pop {r2} /* Recover LR in R2 */ - mov lr, r2 /* Restore LR */ - - /* Execute the SYS_signal_handler_return SVCall (will not return) */ - - mov r0, #SYS_signal_handler_return - svc #SYS_syscall - nop - - .size up_signal_handler, .-up_signal_handler - .end - -#endif /* CONFIG_BUILD_PROTECTED && !__KERNEL__ */ diff --git a/arch/arm/src/armv7-m/gnu/arm_testset.S b/arch/arm/src/armv7-m/gnu/arm_testset.S deleted file mode 100644 index 36e039d0ba..0000000000 --- a/arch/arm/src/armv7-m/gnu/arm_testset.S +++ /dev/null @@ -1,108 +0,0 @@ -/**************************************************************************** - * arch/arm/src/armv7-m/gnu/arm_testset.S - * - * 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 -#include - - .syntax unified - .thumb - .file "arm_testset.S" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Public Symbols - ****************************************************************************/ - - .globl up_testset - -/**************************************************************************** - * Assembly Macros - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - - .text - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: up_testset - * - * Description: - * Perform an atomic test and set operation on the provided spinlock. - * - * This function must be provided via the architecture-specific logic. - * - * Input Parameters: - * lock - A reference to the spinlock object. - * - * Returned Value: - * The spinlock is always locked upon return. The previous value of the - * spinlock variable is returned, either SP_LOCKED if the spinlock was - * previously locked (meaning that the test-and-set operation failed to - * obtain the lock) or SP_UNLOCKED if the spinlock was previously unlocked - * (meaning that we successfully obtained the lock). - * - ****************************************************************************/ - - .globl up_testset - .type up_testset, %function - -up_testset: - - mov r1, #SP_LOCKED - - /* Test if the spinlock is locked or not */ - -1: - ldrexb r2, [r0] /* Test if spinlock is locked or not */ - cmp r2, r1 /* Already locked? */ - beq 2f /* If already locked, return SP_LOCKED */ - - /* Not locked ... attempt to lock it */ - - strexb r2, r1, [r0] /* Attempt to set the locked state */ - cmp r2, r1 /* r2 will be 1 is strexb failed */ - beq 1b /* Failed to lock... try again */ - - /* Lock acquired -- return SP_UNLOCKED */ - - dmb /* Required before accessing protected resource */ - mov r0, #SP_UNLOCKED - bx lr - - /* Lock not acquired -- return SP_LOCKED */ - -2: - mov r0, #SP_LOCKED - bx lr - .size up_testset, . - up_testset - .end diff --git a/arch/arm/src/armv7-m/gnu/vfork.S b/arch/arm/src/armv7-m/gnu/vfork.S deleted file mode 100644 index b5b6dd2142..0000000000 --- a/arch/arm/src/armv7-m/gnu/vfork.S +++ /dev/null @@ -1,127 +0,0 @@ -/**************************************************************************** - * arch/arm/src/armv7-m/gnu/vfork.S - * - * 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 - -#include "arm_vfork.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Public Symbols - ****************************************************************************/ - - .syntax unified - .thumb - .file "vfork.S" - .globl up_vfork - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: vfork - * - * Description: - * The vfork() function has the same effect as fork(), except that the - * behavior is undefined if the process created by vfork() either modifies - * any data other than a variable of type pid_t used to store the return - * value from vfork(), or returns from the function in which vfork() was - * called, or calls any other function before successfully calling _exit() - * or one of the exec family of functions. - * - * This thin layer implements vfork by simply calling up_vfork() with the - * vfork() context as an argument. The overall sequence is: - * - * 1) User code calls vfork(). vfork() collects context information and - * transfers control up up_vfork(). - * 2) up_vfork() and calls nxtask_setup_vfork(). - * 3) nxtask_setup_vfork() allocates and configures the child task's TCB. - * This consists of: - * - Allocation of the child task's TCB. - * - Initialization of file descriptors and streams - * - Configuration of environment variables - * - Allocate and initialize the stack - * - Setup the input parameters for the task. - * - Initialization of the TCB (including call to up_initial_state()) - * 4) up_vfork() provides any additional operating context. up_vfork must: - * - Initialize special values in any CPU registers that were not - * already configured by up_initial_state() - * 5) up_vfork() then calls nxtask_start_vfork() - * 6) nxtask_start_vfork() then executes the child thread. - * - * Input Parameters: - * None - * - * Returned Value: - * Upon successful completion, vfork() returns 0 to the child process and - * returns the process ID of the child process to the parent process. - * Otherwise, -1 is returned to the parent, no child process is created, - * and errno is set to indicate the error. - * - ****************************************************************************/ - - .thumb_func - .globl vfork - .type vfork, function -vfork: - /* Create a stack frame */ - - mov r0, sp /* Save the value of the stack on entry */ - sub sp, sp, #VFORK_SIZEOF /* Allocate the structure on the stack */ - - /* CPU registers */ - /* Save the volatile registers */ - - str r4, [sp, #VFORK_R4_OFFSET] - str r5, [sp, #VFORK_R5_OFFSET] - str r6, [sp, #VFORK_R6_OFFSET] - str r7, [sp, #VFORK_R7_OFFSET] - str r8, [sp, #VFORK_R8_OFFSET] - str r9, [sp, #VFORK_R9_OFFSET] - str r10, [sp, #VFORK_R10_OFFSET] - - /* Save the frame pointer, stack pointer, and return address */ - - str fp, [sp, #VFORK_FP_OFFSET] - str r0, [sp, #VFORK_SP_OFFSET] - str lr, [sp, #VFORK_LR_OFFSET] - - /* Floating point registers (not yet) */ - - /* Then, call up_vfork(), passing it a pointer to the stack structure */ - - mov r0, sp - bl up_vfork - - /* Release the stack data and return the value returned by up_vfork */ - - ldr lr, [sp, #VFORK_LR_OFFSET] - add sp, sp, #VFORK_SIZEOF - bx lr - .size vfork, .-vfork - .end diff --git a/arch/arm/src/armv7-r/arm_fetchadd.S b/arch/arm/src/armv7-r/arm_fetchadd.S deleted file mode 100644 index e8c1f38cfc..0000000000 --- a/arch/arm/src/armv7-r/arm_fetchadd.S +++ /dev/null @@ -1,240 +0,0 @@ -/**************************************************************************** - * arch/arm/src/armv7-r/arm_fetchadd.S - * - * 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 - - .file "arm_fetchadd.S" - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - - .text - -/**************************************************************************** - * Name: up_fetchadd32 - * - * Description: - * Perform an atomic fetch add operation on the provided 32-bit value. - * - * This function must be provided via the architecture-specific logic. - * - * Input Parameters: - * addr - The address of 32-bit value to be incremented. - * value - The 32-bit addend - * - * Returned Value: - * The incremented value (volatile!) - * - ****************************************************************************/ - - .globl up_fetchadd32 - .type up_fetchadd32, %function - -up_fetchadd32: - -1: - ldrex r2, [r0] /* Fetch the value to be incremented */ - add r2, r2, r1 /* Add the addend */ - - strex r3, r2, [r0] /* Attempt to save the result */ - teq r3, #0 /* r3 will be 1 if strex failed */ - bne 1b /* Failed to lock... try again */ - - mov r0, r2 /* Return the incremented value */ - bx lr /* Successful! */ - .size up_fetchadd32, . - up_fetchadd32 - -/**************************************************************************** - * Name: up_fetchsub32 - * - * Description: - * Perform an atomic fetch subtract operation on the provided 32-bit value. - * - * This function must be provided via the architecture-specific logic. - * - * Input Parameters: - * addr - The address of 32-bit value to be decremented. - * value - The 32-bit subtrahend - * - * Returned Value: - * The decremented value (volatile!) - * - ****************************************************************************/ - - .globl up_fetchsub32 - .type up_fetchsub32, %function - -up_fetchsub32: - -1: - ldrex r2, [r0] /* Fetch the value to be decremented */ - sub r2, r2, r1 /* Subtract the subtrahend */ - - strex r3, r2, [r0] /* Attempt to save the result */ - teq r3, #0 /* r3 will be 1 if strex failed */ - bne 1b /* Failed to lock... try again */ - - mov r0, r2 /* Return the decremented value */ - bx lr /* Successful! */ - .size up_fetchsub32, . - up_fetchsub32 - -/**************************************************************************** - * Name: up_fetchadd16 - * - * Description: - * Perform an atomic fetch add operation on the provided 16-bit value. - * - * This function must be provided via the architecture-specific logic. - * - * Input Parameters: - * addr - The address of 16-bit value to be incremented. - * value - The 16-bit addend - * - * Returned Value: - * The incremented value (volatile!) - * - ****************************************************************************/ - - .globl up_fetchadd16 - .type up_fetchadd16, %function - -up_fetchadd16: - -1: - ldrexh r2, [r0] /* Fetch the value to be incremented */ - add r2, r2, r1 /* Add the addend */ - - strexh r3, r2, [r0] /* Attempt to save the result */ - teq r3, #0 /* r3 will be 1 if strexh failed */ - bne 1b /* Failed to lock... try again */ - - mov r0, r2 /* Return the incremented value */ - bx lr /* Successful! */ - .size up_fetchadd16, . - up_fetchadd16 - -/**************************************************************************** - * Name: up_fetchsub16 - * - * Description: - * Perform an atomic fetch subtract operation on the provided 16-bit value. - * - * This function must be provided via the architecture-specific logic. - * - * Input Parameters: - * addr - The address of 16-bit value to be decremented. - * value - The 16-bit subtrahend - * - * Returned Value: - * The decremented value (volatile!) - * - ****************************************************************************/ - - .globl up_fetchsub16 - .type up_fetchsub16, %function - -up_fetchsub16: - -1: - ldrexh r2, [r0] /* Fetch the value to be decremented */ - sub r2, r2, r1 /* Subtract the subtrahend */ - - /* Attempt to save the decremented value */ - - strexh r3, r2, [r0] /* Attempt to save the result */ - teq r3, #0 /* r3 will be 1 if strexh failed */ - bne 1b /* Failed to lock... try again */ - - mov r0, r2 /* Return the decremented value */ - bx lr /* Successful! */ - .size up_fetchsub16, . - up_fetchsub16 - -/**************************************************************************** - * Name: up_fetchadd8 - * - * Description: - * Perform an atomic fetch add operation on the provided 8-bit value. - * - * This function must be provided via the architecture-specific logic. - * - * Input Parameters: - * addr - The address of 8-bit value to be incremented. - * value - The 8-bit addend - * - * Returned Value: - * The incremented value (volatile!) - * - ****************************************************************************/ - - .globl up_fetchadd8 - .type up_fetchadd8, %function - -up_fetchadd8: - -1: - ldrexb r2, [r0] /* Fetch the value to be incremented */ - add r2, r2, r1 /* Add the addend */ - - strexb r3, r2, [r0] /* Attempt to save the result */ - teq r3, #0 /* r3 will be 1 if strexb failed */ - bne 1b /* Failed to lock... try again */ - - mov r0, r2 /* Return the incremented value */ - bx lr /* Successful! */ - .size up_fetchadd8, . - up_fetchadd8 - -/**************************************************************************** - * Name: up_fetchsub8 - * - * Description: - * Perform an atomic fetch subtract operation on the provided 8-bit value. - * - * This function must be provided via the architecture-specific logic. - * - * Input Parameters: - * addr - The address of 8-bit value to be decremented. - * value - The 8-bit subtrahend - * - * Returned Value: - * The decremented value (volatile!) - * - ****************************************************************************/ - - .globl up_fetchsub8 - .type up_fetchsub8, %function - -up_fetchsub8: - -1: - ldrexb r2, [r0] /* Fetch the value to be decremented */ - sub r2, r2, r1 /* Subtract the subtrahend */ - - strexb r3, r2, [r0] /* Attempt to save the result */ - teq r3, #0 /* r3 will be 1 if strexb failed */ - bne 1b /* Failed to lock... try again */ - - mov r0, r2 /* Return the decremented value */ - bx lr /* Successful! */ - .size up_fetchsub8, . - up_fetchsub8 - .end diff --git a/arch/arm/src/armv7-r/arm_signal_handler.S b/arch/arm/src/armv7-r/arm_signal_handler.S deleted file mode 100644 index 585f362d12..0000000000 --- a/arch/arm/src/armv7-r/arm_signal_handler.S +++ /dev/null @@ -1,99 +0,0 @@ -/**************************************************************************** - * arch/arm/src/armv7-r/arm_signal_handler.S - * - * 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 - -#include - -#if defined(CONFIG_BUILD_PROTECTED) && !defined(__KERNEL__) - -/**************************************************************************** - * File info - ****************************************************************************/ - - .file "arm_signal_handler.S" - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: up_signal_handler - * - * Description: - * This function is the user-space, signal handler trampoline function. It - * is called from up_signal_dispatch() in user-mode. - * - * R0-R3, R11 - volatile registers need not be preserved. - * R4-R10 - static registers must be preserved - * R12-R14 - LR and SP must be preserved - * - * Input Parameters: - * R0 = sighand - * The address user-space signal handling function - * R1-R3 = signo, info, and ucontext - * Standard arguments to be passed to the signal handling function. - * - * Returned Value: - * None. This function does not return in the normal sense. It returns - * via the SYS_signal_handler_return (see syscall.h) - * - ****************************************************************************/ - - .text - .globl up_signal_handler - .type up_signal_handler, function -up_signal_handler: - - /* Save some register */ - - push {lr} /* Save LR on the stack */ - - /* Call the signal handler */ - - mov ip, r0 /* IP=sighand */ - mov r0, r1 /* R0=signo */ - mov r1, r2 /* R1=info */ - mov r2, r3 /* R2=ucontext */ - blx ip /* Call the signal handler */ - - /* Restore the registers */ - - pop {r2} /* Recover LR in R2 */ - mov lr, r2 /* Restore LR */ - - /* Execute the SYS_signal_handler_return SVCall (will not return) */ - - mov r0, #SYS_signal_handler_return - svc #SYS_syscall - nop - - .size up_signal_handler, .-up_signal_handler - .end - -#endif /* CONFIG_BUILD_PROTECTED && !__KERNEL__ */ diff --git a/arch/arm/src/armv7-r/arm_testset.S b/arch/arm/src/armv7-r/arm_testset.S deleted file mode 100644 index d8b1aeaad6..0000000000 --- a/arch/arm/src/armv7-r/arm_testset.S +++ /dev/null @@ -1,106 +0,0 @@ -/**************************************************************************** - * arch/arm/src/armv7-r/arm_testset.S - * - * 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 -#include - - .file "arm_testset.S" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Public Symbols - ****************************************************************************/ - - .globl up_testset - -/**************************************************************************** - * Assembly Macros - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - - .text - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: up_testset - * - * Description: - * Perform an atomic test and set operation on the provided spinlock. - * - * This function must be provided via the architecture-specific logic. - * - * Input Parameters: - * lock - A reference to the spinlock object. - * - * Returned Value: - * The spinlock is always locked upon return. The previous value of the - * spinlock variable is returned, either SP_LOCKED if the spinlock was - * previously locked (meaning that the test-and-set operation failed to - * obtain the lock) or SP_UNLOCKED if the spinlock was previously unlocked - * (meaning that we successfully obtained the lock). - * - ****************************************************************************/ - - .globl up_testset - .type up_testset, %function - -up_testset: - - mov r1, #SP_LOCKED - - /* Test if the spinlock is locked or not */ - -1: - ldrexb r2, [r0] /* Test if spinlock is locked or not */ - cmp r2, r1 /* Already locked? */ - beq 2f /* If already locked, return SP_LOCKED */ - - /* Not locked ... attempt to lock it */ - - strexb r2, r1, [r0] /* Attempt to set the locked state */ - cmp r2, r1 /* r2 will be 1 is strexb failed */ - beq 1b /* Failed to lock... try again */ - - /* Lock acquired -- return SP_UNLOCKED */ - - dmb /* Required before accessing protected resource */ - mov r0, #SP_UNLOCKED - bx lr - - /* Lock not acquired -- return SP_LOCKED */ - -2: - mov r0, #SP_LOCKED - bx lr - .size up_testset, . - up_testset - .end diff --git a/arch/arm/src/armv7-r/vfork.S b/arch/arm/src/armv7-r/vfork.S deleted file mode 100644 index 670fdb30de..0000000000 --- a/arch/arm/src/armv7-r/vfork.S +++ /dev/null @@ -1,124 +0,0 @@ -/**************************************************************************** - * arch/arm/src/armv7-r/vfork.S - * - * 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 - -#include "arm_vfork.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Public Symbols - ****************************************************************************/ - - .file "vfork.S" - .globl up_vfork - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: vfork - * - * Description: - * The vfork() function has the same effect as fork(), except that the - * behavior is undefined if the process created by vfork() either modifies - * any data other than a variable of type pid_t used to store the return - * value from vfork(), or returns from the function in which vfork() was - * called, or calls any other function before successfully calling _exit() - * or one of the exec family of functions. - * - * This thin layer implements vfork by simply calling up_vfork() with the - * vfork() context as an argument. The overall sequence is: - * - * 1) User code calls vfork(). vfork() collects context information and - * transfers control up up_vfork(). - * 2) up_vfork() and calls nxtask_setup_vfork(). - * 3) nxtask_setup_vfork() allocates and configures the child task's TCB. - * This consists of: - * - Allocation of the child task's TCB. - * - Initialization of file descriptors and streams - * - Configuration of environment variables - * - Allocate and initialize the stack - * - Setup the input parameters for the task. - * - Initialization of the TCB (including call to up_initial_state()) - * 4) up_vfork() provides any additional operating context. up_vfork must: - * - Initialize special values in any CPU registers that were not - * already configured by up_initial_state() - * 5) up_vfork() then calls nxtask_start_vfork() - * 6) nxtask_start_vfork() then executes the child thread. - * - * Input Parameters: - * None - * - * Returned Value: - * Upon successful completion, vfork() returns 0 to the child process and - * returns the process ID of the child process to the parent process. - * Otherwise, -1 is returned to the parent, no child process is created, - * and errno is set to indicate the error. - * - ****************************************************************************/ - - .globl vfork - .type vfork, function -vfork: - /* Create a stack frame */ - - mov r0, sp /* Save the value of the stack on entry */ - sub sp, sp, #VFORK_SIZEOF /* Allocate the structure on the stack */ - - /* CPU registers */ - /* Save the volatile registers */ - - str r4, [sp, #VFORK_R4_OFFSET] - str r5, [sp, #VFORK_R5_OFFSET] - str r6, [sp, #VFORK_R6_OFFSET] - str r7, [sp, #VFORK_R7_OFFSET] - str r8, [sp, #VFORK_R8_OFFSET] - str r9, [sp, #VFORK_R9_OFFSET] - str r10, [sp, #VFORK_R10_OFFSET] - - /* Save the frame pointer, stack pointer, and return address */ - - str fp, [sp, #VFORK_FP_OFFSET] - str r0, [sp, #VFORK_SP_OFFSET] - str lr, [sp, #VFORK_LR_OFFSET] - - /* Floating point registers (not yet) */ - - /* Then, call up_vfork(), passing it a pointer to the stack structure */ - - mov r0, sp - bl up_vfork - - /* Release the stack data and return the value returned by up_vfork */ - - ldr lr, [sp, #VFORK_LR_OFFSET] - add sp, sp, #VFORK_SIZEOF - bx lr - .size vfork, .-vfork - .end diff --git a/arch/arm/src/armv8-m/vfork.S b/arch/arm/src/armv8-m/vfork.S deleted file mode 100644 index 7f68b3b777..0000000000 --- a/arch/arm/src/armv8-m/vfork.S +++ /dev/null @@ -1,127 +0,0 @@ -/**************************************************************************** - * arch/arm/src/armv8-m/vfork.S - * - * 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 - -#include "arm_vfork.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Public Symbols - ****************************************************************************/ - - .syntax unified - .thumb - .file "vfork.S" - .globl up_vfork - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: vfork - * - * Description: - * The vfork() function has the same effect as fork(), except that the - * behavior is undefined if the process created by vfork() either modifies - * any data other than a variable of type pid_t used to store the return - * value from vfork(), or returns from the function in which vfork() was - * called, or calls any other function before successfully calling _exit() - * or one of the exec family of functions. - * - * This thin layer implements vfork by simply calling up_vfork() with the - * vfork() context as an argument. The overall sequence is: - * - * 1) User code calls vfork(). vfork() collects context information and - * transfers control up up_vfork(). - * 2) up_vfork() and calls nxtask_setup_vfork(). - * 3) nxtask_setup_vfork() allocates and configures the child task's TCB. - * This consists of: - * - Allocation of the child task's TCB. - * - Initialization of file descriptors and streams - * - Configuration of environment variables - * - Allocate and initialize the stack - * - Setup the input parameters for the task. - * - Initialization of the TCB (including call to up_initial_state()) - * 4) up_vfork() provides any additional operating context. up_vfork must: - * - Initialize special values in any CPU registers that were not - * already configured by up_initial_state() - * 5) up_vfork() then calls nxtask_start_vfork() - * 6) nxtask_start_vfork() then executes the child thread. - * - * Input Parameters: - * None - * - * Returned Value: - * Upon successful completion, vfork() returns 0 to the child process and - * returns the process ID of the child process to the parent process. - * Otherwise, -1 is returned to the parent, no child process is created, - * and errno is set to indicate the error. - * - ****************************************************************************/ - - .thumb_func - .globl vfork - .type vfork, function -vfork: - /* Create a stack frame */ - - mov r0, sp /* Save the value of the stack on entry */ - sub sp, sp, #VFORK_SIZEOF /* Allocate the structure on the stack */ - - /* CPU registers */ - /* Save the volatile registers */ - - str r4, [sp, #VFORK_R4_OFFSET] - str r5, [sp, #VFORK_R5_OFFSET] - str r6, [sp, #VFORK_R6_OFFSET] - str r7, [sp, #VFORK_R7_OFFSET] - str r8, [sp, #VFORK_R8_OFFSET] - str r9, [sp, #VFORK_R9_OFFSET] - str r10, [sp, #VFORK_R10_OFFSET] - - /* Save the frame pointer, stack pointer, and return address */ - - str fp, [sp, #VFORK_FP_OFFSET] - str r0, [sp, #VFORK_SP_OFFSET] - str lr, [sp, #VFORK_LR_OFFSET] - - /* Floating point registers (not yet) */ - - /* Then, call up_vfork(), passing it a pointer to the stack structure */ - - mov r0, sp - bl up_vfork - - /* Release the stack data and return the value returned by up_vfork */ - - ldr lr, [sp, #VFORK_LR_OFFSET] - add sp, sp, #VFORK_SIZEOF - bx lr - .size vfork, .-vfork - .end diff --git a/arch/arm/src/armv8-m/arm_fetchadd.S b/arch/arm/src/common/gnu/arm_fetchadd.S similarity index 99% rename from arch/arm/src/armv8-m/arm_fetchadd.S rename to arch/arm/src/common/gnu/arm_fetchadd.S index ca7a6a6397..6d4fb3df06 100644 --- a/arch/arm/src/armv8-m/arm_fetchadd.S +++ b/arch/arm/src/common/gnu/arm_fetchadd.S @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/arm/src/armv8-m/arm_fetchadd.S + * arch/arm/src/common/gnu/arm_fetchadd.S * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -25,7 +25,6 @@ #include .syntax unified - .thumb .file "arm_fetchadd.S" /**************************************************************************** diff --git a/arch/arm/src/armv8-m/arm_signal_handler.S b/arch/arm/src/common/gnu/arm_signal_handler.S similarity index 98% rename from arch/arm/src/armv8-m/arm_signal_handler.S rename to arch/arm/src/common/gnu/arm_signal_handler.S index b2bac1a090..c2666f9cb9 100644 --- a/arch/arm/src/armv8-m/arm_signal_handler.S +++ b/arch/arm/src/common/gnu/arm_signal_handler.S @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/arm/src/armv8-m/arm_signal_handler.S + * arch/arm/src/common/gnu/arm_signal_handler.S * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -33,7 +33,6 @@ ****************************************************************************/ .syntax unified - .thumb .file "arm_signal_handler.S" /**************************************************************************** diff --git a/arch/arm/src/armv8-m/arm_testset.S b/arch/arm/src/common/gnu/arm_testset.S similarity index 98% rename from arch/arm/src/armv8-m/arm_testset.S rename to arch/arm/src/common/gnu/arm_testset.S index 45e2c273f8..544a96f4bd 100644 --- a/arch/arm/src/armv8-m/arm_testset.S +++ b/arch/arm/src/common/gnu/arm_testset.S @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/arm/src/armv8-m/arm_testset.S + * arch/arm/src/common/gnu/arm_testset.S * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -26,7 +26,6 @@ #include .syntax unified - .thumb .file "arm_testset.S" /**************************************************************************** diff --git a/arch/arm/src/armv6-m/vfork.S b/arch/arm/src/common/gnu/vfork.S similarity index 90% rename from arch/arm/src/armv6-m/vfork.S rename to arch/arm/src/common/gnu/vfork.S index 624134d893..e4c4c4929f 100644 --- a/arch/arm/src/armv6-m/vfork.S +++ b/arch/arm/src/common/gnu/vfork.S @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/arm/src/armv6-m/vfork.S + * arch/arm/src/common/vfork.S * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with @@ -26,16 +26,8 @@ #include "arm_vfork.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Public Symbols - ****************************************************************************/ - + .syntax unified .file "vfork.S" - .globl up_vfork /**************************************************************************** * Public Functions @@ -83,11 +75,9 @@ * ****************************************************************************/ - .align 2 - .code 16 - .thumb_func .globl vfork .type vfork, function + vfork: /* Create a stack frame */ @@ -123,5 +113,6 @@ vfork: mov r14, r1 add sp, sp, #VFORK_SIZEOF bx lr + .size vfork, .-vfork .end diff --git a/arch/arm/src/armv7-m/iar/arm_fetchadd.S b/arch/arm/src/common/iar/arm_fetchadd.S similarity index 99% rename from arch/arm/src/armv7-m/iar/arm_fetchadd.S rename to arch/arm/src/common/iar/arm_fetchadd.S index d78479c4c7..c2ada73216 100644 --- a/arch/arm/src/armv7-m/iar/arm_fetchadd.S +++ b/arch/arm/src/common/iar/arm_fetchadd.S @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/arm/src/armv7-m/iar/arm_fetchadd.S + * arch/arm/src/common/iar/arm_fetchadd.S * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with diff --git a/arch/arm/src/armv7-m/iar/arm_testset.S b/arch/arm/src/common/iar/arm_testset.S similarity index 98% rename from arch/arm/src/armv7-m/iar/arm_testset.S rename to arch/arm/src/common/iar/arm_testset.S index 8ad50f9374..e48f2d1dab 100644 --- a/arch/arm/src/armv7-m/iar/arm_testset.S +++ b/arch/arm/src/common/iar/arm_testset.S @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/arm/src/armv7-m/iar/arm_testset.S + * arch/arm/src/common/iar/arm_testset.S * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with diff --git a/arch/arm/src/armv7-m/iar/vfork.S b/arch/arm/src/common/iar/vfork.S similarity index 99% rename from arch/arm/src/armv7-m/iar/vfork.S rename to arch/arm/src/common/iar/vfork.S index 305e74728f..24d469279e 100644 --- a/arch/arm/src/armv7-m/iar/vfork.S +++ b/arch/arm/src/common/iar/vfork.S @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/arm/src/armv7-m/iar/vfork.S + * arch/arm/src/common/iar/vfork.S * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with