Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:23

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /**
0004  * @file
0005  *
0006  * @ingroup RTEMSScoreCPUAArch64
0007  *
0008  * @brief Implementation of _CPU_Context_volatile_clobber
0009  *
0010  * This file implements _CPU_Context_volatile_clobber for use in spcontext01.
0011  */
0012 
0013 /*
0014  * Copyright (C) 2020 On-Line Applications Research Corporation (OAR)
0015  * Written by Kinsey Moore <kinsey.moore@oarcorp.com>
0016  *
0017  * Redistribution and use in source and binary forms, with or without
0018  * modification, are permitted provided that the following conditions
0019  * are met:
0020  * 1. Redistributions of source code must retain the above copyright
0021  *    notice, this list of conditions and the following disclaimer.
0022  * 2. Redistributions in binary form must reproduce the above copyright
0023  *    notice, this list of conditions and the following disclaimer in the
0024  *    documentation and/or other materials provided with the distribution.
0025  *
0026  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0027  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0028  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0029  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0030  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0031  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0032  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0033  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0034  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0035  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0036  * POSSIBILITY OF SUCH DAMAGE.
0037  */
0038 
0039 #ifdef HAVE_CONFIG_H
0040 #include "config.h"
0041 #endif
0042 
0043 #include <rtems/asm.h>
0044 
0045     .section    .text
0046 
0047 FUNCTION_ENTRY(_CPU_Context_volatile_clobber)
0048 
0049 .macro clobber_register reg
0050     sub x0, x0, #1
0051     mov \reg, x0
0052 .endm
0053 
0054 #ifdef AARCH64_MULTILIB_VFP
0055     mrs x1, FPCR
0056     ldr x2, =0xf000001f
0057     bic x1, x1, x2
0058     and x2, x2, x0
0059     orr x1, x1, x2
0060     msr FPCR, x1
0061 
0062 .macro clobber_vfp_register reg
0063     sub x0, x0, #1
0064     fmov    \reg, x0
0065 .endm
0066 
0067     clobber_vfp_register    d0
0068     clobber_vfp_register    d1
0069     clobber_vfp_register    d2
0070     clobber_vfp_register    d3
0071     clobber_vfp_register    d4
0072     clobber_vfp_register    d5
0073     clobber_vfp_register    d6
0074     clobber_vfp_register    d7
0075     clobber_vfp_register    d16
0076     clobber_vfp_register    d17
0077     clobber_vfp_register    d18
0078     clobber_vfp_register    d19
0079     clobber_vfp_register    d20
0080     clobber_vfp_register    d21
0081     clobber_vfp_register    d22
0082     clobber_vfp_register    d23
0083     clobber_vfp_register    d24
0084     clobber_vfp_register    d25
0085     clobber_vfp_register    d26
0086     clobber_vfp_register    d27
0087     clobber_vfp_register    d28
0088     clobber_vfp_register    d29
0089     clobber_vfp_register    d30
0090     clobber_vfp_register    d31
0091 #endif /* AARCH64_MULTILIB_VFP */
0092 
0093 /*
0094  * According to the AAPCS64, X0-X18 and X29 are caller-saved registers. X0 is
0095  * already being clobbered.
0096  */
0097     clobber_register    x1
0098     clobber_register    x2
0099     clobber_register    x3
0100     clobber_register    x4
0101     clobber_register    x5
0102     clobber_register    x6
0103     clobber_register    x7
0104     clobber_register    x8
0105     clobber_register    x9
0106     clobber_register    x10
0107     clobber_register    x11
0108     clobber_register    x12
0109     clobber_register    x13
0110     clobber_register    x14
0111     clobber_register    x15
0112     clobber_register    x16
0113     clobber_register    x17
0114     clobber_register    x18
0115     clobber_register    x29
0116 
0117     ret
0118 
0119 FUNCTION_END(_CPU_Context_volatile_clobber)