Skip to content

Commit

Permalink
- Add initial support for ARMv8A, ARMV7R and ARMV8R
Browse files Browse the repository at this point in the history
- Added core_cxx.h files for ARMv8A, ARMV7R and ARMV8R based profiles
- Moved gic peripheral to separate file
- Moved __FPU_Enable function to the architecture specific file
  • Loading branch information
Masmiseim36 committed Feb 26, 2024
1 parent 4d18b8d commit 7f7aae9
Show file tree
Hide file tree
Showing 35 changed files with 3,183 additions and 1,057 deletions.
812 changes: 76 additions & 736 deletions CMSIS/Core/Include/core_ca.h → CMSIS/Core/Include/a-profile/armv7a.h

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2017 ARM Limited. All rights reserved.
* Copyright (c) 2009-2024 ARM Limited. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
Expand Down Expand Up @@ -362,10 +362,10 @@ __STATIC_FORCEINLINE uint32_t __get_CNTP_CTL(void)

/******************************* VIRTUAL TIMER *******************************/
/** see [ARM DDI 0406C.d] :
. §B4.1.31 "CNTV_CTL, Counter-timer Virtual Timer Control register"
. §B4.1.32 "CNTV_CVAL, Counter-timer Virtual Timer CompareValue register"
. §B4.1.33 "CNTV_TVAL, Counter-timer Virtual Timer TimerValue register"
. §B4.1.34 "CNTVCT, Counter-timer Virtual Count register"
* B4.1.31 "CNTV_CTL, Counter-timer Virtual Timer Control register"
* B4.1.32 "CNTV_CVAL, Counter-timer Virtual Timer CompareValue register"
* B4.1.33 "CNTV_TVAL, Counter-timer Virtual Timer TimerValue register"
* B4.1.34 "CNTVCT, Counter-timer Virtual Count register"
**/
/** \brief Set CNTV_TVAL
This function assigns the given value to VL1 Virtual Timer Value Register (CNTV_TVAL).
Expand Down
641 changes: 641 additions & 0 deletions CMSIS/Core/Include/a-profile/armv8a.h

Large diffs are not rendered by default.

137 changes: 137 additions & 0 deletions CMSIS/Core/Include/a-profile/armv8a_cp15.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
/*
* Copyright (c) 2009-2024 ARM Limited. All rights reserved.
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed 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
*
* 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.
*/
#include <stdint.h>

#if defined ( __ICCARM__ )
#pragma system_include /* treat file as system include file for MISRA check */
#elif defined (__clang__)
#pragma clang system_header /* treat file as system include file */
#endif

#ifndef __CMSIS_SYSTEM_CONTROL_H
#define __CMSIS_SYSTEM_CONTROL_H
/** \brief Get MPIDR EL1
\return Multiprocessor Affinity Register value
*/
__STATIC_FORCEINLINE uint64_t __get_MPIDR_EL1(void)
{
uint64_t result;
__ASM volatile("MRS %0, MPIDR_EL1" : "=r" (result) : : "memory");
return result;
}

/** \brief Get MAIR EL3
\return MAIR value
*/
__STATIC_FORCEINLINE uint64_t __get_MAIR_EL3(void)
{
uint64_t result;
__ASM volatile("MRS %0, mair_el3" : "=r" (result) : : "memory");
return result;
}

/** \brief Set MAIR EL3
\param [in] mair MAIR value to set
*/
__STATIC_FORCEINLINE void __set_MAIR_EL3(uint64_t mair)
{
__ASM volatile("MSR mair_el3, %0" : : "r" (mair) : "memory");
}

/** \brief Get TCR EL3
\return TCR value
*/
__STATIC_FORCEINLINE uint64_t __get_TCR_EL3(void)
{
uint64_t result;
__ASM volatile("MRS %0, tcr_el3" : "=r" (result) : : "memory");
return result;
}

/** \brief Set TCR EL3
\param [in] tcr TCR value to set
*/
__STATIC_FORCEINLINE void __set_TCR_EL3(uint64_t tcr)
{
__ASM volatile("MSR tcr_el3, %0" : : "r" (tcr) : "memory");
}

/** \brief Get TTBR0 EL3
\return Translation Table Base Register 0 value
*/
__STATIC_FORCEINLINE uint64_t __get_TTBR0_EL3(void)
{
uint64_t result;
__ASM volatile("MRS %0, ttbr0_el3" : "=r" (result) : : "memory");
return result;
}

/** \brief Set TTBR0 EL3
\param [in] ttbr0 Translation Table Base Register 0 value to set
*/
__STATIC_FORCEINLINE void __set_TTBR0_EL3(uint64_t ttbr0)
{
__ASM volatile("MSR ttbr0_el3, %0" : : "r" (ttbr0) : "memory");
}

/** \brief Get SCTLR EL3
\return STRLR EL3 value
*/
__STATIC_FORCEINLINE uint64_t __get_SCTLR_EL3(void)
{
uint64_t result;
__ASM volatile("MRS %0, sctlr_el3" : "=r" (result) : : "memory");
return result;
}

/** \brief Set SCTLR EL3
\param [in] vbar SCTLR value to set
*/
__STATIC_FORCEINLINE void __set_SCTLR_EL3(uint64_t sctlr)
{
__ASM volatile("MSR sctlr_el3, %0" : : "r" (sctlr) : "memory");
}

/** \brief Set VBAR EL3
\param [in] vbar VBAR value to set
*/
__STATIC_FORCEINLINE void __set_VBAR_EL3(uint64_t vbar)
{
__ASM volatile("MSR vbar_el3, %0" : : "r" (vbar) : "memory");
}

/** \brief Set VBAR EL2
\param [in] vbar VBAR value to set
*/
__STATIC_FORCEINLINE void __set_VBAR_EL2(uint64_t vbar)
{
__ASM volatile("MSR vbar_el2, %0" : : "r" (vbar) : "memory");
}

/** \brief Set VBAR EL1
\param [in] vbar VBAR value to set
*/
__STATIC_FORCEINLINE void __set_VBAR_EL1(uint64_t vbar)
{
__ASM volatile("MSR vbar_el1, %0" : : "r" (vbar) : "memory");
}


#endif /* __CMSIS_SYSTEM_CONTROL_H */
72 changes: 0 additions & 72 deletions CMSIS/Core/Include/a-profile/cmsis_armclang_a.h
Original file line number Diff line number Diff line change
Expand Up @@ -317,76 +317,4 @@ __STATIC_FORCEINLINE void __set_FPEXC(uint32_t fpexc)
#define __get_CP64(cp, op1, Rt, CRm) __ASM volatile("MRRC p" # cp ", " # op1 ", %Q0, %R0, c" # CRm : "=r" (Rt) : : "memory" )
#define __set_CP64(cp, op1, Rt, CRm) __ASM volatile("MCRR p" # cp ", " # op1 ", %Q0, %R0, c" # CRm : : "r" (Rt) : "memory" )

#include "cmsis_cp15.h"

/** \brief Enable Floating Point Unit
Critical section, called from undef handler, so systick is disabled
*/
__STATIC_INLINE void __FPU_Enable(void)
{
__ASM volatile(
// Permit access to VFP/NEON, registers by modifying CPACR
" MRC p15,0,R1,c1,c0,2 \n"
" ORR R1,R1,#0x00F00000 \n"
" MCR p15,0,R1,c1,c0,2 \n"

// Ensure that subsequent instructions occur in the context of VFP/NEON access permitted
" ISB \n"

// Enable VFP/NEON
" VMRS R1,FPEXC \n"
" ORR R1,R1,#0x40000000 \n"
" VMSR FPEXC,R1 \n"

// Initialise VFP/NEON registers to 0
" MOV R2,#0 \n"

// Initialise D16 registers to 0
" VMOV D0, R2,R2 \n"
" VMOV D1, R2,R2 \n"
" VMOV D2, R2,R2 \n"
" VMOV D3, R2,R2 \n"
" VMOV D4, R2,R2 \n"
" VMOV D5, R2,R2 \n"
" VMOV D6, R2,R2 \n"
" VMOV D7, R2,R2 \n"
" VMOV D8, R2,R2 \n"
" VMOV D9, R2,R2 \n"
" VMOV D10,R2,R2 \n"
" VMOV D11,R2,R2 \n"
" VMOV D12,R2,R2 \n"
" VMOV D13,R2,R2 \n"
" VMOV D14,R2,R2 \n"
" VMOV D15,R2,R2 \n"

#if (defined(__ARM_NEON) && (__ARM_NEON == 1))
// Initialise D32 registers to 0
" VMOV D16,R2,R2 \n"
" VMOV D17,R2,R2 \n"
" VMOV D18,R2,R2 \n"
" VMOV D19,R2,R2 \n"
" VMOV D20,R2,R2 \n"
" VMOV D21,R2,R2 \n"
" VMOV D22,R2,R2 \n"
" VMOV D23,R2,R2 \n"
" VMOV D24,R2,R2 \n"
" VMOV D25,R2,R2 \n"
" VMOV D26,R2,R2 \n"
" VMOV D27,R2,R2 \n"
" VMOV D28,R2,R2 \n"
" VMOV D29,R2,R2 \n"
" VMOV D30,R2,R2 \n"
" VMOV D31,R2,R2 \n"
#endif

// Initialise FPSCR to a known state
" VMRS R1,FPSCR \n"
" LDR R2,=0x00086060 \n" //Mask off all bits that do not have to be preserved. Non-preserved bits can/should be zero.
" AND R1,R1,R2 \n"
" VMSR FPSCR,R1 "
: : : "cc", "r1", "r2"
);
}

#endif /* __CMSIS_ARMCLANG_A_H */
67 changes: 1 addition & 66 deletions CMSIS/Core/Include/a-profile/cmsis_clang_a.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#ifndef __CMSIS_CLANG_H
#error "This file must not be included directly"
#endif

/**
\brief STRT Unprivileged (8 bit)
\details Executes a Unprivileged STRT instruction for 8 bit values.
Expand Down Expand Up @@ -313,72 +314,6 @@ __STATIC_FORCEINLINE void __set_FPEXC(uint32_t fpexc)
#define __get_CP64(cp, op1, Rt, CRm) __ASM volatile("MRRC p" # cp ", " # op1 ", %Q0, %R0, c" # CRm : "=r" (Rt) : : "memory" )
#define __set_CP64(cp, op1, Rt, CRm) __ASM volatile("MCRR p" # cp ", " # op1 ", %Q0, %R0, c" # CRm : : "r" (Rt) : "memory" )

#include "cmsis_cp15.h"

/** \brief Enable Floating Point Unit
Critical section, called from undef handler, so systick is disabled
*/
__STATIC_INLINE void __FPU_Enable(void)
{
// Permit access to VFP/NEON, registers by modifying CPACR
const uint32_t cpacr = __get_CPACR();
__set_CPACR(cpacr | 0x00F00000ul);
__ISB();

// Enable VFP/NEON
const uint32_t fpexc = __get_FPEXC();
__set_FPEXC(fpexc | 0x40000000ul);

__ASM volatile(
// Initialise VFP/NEON registers to 0
" MOV R2,#0 \n"

// Initialise D16 registers to 0
" VMOV D0, R2,R2 \n"
" VMOV D1, R2,R2 \n"
" VMOV D2, R2,R2 \n"
" VMOV D3, R2,R2 \n"
" VMOV D4, R2,R2 \n"
" VMOV D5, R2,R2 \n"
" VMOV D6, R2,R2 \n"
" VMOV D7, R2,R2 \n"
" VMOV D8, R2,R2 \n"
" VMOV D9, R2,R2 \n"
" VMOV D10,R2,R2 \n"
" VMOV D11,R2,R2 \n"
" VMOV D12,R2,R2 \n"
" VMOV D13,R2,R2 \n"
" VMOV D14,R2,R2 \n"
" VMOV D15,R2,R2 \n"

#if (defined(__ARM_NEON) && (__ARM_NEON == 1))
// Initialise D32 registers to 0
" VMOV D16,R2,R2 \n"
" VMOV D17,R2,R2 \n"
" VMOV D18,R2,R2 \n"
" VMOV D19,R2,R2 \n"
" VMOV D20,R2,R2 \n"
" VMOV D21,R2,R2 \n"
" VMOV D22,R2,R2 \n"
" VMOV D23,R2,R2 \n"
" VMOV D24,R2,R2 \n"
" VMOV D25,R2,R2 \n"
" VMOV D26,R2,R2 \n"
" VMOV D27,R2,R2 \n"
" VMOV D28,R2,R2 \n"
" VMOV D29,R2,R2 \n"
" VMOV D30,R2,R2 \n"
" VMOV D31,R2,R2 \n"
#endif
: : : "cc", "r2"
);

// Initialise FPSCR to a known state
const uint32_t fpscr = __get_FPSCR();
__set_FPSCR(fpscr & 0x00086060ul);
}

/*@} end of group CMSIS_Core_intrinsics */

#pragma clang diagnostic pop
Expand Down
66 changes: 0 additions & 66 deletions CMSIS/Core/Include/a-profile/cmsis_gcc_a.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,72 +150,6 @@ __STATIC_FORCEINLINE void __set_FPEXC(uint32_t fpexc)
#define __get_CP64(cp, op1, Rt, CRm) __ASM volatile("MRRC p" # cp ", " # op1 ", %Q0, %R0, c" # CRm : "=r" (Rt) : : "memory" )
#define __set_CP64(cp, op1, Rt, CRm) __ASM volatile("MCRR p" # cp ", " # op1 ", %Q0, %R0, c" # CRm : : "r" (Rt) : "memory" )

#include "cmsis_cp15.h"

/** \brief Enable Floating Point Unit
Critical section, called from undef handler, so systick is disabled
*/
__STATIC_INLINE void __FPU_Enable(void)
{
// Permit access to VFP/NEON, registers by modifying CPACR
const uint32_t cpacr = __get_CPACR();
__set_CPACR(cpacr | 0x00F00000ul);
__ISB();

// Enable VFP/NEON
const uint32_t fpexc = __get_FPEXC();
__set_FPEXC(fpexc | 0x40000000ul);

__ASM volatile(
// Initialise VFP/NEON registers to 0
" MOV R2,#0 \n"

// Initialise D16 registers to 0
" VMOV D0, R2,R2 \n"
" VMOV D1, R2,R2 \n"
" VMOV D2, R2,R2 \n"
" VMOV D3, R2,R2 \n"
" VMOV D4, R2,R2 \n"
" VMOV D5, R2,R2 \n"
" VMOV D6, R2,R2 \n"
" VMOV D7, R2,R2 \n"
" VMOV D8, R2,R2 \n"
" VMOV D9, R2,R2 \n"
" VMOV D10,R2,R2 \n"
" VMOV D11,R2,R2 \n"
" VMOV D12,R2,R2 \n"
" VMOV D13,R2,R2 \n"
" VMOV D14,R2,R2 \n"
" VMOV D15,R2,R2 \n"

#if (defined(__ARM_NEON) && (__ARM_NEON == 1))
// Initialise D32 registers to 0
" VMOV D16,R2,R2 \n"
" VMOV D17,R2,R2 \n"
" VMOV D18,R2,R2 \n"
" VMOV D19,R2,R2 \n"
" VMOV D20,R2,R2 \n"
" VMOV D21,R2,R2 \n"
" VMOV D22,R2,R2 \n"
" VMOV D23,R2,R2 \n"
" VMOV D24,R2,R2 \n"
" VMOV D25,R2,R2 \n"
" VMOV D26,R2,R2 \n"
" VMOV D27,R2,R2 \n"
" VMOV D28,R2,R2 \n"
" VMOV D29,R2,R2 \n"
" VMOV D30,R2,R2 \n"
" VMOV D31,R2,R2 \n"
#endif
: : : "cc", "r2"
);

// Initialise FPSCR to a known state
const uint32_t fpscr = __get_FPSCR();
__set_FPSCR(fpscr & 0x00086060ul);
}

/*@} end of group CMSIS_Core_intrinsics */

#pragma GCC diagnostic pop
Expand Down
Loading

0 comments on commit 7f7aae9

Please sign in to comment.