aboutsummaryrefslogtreecommitdiff
path: root/ReadClock.c
blob: 5ba470ccb1c7ce37957d1798a2d4d60da5a9c054 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// This file was extracted from the TCG Published
// Trusted Platform Module Library
// Part 3: Commands
// Family "2.0"
// Level 00 Revision 01.16
// October 30, 2014

#include "InternalRoutines.h"
#include "ReadClock_fp.h"
TPM_RC
TPM2_ReadClock(
   ReadClock_Out    *out            // OUT: output parameter list
   )
{
// Command Output
   out->currentTime.time = g_time;
   TimeFillInfo(&out->currentTime.clockInfo);

#ifndef EMBEDDED_MODE
   {
       UINT64 start_time = _plat__ClockTimeFromStart();
       // When running on a simulator, some tests fail, because two commands
       // invoked back to back happen to run within the same millisecond, but
       // the test expects time readings to be different. Modifying the tests
       // is more involved, let's just wait a couple of milliseconds here to
       // avoid those tests' false negatives.
       while ((_plat__ClockTimeFromStart() - start_time) < 2)
           ;
   }
#endif
   return TPM_RC_SUCCESS;
}