2021-03-24 09:13:30 +01:00
|
|
|
/****************************************************************************
|
2022-03-09 09:34:04 +01:00
|
|
|
* libs/libc/machine/arm/gnu/arm_setjmp.S
|
2019-08-06 23:59:19 +02:00
|
|
|
*
|
2021-03-20 19:54:56 +01:00
|
|
|
* 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
|
2019-08-06 23:59:19 +02:00
|
|
|
*
|
2021-03-20 19:54:56 +01:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2019-08-06 23:59:19 +02:00
|
|
|
*
|
2021-03-20 19:54:56 +01:00
|
|
|
* 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.
|
2019-08-06 23:59:19 +02:00
|
|
|
*
|
2021-03-24 09:13:30 +01:00
|
|
|
****************************************************************************/
|
2019-08-06 23:59:19 +02:00
|
|
|
|
2021-03-24 09:13:30 +01:00
|
|
|
/****************************************************************************
|
2019-08-06 23:59:19 +02:00
|
|
|
* Included Files
|
2021-03-24 09:13:30 +01:00
|
|
|
****************************************************************************/
|
2019-08-06 23:59:19 +02:00
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
2021-03-24 09:13:30 +01:00
|
|
|
/****************************************************************************
|
2019-08-06 23:59:19 +02:00
|
|
|
* Public Symbols
|
2021-03-24 09:13:30 +01:00
|
|
|
****************************************************************************/
|
2019-08-06 23:59:19 +02:00
|
|
|
|
2021-04-01 12:12:05 +02:00
|
|
|
.globl setjmp
|
|
|
|
.globl longjmp
|
2019-08-06 23:59:19 +02:00
|
|
|
|
2024-07-22 08:42:30 +02:00
|
|
|
#ifndef __ghs__
|
2021-04-01 12:12:05 +02:00
|
|
|
.syntax unified
|
2024-07-22 08:42:30 +02:00
|
|
|
#endif
|
2021-04-01 12:12:05 +02:00
|
|
|
.file "setjmp.S"
|
2019-08-06 23:59:19 +02:00
|
|
|
|
2021-03-24 09:13:30 +01:00
|
|
|
/****************************************************************************
|
2019-08-06 23:59:19 +02:00
|
|
|
* Public Functions
|
2021-03-24 09:13:30 +01:00
|
|
|
****************************************************************************/
|
2019-08-06 23:59:19 +02:00
|
|
|
|
2021-03-24 09:13:30 +01:00
|
|
|
/****************************************************************************
|
2019-08-06 23:59:19 +02:00
|
|
|
* Name: setjmp
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Given the pointer to a register save area (in R0), save the state of the
|
|
|
|
* all callee-saved registers
|
|
|
|
*
|
|
|
|
* C Function Prototype:
|
|
|
|
* int setjmp(jmp_buf env);
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* env - A pointer to the register save area in which to save the floating point
|
|
|
|
* registers and core registers. Since setjmp() can not be inlined, we
|
|
|
|
* only need to save the ABI-specified callee-saved registers.
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* 0 setjmp called directly
|
|
|
|
* non-0 we justed returned from a longjmp()
|
|
|
|
*
|
2021-03-24 09:13:30 +01:00
|
|
|
****************************************************************************/
|
2019-08-06 23:59:19 +02:00
|
|
|
|
2024-07-22 08:42:30 +02:00
|
|
|
#ifndef __ghs__
|
2021-04-01 12:12:05 +02:00
|
|
|
.type setjmp, function
|
2024-07-22 08:42:30 +02:00
|
|
|
#else
|
|
|
|
.type setjmp, $function
|
|
|
|
#endif
|
|
|
|
|
2019-08-06 23:59:19 +02:00
|
|
|
setjmp:
|
|
|
|
|
2021-04-01 12:12:05 +02:00
|
|
|
/* Store callee-saved Core registers */
|
2019-08-06 23:59:19 +02:00
|
|
|
|
2021-04-01 12:12:05 +02:00
|
|
|
mov ip, sp /* Move sp to ip so we can save it */
|
2022-04-26 18:13:56 +02:00
|
|
|
|
|
|
|
#ifdef CONFIG_ARCH_ARMV6M
|
|
|
|
stmia r0!, {r4-r7} /* Save R4 ~ R7 */
|
|
|
|
|
|
|
|
mov r2, r8
|
|
|
|
mov r3, r9
|
|
|
|
mov r4, r10
|
|
|
|
mov r5, r11
|
|
|
|
mov r6, ip
|
|
|
|
mov r7, lr
|
|
|
|
stmia r0!, {r2-r7} /* Save R8 ~ R11, IP, LR */
|
|
|
|
#else
|
2021-04-01 12:12:05 +02:00
|
|
|
stmia r0!, {r4-r11, ip, lr}
|
2022-04-26 18:13:56 +02:00
|
|
|
#endif
|
2019-08-06 23:59:19 +02:00
|
|
|
|
|
|
|
#ifdef CONFIG_ARCH_FPU
|
2021-04-01 12:12:05 +02:00
|
|
|
vstmia r0!, {s16-s31} /* Save the callee-saved FP registers */
|
2019-08-06 23:59:19 +02:00
|
|
|
|
2021-04-01 12:12:05 +02:00
|
|
|
/* Store the floating point control and status register. At the end of the
|
2022-02-16 16:01:00 +01:00
|
|
|
* vstmia, r0 will point to the FPSCR storage location.
|
2021-04-01 12:12:05 +02:00
|
|
|
*/
|
2019-08-06 23:59:19 +02:00
|
|
|
|
2022-02-16 16:01:00 +01:00
|
|
|
vmrs r1, fpscr /* Fetch the FPSCR */
|
2021-04-01 12:12:05 +02:00
|
|
|
str r1, [r0], #4 /* Save the floating point control and status register */
|
|
|
|
/* DSA: don't need to inc r0 */
|
2019-08-06 23:59:19 +02:00
|
|
|
#endif /* CONFIG_ARCH_FPU */
|
|
|
|
|
2021-04-01 12:12:05 +02:00
|
|
|
/* we're done, we're out of here */
|
2019-08-06 23:59:19 +02:00
|
|
|
|
2022-04-26 18:13:56 +02:00
|
|
|
movs r0, #0
|
2021-04-01 12:12:05 +02:00
|
|
|
bx lr
|
2019-08-06 23:59:19 +02:00
|
|
|
|
2021-04-01 12:12:05 +02:00
|
|
|
.size setjmp, .-setjmp
|
2019-08-06 23:59:19 +02:00
|
|
|
|
2021-03-24 09:13:30 +01:00
|
|
|
/****************************************************************************
|
2019-08-06 23:59:19 +02:00
|
|
|
* Name: longjmp
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* The longjmp() function used the information saved in env to transfer control
|
|
|
|
* control back to the point where setjmp() was called and to restore ("rewind")
|
|
|
|
* the stack to its state at the time of the setjmp() call. When control is
|
|
|
|
* passed back to where setjmp() had been called, setjmp() will return with
|
2020-02-23 09:50:23 +01:00
|
|
|
* 'val', the second parameter passed to longjmp().
|
2019-08-06 23:59:19 +02:00
|
|
|
*
|
|
|
|
* C Function Prototype:
|
|
|
|
* void longjmp(jmp_buf env, int val);
|
|
|
|
*
|
|
|
|
* Input Parameters:
|
|
|
|
* jmp_buf env
|
|
|
|
* int val
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* This function does not return anything explicitly.
|
|
|
|
*
|
2021-03-24 09:13:30 +01:00
|
|
|
****************************************************************************/
|
2019-08-06 23:59:19 +02:00
|
|
|
|
2024-07-22 08:42:30 +02:00
|
|
|
#ifndef __ghs__
|
2021-04-01 12:12:05 +02:00
|
|
|
.type longjmp, function
|
2024-07-22 08:42:30 +02:00
|
|
|
#else
|
|
|
|
.type longjmp, $function
|
|
|
|
#endif
|
2019-08-06 23:59:19 +02:00
|
|
|
longjmp:
|
|
|
|
|
2021-04-01 12:12:05 +02:00
|
|
|
/* Load callee-saved Core registers */
|
2019-08-06 23:59:19 +02:00
|
|
|
|
2022-04-26 18:13:56 +02:00
|
|
|
#ifdef CONFIG_ARCH_ARMV6M
|
|
|
|
ldmia r0!, {r4-r7} /* Restore R4 ~ R7 */
|
|
|
|
|
|
|
|
ldmia r0!, {r2-r3} /* Restore R8, R9 */
|
|
|
|
mov r8, r2
|
|
|
|
mov r9, r3
|
|
|
|
|
|
|
|
ldmia r0!, {r2-r3} /* Restore R10, R11 */
|
|
|
|
mov r10, r2
|
|
|
|
mov r11, r3
|
|
|
|
|
|
|
|
ldmia r0!, {r2-r3} /* Restore IP, LR */
|
|
|
|
mov ip, r2
|
|
|
|
mov lr, r3
|
|
|
|
#else
|
2021-04-01 12:12:05 +02:00
|
|
|
ldmia r0!, {r4-r11, ip, lr}
|
2022-04-26 18:13:56 +02:00
|
|
|
#endif
|
|
|
|
|
2021-04-01 12:12:05 +02:00
|
|
|
mov sp, ip /* Restore sp */
|
2019-08-06 23:59:19 +02:00
|
|
|
|
|
|
|
#ifdef CONFIG_ARCH_FPU
|
2021-04-01 12:12:05 +02:00
|
|
|
/* Load callee-saved floating point registers. */
|
2019-08-06 23:59:19 +02:00
|
|
|
|
2021-04-01 12:12:05 +02:00
|
|
|
vldmia r0!, {s16-s31} /* Restore FP context */
|
2019-08-06 23:59:19 +02:00
|
|
|
|
2021-04-01 12:12:05 +02:00
|
|
|
/* Load the floating point control and status register. */
|
2019-08-06 23:59:19 +02:00
|
|
|
|
2021-04-01 12:12:05 +02:00
|
|
|
ldr r2, [r0], #4 /* Fetch the floating point control and status register */
|
|
|
|
/* DSA: don't need to inc r0 */
|
2022-02-16 16:01:00 +01:00
|
|
|
vmsr fpscr, r2 /* Restore the FPSCR */
|
2019-08-06 23:59:19 +02:00
|
|
|
#endif /* CONFIG_ARCH_FPU */
|
|
|
|
|
2021-04-01 12:12:05 +02:00
|
|
|
mov r0, r1 /* return val */
|
|
|
|
bx lr
|
2019-08-06 23:59:19 +02:00
|
|
|
|
2021-04-01 12:12:05 +02:00
|
|
|
.size longjmp, .-longjmp
|
|
|
|
.end
|