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 36 #ifndef FTPM_TA_H 37 #define FTPM_TA_H 38 39 #include <Implementation.h> 40 41 /* This UUID is generated with uuidgen */ 42 #define TA_FTPM_UUID { 0xBC50D971, 0xD4C9, 0x42C4, \ 43 {0x82, 0xCB, 0x34, 0x3F, 0xB7, 0xF3, 0x78, 0x96}} 44 45 /* The TAFs ID implemented in this TA */ 46 #define TA_FTPM_SUBMIT_COMMAND (0) 47 #define TA_FTPM_EMULATE_PPI (1) 48 49 // 50 // These must match values from reference/TPM/include/Implementation.h 51 // 52 #define MAX_COMMAND_SIZE 4096 53 #define MAX_RESPONSE_SIZE 4096 54 55 // 56 // Macro for intentionally unreferenced parameters 57 // 58 #define UNREFERENCED_PARAMETER(_Parameter_) (void)(_Parameter_) 59 60 // 61 // Shorthand for TA functions taking uniform arg types 62 // 63 #define TA_ALL_PARAM_TYPE(a) TEE_PARAM_TYPES((a), (a), (a), (a)) 64 65 // 66 // Used to extract size field from TPM command buffers 67 // 68 #define BYTE_ARRAY_TO_UINT32(b) (uint32_t)( ((b)[0] << 24) \ 69 + ((b)[1] << 16) \ 70 + ((b)[2] << 8 ) \ 71 + (b)[3]) 72 // 73 // Entrypoint for reference implemntation 74 // 75 extern void ExecuteCommand( 76 uint32_t requestSize, // IN: command buffer size 77 unsigned char *request, // IN: command buffer 78 uint32_t *responseSize, // OUT: response buffer size 79 unsigned char **response // OUT: response buffer 80 ); 81 82 // 83 // External functions supporting TPM initialization 84 // 85 extern int _plat__NVEnable(void *platParameter); 86 extern int TPM_Manufacture(bool firstTime); 87 extern bool _plat__NvNeedsManufacture(void); 88 extern void _TPM_Init(void); 89 extern void _plat__Signal_PowerOn(void); 90 extern void _plat__NVDisable(void); 91 extern void _admin__SaveChipFlags(void); 92 93 // 94 // External types/data supporting TPM initialization 95 // 96 typedef union { 97 uint32_t flags; 98 struct { 99 uint32_t Remanufacture : 1; // Perform a TPM_Remanufacture() on startup (SET by default) 100 uint32_t TpmStatePresent : 1; // Init TPM and NV with contents of TpmState and NVState on startup 101 uint32_t Reserved : 30; 102 } fields; 103 } TPM_CHIP_STATE; 104 105 extern TPM_CHIP_STATE g_chipFlags; 106 #endif /* FTPM_TA_H */