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 Jan 27, 2024
1 parent 03d57c8 commit dd2c27b
Show file tree
Hide file tree
Showing 27 changed files with 3,035 additions and 950 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
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
647 changes: 647 additions & 0 deletions CMSIS/Core/Include/a-profile/armv8a.h

Large diffs are not rendered by default.

143 changes: 143 additions & 0 deletions CMSIS/Core/Include/a-profile/armv8a_cp15.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
/**************************************************************************//**
* @file armv8a_cp15.h
* @brief CMSIS compiler specific macros, functions, instructions
* @version V6.0.0
* @date 4. August 2023
******************************************************************************/
/*
* Copyright (c) 2009-2023 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 @@ -700,76 +700,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 */
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 @@ -863,72 +863,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
71 changes: 0 additions & 71 deletions CMSIS/Core/Include/a-profile/cmsis_iccarm_a.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,6 @@
#define __set_CP64(cp, op1, Rt, CRm) \
__ASM volatile("MCRR p" # cp ", " # op1 ", %Q0, %R0, c" # CRm : : "r" (Rt) : "memory" )

#include "cmsis_cp15.h"

#define __NOP __iar_builtin_no_operation

#define __CLZ __iar_builtin_CLZ
Expand Down Expand Up @@ -480,75 +478,6 @@ __IAR_FT void __set_SP_usr(uint32_t topOfProcStack)

#define __get_mode() (__get_CPSR() & 0x1FU)

__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"

#ifdef __ARM_ADVANCED_SIMD__
//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"
" MOV32 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 \n"
: : : "cc", "r1", "r2"
);
}



#undef __IAR_FT
#undef __ICCARM_V8

Expand Down
Loading

0 comments on commit dd2c27b

Please sign in to comment.