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 "PCR_Allocate_fp.h" 10 // 11 // 12 // Error Returns Meaning 13 // 14 // TPM_RC_PCR the allocation did not have required PCR 15 // TPM_RC_NV_UNAVAILABLE NV is not accessible 16 // TPM_RC_NV_RATE NV is in a rate-limiting mode 17 // 18 TPM_RC TPM2_PCR_Allocate(PCR_Allocate_In * in,PCR_Allocate_Out * out)19TPM2_PCR_Allocate( 20 PCR_Allocate_In *in, // IN: input parameter list 21 PCR_Allocate_Out *out // OUT: output parameter list 22 ) 23 { 24 TPM_RC result; 25 26 // The command needs NV update. Check if NV is available. 27 // A TPM_RC_NV_UNAVAILABLE or TPM_RC_NV_RATE error may be returned at 28 // this point. 29 // Note: These codes are not listed in the return values above because it is 30 // an implementation choice to check in this routine rather than in a common 31 // function that is called before these actions are called. These return values 32 // are described in the Response Code section of Part 3. 33 result = NvIsAvailable(); 34 if(result != TPM_RC_SUCCESS) 35 return result; 36 37 // Command Output 38 39 // Call PCR Allocation function. 40 result = PCRAllocate(&in->pcrAllocation, &out->maxPCR, 41 &out->sizeNeeded, &out->sizeAvailable); 42 if(result == TPM_RC_PCR) 43 return result; 44 45 // 46 out->allocationSuccess = (result == TPM_RC_SUCCESS); 47 48 // if re-configuration succeeds, set the flag to indicate PCR configuration is 49 // going to be changed in next boot 50 if(out->allocationSuccess == YES) 51 g_pcrReConfig = TRUE; 52 53 return TPM_RC_SUCCESS; 54 } 55