Home | History | Annotate | Download | only in tpm2
      1 // This file was extracted from the TCG Published
      2 // Trusted Platform Module Library
      3 // Part 3: Commands
      4 // Family "2.0"
      5 // Level 00 Revision 01.16
      6 // October 30, 2014
      7 
      8 #include "InternalRoutines.h"
      9 #include "ReadClock_fp.h"
     10 TPM_RC
     11 TPM2_ReadClock(
     12    ReadClock_Out    *out            // OUT: output parameter list
     13    )
     14 {
     15 // Command Output
     16    out->currentTime.time = g_time;
     17    TimeFillInfo(&out->currentTime.clockInfo);
     18 
     19 #ifndef EMBEDDED_MODE
     20    {
     21        UINT64 start_time = _plat__ClockTimeFromStart();
     22        // When running on a simulator, some tests fail, because two commands
     23        // invoked back to back happen to run within the same millisecond, but
     24        // the test expects time readings to be different. Modifying the tests
     25        // is more involved, let's just wait a couple of milliseconds here to
     26        // avoid those tests' false negatives.
     27        while ((_plat__ClockTimeFromStart() - start_time) < 2)
     28            ;
     29    }
     30 #endif
     31    return TPM_RC_SUCCESS;
     32 }
     33