Skip to content

Commit 03d57c8

Browse files
authored
Added Virtual Timer support
Updated cmsis_cp15.h and core_ca.h files for adding Virtual Timer support for Cortex A7.
1 parent f6e554e commit 03d57c8

2 files changed

Lines changed: 141 additions & 0 deletions

File tree

CMSIS/Core/Include/a-profile/cmsis_cp15.h

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,84 @@ __STATIC_FORCEINLINE uint32_t __get_CNTP_CTL(void)
360360
return result;
361361
}
362362

363+
/******************************* VIRTUAL TIMER *******************************/
364+
/** see [ARM DDI 0406C.d] :
365+
. §B4.1.31 "CNTV_CTL, Counter-timer Virtual Timer Control register"
366+
. §B4.1.32 "CNTV_CVAL, Counter-timer Virtual Timer CompareValue register"
367+
. §B4.1.33 "CNTV_TVAL, Counter-timer Virtual Timer TimerValue register"
368+
. §B4.1.34 "CNTVCT, Counter-timer Virtual Count register"
369+
**/
370+
/** \brief Set CNTV_TVAL
371+
This function assigns the given value to VL1 Virtual Timer Value Register (CNTV_TVAL).
372+
\param [in] value CNTV_TVAL Register value to set
373+
*/
374+
__STATIC_FORCEINLINE void __set_CNTV_TVAL(uint32_t value)
375+
{
376+
__set_CP(15, 0, value, 14, 3, 0);
377+
}
378+
379+
/** \brief Get CNTV_TVAL
380+
This function returns the value of the VL1 Virtual Timer Value Register (CNTV_TVAL).
381+
\return CNTV_TVAL Register value
382+
*/
383+
__STATIC_FORCEINLINE uint32_t __get_CNTV_TVAL(void)
384+
{
385+
uint32_t result;
386+
__get_CP(15, 0, result, 14, 3, 0);
387+
return result;
388+
}
389+
390+
/** \brief Get CNTVCT
391+
This function returns the value of the 64 bits VL1 Virtual Count Register (CNTVCT).
392+
\return CNTVCT Register value
393+
*/
394+
__STATIC_FORCEINLINE uint64_t __get_CNTVCT(void)
395+
{
396+
uint64_t result;
397+
__get_CP64(15, 1, result, 14);
398+
return result;
399+
}
400+
401+
/** \brief Set CNTV_CVAL
402+
This function assigns the given value to 64bits VL1 Virtual Timer CompareValue Register (CNTV_CVAL).
403+
\param [in] value CNTV_CVAL Register value to set
404+
*/
405+
__STATIC_FORCEINLINE void __set_CNTV_CVAL(uint64_t value)
406+
{
407+
__set_CP64(15, 3, value, 14);
408+
}
409+
410+
/** \brief Get CNTV_CVAL
411+
This function returns the value of the 64 bits VL1 Virtual Timer CompareValue Register (CNTV_CVAL).
412+
\return CNTV_CVAL Register value
413+
*/
414+
__STATIC_FORCEINLINE uint64_t __get_CNTV_CVAL(void)
415+
{
416+
uint64_t result;
417+
__get_CP64(15, 3, result, 14);
418+
return result;
419+
}
420+
421+
/** \brief Set CNTV_CTL
422+
This function assigns the given value to VL1 Virtual Timer Control Register (CNTV_CTL).
423+
\param [in] value CNTV_CTL Register value to set
424+
*/
425+
__STATIC_FORCEINLINE void __set_CNTV_CTL(uint32_t value)
426+
{
427+
__set_CP(15, 0, value, 14, 3, 1);
428+
}
429+
430+
/** \brief Get CNTV_CTL register
431+
\return CNTV_CTL Register value
432+
*/
433+
__STATIC_FORCEINLINE uint32_t __get_CNTV_CTL(void)
434+
{
435+
uint32_t result;
436+
__get_CP(15, 0, result, 14, 3, 1);
437+
return result;
438+
}
439+
440+
/***************************** VIRTUAL TIMER END *****************************/
363441
#endif
364442

365443
/** \brief Set TLBIALL

CMSIS/Core/Include/core_ca.h

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1936,6 +1936,69 @@ __STATIC_INLINE uint32_t PL1_GetControl(void)
19361936
{
19371937
return(__get_CNTP_CTL());
19381938
}
1939+
1940+
/******************************* VIRTUAL TIMER *******************************/
1941+
/** \brief Virtual Timer Control register */
1942+
1943+
/** \brief Sets the reset value of the virtual timer.
1944+
* \param [in] value The value the virtual timer is loaded with.
1945+
*/
1946+
__STATIC_INLINE void VL1_SetCurrentTimerValue(uint32_t value)
1947+
{
1948+
__set_CNTV_TVAL(value);
1949+
__ISB();
1950+
}
1951+
1952+
/** \brief Get the current virtual timer value.
1953+
* \return Current virtual timer value.
1954+
*/
1955+
__STATIC_INLINE uint32_t VL1_GetCurrentTimerValue(void)
1956+
{
1957+
return(__get_CNTV_TVAL());
1958+
}
1959+
1960+
/** \brief Get the current virtual count value.
1961+
* \return Current virtual count value.
1962+
*/
1963+
__STATIC_INLINE uint64_t VL1_GetCurrentCountValue(void)
1964+
{
1965+
return(__get_CNTVCT());
1966+
}
1967+
1968+
/** \brief Set the virtual timer compare value.
1969+
* \param [in] value New virtual timer compare value.
1970+
*/
1971+
__STATIC_INLINE void VL1_SetTimerCompareValue(uint64_t value)
1972+
{
1973+
__set_CNTV_CVAL(value);
1974+
__ISB();
1975+
}
1976+
1977+
/** \brief Get the virtual timer compare value.
1978+
* \return Virtual timer compare value.
1979+
*/
1980+
__STATIC_INLINE uint64_t VL1_GetTimerCompareValue(void)
1981+
{
1982+
return(__get_CNTV_CVAL());
1983+
}
1984+
1985+
/** \brief Configure the virtual timer by setting the control value.
1986+
* \param [in] value New virtual timer control value.
1987+
*/
1988+
__STATIC_INLINE void VL1_SetControl(uint32_t value)
1989+
{
1990+
__set_CNTV_CTL(value);
1991+
__ISB();
1992+
}
1993+
1994+
/** \brief Get the virtual timer control value.
1995+
* \return Virtual timer control value.
1996+
*/
1997+
__STATIC_INLINE uint32_t VL1_GetControl(void)
1998+
{
1999+
return(__get_CNTV_CTL());
2000+
}
2001+
/***************************** VIRTUAL TIMER END *****************************/
19392002
#endif
19402003

19412004
/* Private Timer */

0 commit comments

Comments
 (0)