VirtualBox

Changeset 99978 in vbox for trunk/include/iprt


Ignore:
Timestamp:
May 25, 2023 11:45:24 AM (23 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
157638
Message:

iprt/asm-arm.h: Add method to read the CNTFRQ_EL0 register providing the frequency the timer runs with, bugref:10385

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/asm-arm.h

    r98103 r99978  
    137137#endif
    138138
     139
     140/**
     141 * Gets the content of the CNTFRQ_EL0 register.
     142 *
     143 * @returns CNTFRQ_EL0 value.
     144 */
     145#if RT_INLINE_ASM_EXTERNAL
     146DECLASM(uint64_t) ASMReadCntFrqEl0(void);
     147#else
     148DECLINLINE(uint64_t) ASMReadCntFrqEl0(void)
     149{
     150# if RT_INLINE_ASM_GNU_STYLE
     151    uint64_t u64;
     152#  ifdef RT_ARCH_ARM64
     153    __asm__ __volatile__("isb\n\t"
     154                         "mrs %0, CNTFRQ_EL0\n\t"
     155                         : "=r" (u64));
     156#  else
     157    u64 = 0;
     158    __asm__ __volatile__("isb\n"
     159                         "mrc p15, 0, %[uRet], c14, 0, 0\n\t"  /* CNTFRQ */
     160                         : [uRet] "=r" (u64));
     161#  endif
     162    return u64;
     163
     164# else
     165#  error "Unsupported compiler"
     166# endif
     167}
     168#endif
     169
     170
    139171#if 0 /* port to arm64, armv7 and check */
    140172
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette