1 /* Microsoft Reference Implementation for TPM 2.0 2 * 3 * The copyright in this software is being made available under the BSD License, 4 * included below. This software may be subject to other third party and 5 * contributor rights, including patent rights, and no such rights are granted 6 * under this license. 7 * 8 * Copyright (c) Microsoft Corporation 9 * 10 * All rights reserved. 11 * 12 * BSD License 13 * 14 * Redistribution and use in source and binary forms, with or without modification, 15 * are permitted provided that the following conditions are met: 16 * 17 * Redistributions of source code must retain the above copyright notice, this list 18 * of conditions and the following disclaimer. 19 * 20 * Redistributions in binary form must reproduce the above copyright notice, this 21 * list of conditions and the following disclaimer in the documentation and/or 22 * other materials provided with the distribution. 23 * 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ""AS IS"" 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 28 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 30 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 31 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 33 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 */ 35 // This file contains the instance data for the Platform module. It is collected 36 // in this file so that the state of the module is easier to manage. 37 38 #ifndef _PLATFORM_CLOCK_H_ 39 #define _PLATFORM_CLOCK_H_ 40 41 #ifdef _MSC_VER 42 #include <sys/types.h> 43 #include <sys/timeb.h> 44 #else 45 #include <sys/time.h> 46 #include <time.h> 47 #endif 48 49 // CLOCK_NOMINAL is the number of hardware ticks per mS. A value of 300000 means 50 // that the nominal clock rate used to drive the hardware clock is 30 MHz. The 51 // adjustment rates are used to determine the conversion of the hardware ticks to 52 // internal hardware clock value. In practice, we would expect that there would be 53 // a hardware register will accumulated mS. It would be incremented by the output 54 // of a pre-scaler. The pre-scaler would divide the ticks from the clock by some 55 // value that would compensate for the difference between clock time and real time. 56 // The code in Clock does the emulation of this function. 57 #define CLOCK_NOMINAL 30000 58 // A 1% change in rate is 300 counts 59 #define CLOCK_ADJUST_COARSE 300 60 // A 0.1% change in rate is 30 counts 61 #define CLOCK_ADJUST_MEDIUM 30 62 // A minimum change in rate is 1 count 63 #define CLOCK_ADJUST_FINE 1 64 // The clock tolerance is +/-15% (4500 counts) 65 // Allow some guard band (16.7%) 66 #define CLOCK_ADJUST_LIMIT 5000 67 68 #endif // _PLATFORM_CLOCK_H_ 69