--- /dev/null
+/** @file\r
+ Public API for the Tcg Core library to perform the lowest level TCG Data encoding.\r
+\r
+Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution. The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#ifndef _TCG_CORE_H_\r
+#define _TCG_CORE_H_\r
+\r
+#include <IndustryStandard/TcgStorageCore.h>\r
+\r
+#define ERROR_CHECK(arg) \\r
+ { \\r
+ TCG_RESULT ret = (arg); \\r
+ if (ret != TcgResultSuccess) { \\r
+ DEBUG ((DEBUG_INFO, "ERROR_CHECK failed at %s:%u\n", __FILE__, __LINE__)); \\r
+ return ret; \\r
+ } \\r
+ }\r
+\r
+#define METHOD_STATUS_ERROR_CHECK(arg, failRet) \\r
+ if ((arg) != TCG_METHOD_STATUS_CODE_SUCCESS) { \\r
+ DEBUG ((DEBUG_INFO, "Method Status error: 0x%02X (%s)\n", arg, TcgMethodStatusString(arg))); \\r
+ return (failRet); \\r
+ }\r
+\r
+#define NULL_CHECK(arg) \\r
+ do { \\r
+ if ((arg) == NULL) { \\r
+ DEBUG ((DEBUG_INFO, "NULL_CHECK(%s) failed at %s:%u\n", #arg, __FILE__, __LINE__)); \\r
+ return TcgResultFailureNullPointer; \\r
+ } \\r
+ } while (0)\r
+\r
+#pragma pack(1)\r
+\r
+/**\r
+Tcg result codes.\r
+\r
+The result code indicates if the Tcg function call was successful or not\r
+**/\r
+typedef enum {\r
+ //\r
+ // This is the return result upon successful completion of a Tcg function call\r
+ //\r
+ TcgResultSuccess,\r
+\r
+ //\r
+ // This is the return "catchall" result for the failure of a Tcg function call\r
+ //\r
+ TcgResultFailure,\r
+\r
+ //\r
+ // This is the return result if a required parameter was Null for a Tcg function call\r
+ //\r
+ TcgResultFailureNullPointer,\r
+\r
+ //\r
+ // This is the return result if a required buffersize was 0 for a Tcg function call\r
+ //\r
+ TcgResultFailureZeroSize,\r
+\r
+ //\r
+ // This is the return result if a Tcg function call was executed out of order.\r
+ // For instance, starting a Tcg subpacket before starting its Tcg packet.\r
+ //\r
+ TcgResultFailureInvalidAction,\r
+\r
+ //\r
+ // This is the return result if the buffersize provided is not big enough to add a requested Tcg encoded item.\r
+ //\r
+ TcgResultFailureBufferTooSmall,\r
+\r
+ //\r
+ // This is the return result for a Tcg parse function if the end of the parsed Buffer is reached, yet Data is still attempted to be retrieved.\r
+ // For instance, attempting to retrieve another Tcg token from the Buffer after it has reached the end of the Tcg subpacket payload.\r
+ //\r
+ TcgResultFailureEndBuffer,\r
+\r
+ //\r
+ // This is the return result for a Tcg parse function if the Tcg Token item requested is not the expected type.\r
+ // For instance, the caller requested to receive an integer and the Tcg token was a byte sequence.\r
+ //\r
+ TcgResultFailureInvalidType,\r
+} TCG_RESULT;\r
+\r
+//\r
+// Structure that is used to build the Tcg ComPacket. It contains the start Buffer pointer and the current position of the\r
+// Tcg ComPacket, current Tcg Packet and Tcg SubPacket. This structure must be initialized\r
+// by calling tcgInitTcgCreateStruct before it is used as parameter to any other Tcg function.\r
+// This structure should NOT be directly modified by the client of this library.\r
+//\r
+// NOTE: WE MAY MAKE THIS AN ABSTRACT STRUCTURE WITH A DEFINED SIZE AND KEEP THE VARIABLES\r
+// INTERNAL AND ONLY KNOWN TO THE TCG LIBRARY\r
+//\r
+// tcgInitTcgCreateStruct\r
+//\r
+typedef struct {\r
+ //\r
+ // Buffer allocated and freed by the client of the Tcg library.\r
+ // This is the Buffer that shall contain the final Tcg encoded compacket.\r
+ //\r
+ VOID *Buffer;\r
+\r
+ //\r
+ // Size of the Buffer provided.\r
+ //\r
+ UINT32 BufferSize;\r
+\r
+ //\r
+ //Pointer to the start of the Tcg ComPacket. It should point to a location within Buffer.\r
+ //\r
+ TCG_COM_PACKET *ComPacket;\r
+\r
+ //\r
+ // Current Tcg Packet that is being created. It should point to a location within Buffer.\r
+ //\r
+ TCG_PACKET *CurPacket;\r
+\r
+ //\r
+ // Current Tcg SubPacket that is being created. It should point to a location within Buffer.\r
+ //\r
+ TCG_SUB_PACKET *CurSubPacket;\r
+\r
+ //\r
+ // Flag used to indicate if the Buffer of the structure should be filled out.\r
+ // This is intended to be used to support a use-case where the client of library\r
+ // can perform all the desired tcg calls to determine what the actual Size of the final compacket will be.\r
+ // Then the client can allocate the required Buffer Size and re-run the tcg calls.\r
+ // THIS MAY NOT BE IMPLEMENTED... REQUIRES MORE THOUGHT BECAUSE YOU CANNOT SOLVE ISSUE FOR RECEIVE\r
+ //\r
+ BOOLEAN DryRun;\r
+} TCG_CREATE_STRUCT;\r
+\r
+//\r
+// Structure that is used to parse the Tcg response received. It contains the response Buffer pointer\r
+// and the current position of the Tcg ComPacket, current Tcg Packet and Tcg SubPacket being parsed.\r
+// This structure must be initialized by calling tcgInitTcgParseStruct before it is used as parameter to any other Tcg parse function.\r
+// This structure should NOT be directly modified by the client of this library.\r
+//\r
+// NOTE: WE MAY MAKE THIS AN ABSTRACT STRUCTURE WITH A DEFINED SIZE AND KEEP THE VARIABLES\r
+// INTERNAL AND ONLY KNOWN TO THE TCG LIBRARY\r
+//\r
+// @sa tcgInitTcgParseStruct\r
+//\r
+typedef struct {\r
+ //\r
+ // Buffer allocated and freed by the client of the Tcg library.\r
+ // This is the Buffer that contains the Tcg response to decode/parse.\r
+ //\r
+ const VOID* Buffer;\r
+\r
+ //\r
+ //Size of the Buffer provided.\r
+ //\r
+ UINT32 BufferSize;\r
+\r
+ //\r
+ // Pointer to the start of the Tcg ComPacket. It should point to a location within Buffer.\r
+ //\r
+ TCG_COM_PACKET *ComPacket;\r
+\r
+ //\r
+ // Current Tcg Packet that is being created. It should point to a location within Buffer.\r
+ //\r
+ TCG_PACKET *CurPacket;\r
+\r
+ //\r
+ // Current Tcg SubPacket that is being created. It should point to a location within Buffer.\r
+ //\r
+ TCG_SUB_PACKET *CurSubPacket;\r
+\r
+ //\r
+ // Current pointer within the current subpacket payload.\r
+ //\r
+ UINT8 *CurPtr;\r
+} TCG_PARSE_STRUCT ;\r
+\r
+\r
+//\r
+// Structure that is used to represent a Tcg Token that is retrieved by Tcg parse functions.\r
+//\r
+typedef struct {\r
+ //\r
+ // Describes the type of Tcg token the Hdr start points to.\r
+ //\r
+ TCG_TOKEN_TYPE Type;\r
+\r
+ //\r
+ // Pointer to the beginning of the Header of the Tcg token\r
+ //\r
+ UINT8 *HdrStart;\r
+} TCG_TOKEN ;\r
+\r
+/**\r
+\r
+ Required to be called before calling any other Tcg functions with the TCG_CREATE_STRUCT.\r
+ Initializes the packet variables to NULL. Additionally, the buffer will be memset.\r
+\r
+ @param[in/out] CreateStruct Structure to initialize\r
+ @param[in] Buffer Buffer allocated by client of library. It will contain the Tcg encoded packet. This cannot be null.\r
+ @param[in] BufferSize Size of buffer provided. It cannot be 0.\r
+\r
+**/\r
+TCG_RESULT\r
+EFIAPI\r
+TcgInitTcgCreateStruct(\r
+ TCG_CREATE_STRUCT *CreateStruct,\r
+ VOID *Buffer,\r
+ UINT32 BufferSize\r
+ );\r
+\r
+\r
+/**\r
+\r
+ Encodes the ComPacket header to the data structure.\r
+\r
+ @param[in/out] CreateStruct Structure to initialize\r
+ @param[in] ComId ComID of the Tcg ComPacket.\r
+ @param[in] ComIdExtension ComID Extension of the Tcg ComPacket.\r
+\r
+**/\r
+TCG_RESULT\r
+EFIAPI\r
+TcgStartComPacket(\r
+ TCG_CREATE_STRUCT *CreateStruct,\r
+ UINT16 ComId,\r
+ UINT16 ComIdExtension\r
+ );\r
+\r
+\r
+/**\r
+\r
+ Starts a new ComPacket in the Data structure.\r
+\r
+ @param[in/out] CreateStruct Structure used to add Tcg Packet\r
+ @param[in] Tsn Packet Tper session number\r
+ @param[in] Hsn Packet Host session number\r
+ @param[in] SeqNumber Packet Sequence Number\r
+ @param[in] AckType Packet Acknowledge Type\r
+ @param[in] Ack Packet Acknowledge\r
+\r
+**/\r
+TCG_RESULT\r
+EFIAPI\r
+TcgStartPacket(\r
+ TCG_CREATE_STRUCT *CreateStruct,\r
+ UINT32 Tsn,\r
+ UINT32 Hsn,\r
+ UINT32 SeqNumber,\r
+ UINT16 AckType,\r
+ UINT32 Ack\r
+ );\r
+\r
+/**\r
+\r
+ Starts a new SubPacket in the Data structure.\r
+\r
+ @param[in/out] CreateStruct Structure used to start Tcg SubPacket\r
+ @param[in] Kind SubPacket kind\r
+\r
+**/\r
+TCG_RESULT\r
+EFIAPI\r
+TcgStartSubPacket(\r
+ TCG_CREATE_STRUCT *CreateStruct,\r
+ UINT16 Kind\r
+ );\r
+\r
+\r
+/**\r
+\r
+ Ends the current SubPacket in the Data structure. This function will also perform the 4-byte padding\r
+ required for Subpackets.\r
+\r
+ @param[in/out] CreateStruct Structure used to end the current Tcg SubPacket\r
+\r
+**/\r
+TCG_RESULT\r
+EFIAPI\r
+TcgEndSubPacket(\r
+ TCG_CREATE_STRUCT *CreateStruct\r
+ );\r
+\r
+\r
+/**\r
+\r
+ Ends the current Packet in the Data structure.\r
+\r
+ @param[in/out] CreateStruct Structure used to end the current Tcg Packet\r
+\r
+**/\r
+TCG_RESULT\r
+EFIAPI\r
+TcgEndPacket(\r
+ TCG_CREATE_STRUCT *CreateStruct\r
+ );\r
+\r
+\r
+/**\r
+\r
+ Ends the ComPacket in the Data structure and ret\r
+\r
+ @param[in/out] CreateStruct Structure used to end the Tcg ComPacket\r
+ @param[in/out] Size Describes the Size of the entire ComPacket (Header and payload). Filled out by function.\r
+\r
+**/\r
+TCG_RESULT\r
+EFIAPI\r
+TcgEndComPacket(\r
+ TCG_CREATE_STRUCT *CreateStruct,\r
+ UINT32 *Size\r
+ );\r
+\r
+/**\r
+ Adds a single raw token byte to the Data structure.\r
+\r
+ @param[in/out] CreateStruct Structure used to add the byte\r
+ @param [in] Byte Byte to add\r
+\r
+**/\r
+TCG_RESULT\r
+EFIAPI\r
+TcgAddRawByte(\r
+ TCG_CREATE_STRUCT *CreateStruct,\r
+ UINT8 Byte\r
+ );\r
+\r
+\r
+/**\r
+\r
+ Adds the Data parameter as a byte sequence to the Data structure.\r
+\r
+ @param [in/out] CreateStruct Structure used to add the byte sequence\r
+ @param[in] Data Byte sequence that will be encoded and copied into Data structure\r
+ @param[in] DataSize Length of Data provided\r
+ @param[in] Continued TRUE if byte sequence is continued or\r
+ FALSE if the Data contains the entire byte sequence to be encoded\r
+\r
+**/\r
+TCG_RESULT\r
+EFIAPI\r
+TcgAddByteSequence(\r
+ TCG_CREATE_STRUCT *CreateStruct,\r
+ const VOID *Data,\r
+ UINT32 DataSize,\r
+ BOOLEAN Continued\r
+ );\r
+\r
+\r
+/**\r
+\r
+ Adds an arbitrary-Length integer to the Data structure.\r
+\r
+ The integer will be encoded using the shortest possible atom.\r
+\r
+ @param[in/out] CreateStruct Structure used to add the integer\r
+ @param[in] Data Integer in host byte order that will be encoded and copied into Data structure\r
+ @param[in] DataSize Length in bytes of the Data provided\r
+ @param[in] SignedInteger TRUE if the integer is signed or FALSE if the integer is unsigned\r
+\r
+**/\r
+TCG_RESULT\r
+EFIAPI\r
+TcgAddInteger(\r
+ TCG_CREATE_STRUCT *CreateStruct,\r
+ const VOID *Data,\r
+ UINT32 DataSize,\r
+ BOOLEAN SignedInteger\r
+ );\r
+\r
+\r
+/**\r
+ Adds an 8-bit unsigned integer to the Data structure.\r
+\r
+ @param[in/out] CreateStruct Structure used to add the integer\r
+ @param[in] Value Integer Value to add\r
+\r
+**/\r
+TCG_RESULT\r
+EFIAPI\r
+TcgAddUINT8(\r
+ TCG_CREATE_STRUCT *CreateStruct,\r
+ UINT8 Value\r
+ );\r
+\r
+/**\r
+\r
+ Adds a 16-bit unsigned integer to the Data structure.\r
+\r
+ @param[in/out] CreateStruct Structure used to add the integer\r
+ @param[in] Value Integer Value to add\r
+\r
+**/\r
+TCG_RESULT\r
+EFIAPI\r
+TcgAddUINT16 (\r
+ TCG_CREATE_STRUCT *CreateStruct,\r
+ UINT16 Value\r
+ );\r
+\r
+/**\r
+\r
+ Adds a 32-bit unsigned integer to the Data structure.\r
+\r
+ @param[in/out] CreateStruct Structure used to add the integer\r
+ @param[in] Value Integer Value to add\r
+\r
+**/\r
+TCG_RESULT\r
+EFIAPI\r
+TcgAddUINT32(\r
+ TCG_CREATE_STRUCT *CreateStruct,\r
+ UINT32 Value\r
+ );\r
+\r
+\r
+/**\r
+\r
+ Adds a 64-bit unsigned integer to the Data structure.\r
+\r
+ @param[in/out] CreateStruct Structure used to add the integer\r
+ @param[in] Value Integer Value to add\r
+\r
+**/\r
+TCG_RESULT\r
+EFIAPI\r
+TcgAddUINT64(\r
+ TCG_CREATE_STRUCT *CreateStruct,\r
+ UINT64 Value\r
+ );\r
+\r
+/**\r
+ Adds a BOOLEAN to the Data structure.\r
+\r
+ @param[in/out] CreateStruct Structure used to add the integer\r
+ @param[in] Value BOOLEAN Value to add\r
+\r
+**/\r
+TCG_RESULT\r
+EFIAPI\r
+TcgAddBOOLEAN(\r
+ TCG_CREATE_STRUCT *CreateStruct,\r
+ BOOLEAN Value\r
+ );\r
+\r
+/**\r
+ Add tcg uid info.\r
+\r
+ @param [in/out] CreateStruct Structure used to add the integer\r
+ @param Uid Input uid info.\r
+\r
+ @retval return the action result.\r
+\r
+**/\r
+TCG_RESULT\r
+EFIAPI\r
+TcgAddTcgUid(\r
+ TCG_CREATE_STRUCT *CreateStruct,\r
+ TCG_UID Uid\r
+ );\r
+\r
+/**\r
+ Adds a Start List token to the Data structure.\r
+\r
+ @param[in/out] CreateStruct Structure used to add the token\r
+\r
+**/\r
+TCG_RESULT\r
+EFIAPI\r
+TcgAddStartList(\r
+ TCG_CREATE_STRUCT *CreateStruct\r
+ );\r
+\r
+\r
+/**\r
+\r
+ Adds an End List token to the Data structure.\r
+\r
+ @param [in/out] CreateStruct Structure used to add the token\r
+\r
+**/\r
+TCG_RESULT\r
+EFIAPI\r
+TcgAddEndList(\r
+ TCG_CREATE_STRUCT *CreateStruct\r
+ );\r
+\r
+\r
+/**\r
+ Adds a Start Name token to the Data structure.\r
+\r
+ @param[in/out] CreateStruct Structure used to add the token\r
+\r
+**/\r
+TCG_RESULT\r
+EFIAPI\r
+TcgAddStartName(\r
+ TCG_CREATE_STRUCT *CreateStruct\r
+ );\r
+\r
+\r
+/**\r
+\r
+ Adds an End Name token to the Data structure.\r
+\r
+ @param [in/out] CreateStruct Structure used to add the token\r
+\r
+**/\r
+TCG_RESULT\r
+EFIAPI\r
+TcgAddEndName(\r
+ TCG_CREATE_STRUCT *CreateStruct\r
+ );\r
+\r
+\r
+/**\r
+ Adds a Call token to the Data structure.\r
+\r
+ @param [in/out] CreateStruct Structure used to add the token\r
+\r
+**/\r
+TCG_RESULT\r
+EFIAPI\r
+TcgAddCall(\r
+ TCG_CREATE_STRUCT *CreateStruct\r
+ );\r
+\r
+\r
+/**\r
+\r
+Adds an End of Data token to the Data structure.\r
+\r
+@param[in/out] CreateStruct Structure used to add the token\r
+\r
+**/\r
+TCG_RESULT\r
+EFIAPI\r
+TcgAddEndOfData(\r
+ TCG_CREATE_STRUCT *CreateStruct\r
+ );\r
+\r
+\r
+/**\r
+\r
+Adds an End of Session token to the Data structure.\r
+\r
+@param [in/out] CreateStruct Structure used to add the token\r
+\r
+**/\r
+TCG_RESULT\r
+EFIAPI\r
+TcgAddEndOfSession(\r
+ TCG_CREATE_STRUCT *CreateStruct\r
+ );\r
+\r
+\r
+/**\r
+ Adds a Start Transaction token to the Data structure.\r
+\r
+ @param [in/out] CreateStruct Structure used to add the token\r
+\r
+**/\r
+TCG_RESULT\r
+EFIAPI\r
+TcgAddStartTransaction(\r
+ TCG_CREATE_STRUCT *CreateStruct\r
+ );\r
+\r
+\r
+/**\r
+ Adds an End Transaction token to the Data structure.\r
+\r
+ @param[in/out] CreateStruct Structure used to add the token\r
+\r
+**/\r
+TCG_RESULT\r
+EFIAPI\r
+TcgAddEndTransaction(\r
+ TCG_CREATE_STRUCT *CreateStruct\r
+ );\r
+\r
+/**\r
+ Initial the tcg parse stucture.\r
+\r
+ @param ParseStruct Input parse structure.\r
+ @param Buffer Input buffer data.\r
+ @param BufferSize Input buffer size.\r
+\r
+ @retval return the action result.\r
+\r
+**/\r
+TCG_RESULT\r
+EFIAPI\r
+TcgInitTcgParseStruct(\r
+ TCG_PARSE_STRUCT *ParseStruct,\r
+ const VOID *Buffer,\r
+ UINT32 BufferSize\r
+ );\r
+\r
+/**\r
+ Get next token info.\r
+\r
+ @param ParseStruct Input parse structure info.\r
+ @param TcgToken return the tcg token info.\r
+\r
+ @retval return the action result.\r
+\r
+**/\r
+TCG_RESULT\r
+EFIAPI\r
+TcgGetNextToken(\r
+ TCG_PARSE_STRUCT *ParseStruct,\r
+ TCG_TOKEN *TcgToken\r
+ );\r
+\r
+/**\r
+ Get next token Type.\r
+\r
+ @param ParseStruct Input parse structure.\r
+ @param Type Input the type need to check.\r
+\r
+ @retval return the action result.\r
+\r
+**/\r
+TCG_RESULT\r
+EFIAPI\r
+TcgGetNextTokenType(\r
+ TCG_PARSE_STRUCT *ParseStruct,\r
+ TCG_TOKEN_TYPE Type\r
+ );\r
+\r
+/**\r
+ Get atom info.\r
+\r
+ @param TcgToken Input token info.\r
+ @param HeaderLength return the header length.\r
+ @param DataLength return the data length.\r
+ @param ByteOrInt return the atom Type.\r
+ @param SignOrCont return the sign or count info.\r
+\r
+ @retval return the action result.\r
+\r
+**/\r
+TCG_RESULT\r
+EFIAPI\r
+TcgGetAtomInfo(\r
+ const TCG_TOKEN *TcgToken,\r
+ UINT32 *HeaderLength,\r
+ UINT32 *DataLength,\r
+ UINT8 *ByteOrInt,\r
+ UINT8 *SignOrCont\r
+ );\r
+\r
+/**\r
+ Get token byte sequence.\r
+\r
+ @param TcgToken Input token info.\r
+ @param Length Input the length info.\r
+\r
+ @retval Return the value data.\r
+\r
+**/\r
+UINT8*\r
+EFIAPI\r
+TcgGetTokenByteSequence(\r
+ const TCG_TOKEN *TcgToken,\r
+ UINT32 *Length\r
+ );\r
+\r
+/**\r
+ Get token specified value.\r
+\r
+ @param TcgToken Input token info.\r
+ @param Value return the value.\r
+\r
+ @retval return the action result.\r
+\r
+**/\r
+TCG_RESULT\r
+EFIAPI\r
+TcgGetTokenUINT64(\r
+ const TCG_TOKEN *TcgToken,\r
+ UINT64 *Value\r
+ );\r
+\r
+\r
+/**\r
+ Get next specify value.\r
+\r
+ @param ParseStruct Input parse structure.\r
+ @param Value Return vlaue.\r
+\r
+ @retval return the action result.\r
+\r
+**/\r
+TCG_RESULT\r
+EFIAPI\r
+TcgGetNextUINT8(\r
+ TCG_PARSE_STRUCT *ParseStruct,\r
+ UINT8 *Value\r
+ );\r
+\r
+\r
+/**\r
+ Get next specify value.\r
+\r
+ @param ParseStruct Input parse structure.\r
+ @param Value Return vlaue.\r
+\r
+ @retval return the action result.\r
+\r
+**/\r
+TCG_RESULT\r
+EFIAPI\r
+TcgGetNextUINT16(\r
+ TCG_PARSE_STRUCT *ParseStruct,\r
+ UINT16 *Value\r
+ );\r
+\r
+/**\r
+ Get next specify value.\r
+\r
+ @param ParseStruct Input parse structure.\r
+ @param Value Return vlaue.\r
+\r
+ @retval return the action result.\r
+\r
+**/\r
+TCG_RESULT\r
+EFIAPI\r
+TcgGetNextUINT32(\r
+ TCG_PARSE_STRUCT *ParseStruct,\r
+ UINT32 *Value\r
+ );\r
+\r
+/**\r
+ Get next specify value.\r
+\r
+ @param ParseStruct Input parse structure.\r
+ @param Value Return vlaue.\r
+\r
+ @retval return the action result.\r
+\r
+**/\r
+TCG_RESULT\r
+EFIAPI\r
+TcgGetNextUINT64(\r
+ TCG_PARSE_STRUCT *ParseStruct,\r
+ UINT64 *Value\r
+ );\r
+\r
+/**\r
+ Get next specify value.\r
+\r
+ @param ParseStruct Input parse structure.\r
+ @param Value Return vlaue.\r
+\r
+ @retval return the action result.\r
+\r
+**/\r
+TCG_RESULT\r
+EFIAPI\r
+TcgGetNextBOOLEAN(\r
+ TCG_PARSE_STRUCT *ParseStruct,\r
+ BOOLEAN *Value\r
+ );\r
+\r
+/**\r
+ Get next tcg uid info.\r
+\r
+ @param ParseStruct Input parse structure.\r
+ @param Uid Get the uid info.\r
+\r
+ @retval return the action result.\r
+\r
+**/\r
+TCG_RESULT\r
+EFIAPI\r
+TcgGetNextTcgUid(\r
+ TCG_PARSE_STRUCT *ParseStruct,\r
+ TCG_UID *Uid\r
+ );\r
+\r
+/**\r
+ Get next byte sequence.\r
+\r
+ @param ParseStruct Input parse structure.\r
+ @param Data return the data.\r
+ @param Length return the length.\r
+\r
+ @retval return the action result.\r
+\r
+**/\r
+TCG_RESULT\r
+EFIAPI\r
+TcgGetNextByteSequence(\r
+ TCG_PARSE_STRUCT *ParseStruct,\r
+ const VOID **Data,\r
+ UINT32 *Length\r
+ );\r
+\r
+/**\r
+ Get next start list.\r
+\r
+ @param ParseStruct Input parse structure.\r
+\r
+ @retval return the action result.\r
+\r
+**/\r
+TCG_RESULT\r
+EFIAPI\r
+TcgGetNextStartList(\r
+ TCG_PARSE_STRUCT *ParseStruct\r
+ );\r
+\r
+/**\r
+ Get next end list.\r
+\r
+ @param ParseStruct Input parse structure.\r
+\r
+ @retval return the action result.\r
+\r
+**/\r
+TCG_RESULT\r
+EFIAPI\r
+TcgGetNextEndList(\r
+ TCG_PARSE_STRUCT *ParseStruct\r
+ );\r
+\r
+/**\r
+ Get next start name.\r
+\r
+ @param ParseStruct Input parse structure.\r
+\r
+ @retval return the action result.\r
+\r
+**/\r
+TCG_RESULT\r
+EFIAPI\r
+TcgGetNextStartName(\r
+ TCG_PARSE_STRUCT *ParseStruct\r
+ );\r
+\r
+/**\r
+ Get next end name.\r
+\r
+ @param ParseStruct Input parse structure.\r
+\r
+ @retval return the action result.\r
+\r
+**/\r
+TCG_RESULT\r
+EFIAPI\r
+TcgGetNextEndName(\r
+ TCG_PARSE_STRUCT *ParseStruct\r
+ );\r
+\r
+/**\r
+ Get next call.\r
+\r
+ @param ParseStruct Input parse structure.\r
+\r
+ @retval return the action result.\r
+\r
+**/\r
+TCG_RESULT\r
+EFIAPI\r
+TcgGetNextCall(\r
+ TCG_PARSE_STRUCT *ParseStruct\r
+ );\r
+\r
+/**\r
+ Get next end data.\r
+\r
+ @param ParseStruct Input parse structure.\r
+\r
+ @retval return the action result.\r
+\r
+**/\r
+TCG_RESULT\r
+EFIAPI\r
+TcgGetNextEndOfData(\r
+ TCG_PARSE_STRUCT *ParseStruct\r
+ );\r
+\r
+/**\r
+ Get next end of session.\r
+\r
+ @param ParseStruct Input parse structure.\r
+\r
+ @retval return the action result.\r
+\r
+**/\r
+TCG_RESULT\r
+EFIAPI\r
+TcgGetNextEndOfSession(\r
+ TCG_PARSE_STRUCT *ParseStruct\r
+ );\r
+\r
+/**\r
+ Get next start transaction.\r
+\r
+ @param ParseStruct Input parse structure.\r
+\r
+ @retval return the action result.\r
+\r
+**/\r
+TCG_RESULT\r
+EFIAPI\r
+TcgGetNextStartTransaction(\r
+ TCG_PARSE_STRUCT *ParseStruct\r
+ );\r
+\r
+/**\r
+ Get next end transaction.\r
+\r
+ @param ParseStruct Input parse structure.\r
+\r
+ @retval return the action result.\r
+\r
+**/\r
+TCG_RESULT\r
+EFIAPI\r
+TcgGetNextEndTransaction(\r
+ TCG_PARSE_STRUCT *ParseStruct\r
+ );\r
+\r
+// end of parse functions\r
+\r
+\r
+typedef\r
+BOOLEAN\r
+(EFIAPI* TCG_LEVEL0_ENUM_CALLBACK) (\r
+ const TCG_LEVEL0_DISCOVERY_HEADER *DiscoveryHeader,\r
+ TCG_LEVEL0_FEATURE_DESCRIPTOR_HEADER *Feature,\r
+ UINTN FeatureSize, // includes header\r
+ VOID *Context\r
+);\r
+\r
+/**\r
+ Adds call token and method Header (invoking id, and method id).\r
+\r
+ @param CreateStruct The input create structure.\r
+ @param InvokingId Invoking id.\r
+ @param MethodId Method id.\r
+\r
+**/\r
+TCG_RESULT\r
+EFIAPI\r
+TcgStartMethodCall(\r
+ TCG_CREATE_STRUCT *CreateStruct,\r
+ TCG_UID InvokingId,\r
+ TCG_UID MethodId\r
+ );\r
+\r
+/**\r
+ Adds START LIST token.\r
+\r
+ @param CreateStruct The input create structure.\r
+\r
+**/\r
+TCG_RESULT\r
+EFIAPI\r
+TcgStartParameters(\r
+ TCG_CREATE_STRUCT *CreateStruct\r
+ );\r
+\r
+/**\r
+ Adds END LIST token.\r
+\r
+ @param CreateStruct The input create structure.\r
+\r
+**/\r
+TCG_RESULT\r
+EFIAPI\r
+TcgEndParameters(\r
+ TCG_CREATE_STRUCT *CreateStruct\r
+ );\r
+\r
+/**\r
+ Adds END Data token and method list.\r
+\r
+ @param CreateStruct The input create structure.\r
+\r
+**/\r
+TCG_RESULT\r
+EFIAPI\r
+TcgEndMethodCall(\r
+ TCG_CREATE_STRUCT *CreateStruct\r
+ );\r
+\r
+/**\r
+\r
+ Adds Start Session call to the data structure. This creates the entire ComPacket structure and\r
+ returns the size of the entire compacket in the size parameter.\r
+\r
+ @param [in/out] CreateStruct Structure used to add the start session call\r
+ @param [in/out] Size Describes the size of the entire ComPacket (header and payload). Filled out by function.\r
+ @param [in] ComId ComID for the ComPacket\r
+ @param [in] ComIdExtension Extended ComID for the ComPacket\r
+ @param [in] HostSessionId Host Session ID\r
+ @param [in] SpId Security Provider to start session with\r
+ @param [in] Write Write option for start session. TRUE = start session requests write access\r
+ @param [in] HostChallengeLength Length of the host challenge. Length should be 0 if hostChallenge is NULL\r
+ @param [in] HostChallenge Host challenge for Host Signing Authority. If NULL, then no Host Challenge shall be sent.\r
+ @param [in] HostSigningAuthority Host Signing Authority used for start session. If NULL, then no Host Signing Authority shall be sent.\r
+\r
+**/\r
+TCG_RESULT\r
+EFIAPI\r
+TcgCreateStartSession(\r
+ TCG_CREATE_STRUCT *CreateStruct,\r
+ UINT32 *Size,\r
+ UINT16 ComId,\r
+ UINT16 ComIdExtension,\r
+ UINT32 HostSessionId,\r
+ TCG_UID SpId,\r
+ BOOLEAN Write,\r
+ UINT32 HostChallengeLength,\r
+ const VOID *HostChallenge,\r
+ TCG_UID HostSigningAuthority\r
+ );\r
+\r
+/**\r
+ Creates ComPacket with a Method call that sets the PIN column for the row specified.\r
+ This assumes a start session has already been opened with the desired SP.\r
+\r
+ @param [in/out] CreateStruct Structure used to add method call.\r
+ @param [in/out] Size Describes the size of the entire ComPacket (header and payload). Filled out by function.\r
+ @param [in] ComId ComID for the ComPacket\r
+ @param [in] ComIdExtension Extended ComID for the ComPacket\r
+ @param [in] TperSession Tper Session ID for the Packet\r
+ @param [in] HostSession Host Session ID for the Packet\r
+ @param [in] SidRow UID of row of current SP to set PIN column\r
+ @param [in] Password value of PIN to set\r
+ @param [in] PasswordSize Size of PIN\r
+\r
+**/\r
+TCG_RESULT\r
+EFIAPI\r
+TcgCreateSetCPin(\r
+ TCG_CREATE_STRUCT *CreateStruct,\r
+ UINT32 *Size,\r
+ UINT16 ComId,\r
+ UINT16 ComIdExtension,\r
+ UINT32 TperSession,\r
+ UINT32 HostSession,\r
+ TCG_UID SidRow,\r
+ const VOID *Password,\r
+ UINT32 PasswordSize\r
+ );\r
+\r
+/**\r
+ Creates ComPacket with a Method call that sets the "Enabled" column for the row specified using the value specified.\r
+ This assumes a start session has already been opened with the desired SP.\r
+\r
+ @param [in/out] CreateStruct Structure used to add method call\r
+ @param [in/out] Size Describes the size of the entire ComPacket (header and payload). Filled out by function.\r
+ @param [in] ComId ComID for the ComPacket\r
+ @param [in] ComIdExtension Extended ComID for the ComPacket\r
+ @param [in] TperSession Tper Session ID for the Packet\r
+ @param [in] HostSession Host Session ID for the Packet\r
+ @param [in] AuthorityUid Authority UID to modify the "Enabled" column for\r
+ @param [in] Enabled Value to set the "Enabled" column to\r
+\r
+**/\r
+TCG_RESULT\r
+EFIAPI\r
+TcgSetAuthorityEnabled(\r
+ TCG_CREATE_STRUCT *CreateStruct,\r
+ UINT32 *Size,\r
+ UINT16 ComId,\r
+ UINT16 ComIdExtension,\r
+ UINT32 TperSession,\r
+ UINT32 HostSession,\r
+ TCG_UID AuthorityUid,\r
+ BOOLEAN Enabled\r
+ );\r
+\r
+/**\r
+\r
+ Creates ComPacket with EndSession.\r
+ This assumes a start session has already been opened.\r
+\r
+ @param [in/out] CreateStruct Structure used to add Endsession\r
+ @param [in/out] Size Describes the size of the entire ComPacket (header and payload). Filled out by function.\r
+ @param [in] ComId ComID for the ComPacket\r
+ @param [in] ComIdExtension Extended ComID for the ComPacket\r
+ @param [in] HostSessionId Host Session ID for the Packet\r
+ @param [in] TpSessionId Tper Session ID for the Packet\r
+\r
+**/\r
+TCG_RESULT\r
+EFIAPI\r
+TcgCreateEndSession(\r
+ TCG_CREATE_STRUCT *CreateStruct,\r
+ UINT32 *Size,\r
+ UINT16 ComId,\r
+ UINT16 ComIdExtension,\r
+ UINT32 HostSessionId,\r
+ UINT32 TpSessionId\r
+ );\r
+\r
+\r
+/**\r
+\r
+ Retrieves human-readable token type name.\r
+\r
+ @param[in] Type Token type to retrieve\r
+\r
+**/\r
+CHAR8*\r
+EFIAPI\r
+TcgTokenTypeString(\r
+ TCG_TOKEN_TYPE Type\r
+ );\r
+\r
+/**\r
+ Returns the method status of the current subpacket. Does not affect the current position\r
+ in the ComPacket. In other words, it can be called whenever you have a valid SubPacket.\r
+\r
+ @param [in/out] ParseStruct Structure used to parse received TCG response\r
+ @param [in/out] MethodStatus Method status retrieved of the current SubPacket\r
+\r
+**/\r
+TCG_RESULT\r
+EFIAPI\r
+TcgGetMethodStatus(\r
+ const TCG_PARSE_STRUCT *ParseStruct,\r
+ UINT8 *MethodStatus\r
+ );\r
+\r
+/**\r
+ Returns a human-readable string representing a method status return code.\r
+\r
+ @param[in] MethodStatus Method status to translate to a string\r
+\r
+\r
+ @retval return the string info.\r
+**/\r
+CHAR8*\r
+EFIAPI\r
+TcgMethodStatusString(\r
+ UINT8 MethodStatus\r
+ );\r
+\r
+\r
+/**\r
+ Retrieves the comID and Extended comID of the ComPacket in the Tcg response.\r
+ It is intended to be used to confirm the received Tcg response is intended for user that received it.\r
+\r
+ @param [in] ParseStruct Structure used to parse received TCG response.\r
+ @param [in/out] ComId comID retrieved from received ComPacket.\r
+ @param [in/out] ComIdExtension Extended comID retrieved from received ComPacket\r
+\r
+**/\r
+TCG_RESULT\r
+EFIAPI\r
+TcgGetComIds(\r
+ const TCG_PARSE_STRUCT *ParseStruct,\r
+ UINT16 *ComId,\r
+ UINT16 *ComIdExtension\r
+ );\r
+\r
+/**\r
+ Checks if the ComIDs of the response match the expected values.\r
+\r
+ @param[in] ParseStruct Structure used to parse received TCG response\r
+ @param[in] ExpectedComId Expected comID\r
+ @param[in] ExpectedComIdExtension Expected extended comID\r
+\r
+**/\r
+TCG_RESULT\r
+EFIAPI\r
+TcgCheckComIds(\r
+ const TCG_PARSE_STRUCT *ParseStruct,\r
+ UINT16 ExpectedComId,\r
+ UINT16 ExpectedComIdExtension\r
+ );\r
+\r
+/**\r
+ Parses the Sync Session response contained in the parseStruct to retrieve Tper session ID. If the Sync Session response\r
+ parameters do not match the comID, extended ComID and host session ID then a failure is returned.\r
+\r
+ @param[in/out] ParseStruct Structure used to parse received TCG response, contains Sync Session response.\r
+ @param[in] ComId Expected ComID that is compared to actual ComID of response\r
+ @param[in] ComIdExtension Expected Extended ComID that is compared to actual Extended ComID of response\r
+ @param[in] HostSessionId Expected Host Session ID that is compared to actual Host Session ID of response\r
+ @param[in/out] TperSessionId Tper Session ID retrieved from the Sync Session response.\r
+\r
+**/\r
+TCG_RESULT\r
+EFIAPI\r
+TcgParseSyncSession(\r
+ const TCG_PARSE_STRUCT *ParseStruct,\r
+ UINT16 ComId,\r
+ UINT16 ComIdExtension,\r
+ UINT32 HostSessionId,\r
+ UINT32 *TperSessionId\r
+ );\r
+\r
+/**\r
+ Create set ace.\r
+\r
+ @param CreateStruct Input create structure.\r
+ @param Size size info.\r
+ @param ComId ComId info.\r
+ @param ComIdExtension ComId extension info.\r
+ @param TperSession Tper session data.\r
+ @param HostSession Host session data.\r
+ @param AceRow Ace row info.\r
+ @param Authority1 Authority 1 info.\r
+ @param LogicalOperator Logiccal operator info.\r
+ @param Authority2 Authority 2 info.\r
+\r
+ @retval Return the action result.\r
+\r
+**/\r
+TCG_RESULT\r
+EFIAPI\r
+TcgCreateSetAce(\r
+ TCG_CREATE_STRUCT *CreateStruct,\r
+ UINT32 *Size,\r
+ UINT16 ComId,\r
+ UINT16 ComIdExtension,\r
+ UINT32 TperSession,\r
+ UINT32 HostSession,\r
+ TCG_UID AceRow,\r
+ TCG_UID Authority1,\r
+ BOOLEAN LogicalOperator,\r
+ TCG_UID Authority2\r
+ );\r
+\r
+/**\r
+ Enum level 0 discovery.\r
+\r
+ @param DiscoveryHeader Discovery header.\r
+ @param Callback Callback function.\r
+ @param Context The context for the function.\r
+\r
+ @retval return true if the callback return TRUE, else return FALSE.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+TcgEnumLevel0Discovery(\r
+ const TCG_LEVEL0_DISCOVERY_HEADER *DiscoveryHeader,\r
+ TCG_LEVEL0_ENUM_CALLBACK Callback,\r
+ VOID *Context\r
+ );\r
+\r
+/**\r
+ Get Feature code from the header.\r
+\r
+ @param DiscoveryHeader The discovery header.\r
+ @param FeatureCode reutrn the Feature code.\r
+ @param FeatureSize return the Feature size.\r
+\r
+ @retval return the Feature code data.\r
+**/\r
+TCG_LEVEL0_FEATURE_DESCRIPTOR_HEADER*\r
+EFIAPI\r
+TcgGetFeature(\r
+ const TCG_LEVEL0_DISCOVERY_HEADER *DiscoveryHeader,\r
+ UINT16 FeatureCode,\r
+ UINTN *FeatureSize\r
+ );\r
+\r
+/**\r
+ Determines if the protocol provided is part of the provided supported protocol list.\r
+\r
+ @param[in] ProtocolList Supported protocol list to investigate\r
+ @param[in] Protocol Protocol value to determine if supported\r
+\r
+ @return TRUE = protocol is supported, FALSE = protocol is not supported\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+TcgIsProtocolSupported(\r
+ const TCG_SUPPORTED_SECURITY_PROTOCOLS *ProtocolList,\r
+ UINT16 Protocol\r
+ );\r
+\r
+/**\r
+ Determines if the Locking Feature "Locked" bit is set in the level 0 discovery response.\r
+\r
+ @param[in] Discovery Level 0 discovery response\r
+\r
+ @return TRUE = Locked is set, FALSE = Locked is false\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+TcgIsLocked(\r
+ const TCG_LEVEL0_DISCOVERY_HEADER *Discovery\r
+ );\r
+\r
+#pragma pack()\r
+\r
+\r
+#endif // _TCG_CORE_H_\r