Skip to content

Commit 17287cd

Browse files
committed
wolfEntropy: Add ARM Generic Timer virtual counter as time src
1 parent 1c77414 commit 17287cd

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

wolfcrypt/src/wolfentropy.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,20 @@ static WC_INLINE word64 Entropy_TimeHiRes(void)
155155
QueryPerformanceCounter(&count);
156156
return (word64)(count.QuadPart);
157157
}
158+
#elif !defined(ENTROPY_MEMUSE_THREAD) && defined(__arm__)
159+
/* Get time counter from arch_sys_counter clocksource.
160+
*
161+
* @return 64-bit timer count.
162+
*/
163+
static WC_INLINE word64 Entropy_TimeHiRes(void)
164+
{
165+
word32 lo, hi;
166+
__asm__ __volatile__ (
167+
"mrrc p15, 1, %[lo], %[hi], c14"
168+
: [lo] "=r"(lo), [hi] "=r"(hi)
169+
);
170+
return ((word64)hi << 32) | lo;
171+
}
158172
#elif defined(WOLFSSL_THREAD_NO_JOIN)
159173

160174
/* Start and stop thread that counts as a proxy for time counter. */

0 commit comments

Comments
 (0)