|
|
@ -47,6 +47,16 @@ static void TPAUSE() { |
|
|
const auto edx = static_cast<u32>(tsc >> 32); |
|
|
const auto edx = static_cast<u32>(tsc >> 32); |
|
|
asm volatile("tpause %0" : : "r"(RequestC02State), "d"(edx), "a"(eax)); |
|
|
asm volatile("tpause %0" : : "r"(RequestC02State), "d"(edx), "a"(eax)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void MWAITX() { |
|
|
|
|
|
static constexpr auto EnableWaitTimeFlag = 1U << 1; |
|
|
|
|
|
static constexpr auto RequestC1State = 0U; |
|
|
|
|
|
|
|
|
|
|
|
// monitor_var should be aligned to a cache line.
|
|
|
|
|
|
alignas(64) u64 monitor_var{}; |
|
|
|
|
|
asm volatile("monitorx" : : "a"(&monitor_var), "c"(0), "d"(0)); |
|
|
|
|
|
asm volatile("mwaitx" : : "a"(RequestC1State), "b"(PauseCycles), "c"(EnableWaitTimeFlag)); |
|
|
|
|
|
} |
|
|
#endif
|
|
|
#endif
|
|
|
|
|
|
|
|
|
void MicroSleep() { |
|
|
void MicroSleep() { |
|
|
|