Home | History | Annotate | Download | only in tpm2
      1 // This file was extracted from the TCG Published
      2 // Trusted Platform Module Library
      3 // Part 4: Supporting Routines
      4 // Family "2.0"
      5 // Level 00 Revision 01.16
      6 // October 30, 2014
      7 
      8 #define GLOBAL_C
      9 #include "InternalRoutines.h"
     10 //
     11 //
     12 //           Global Data Values
     13 //
     14 //      These values are visible across multiple modules.
     15 //
     16 BOOL                      g_phEnable;
     17 const UINT16              g_rcIndex[15] = {TPM_RC_1,       TPM_RC_2,    TPM_RC_3, TPM_RC_4,
     18                                           TPM_RC_5,       TPM_RC_6,    TPM_RC_7, TPM_RC_8,
     19                                           TPM_RC_9,       TPM_RC_A,    TPM_RC_B, TPM_RC_C,
     20                                           TPM_RC_D,       TPM_RC_E,    TPM_RC_F
     21                                        };
     22 TPM_HANDLE              g_exclusiveAuditSession;
     23 UINT64                  g_time;
     24 BOOL                    g_pcrReConfig;
     25 TPMI_DH_OBJECT          g_DRTMHandle;
     26 BOOL                    g_DrtmPreStartup;
     27 BOOL                    g_StartupLocality3;
     28 BOOL                    g_clearOrderly;
     29 TPM_SU                  g_prevOrderlyState;
     30 BOOL                    g_updateNV;
     31 BOOL                    g_nvOk;
     32 TPM2B_AUTH              g_platformUniqueDetails;
     33 STATE_CLEAR_DATA        gc;
     34 STATE_RESET_DATA        gr;
     35 PERSISTENT_DATA         gp;
     36 ORDERLY_DATA            go;
     37 //
     38 //
     39 //          Private Values
     40 //
     41 //          SessionProcess.c
     42 //
     43 #ifndef __IGNORE_STATE__           // DO NOT DEFINE THIS VALUE
     44 //
     45 //     These values do not need to be retained between commands.
     46 //
     47 TPM_HANDLE           s_sessionHandles[MAX_SESSION_NUM];
     48 TPMA_SESSION         s_attributes[MAX_SESSION_NUM];
     49 TPM_HANDLE           s_associatedHandles[MAX_SESSION_NUM];
     50 TPM2B_NONCE          s_nonceCaller[MAX_SESSION_NUM];
     51 TPM2B_AUTH           s_inputAuthValues[MAX_SESSION_NUM];
     52 UINT32               s_encryptSessionIndex;
     53 UINT32               s_decryptSessionIndex;
     54 UINT32               s_auditSessionIndex;
     55 TPM2B_DIGEST         s_cpHashForAudit;
     56 UINT32               s_sessionNum;
     57 #endif // __IGNORE_STATE__
     58 BOOL                 s_DAPendingOnNV;
     59 #ifdef TPM_CC_GetCommandAuditDigest
     60 TPM2B_DIGEST         s_cpHashForCommandAudit;
     61 #endif
     62 //
     63 //
     64 //          DA.c
     65 //
     66 UINT64                  s_selfHealTimer;
     67 UINT64                  s_lockoutTimer;
     68 //
     69 //
     70 //          NV.c
     71 //
     72 UINT32                  s_reservedAddr[NV_RESERVE_LAST];
     73 UINT32                  s_reservedSize[NV_RESERVE_LAST];
     74 UINT32                  s_ramIndexSize;
     75 BYTE                    s_ramIndex[RAM_INDEX_SPACE];
     76 UINT32                  s_ramIndexSizeAddr;
     77 UINT32                  s_ramIndexAddr;
     78 UINT32                  s_maxCountAddr;
     79 UINT32                  s_evictNvStart;
     80 UINT32                  s_evictNvEnd;
     81 TPM_RC                  s_NvStatus;
     82 //
     83 //
     84 //
     85 //          Object.c
     86 //
     87 OBJECT_SLOT               s_objects[MAX_LOADED_OBJECTS];
     88 //
     89 //
     90 //          PCR.c
     91 //
     92 PCR                       s_pcrs[IMPLEMENTATION_PCR];
     93 //
     94 //
     95 //          Session.c
     96 //
     97 SESSION_SLOT              s_sessions[MAX_LOADED_SESSIONS];
     98 UINT32                    s_oldestSavedSession;
     99 int                       s_freeSessionSlots;
    100 //
    101 //
    102 //          Manufacture.c
    103 //
    104 BOOL                      g_manufactured = FALSE;
    105 //
    106 //
    107 //          Power.c
    108 //
    109 BOOL                      s_initialized = FALSE;
    110 //
    111 //
    112 //          MemoryLib.c
    113 //
    114 //     The s_actionOutputBuffer should not be modifiable by the host system until the TPM has returned a
    115 //     response code. The s_actionOutputBuffer should not be accessible until response parameter encryption,
    116 //     if any, is complete. This memory is not used between commands
    117 //
    118 #ifndef __IGNORE_STATE__        // DO NOT DEFINE THIS VALUE
    119 #ifndef EMBEDDED_MODE
    120 UINT32   s_actionInputBuffer[1024];          // action input buffer
    121 UINT32   s_actionOutputBuffer[1024];         // action output buffer
    122 #endif  // EMBEDDED_MODE   ^^^ not defined
    123 BYTE     s_responseBuffer[MAX_RESPONSE_SIZE];// response buffer
    124 #endif  // __IGNORE_STATE__   ^^^ not defined
    125 //
    126 //
    127 //         SelfTest.c
    128 //
    129 //     Define these values here if the AlgorithmTests() project is not used
    130 //
    131 #ifndef SELF_TEST
    132 ALGORITHM_VECTOR          g_implementedAlgorithms;
    133 ALGORITHM_VECTOR          g_toTest;
    134 #endif
    135 //
    136 //
    137 //         TpmFail.c
    138 //
    139 #ifndef EMBEDDED_MODE
    140 jmp_buf                   g_jumpBuffer;
    141 #endif  // EMBEDDED_MODE   ^^^ not defined
    142 BOOL                      g_forceFailureMode;
    143 BOOL                      g_inFailureMode;
    144 UINT32                    s_failFunction;
    145 UINT32                    s_failLine;
    146 UINT32                    s_failCode;
    147