1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 20:28:11 +00:00

Kernel: Add helpers for rdrand and rdseed

This commit is contained in:
Idan Horowitz 2022-03-21 22:59:07 +02:00 committed by Andreas Kling
parent 8ab25f8d8c
commit a9764dabee

View file

@ -160,6 +160,28 @@ ALWAYS_INLINE u64 read_tsc()
return ((u64)msw << 32) | lsw;
}
ALWAYS_INLINE u32 rdrand()
{
u32 value;
asm volatile(
"1:\n"
"rdrand %0\n"
"jnc 1b\n"
: "=r"(value)::"cc");
return value;
}
ALWAYS_INLINE u32 rdseed()
{
u32 value;
asm volatile(
"1:\n"
"rdseed %0\n"
"jnc 1b\n"
: "=r"(value)::"cc");
return value;
}
void stac();
void clac();