Subrata Banik has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/83414?usp=email )
Change subject: libpayload/x86: Add x86-64 support to rdtsc() ......................................................................
libpayload/x86: Add x86-64 support to rdtsc()
This patch adds support for x86-64 to the rdtsc() function, allowing it to correctly read the Time Stamp Counter (TSC) on both 32-bit and 64-bit x86 architectures.
BUG=b:242829490 TEST=Builds and boots on google/rex0 and google/rex64 systems and manually verified correct TSC readings on x86-32 and x86-64 hardware.
Change-Id: I0afac3db2e82a245a37c2e5cf2302bf1dad62c01 Signed-off-by: Subrata Banik subratabanik@google.com --- M payloads/libpayload/include/x86/arch/rdtsc.h 1 file changed, 9 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/14/83414/1
diff --git a/payloads/libpayload/include/x86/arch/rdtsc.h b/payloads/libpayload/include/x86/arch/rdtsc.h index 41ab24a..36be002 100644 --- a/payloads/libpayload/include/x86/arch/rdtsc.h +++ b/payloads/libpayload/include/x86/arch/rdtsc.h @@ -31,11 +31,20 @@
#include <stdint.h>
+#if CONFIG(LP_ARCH_X86_64) +static u64 rdtsc(void) +{ + unsigned int lo, hi; + __asm__ __volatile__ ("rdtsc" : "=a" (lo), "=d" (hi)); + return (u64)hi << 32 | lo; +} +#else static u64 rdtsc(void) { u64 val; __asm__ __volatile__ ("rdtsc" : "=A" (val)); return val; } +#endif
#endif