Skip to content

Commit

Permalink
Add rdtsc implementation and get efiwarpper start tsc
Browse files Browse the repository at this point in the history
Test Done: boot success

Tracked-On: OAM-115655
Signed-off-by: Chen, Gang G <[email protected]>
  • Loading branch information
GangSecurity committed Feb 20, 2024
1 parent 708fcec commit 26c222a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
14 changes: 14 additions & 0 deletions include/libefiwrapper/rdtsc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#ifndef RDTSC_H
#define RDTSC_H

#include <stdint.h>

static uint64_t rdtsc(void)
{
uint32_t lo, hi;

asm volatile ("rdtsc" : "=a" (lo), "=d" (hi));
return (uint64_t) hi << 32 | lo;
}

#endif
10 changes: 10 additions & 0 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,23 @@
#include <ewdrv.h>
#include <ewlog.h>
#include <storage.h>
#include <rdtsc.h>

static uint64_t efiwarpper_start_tsc;
uint64_t efiwrapper_tsc()
{
return efiwarpper_start_tsc;
}

/* Entry point */
int main(int argc, char **argv)
{
EFI_HANDLE image = NULL;
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");
Expand Down

0 comments on commit 26c222a

Please sign in to comment.