34 NULL_CHECK (CreateStruct);
37 if (BufferSize == 0) {
38 DEBUG ((DEBUG_INFO,
"BufferSize=0\n"));
39 return (TcgResultFailureZeroSize);
43 CreateStruct->BufferSize = BufferSize;
44 CreateStruct->Buffer = Buffer;
45 CreateStruct->ComPacket =
NULL;
46 CreateStruct->CurPacket =
NULL;
47 CreateStruct->CurSubPacket =
NULL;
49 return (TcgResultSuccess);
69 NULL_CHECK (CreateStruct);
71 if ((CreateStruct->ComPacket !=
NULL) ||
72 (CreateStruct->CurPacket !=
NULL) ||
73 (CreateStruct->CurSubPacket !=
NULL)
78 "unexpected state: ComPacket=%p CurPacket=%p CurSubPacket=%p\n",
79 CreateStruct->ComPacket,
80 CreateStruct->CurPacket,
81 CreateStruct->CurSubPacket
83 return (TcgResultFailureInvalidAction);
87 DEBUG ((DEBUG_INFO,
"BufferSize=0x%X\n", CreateStruct->BufferSize));
88 return (TcgResultFailureBufferTooSmall);
92 CreateStruct->ComPacket->ComIDBE =
SwapBytes16 (ComId);
93 CreateStruct->ComPacket->ComIDExtensionBE =
SwapBytes16 (ComIdExtension);
95 return (TcgResultSuccess);
123 NULL_CHECK (CreateStruct);
127 if ((CreateStruct->ComPacket ==
NULL) ||
128 (CreateStruct->CurPacket !=
NULL) ||
129 (CreateStruct->CurSubPacket !=
NULL)
132 DEBUG ((DEBUG_INFO,
"unexpected state: ComPacket=%p CurPacket=%p CurSubPacket=%p\n", CreateStruct->ComPacket, CreateStruct->CurPacket, CreateStruct->CurSubPacket));
133 return (TcgResultFailureInvalidAction);
139 if ((
SwapBytes32 (CreateStruct->ComPacket->LengthBE) + AddedSize) > CreateStruct->BufferSize) {
140 DEBUG ((DEBUG_INFO,
"BufferSize=0x%X\n", CreateStruct->BufferSize));
141 return (TcgResultFailureBufferTooSmall);
144 CreateStruct->CurPacket = (
TCG_PACKET *)(CreateStruct->ComPacket->Payload +
SwapBytes32 (CreateStruct->ComPacket->LengthBE));
146 CreateStruct->CurPacket->TperSessionNumberBE =
SwapBytes32 (Tsn);
147 CreateStruct->CurPacket->HostSessionNumberBE =
SwapBytes32 (Hsn);
148 CreateStruct->CurPacket->SequenceNumberBE =
SwapBytes32 (SeqNumber);
149 CreateStruct->CurPacket->AckTypeBE =
SwapBytes16 (AckType);
150 CreateStruct->CurPacket->AcknowledgementBE =
SwapBytes32 (Ack);
152 CreateStruct->CurPacket->LengthBE = 0;
155 CreateStruct->ComPacket->LengthBE =
SwapBytes32 (
SwapBytes32 (CreateStruct->ComPacket->LengthBE) + AddedSize);
157 return (TcgResultSuccess);
177 NULL_CHECK (CreateStruct);
181 if ((CreateStruct->ComPacket ==
NULL) ||
182 (CreateStruct->CurPacket ==
NULL) ||
183 (CreateStruct->CurSubPacket !=
NULL)
186 DEBUG ((DEBUG_INFO,
"unexpected state: ComPacket=%p CurPacket=%p CurSubPacket=%p\n", CreateStruct->ComPacket, CreateStruct->CurPacket, CreateStruct->CurSubPacket));
187 return (TcgResultFailureInvalidAction);
192 if ((
SwapBytes32 (CreateStruct->ComPacket->LengthBE) + AddedSize) > CreateStruct->BufferSize) {
193 DEBUG ((DEBUG_INFO,
"BufferSize=0x%X\n", CreateStruct->BufferSize));
194 return (TcgResultFailureBufferTooSmall);
197 CreateStruct->CurSubPacket = (
TCG_SUB_PACKET *)(CreateStruct->CurPacket->Payload +
SwapBytes32 (CreateStruct->CurPacket->LengthBE));
198 CreateStruct->CurSubPacket->KindBE =
SwapBytes16 (Kind);
201 CreateStruct->CurSubPacket->LengthBE = 0;
204 CreateStruct->ComPacket->LengthBE =
SwapBytes32 (
SwapBytes32 (CreateStruct->ComPacket->LengthBE) + AddedSize);
205 CreateStruct->CurPacket->LengthBE =
SwapBytes32 (
SwapBytes32 (CreateStruct->CurPacket->LengthBE) + AddedSize);
207 return (TcgResultSuccess);
226 NULL_CHECK (CreateStruct);
230 if ((CreateStruct->ComPacket ==
NULL) ||
231 (CreateStruct->CurPacket ==
NULL) ||
232 (CreateStruct->CurSubPacket ==
NULL)
235 DEBUG ((DEBUG_INFO,
"unexpected state: ComPacket=%p CurPacket=%p CurSubPacket=%p\n", CreateStruct->ComPacket, CreateStruct->CurPacket, CreateStruct->CurSubPacket));
236 return (TcgResultFailureInvalidAction);
241 PadSize = TCG_SUBPACKET_ALIGNMENT - (
SwapBytes32 (CreateStruct->CurSubPacket->LengthBE) & (TCG_SUBPACKET_ALIGNMENT - 1));
243 if (PadSize == TCG_SUBPACKET_ALIGNMENT) {
247 if ((
SwapBytes32 (CreateStruct->ComPacket->LengthBE) + PadSize) > CreateStruct->BufferSize) {
248 DEBUG ((DEBUG_INFO,
"BufferSize=0x%X\n", CreateStruct->BufferSize));
249 return (TcgResultFailureBufferTooSmall);
252 CreateStruct->CurPacket->LengthBE =
SwapBytes32 (
SwapBytes32 (CreateStruct->CurPacket->LengthBE) + PadSize);
253 CreateStruct->ComPacket->LengthBE =
SwapBytes32 (
SwapBytes32 (CreateStruct->ComPacket->LengthBE) + PadSize);
255 CreateStruct->CurSubPacket =
NULL;
257 return (TcgResultSuccess);
273 NULL_CHECK (CreateStruct);
275 if ((CreateStruct->ComPacket ==
NULL) ||
276 (CreateStruct->CurPacket ==
NULL) ||
277 (CreateStruct->CurSubPacket !=
NULL)
280 DEBUG ((DEBUG_INFO,
"unexpected state: ComPacket=%p CurPacket=%p CurSubPacket=%p\n", CreateStruct->ComPacket, CreateStruct->CurPacket, CreateStruct->CurSubPacket));
281 return (TcgResultFailureInvalidAction);
284 CreateStruct->CurPacket =
NULL;
286 return (TcgResultSuccess);
304 NULL_CHECK (CreateStruct);
307 if ((CreateStruct->ComPacket ==
NULL) ||
308 (CreateStruct->CurPacket !=
NULL) ||
309 (CreateStruct->CurSubPacket !=
NULL)
312 DEBUG ((DEBUG_INFO,
"unexpected state: ComPacket=%p CurPacket=%p CurSubPacket=%p\n", CreateStruct->ComPacket, CreateStruct->CurPacket, CreateStruct->CurSubPacket));
313 return (TcgResultFailureInvalidAction);
316 *Size =
SwapBytes32 (CreateStruct->ComPacket->LengthBE) +
sizeof (*CreateStruct->ComPacket);
317 CreateStruct->ComPacket =
NULL;
319 return (TcgResultSuccess);
345 const UINT8 *DataBytes;
352 NULL_CHECK (CreateStruct);
354 if (((HeaderSize != 0) && (Header ==
NULL)) ||
355 ((DataSize != 0) && (Data ==
NULL))
358 DEBUG ((DEBUG_INFO,
"HeaderSize=0x%X Header=%p DataSize=0x%X Data=%p\n", HeaderSize, Header, DataSize, Data));
359 return (TcgResultFailureNullPointer);
362 if ((CreateStruct->ComPacket ==
NULL) ||
363 (CreateStruct->CurPacket ==
NULL) ||
364 (CreateStruct->CurSubPacket ==
NULL)
367 DEBUG ((DEBUG_INFO,
"unexpected state: ComPacket=%p CurPacket=%p CurSubPacket=%p\n", CreateStruct->ComPacket, CreateStruct->CurPacket, CreateStruct->CurSubPacket));
368 return (TcgResultFailureInvalidAction);
372 AddedSize = HeaderSize + DataSize;
373 if ((
SwapBytes32 (CreateStruct->ComPacket->LengthBE) + AddedSize) > CreateStruct->BufferSize) {
374 return (TcgResultFailureBufferTooSmall);
378 Dest = CreateStruct->ComPacket->Payload +
SwapBytes32 (CreateStruct->ComPacket->LengthBE);
380 switch (HeaderSize) {
384 CopyMem (Dest, Header, HeaderSize);
390 DEBUG ((DEBUG_INFO,
"unsupported HeaderSize=%u\n", HeaderSize));
391 return TcgResultFailure;
396 DataBytes = (
const UINT8 *)Data;
397 for (Index = 0; Index < DataSize; Index++) {
398 Dest[Index] = DataBytes[DataSize - 1 - Index];
401 CopyMem (Dest, Data, DataSize);
405 CreateStruct->ComPacket->LengthBE =
SwapBytes32 (
SwapBytes32 (CreateStruct->ComPacket->LengthBE) + AddedSize);
406 CreateStruct->CurPacket->LengthBE =
SwapBytes32 (
SwapBytes32 (CreateStruct->CurPacket->LengthBE) + AddedSize);
407 CreateStruct->CurSubPacket->LengthBE =
SwapBytes32 (
SwapBytes32 (CreateStruct->CurSubPacket->LengthBE) + AddedSize);
409 return (TcgResultSuccess);
452 const UINT8 *DataBytes;
458 NULL_CHECK (CreateStruct);
461 if (ByteOrInt == TCG_ATOM_TYPE_INTEGER) {
462 DEBUG ((DEBUG_INFO,
"0-Size integer not allowed\n"));
463 return TcgResultFailure;
471 DataBytes = (
const UINT8 *)Data;
472 if ((DataSize == 1) &&
473 (ByteOrInt == TCG_ATOM_TYPE_INTEGER) &&
474 (((SignOrCont != 0) && ((TCG_TOKEN_TINYATOM_SIGNED_MIN_VALUE <= *(INT8 *)Data) && (*(INT8 *)Data <= TCG_TOKEN_TINYATOM_SIGNED_MAX_VALUE))) ||
475 ((SignOrCont == 0) && ((*DataBytes <= TCG_TOKEN_TINYATOM_UNSIGNED_MAX_VALUE))))
478 TinyAtom.TinyAtomBits.IsZero = 0;
479 TinyAtom.TinyAtomBits.Sign = SignOrCont;
480 TinyAtom.TinyAtomBits.Data = *DataBytes & TCG_TOKEN_TINYATOM_UNSIGNED_MAX_VALUE;
484 if (DataSize <= TCG_TOKEN_SHORTATOM_MAX_BYTE_SIZE) {
485 ShortAtom.ShortAtomBits.IsOne = 1;
486 ShortAtom.ShortAtomBits.IsZero = 0;
487 ShortAtom.ShortAtomBits.ByteOrInt = ByteOrInt;
488 ShortAtom.ShortAtomBits.SignOrCont = SignOrCont;
489 ShortAtom.ShortAtomBits.Length = DataSize & 0x0F;
493 if (DataSize <= TCG_TOKEN_MEDIUMATOM_MAX_BYTE_SIZE) {
494 MediumAtom.MediumAtomBits.IsOne1 = 1;
495 MediumAtom.MediumAtomBits.IsOne2 = 1;
496 MediumAtom.MediumAtomBits.IsZero = 0;
497 MediumAtom.MediumAtomBits.ByteOrInt = ByteOrInt;
498 MediumAtom.MediumAtomBits.SignOrCont = SignOrCont;
499 MediumAtom.MediumAtomBits.LengthLow = DataSize & 0xFF;
500 MediumAtom.MediumAtomBits.LengthHigh = (DataSize >> TCG_MEDIUM_ATOM_LENGTH_HIGH_SHIFT) & TCG_MEDIUM_ATOM_LENGTH_HIGH_MASK;
504 LongAtom.LongAtomBits.IsOne1 = 1;
505 LongAtom.LongAtomBits.IsOne2 = 1;
506 LongAtom.LongAtomBits.IsOne3 = 1;
507 LongAtom.LongAtomBits.IsZero = 0;
508 LongAtom.LongAtomBits.ByteOrInt = ByteOrInt;
509 LongAtom.LongAtomBits.SignOrCont = SignOrCont;
510 LongAtom.LongAtomBits.LengthLow = DataSize & 0xFF;
511 LongAtom.LongAtomBits.LengthMid = (DataSize >> TCG_LONG_ATOM_LENGTH_MID_SHIFT) & 0xFF;
512 LongAtom.LongAtomBits.LengthHigh = (DataSize >> TCG_LONG_ATOM_LENGTH_HIGH_SHIFT) & 0xFF;
536 return TcgAddAtom (CreateStruct, Data, DataSize, TCG_ATOM_TYPE_BYTE, Continued ? 1 : 0);
556 BOOLEAN SignedInteger
559 const UINT8 *DataBytes;
560 UINT32 ActualDataSize;
561 BOOLEAN ValueIsNegative;
563 NULL_CHECK (CreateStruct);
567 DEBUG ((DEBUG_INFO,
"invalid DataSize=0\n"));
568 return TcgResultFailure;
571 DataBytes = (
const UINT8 *)Data;
575 ValueIsNegative = SignedInteger && DataBytes[DataSize - 1] & 0x80;
579 for (ActualDataSize = DataSize; ActualDataSize > 1; ActualDataSize--) {
581 if (ValueIsNegative && (DataBytes[ActualDataSize - 1] != 0xFF)) {
583 }
else if (!ValueIsNegative && (DataBytes[ActualDataSize - 1] != 0)) {
589 return TcgAddAtom (CreateStruct, Data, ActualDataSize, TCG_ATOM_TYPE_INTEGER, SignedInteger ? 1 : 0);
832 return TcgAddRawByte (CreateStruct, TCG_TOKEN_STARTTRANSACTION);
849 return TcgAddRawByte (CreateStruct, TCG_TOKEN_ENDTRANSACTION);
870 UINT32 ComPacketLength;
873 NULL_CHECK (ParseStruct);
877 return (TcgResultFailureBufferTooSmall);
882 ComPacketLength =
SwapBytes32 (ParseStruct->ComPacket->LengthBE);
885 DEBUG ((DEBUG_INFO,
"Buffer %u too small for ComPacket %u\n", BufferSize, ComPacketLength));
886 return (TcgResultFailureBufferTooSmall);
889 ParseStruct->BufferSize = BufferSize;
890 ParseStruct->Buffer = Buffer;
892 ParseStruct->CurPacket =
NULL;
893 ParseStruct->CurSubPacket =
NULL;
894 ParseStruct->CurPtr =
NULL;
897 if (ComPacketLength != 0) {
899 DEBUG ((DEBUG_INFO,
"ComPacket too small for Packet\n"));
900 return (TcgResultFailureBufferTooSmall);
903 ParseStruct->CurPacket = (
TCG_PACKET *)ParseStruct->ComPacket->Payload;
905 PacketLength =
SwapBytes32 (ParseStruct->CurPacket->LengthBE);
907 if (PacketLength > 0) {
909 DEBUG ((DEBUG_INFO,
"Packet too small for SubPacket\n"));
910 return (TcgResultFailureBufferTooSmall);
913 ParseStruct->CurSubPacket = (
TCG_SUB_PACKET *)ParseStruct->CurPacket->Payload;
919 return (TcgResultSuccess);
938 const UINT8 *EndOfSubPacket;
945 NULL_CHECK (ParseStruct);
946 NULL_CHECK (TcgToken);
948 if ((ParseStruct->ComPacket ==
NULL) ||
949 (ParseStruct->CurPacket ==
NULL) ||
950 (ParseStruct->CurSubPacket ==
NULL)
953 DEBUG ((DEBUG_INFO,
"unexpected state: ComPacket=%p CurPacket=%p CurSubPacket=%p\n", ParseStruct->ComPacket, ParseStruct->CurPacket, ParseStruct->CurSubPacket));
954 return TcgResultFailureInvalidAction;
958 if (ParseStruct->CurPtr ==
NULL) {
959 ParseStruct->CurPtr = ParseStruct->CurSubPacket->Payload;
962 EndOfSubPacket = ParseStruct->CurSubPacket->Payload +
SwapBytes32 (ParseStruct->CurSubPacket->LengthBE);
967 if (ParseStruct->CurPtr >= EndOfSubPacket) {
968 DEBUG ((DEBUG_INFO,
"ParseStruct->CurPtr >= EndOfSubPacket\n"));
969 return (TcgResultFailureEndBuffer);
972 Hdr = *ParseStruct->CurPtr;
973 TcgToken->HdrStart = ParseStruct->CurPtr;
978 TcgToken->Type = TcgTokenTypeTinyAtom;
983 if (TokenEnd >= EndOfSubPacket) {
984 DEBUG ((DEBUG_INFO,
"Tiny Atom TokenEnd >= EndOfSubPacket\n"));
985 return (TcgResultFailureEndBuffer);
989 else if ((0x80 <= Hdr) && (Hdr <= 0xBF)) {
992 TcgToken->Type = TcgTokenTypeShortAtom;
997 if (TokenEnd >= EndOfSubPacket) {
998 DEBUG ((DEBUG_INFO,
"Short Atom TokenEnd >= EndOfSubPacket\n"));
999 return (TcgResultFailureEndBuffer);
1003 else if ((0xC0 <= Hdr) && (Hdr <= 0xDF)) {
1005 return (TcgResultFailureEndBuffer);
1009 TcgToken->Type = TcgTokenTypeMediumAtom;
1011 ((TmpMed->MediumAtomBits.LengthHigh << TCG_MEDIUM_ATOM_LENGTH_HIGH_SHIFT) |
1012 TmpMed->MediumAtomBits.LengthLow);
1015 if (TokenEnd >= EndOfSubPacket) {
1016 DEBUG ((DEBUG_INFO,
"Medium Atom TokenEnd >= EndOfSubPacket\n"));
1017 return (TcgResultFailureEndBuffer);
1021 else if ((0xE0 <= Hdr) && (Hdr <= 0xE3)) {
1023 return (TcgResultFailureEndBuffer);
1027 TcgToken->Type = TcgTokenTypeLongAtom;
1030 ((TmpLong->LongAtomBits.LengthHigh << TCG_LONG_ATOM_LENGTH_HIGH_SHIFT) |
1031 (TmpLong->LongAtomBits.LengthMid << TCG_LONG_ATOM_LENGTH_MID_SHIFT) |
1032 TmpLong->LongAtomBits.LengthLow);
1035 if (TokenEnd >= EndOfSubPacket) {
1036 DEBUG ((DEBUG_INFO,
"Long Atom TokenEnd >= EndOfSubPacket\n"));
1037 return (TcgResultFailureEndBuffer);
1042 case TCG_TOKEN_STARTLIST:
1043 TcgToken->Type = TcgTokenTypeStartList;
1045 case TCG_TOKEN_ENDLIST:
1046 TcgToken->Type = TcgTokenTypeEndList;
1048 case TCG_TOKEN_STARTNAME:
1049 TcgToken->Type = TcgTokenTypeStartName;
1051 case TCG_TOKEN_ENDNAME:
1052 TcgToken->Type = TcgTokenTypeEndName;
1054 case TCG_TOKEN_CALL:
1055 TcgToken->Type = TcgTokenTypeCall;
1057 case TCG_TOKEN_ENDDATA:
1058 TcgToken->Type = TcgTokenTypeEndOfData;
1060 case TCG_TOKEN_ENDSESSION:
1061 TcgToken->Type = TcgTokenTypeEndOfSession;
1063 case TCG_TOKEN_STARTTRANSACTION:
1064 TcgToken->Type = TcgTokenTypeStartTransaction;
1066 case TCG_TOKEN_ENDTRANSACTION:
1067 TcgToken->Type = TcgTokenTypeEndTransaction;
1069 case TCG_TOKEN_EMPTY:
1070 TcgToken->Type = TcgTokenTypeEmptyAtom;
1073 DEBUG ((DEBUG_INFO,
"WARNING: reserved token Type 0x%02X\n", Hdr));
1074 TcgToken->Type = TcgTokenTypeReserved;
1078 ParseStruct->CurPtr++;
1079 TokenEnd = TcgToken->HdrStart + 1;
1083 ParseStruct->CurPtr = TokenEnd;
1084 return (TcgResultSuccess);
1103 UINT32 *HeaderLength,
1114 NULL_CHECK (TcgToken);
1115 NULL_CHECK (HeaderLength);
1116 NULL_CHECK (DataLength);
1117 NULL_CHECK (ByteOrInt);
1118 NULL_CHECK (SignOrCont);
1120 switch (TcgToken->Type) {
1121 case TcgTokenTypeTinyAtom:
1124 *ByteOrInt = TCG_ATOM_TYPE_INTEGER;
1125 *SignOrCont = TinyAtom->TinyAtomBits.Sign;
1128 return TcgResultSuccess;
1131 case TcgTokenTypeShortAtom:
1134 *ByteOrInt = ShortAtom->ShortAtomBits.ByteOrInt;
1135 *SignOrCont = ShortAtom->ShortAtomBits.SignOrCont;
1137 *DataLength = ShortAtom->ShortAtomBits.Length;
1138 return TcgResultSuccess;
1141 case TcgTokenTypeMediumAtom:
1144 *ByteOrInt = MediumAtom->MediumAtomBits.ByteOrInt;
1145 *SignOrCont = MediumAtom->MediumAtomBits.SignOrCont;
1147 *DataLength = (MediumAtom->MediumAtomBits.LengthHigh << TCG_MEDIUM_ATOM_LENGTH_HIGH_SHIFT) | MediumAtom->MediumAtomBits.LengthLow;
1148 return TcgResultSuccess;
1151 case TcgTokenTypeLongAtom:
1154 *ByteOrInt = LongAtom->LongAtomBits.ByteOrInt;
1155 *SignOrCont = LongAtom->LongAtomBits.SignOrCont;
1157 *DataLength = (LongAtom->LongAtomBits.LengthHigh << TCG_LONG_ATOM_LENGTH_HIGH_SHIFT) |
1158 (LongAtom->LongAtomBits.LengthMid << TCG_LONG_ATOM_LENGTH_MID_SHIFT) |
1159 LongAtom->LongAtomBits.LengthLow;
1160 return TcgResultSuccess;
1164 DEBUG ((DEBUG_INFO,
"Token Type is not simple atom (%d)\n", TcgToken->Type));
1165 return (TcgResultFailureInvalidType);
1193 NULL_CHECK (TcgToken);
1198 ERROR_CHECK (
TcgGetAtomInfo (TcgToken, &HdrLength, &DataLength, &ByteOrInt, &IsSigned));
1200 if (ByteOrInt != TCG_ATOM_TYPE_INTEGER) {
1201 DEBUG ((DEBUG_INFO,
"Invalid Type, expected integer not byte sequence\n"));
1202 return TcgResultFailureInvalidType;
1205 if (IsSigned != 0) {
1206 DEBUG ((DEBUG_INFO,
"Integer is signed, expected unsigned\n"));
1207 return TcgResultFailureInvalidType;
1212 if (TcgToken->Type == TcgTokenTypeTinyAtom) {
1214 *Value = TmpTiny->TinyAtomBits.Data;
1215 return TcgResultSuccess;
1218 if (DataLength >
sizeof (UINT64)) {
1219 DEBUG ((DEBUG_INFO,
"Length %d is greater than Size of UINT64\n", DataLength));
1220 return TcgResultFailureBufferTooSmall;
1224 Data = TcgToken->HdrStart + HdrLength;
1225 for (Index = 0; Index < DataLength; Index++) {
1226 *Value =
LShiftU64 (*Value, 8) | Data[Index];
1229 return TcgResultSuccess;
1252 if ((TcgToken ==
NULL) || (Length ==
NULL)) {
1257 if (
TcgGetAtomInfo (TcgToken, &HdrLength, Length, &ByteOrInt, &SignOrCont) != TcgResultSuccess) {
1258 DEBUG ((DEBUG_INFO,
"Failed to get simple token info\n"));
1262 if (ByteOrInt != TCG_ATOM_TYPE_BYTE) {
1263 DEBUG ((DEBUG_INFO,
"Invalid Type, expected byte sequence not integer\n"));
1267 return (TcgToken->HdrStart + HdrLength);
1294 if (Value64 > MAX_UINT8) {
1295 return TcgResultFailure;
1298 *Value = (UINT8)Value64;
1300 return TcgResultSuccess;
1327 if (Value64 > MAX_UINT16) {
1328 return TcgResultFailure;
1331 *Value = (UINT16)Value64;
1333 return TcgResultSuccess;
1360 if (Value64 > MAX_UINT32) {
1361 return TcgResultFailure;
1364 *Value = (UINT32)Value64;
1366 return TcgResultSuccess;
1389 return TcgResultSuccess;
1417 return TcgResultFailure;
1420 *Value = (BOOLEAN)Value64;
1422 return TcgResultSuccess;
1443 const UINT8 *ByteSeq;
1450 if (Length !=
sizeof (
TCG_UID)) {
1451 DEBUG ((DEBUG_INFO,
"Token Length %u != TCG_UID Size %u\n", Length, (UINT32)
sizeof (
TCG_UID)));
1452 return TcgResultFailure;
1455 ASSERT (ByteSeq !=
NULL);
1459 return TcgResultSuccess;
1487 return TcgResultFailure;
1491 return TcgResultSuccess;
1513 if (Tok.Type != Type) {
1514 DEBUG ((DEBUG_INFO,
"expected Type %u, got Type %u\n", Type, Tok.Type));
1515 return TcgResultFailure;
1518 return TcgResultSuccess;
UINT16 EFIAPI SwapBytes16(IN UINT16 Value)
UINT32 EFIAPI SwapBytes32(IN UINT32 Value)
UINT64 EFIAPI LShiftU64(IN UINT64 Operand, IN UINTN Count)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
#define DEBUG(Expression)
TCG_RESULT EFIAPI TcgGetNextToken(TCG_PARSE_STRUCT *ParseStruct, TCG_TOKEN *TcgToken)
TCG_RESULT EFIAPI TcgAddUINT16(TCG_CREATE_STRUCT *CreateStruct, UINT16 Value)
TCG_RESULT EFIAPI TcgGetNextBOOLEAN(TCG_PARSE_STRUCT *ParseStruct, BOOLEAN *Value)
TCG_RESULT EFIAPI TcgGetNextStartTransaction(TCG_PARSE_STRUCT *ParseStruct)
UINT8 *EFIAPI TcgGetTokenByteSequence(const TCG_TOKEN *TcgToken, UINT32 *Length)
TCG_RESULT EFIAPI TcgAddEndOfSession(TCG_CREATE_STRUCT *CreateStruct)
TCG_RESULT TcgAddAtom(TCG_CREATE_STRUCT *CreateStruct, const VOID *Data, UINT32 DataSize, UINT8 ByteOrInt, UINT8 SignOrCont)
TCG_RESULT EFIAPI TcgGetNextUINT8(TCG_PARSE_STRUCT *ParseStruct, UINT8 *Value)
TCG_RESULT EFIAPI TcgEndComPacket(TCG_CREATE_STRUCT *CreateStruct, UINT32 *Size)
TCG_RESULT EFIAPI TcgGetNextUINT64(TCG_PARSE_STRUCT *ParseStruct, UINT64 *Value)
TCG_RESULT EFIAPI TcgGetNextEndTransaction(TCG_PARSE_STRUCT *ParseStruct)
TCG_RESULT EFIAPI TcgAddEndTransaction(TCG_CREATE_STRUCT *CreateStruct)
TCG_RESULT EFIAPI TcgAddInteger(TCG_CREATE_STRUCT *CreateStruct, const VOID *Data, UINT32 DataSize, BOOLEAN SignedInteger)
TCG_RESULT EFIAPI TcgAddRawByte(TCG_CREATE_STRUCT *CreateStruct, UINT8 Byte)
TCG_RESULT EFIAPI TcgAddByteSequence(TCG_CREATE_STRUCT *CreateStruct, const VOID *Data, UINT32 DataSize, BOOLEAN Continued)
TCG_RESULT EFIAPI TcgStartPacket(TCG_CREATE_STRUCT *CreateStruct, UINT32 Tsn, UINT32 Hsn, UINT32 SeqNumber, UINT16 AckType, UINT32 Ack)
TCG_RESULT EFIAPI TcgGetNextEndOfSession(TCG_PARSE_STRUCT *ParseStruct)
TCG_RESULT EFIAPI TcgAddEndOfData(TCG_CREATE_STRUCT *CreateStruct)
TCG_RESULT EFIAPI TcgGetNextStartList(TCG_PARSE_STRUCT *ParseStruct)
TCG_RESULT EFIAPI TcgGetNextUINT32(TCG_PARSE_STRUCT *ParseStruct, UINT32 *Value)
TCG_RESULT EFIAPI TcgGetTokenUINT64(const TCG_TOKEN *TcgToken, UINT64 *Value)
TCG_RESULT EFIAPI TcgAddEndList(TCG_CREATE_STRUCT *CreateStruct)
TCG_RESULT EFIAPI TcgGetNextCall(TCG_PARSE_STRUCT *ParseStruct)
TCG_RESULT EFIAPI TcgAddTcgUid(TCG_CREATE_STRUCT *CreateStruct, TCG_UID Uid)
TCG_RESULT EFIAPI TcgGetNextEndName(TCG_PARSE_STRUCT *ParseStruct)
TCG_RESULT EFIAPI TcgGetNextTcgUid(TCG_PARSE_STRUCT *ParseStruct, TCG_UID *Uid)
TCG_RESULT EFIAPI TcgGetNextByteSequence(TCG_PARSE_STRUCT *ParseStruct, const VOID **Data, UINT32 *Length)
TCG_RESULT EFIAPI TcgGetNextEndList(TCG_PARSE_STRUCT *ParseStruct)
TCG_RESULT EFIAPI TcgAddUINT32(TCG_CREATE_STRUCT *CreateStruct, UINT32 Value)
TCG_RESULT EFIAPI TcgGetAtomInfo(const TCG_TOKEN *TcgToken, UINT32 *HeaderLength, UINT32 *DataLength, UINT8 *ByteOrInt, UINT8 *SignOrCont)
TCG_RESULT EFIAPI TcgGetNextStartName(TCG_PARSE_STRUCT *ParseStruct)
TCG_RESULT EFIAPI TcgAddStartTransaction(TCG_CREATE_STRUCT *CreateStruct)
TCG_RESULT EFIAPI TcgEndSubPacket(TCG_CREATE_STRUCT *CreateStruct)
TCG_RESULT EFIAPI TcgInitTcgCreateStruct(TCG_CREATE_STRUCT *CreateStruct, VOID *Buffer, UINT32 BufferSize)
TCG_RESULT EFIAPI TcgAddStartList(TCG_CREATE_STRUCT *CreateStruct)
TCG_RESULT EFIAPI TcgInitTcgParseStruct(TCG_PARSE_STRUCT *ParseStruct, const VOID *Buffer, UINT32 BufferSize)
TCG_RESULT EFIAPI TcgAddCall(TCG_CREATE_STRUCT *CreateStruct)
TCG_RESULT EFIAPI TcgGetNextUINT16(TCG_PARSE_STRUCT *ParseStruct, UINT16 *Value)
TCG_RESULT EFIAPI TcgStartSubPacket(TCG_CREATE_STRUCT *CreateStruct, UINT16 Kind)
TCG_RESULT EFIAPI TcgStartComPacket(TCG_CREATE_STRUCT *CreateStruct, UINT16 ComId, UINT16 ComIdExtension)
TCG_RESULT EFIAPI TcgEndPacket(TCG_CREATE_STRUCT *CreateStruct)
TCG_RESULT EFIAPI TcgGetNextTokenType(TCG_PARSE_STRUCT *ParseStruct, TCG_TOKEN_TYPE Type)
TCG_RESULT TcgAddRawTokenData(TCG_CREATE_STRUCT *CreateStruct, const VOID *Header, UINT8 HeaderSize, const VOID *Data, UINT32 DataSize, BOOLEAN ByteSwapData)
TCG_RESULT EFIAPI TcgAddUINT64(TCG_CREATE_STRUCT *CreateStruct, UINT64 Value)
TCG_RESULT EFIAPI TcgAddEndName(TCG_CREATE_STRUCT *CreateStruct)
TCG_RESULT EFIAPI TcgGetNextEndOfData(TCG_PARSE_STRUCT *ParseStruct)
TCG_RESULT EFIAPI TcgAddStartName(TCG_CREATE_STRUCT *CreateStruct)
TCG_RESULT EFIAPI TcgAddBOOLEAN(TCG_CREATE_STRUCT *CreateStruct, BOOLEAN Value)
TCG_RESULT EFIAPI TcgAddUINT8(TCG_CREATE_STRUCT *CreateStruct, UINT8 Value)
UINT64 TCG_UID
UID in host native byte order.