diff --git a/include/libefiwrapper/rdtsc.h b/include/libefiwrapper/rdtsc.h new file mode 100644 index 0000000..8451c3e --- /dev/null +++ b/include/libefiwrapper/rdtsc.h @@ -0,0 +1,14 @@ +#ifndef RDTSC_H +#define RDTSC_H + +#include + +static uint64_t rdtsc(void) +{ + uint32_t lo, hi; + + asm volatile ("rdtsc" : "=a" (lo), "=d" (hi)); + return (uint64_t) hi << 32 | lo; +} + +#endif diff --git a/main.c b/main.c index 7fbedad..b3b1fc1 100644 --- a/main.c +++ b/main.c @@ -37,6 +37,14 @@ #include #include #include +#include + +static uint64_t efiwarpper_start_tsc; +uint64_t efiwrapper_tsc() +{ + return efiwarpper_start_tsc; +} + /* Entry point */ int main(int argc, char **argv) { @@ -44,6 +52,8 @@ int main(int argc, char **argv) EFI_SYSTEM_TABLE *st; EFI_STATUS ret; + efiwarpper_start_tsc = rdtsc(); + ret = efiwrapper_init(argc, argv, &st, &image); if (ret) { ewerr("efiwrapper library initialization failed");