From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0b-002e3701.pphosted.com (mx0b-002e3701.pphosted.com [148.163.143.35]) by mx.groups.io with SMTP id smtpd.web12.6233.1576639987162501702 for ; Tue, 17 Dec 2019 19:33:07 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: hpe.com, ip: 148.163.143.35, mailfrom: prvs=0255388ba3=derek.lin2@hpe.com) Received: from pps.filterd (m0150245.ppops.net [127.0.0.1]) by mx0b-002e3701.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id xBI3Dg5D017132; Wed, 18 Dec 2019 03:33:05 GMT Received: from g2t2352.austin.hpe.com (g2t2352.austin.hpe.com [15.233.44.25]) by mx0b-002e3701.pphosted.com with ESMTP id 2wy21jc4qs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 18 Dec 2019 03:33:05 +0000 Received: from g2t2360.austin.hpecorp.net (g2t2360.austin.hpecorp.net [16.196.225.135]) by g2t2352.austin.hpe.com (Postfix) with ESMTP id 66184133; Wed, 18 Dec 2019 03:33:04 +0000 (UTC) Received: from SZC0PA4FXD.asiapacific.hpqcorp.net (szc0pa4fxd.asiapacific.hpqcorp.net [10.43.42.135]) by g2t2360.austin.hpecorp.net (Postfix) with ESMTP id 2BF193A; Wed, 18 Dec 2019 03:33:01 +0000 (UTC) From: "Lin, Derek (HPS SW)" To: derek.lin2@hpe.com, devel@edk2.groups.io Cc: kitty.chen@hpe.com, jordan.l.justen@intel.com, afish@apple.com, ray.ni@intel.com Subject: [PATCH] EmulatorPkg: Implement QueryPerformanceCounter() Date: Wed, 18 Dec 2019 11:32:41 +0800 Message-Id: <20191218033241.372320-1-derek.lin2@hpe.com> X-Mailer: git-send-email 2.20.1.windows.1 MIME-Version: 1.0 X-HPE-SCL: -1 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,18.0.572 definitions=2019-12-17_05:2019-12-17,2019-12-17 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 adultscore=0 clxscore=1011 malwarescore=0 bulkscore=0 lowpriorityscore=0 spamscore=0 mlxscore=0 mlxlogscore=699 impostorscore=0 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1910280000 definitions=main-1912180023 Content-Transfer-Encoding: 8bit Implement QueryPerformanceCounter() for Emulator on both Unix and Windows. Signed-off-by: Derek Lin Signed-off-by: Kitty Chen --- EmulatorPkg/Unix/Host/EmuThunk.c | 6 ++++-- EmulatorPkg/Win/Host/WinThunk.c | 7 ++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/EmulatorPkg/Unix/Host/EmuThunk.c b/EmulatorPkg/Unix/Host/EmuThunk.c index 1e9dc99187..4fd7b3d093 100644 --- a/EmulatorPkg/Unix/Host/EmuThunk.c +++ b/EmulatorPkg/Unix/Host/EmuThunk.c @@ -274,8 +274,10 @@ QueryPerformanceCounter ( return (Start * sTimebaseInfo.numer) / sTimebaseInfo.denom; #else - // Need to figure out what to do for Linux? - return 0; + int status; + struct timespec time; + status = clock_gettime(CLOCK_REALTIME, &time); + return time.tv_nsec; #endif } diff --git a/EmulatorPkg/Win/Host/WinThunk.c b/EmulatorPkg/Win/Host/WinThunk.c index a77be2a64b..a1f8870e27 100644 --- a/EmulatorPkg/Win/Host/WinThunk.c +++ b/EmulatorPkg/Win/Host/WinThunk.c @@ -447,7 +447,12 @@ SecQueryPerformanceCounter ( VOID ) { - return 0; + UINT64 PerformanceCount; + + PerformanceCount = 0; + QueryPerformanceCounter ((LARGE_INTEGER *) &PerformanceCount); + + return PerformanceCount; } -- 2.20.1.windows.1