mirror of
https://github.com/stefanberger/libtpms
synced 2026-08-11 21:50:09 +00:00
tpm2: Move CLOCK #defines into PlatformClock.h
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
This commit is contained in:
parent
2b8ce8d8c1
commit
bb84bfbf36
@ -411,6 +411,7 @@ noinst_HEADERS += \
|
||||
tpm2/PCR_SetAuthPolicy_fp.h \
|
||||
tpm2/PCR_SetAuthValue_fp.h \
|
||||
tpm2/Platform.h \
|
||||
tpm2/PlatformClock.h \
|
||||
tpm2/PlatformData.h \
|
||||
tpm2/Platform_fp.h \
|
||||
tpm2/PolicyAuthorize_fp.h \
|
||||
|
||||
@ -68,6 +68,7 @@
|
||||
#include "TPMB.h"
|
||||
#include "MinMax.h"
|
||||
#include "TpmProfile.h"
|
||||
#include "PlatformClock.h"
|
||||
#include "PlatformData.h"
|
||||
#include "Platform_fp.h"
|
||||
#endif // _PLATFORM_H_
|
||||
|
||||
89
src/tpm2/PlatformClock.h
Normal file
89
src/tpm2/PlatformClock.h
Normal file
@ -0,0 +1,89 @@
|
||||
/********************************************************************************/
|
||||
/* */
|
||||
/* Platform Clock . */
|
||||
/* Written by Ken Goldman */
|
||||
/* IBM Thomas J. Watson Research Center */
|
||||
/* $Id$ */
|
||||
/* */
|
||||
/* Licenses and Notices */
|
||||
/* */
|
||||
/* 1. Copyright Licenses: */
|
||||
/* */
|
||||
/* - Trusted Computing Group (TCG) grants to the user of the source code in */
|
||||
/* this specification (the "Source Code") a worldwide, irrevocable, */
|
||||
/* nonexclusive, royalty free, copyright license to reproduce, create */
|
||||
/* derivative works, distribute, display and perform the Source Code and */
|
||||
/* derivative works thereof, and to grant others the rights granted herein. */
|
||||
/* */
|
||||
/* - The TCG grants to the user of the other parts of the specification */
|
||||
/* (other than the Source Code) the rights to reproduce, distribute, */
|
||||
/* display, and perform the specification solely for the purpose of */
|
||||
/* developing products based on such documents. */
|
||||
/* */
|
||||
/* 2. Source Code Distribution Conditions: */
|
||||
/* */
|
||||
/* - Redistributions of Source Code must retain the above copyright licenses, */
|
||||
/* this list of conditions and the following disclaimers. */
|
||||
/* */
|
||||
/* - Redistributions in binary form must reproduce the above copyright */
|
||||
/* licenses, this list of conditions and the following disclaimers in the */
|
||||
/* documentation and/or other materials provided with the distribution. */
|
||||
/* */
|
||||
/* 3. Disclaimers: */
|
||||
/* */
|
||||
/* - THE COPYRIGHT LICENSES SET FORTH ABOVE DO NOT REPRESENT ANY FORM OF */
|
||||
/* LICENSE OR WAIVER, EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, WITH */
|
||||
/* RESPECT TO PATENT RIGHTS HELD BY TCG MEMBERS (OR OTHER THIRD PARTIES) */
|
||||
/* THAT MAY BE NECESSARY TO IMPLEMENT THIS SPECIFICATION OR OTHERWISE. */
|
||||
/* Contact TCG Administration (admin@trustedcomputinggroup.org) for */
|
||||
/* information on specification licensing rights available through TCG */
|
||||
/* membership agreements. */
|
||||
/* */
|
||||
/* - THIS SPECIFICATION IS PROVIDED "AS IS" WITH NO EXPRESS OR IMPLIED */
|
||||
/* WARRANTIES WHATSOEVER, INCLUDING ANY WARRANTY OF MERCHANTABILITY OR */
|
||||
/* FITNESS FOR A PARTICULAR PURPOSE, ACCURACY, COMPLETENESS, OR */
|
||||
/* NONINFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS, OR ANY WARRANTY */
|
||||
/* OTHERWISE ARISING OUT OF ANY PROPOSAL, SPECIFICATION OR SAMPLE. */
|
||||
/* */
|
||||
/* - Without limitation, TCG and its members and licensors disclaim all */
|
||||
/* liability, including liability for infringement of any proprietary */
|
||||
/* rights, relating to use of information in this specification and to the */
|
||||
/* implementation of this specification, and TCG disclaims all liability for */
|
||||
/* cost of procurement of substitute goods or services, lost profits, loss */
|
||||
/* of use, loss of data or any incidental, consequential, direct, indirect, */
|
||||
/* or special damages, whether under contract, tort, warranty or otherwise, */
|
||||
/* arising in any way out of use or reliance upon this specification or any */
|
||||
/* information herein. */
|
||||
/* */
|
||||
/* (c) Copyright IBM Corp. and others, 2019 */
|
||||
/* */
|
||||
/********************************************************************************/
|
||||
|
||||
// C.16 PlatformClock.h This file contains the instance data for the Platform module. It is
|
||||
// collected in this file so that the state of the module is easier to manage.
|
||||
#ifndef _PLATFORM_CLOCK_H_
|
||||
#define _PLATFORM_CLOCK_H_
|
||||
#ifdef _MSC_VER
|
||||
#include <sys/types.h>
|
||||
#include <sys/timeb.h>
|
||||
#else
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
#endif
|
||||
// CLOCK_NOMINAL is the number of hardware ticks per mS. A value of 300000 means that the nominal
|
||||
// clock rate used to drive the hardware clock is 30 MHz. The adjustment rates are used to determine
|
||||
// the conversion of the hardware ticks to internal hardware clock value. In practice, we would
|
||||
// expect that there woudl be a hardware register will accumulated mS. It would be incremented by
|
||||
// the output of a pre-scaler. The pre-scaler would divide the ticks from the clock by some value
|
||||
// that would compensate for the difference between clock time and real time. The code in Clock does
|
||||
// the emulation of this function.
|
||||
#define CLOCK_NOMINAL 30000
|
||||
// A 1% change in rate is 300 counts
|
||||
#define CLOCK_ADJUST_COARSE 300
|
||||
// A 0.1% change in rate is 30 counts
|
||||
#define CLOCK_ADJUST_MEDIUM 30
|
||||
// A minimum change in rate is 1 count
|
||||
#define CLOCK_ADJUST_FINE 1
|
||||
// The clock tolerance is +/-15% (4500 counts) Allow some guard band (16.7%)
|
||||
#define CLOCK_ADJUST_LIMIT 5000
|
||||
#endif // _PLATFORM_CLOCK_H_
|
||||
@ -96,22 +96,6 @@ EXTERN uint64_t s_suspendedElapsedTime;
|
||||
EXTERN BOOL s_timerReset;
|
||||
/* This value indicates that the timer was stopped. It causes a clock discontinuity. */
|
||||
EXTERN BOOL s_timerStopped;
|
||||
/* CLOCK_NOMINAL is the number of hardware ticks per mS. A value of 300000 means that the nominal
|
||||
clock rate used to drive the hardware clock is 30 MHz. The adjustment rates are used to
|
||||
determine the conversion of the hardware ticks to internal hardware clock value. In practice, we
|
||||
would expect that there would be a hardware register will accumulated mS. It would be incremented
|
||||
by the output of a pre-scaler. The pre-scaler would divide the ticks from the clock by some value
|
||||
that would compensate for the difference between clock time and real time. The code in Clock does
|
||||
the emulation of this function.*/
|
||||
#define CLOCK_NOMINAL 30000
|
||||
/* A 1% change in rate is 300 counts */
|
||||
#define CLOCK_ADJUST_COARSE 300
|
||||
/* A 0.1% change in rate is 30 counts */
|
||||
#define CLOCK_ADJUST_MEDIUM 30
|
||||
/* A minimum change in rate is 1 count */
|
||||
#define CLOCK_ADJUST_FINE 1
|
||||
/* The clock tolerance is +/-15% (4500 counts) Allow some guard band (16.7%) */
|
||||
#define CLOCK_ADJUST_LIMIT 5000
|
||||
/* This variable records the time when _plat__TimerReset() is called. This mechanism allow us to
|
||||
subtract the time when TPM is power off from the total time reported by clock() function */
|
||||
EXTERN uint64_t s_initClock;
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
/* Functions relating to the TPM's time functions */
|
||||
/* Written by Ken Goldman */
|
||||
/* IBM Thomas J. Watson Research Center */
|
||||
/* $Id: Time.c 1490 2019-07-26 21:13:22Z kgoldman $ */
|
||||
/* $Id: Time.c 1519 2019-11-15 20:43:51Z kgoldman $ */
|
||||
/* */
|
||||
/* Licenses and Notices */
|
||||
/* */
|
||||
@ -64,7 +64,7 @@
|
||||
the implementation-specific time functions. */
|
||||
/* 8.10.2 Includes */
|
||||
#include "Tpm.h"
|
||||
#include "PlatformData.h"
|
||||
#include "PlatformClock.h"
|
||||
/* 8.10.3 Functions */
|
||||
/* 8.10.3.1 TimePowerOn() */
|
||||
/* This function initialize time info at _TPM_Init(). */
|
||||
|
||||
Loading…
Reference in New Issue
Block a user