2 Provide functions to provide tcg storage core spec related functions.
4 Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
9 #include <Library/TcgStorageCoreLib.h>
11 #include <Library/BaseLib.h>
12 #include <Library/BaseMemoryLib.h>
13 #include <Library/DebugLib.h>
14 //#include <Library/PrintLib.h>
17 Required to be called before calling any other Tcg functions with the TCG_CREATE_STRUCT.
18 Initializes the packet variables to NULL. Additionally, the buffer will be memset.
20 @param [in/out] CreateStruct Structure to initialize
21 @param [in] Buffer Buffer allocated by client of library. It will contain the Tcg encoded packet. This cannot be null.
22 @param [in] BufferSize Size of buffer provided. It cannot be 0.
24 @retval Return the action result.
28 TcgInitTcgCreateStruct(
29 TCG_CREATE_STRUCT
*CreateStruct
,
34 NULL_CHECK(CreateStruct
);
37 if (BufferSize
== 0) {
38 DEBUG ((DEBUG_INFO
, "BufferSize=0\n"));
39 return (TcgResultFailureZeroSize
);
42 ZeroMem(Buffer
, BufferSize
);
43 CreateStruct
->BufferSize
= BufferSize
;
44 CreateStruct
->Buffer
= Buffer
;
45 CreateStruct
->ComPacket
= NULL
;
46 CreateStruct
->CurPacket
= NULL
;
47 CreateStruct
->CurSubPacket
= NULL
;
49 return (TcgResultSuccess
);
54 Encodes the ComPacket header to the data structure.
56 @param[in/out] CreateStruct Structure to initialize
57 @param[in] ComId ComID of the Tcg ComPacket.
58 @param[in] ComIdExtension ComID Extension of the Tcg ComPacket.
64 TCG_CREATE_STRUCT
*CreateStruct
,
69 NULL_CHECK(CreateStruct
);
71 if (CreateStruct
->ComPacket
!= NULL
||
72 CreateStruct
->CurPacket
!= NULL
||
73 CreateStruct
->CurSubPacket
!= NULL
75 DEBUG ((DEBUG_INFO
, "unexpected state: ComPacket=%p CurPacket=%p CurSubPacket=%p\n", CreateStruct
->ComPacket
, CreateStruct
->CurPacket
,
76 CreateStruct
->CurSubPacket
));
77 return (TcgResultFailureInvalidAction
);
80 if (sizeof(TCG_COM_PACKET
) > CreateStruct
->BufferSize
) {
81 DEBUG ((DEBUG_INFO
, "BufferSize=0x%X\n", CreateStruct
->BufferSize
));
82 return (TcgResultFailureBufferTooSmall
);
85 CreateStruct
->ComPacket
= (TCG_COM_PACKET
*)CreateStruct
->Buffer
;
86 CreateStruct
->ComPacket
->ComIDBE
= SwapBytes16(ComId
);
87 CreateStruct
->ComPacket
->ComIDExtensionBE
= SwapBytes16(ComIdExtension
);
89 return (TcgResultSuccess
);
94 Starts a new ComPacket in the Data structure.
96 @param [in/out] CreateStruct Structure used to add Tcg Packet
97 @param[in] Tsn Packet Tper session number
98 @param[in] Hsn Packet Host session number
99 @param[in] SeqNumber Packet Sequence Number
100 @param[in] AckType Packet Acknowledge Type
101 @param[in] Ack Packet Acknowledge
107 TCG_CREATE_STRUCT
*CreateStruct
,
116 NULL_CHECK(CreateStruct
);
120 if (CreateStruct
->ComPacket
== NULL
||
121 CreateStruct
->CurPacket
!= NULL
||
122 CreateStruct
->CurSubPacket
!= NULL
124 DEBUG ((DEBUG_INFO
, "unexpected state: ComPacket=%p CurPacket=%p CurSubPacket=%p\n", CreateStruct
->ComPacket
, CreateStruct
->CurPacket
, CreateStruct
->CurSubPacket
));
125 return (TcgResultFailureInvalidAction
);
128 // update TCG_COM_PACKET and packet lengths
129 AddedSize
= sizeof(TCG_PACKET
);
131 if ((SwapBytes32(CreateStruct
->ComPacket
->LengthBE
) + AddedSize
) > CreateStruct
->BufferSize
) {
132 DEBUG ((DEBUG_INFO
, "BufferSize=0x%X\n", CreateStruct
->BufferSize
));
133 return (TcgResultFailureBufferTooSmall
);
136 CreateStruct
->CurPacket
= (TCG_PACKET
*)(CreateStruct
->ComPacket
->Payload
+ SwapBytes32(CreateStruct
->ComPacket
->LengthBE
));
138 CreateStruct
->CurPacket
->TperSessionNumberBE
= SwapBytes32( Tsn
);
139 CreateStruct
->CurPacket
->HostSessionNumberBE
= SwapBytes32( Hsn
);
140 CreateStruct
->CurPacket
->SequenceNumberBE
= SwapBytes32( SeqNumber
);
141 CreateStruct
->CurPacket
->AckTypeBE
= SwapBytes16( AckType
);
142 CreateStruct
->CurPacket
->AcknowledgementBE
= SwapBytes32( Ack
);
144 CreateStruct
->CurPacket
->LengthBE
= 0;
146 // update TCG_COM_PACKET Length for next pointer
147 CreateStruct
->ComPacket
->LengthBE
= SwapBytes32( SwapBytes32(CreateStruct
->ComPacket
->LengthBE
) + AddedSize
);
149 return (TcgResultSuccess
);
154 Starts a new SubPacket in the Data structure.
156 @param[in/out] CreateStruct Structure used to start Tcg SubPacket
157 @param[in] Kind SubPacket kind
163 TCG_CREATE_STRUCT
*CreateStruct
,
169 NULL_CHECK(CreateStruct
);
173 if (CreateStruct
->ComPacket
== NULL
||
174 CreateStruct
->CurPacket
== NULL
||
175 CreateStruct
->CurSubPacket
!= NULL
177 DEBUG ((DEBUG_INFO
, "unexpected state: ComPacket=%p CurPacket=%p CurSubPacket=%p\n", CreateStruct
->ComPacket
, CreateStruct
->CurPacket
, CreateStruct
->CurSubPacket
));
178 return (TcgResultFailureInvalidAction
);
181 AddedSize
= sizeof(TCG_SUB_PACKET
);
183 if ((SwapBytes32(CreateStruct
->ComPacket
->LengthBE
) + AddedSize
) > CreateStruct
->BufferSize
) {
184 DEBUG ((DEBUG_INFO
, "BufferSize=0x%X\n", CreateStruct
->BufferSize
));
185 return (TcgResultFailureBufferTooSmall
);
188 CreateStruct
->CurSubPacket
= (TCG_SUB_PACKET
*)(CreateStruct
->CurPacket
->Payload
+ SwapBytes32(CreateStruct
->CurPacket
->LengthBE
));
189 CreateStruct
->CurSubPacket
->KindBE
= SwapBytes16(Kind
);
192 CreateStruct
->CurSubPacket
->LengthBE
= 0;
194 // update TCG_COM_PACKET and packet lengths
195 CreateStruct
->ComPacket
->LengthBE
= SwapBytes32(SwapBytes32(CreateStruct
->ComPacket
->LengthBE
) + AddedSize
);
196 CreateStruct
->CurPacket
->LengthBE
= SwapBytes32(SwapBytes32(CreateStruct
->CurPacket
->LengthBE
) + AddedSize
);
198 return (TcgResultSuccess
);
203 Ends the current SubPacket in the Data structure. This function will also perform the 4-byte padding
204 required for Subpackets.
206 @param[in/out] CreateStruct Structure used to end the current Tcg SubPacket
212 TCG_CREATE_STRUCT
*CreateStruct
217 NULL_CHECK(CreateStruct
);
221 if (CreateStruct
->ComPacket
== NULL
||
222 CreateStruct
->CurPacket
== NULL
||
223 CreateStruct
->CurSubPacket
== NULL
225 DEBUG ((DEBUG_INFO
, "unexpected state: ComPacket=%p CurPacket=%p CurSubPacket=%p\n", CreateStruct
->ComPacket
, CreateStruct
->CurPacket
, CreateStruct
->CurSubPacket
));
226 return (TcgResultFailureInvalidAction
);
229 // align to 4-byte boundaries, so shift padding
230 // pad Size does not apply to subpacket Length
231 PadSize
= TCG_SUBPACKET_ALIGNMENT
- (SwapBytes32(CreateStruct
->CurSubPacket
->LengthBE
) & (TCG_SUBPACKET_ALIGNMENT
- 1));
233 if (PadSize
== TCG_SUBPACKET_ALIGNMENT
) {
237 if ((SwapBytes32(CreateStruct
->ComPacket
->LengthBE
) + PadSize
) > CreateStruct
->BufferSize
) {
238 DEBUG ((DEBUG_INFO
, "BufferSize=0x%X\n", CreateStruct
->BufferSize
));
239 return (TcgResultFailureBufferTooSmall
);
242 CreateStruct
->CurPacket
->LengthBE
= SwapBytes32(SwapBytes32(CreateStruct
->CurPacket
->LengthBE
) + PadSize
);
243 CreateStruct
->ComPacket
->LengthBE
= SwapBytes32(SwapBytes32(CreateStruct
->ComPacket
->LengthBE
) + PadSize
);
245 CreateStruct
->CurSubPacket
= NULL
;
247 return (TcgResultSuccess
);
252 Ends the current Packet in the Data structure.
254 @param[in/out] CreateStruct Structure used to end the current Tcg Packet
260 TCG_CREATE_STRUCT
*CreateStruct
263 NULL_CHECK(CreateStruct
);
265 if (CreateStruct
->ComPacket
== NULL
||
266 CreateStruct
->CurPacket
== NULL
||
267 CreateStruct
->CurSubPacket
!= NULL
269 DEBUG ((DEBUG_INFO
, "unexpected state: ComPacket=%p CurPacket=%p CurSubPacket=%p\n", CreateStruct
->ComPacket
, CreateStruct
->CurPacket
, CreateStruct
->CurSubPacket
));
270 return (TcgResultFailureInvalidAction
);
273 CreateStruct
->CurPacket
= NULL
;
275 return (TcgResultSuccess
);
280 Ends the ComPacket in the Data structure and ret
282 @param [in/out] CreateStruct Structure used to end the Tcg ComPacket
283 @param [in/out] Size Describes the Size of the entire ComPacket (Header and payload). Filled out by function.
289 TCG_CREATE_STRUCT
*CreateStruct
,
293 NULL_CHECK(CreateStruct
);
296 if (CreateStruct
->ComPacket
== NULL
||
297 CreateStruct
->CurPacket
!= NULL
||
298 CreateStruct
->CurSubPacket
!= NULL
300 DEBUG ((DEBUG_INFO
, "unexpected state: ComPacket=%p CurPacket=%p CurSubPacket=%p\n", CreateStruct
->ComPacket
, CreateStruct
->CurPacket
, CreateStruct
->CurSubPacket
));
301 return (TcgResultFailureInvalidAction
);
304 *Size
= SwapBytes32(CreateStruct
->ComPacket
->LengthBE
) + sizeof(*CreateStruct
->ComPacket
);
305 CreateStruct
->ComPacket
= NULL
;
307 return (TcgResultSuccess
);
311 Adds raw Data with optional Header
313 @param CreateStruct The create structure.
314 @param Header The header structure.
315 @param HeaderSize The header size.
316 @param Data The data need to add.
317 @param DataSize The data size.
318 @param ByteSwapData Whether byte or swap data.
323 TCG_CREATE_STRUCT
*CreateStruct
,
333 const UINT8
* DataBytes
;
340 NULL_CHECK(CreateStruct
);
342 if ((HeaderSize
!= 0 && Header
== NULL
) ||
343 (DataSize
!= 0 && Data
== NULL
)
345 DEBUG ((DEBUG_INFO
, "HeaderSize=0x%X Header=%p DataSize=0x%X Data=%p\n", HeaderSize
, Header
, DataSize
, Data
));
346 return (TcgResultFailureNullPointer
);
349 if (CreateStruct
->ComPacket
== NULL
||
350 CreateStruct
->CurPacket
== NULL
||
351 CreateStruct
->CurSubPacket
== NULL
353 DEBUG ((DEBUG_INFO
, "unexpected state: ComPacket=%p CurPacket=%p CurSubPacket=%p\n", CreateStruct
->ComPacket
, CreateStruct
->CurPacket
, CreateStruct
->CurSubPacket
));
354 return (TcgResultFailureInvalidAction
);
357 // verify there is enough Buffer Size
358 AddedSize
= HeaderSize
+ DataSize
;
359 if ((SwapBytes32(CreateStruct
->ComPacket
->LengthBE
) + AddedSize
) > CreateStruct
->BufferSize
) {
360 return (TcgResultFailureBufferTooSmall
);
363 // Get a pointer to where the new bytes should go
364 Dest
= CreateStruct
->ComPacket
->Payload
+ SwapBytes32(CreateStruct
->ComPacket
->LengthBE
);
366 switch (HeaderSize
) {
367 case sizeof(TCG_SIMPLE_TOKEN_SHORT_ATOM
):
368 case sizeof(TCG_SIMPLE_TOKEN_MEDIUM_ATOM
):
369 case sizeof(TCG_SIMPLE_TOKEN_LONG_ATOM
):
370 CopyMem(Dest
, Header
, HeaderSize
);
372 case 0: // no Header is valid
374 // invalid Header Size
376 DEBUG ((DEBUG_INFO
, "unsupported HeaderSize=%u\n", HeaderSize
));
377 return TcgResultFailure
;
380 // copy the Data bytes
382 DataBytes
= (const UINT8
*)Data
;
383 for (Index
= 0; Index
< DataSize
; Index
++) {
384 Dest
[Index
] = DataBytes
[DataSize
- 1 - Index
];
387 CopyMem(Dest
, Data
, DataSize
);
390 // Update all the packet sizes
391 CreateStruct
->ComPacket
->LengthBE
= SwapBytes32(SwapBytes32(CreateStruct
->ComPacket
->LengthBE
) + AddedSize
);
392 CreateStruct
->CurPacket
->LengthBE
= SwapBytes32(SwapBytes32(CreateStruct
->CurPacket
->LengthBE
) + AddedSize
);
393 CreateStruct
->CurSubPacket
->LengthBE
= SwapBytes32(SwapBytes32(CreateStruct
->CurSubPacket
->LengthBE
) + AddedSize
);
395 return (TcgResultSuccess
);
400 Adds a single raw token byte to the Data structure.
402 @param[in/out] CreateStruct Structure used to add the byte
403 @param[in] Byte Byte to add
409 TCG_CREATE_STRUCT
*CreateStruct
,
413 return TcgAddRawTokenData(CreateStruct
, NULL
, 0, &Byte
, 1, FALSE
);
418 simple tokens - atoms: tiny, short, medium, long and empty atoms.
419 tiny atom can be a signed or unsigned integer.
420 short, medium, long can be a signed or unsigned integer OR a complete or non-final byte sequence.
422 @param CreateStruct The create structure.
423 @param Data The data need to add.
424 @param DataSize The data size.
425 @param ByteOrInt, Data format is byte or int.
426 @param SignOrCont sign or cont.
432 TCG_CREATE_STRUCT
*CreateStruct
,
439 const UINT8
* DataBytes
;
440 TCG_SIMPLE_TOKEN_TINY_ATOM TinyAtom
;
441 TCG_SIMPLE_TOKEN_SHORT_ATOM ShortAtom
;
442 TCG_SIMPLE_TOKEN_MEDIUM_ATOM MediumAtom
;
443 TCG_SIMPLE_TOKEN_LONG_ATOM LongAtom
;
445 NULL_CHECK(CreateStruct
);
448 if (ByteOrInt
== TCG_ATOM_TYPE_INTEGER
) {
449 DEBUG ((DEBUG_INFO
, "0-Size integer not allowed\n"));
450 return TcgResultFailure
;
453 // if DataSize != 0, Data must be valid
457 // encode Data using the shortest possible atom
458 DataBytes
= (const UINT8
*)Data
;
459 if ((DataSize
== 1) &&
460 (ByteOrInt
== TCG_ATOM_TYPE_INTEGER
) &&
461 ((SignOrCont
!= 0 && ((TCG_TOKEN_TINYATOM_SIGNED_MIN_VALUE
<= *(INT8
*)Data
) && (*(INT8
*)Data
<= TCG_TOKEN_TINYATOM_SIGNED_MAX_VALUE
))) ||
462 (SignOrCont
== 0 && ((*DataBytes
<= TCG_TOKEN_TINYATOM_UNSIGNED_MAX_VALUE
))))
464 TinyAtom
.TinyAtomBits
.IsZero
= 0;
465 TinyAtom
.TinyAtomBits
.Sign
= SignOrCont
;
466 TinyAtom
.TinyAtomBits
.Data
= *DataBytes
& TCG_TOKEN_TINYATOM_UNSIGNED_MAX_VALUE
;
467 return TcgAddRawTokenData(CreateStruct
, NULL
, 0, (UINT8
*)&TinyAtom
, sizeof(TCG_SIMPLE_TOKEN_TINY_ATOM
), FALSE
);
470 if (DataSize
<= TCG_TOKEN_SHORTATOM_MAX_BYTE_SIZE
) {
471 ShortAtom
.ShortAtomBits
.IsOne
= 1;
472 ShortAtom
.ShortAtomBits
.IsZero
= 0;
473 ShortAtom
.ShortAtomBits
.ByteOrInt
= ByteOrInt
;
474 ShortAtom
.ShortAtomBits
.SignOrCont
= SignOrCont
;
475 ShortAtom
.ShortAtomBits
.Length
= DataSize
& 0x0F;
476 return TcgAddRawTokenData(CreateStruct
, &ShortAtom
, sizeof(TCG_SIMPLE_TOKEN_SHORT_ATOM
), Data
, DataSize
, ByteOrInt
== TCG_ATOM_TYPE_INTEGER
);
479 if (DataSize
<= TCG_TOKEN_MEDIUMATOM_MAX_BYTE_SIZE
) {
480 MediumAtom
.MediumAtomBits
.IsOne1
= 1;
481 MediumAtom
.MediumAtomBits
.IsOne2
= 1;
482 MediumAtom
.MediumAtomBits
.IsZero
= 0;
483 MediumAtom
.MediumAtomBits
.ByteOrInt
= ByteOrInt
;
484 MediumAtom
.MediumAtomBits
.SignOrCont
= SignOrCont
;
485 MediumAtom
.MediumAtomBits
.LengthLow
= DataSize
& 0xFF;
486 MediumAtom
.MediumAtomBits
.LengthHigh
= (DataSize
>> TCG_MEDIUM_ATOM_LENGTH_HIGH_SHIFT
) & TCG_MEDIUM_ATOM_LENGTH_HIGH_MASK
;
487 return TcgAddRawTokenData(CreateStruct
, &MediumAtom
, sizeof(TCG_SIMPLE_TOKEN_MEDIUM_ATOM
), Data
, DataSize
, ByteOrInt
== TCG_ATOM_TYPE_INTEGER
);
490 LongAtom
.LongAtomBits
.IsOne1
= 1;
491 LongAtom
.LongAtomBits
.IsOne2
= 1;
492 LongAtom
.LongAtomBits
.IsOne3
= 1;
493 LongAtom
.LongAtomBits
.IsZero
= 0;
494 LongAtom
.LongAtomBits
.ByteOrInt
= ByteOrInt
;
495 LongAtom
.LongAtomBits
.SignOrCont
= SignOrCont
;
496 LongAtom
.LongAtomBits
.LengthLow
= DataSize
& 0xFF;
497 LongAtom
.LongAtomBits
.LengthMid
= (DataSize
>> TCG_LONG_ATOM_LENGTH_MID_SHIFT
) & 0xFF;
498 LongAtom
.LongAtomBits
.LengthHigh
= (DataSize
>> TCG_LONG_ATOM_LENGTH_HIGH_SHIFT
) & 0xFF;
499 return TcgAddRawTokenData(CreateStruct
, &LongAtom
, sizeof(TCG_SIMPLE_TOKEN_LONG_ATOM
), Data
, DataSize
, ByteOrInt
== TCG_ATOM_TYPE_INTEGER
);
504 Adds the Data parameter as a byte sequence to the Data structure.
506 @param[in/out] CreateStruct Structure used to add the byte sequence
507 @param[in] Data Byte sequence that will be encoded and copied into Data structure
508 @param[in] DataSize Length of Data provided
509 @param[in] Continued TRUE if byte sequence is continued or
510 FALSE if the Data contains the entire byte sequence to be encoded
516 TCG_CREATE_STRUCT
*CreateStruct
,
522 return TcgAddAtom(CreateStruct
, Data
, DataSize
, TCG_ATOM_TYPE_BYTE
, Continued
? 1 : 0);
527 Adds an arbitrary-Length integer to the Data structure.
528 The integer will be encoded using the shortest possible atom.
530 @param[in/out] CreateStruct Structure used to add the integer
531 @param[in] Data Integer in host byte order that will be encoded and copied into Data structure
532 @param[in] DataSize Length in bytes of the Data provided
533 @param[in] SignedInteger TRUE if the integer is signed or FALSE if the integer is unsigned
539 TCG_CREATE_STRUCT
*CreateStruct
,
542 BOOLEAN SignedInteger
545 const UINT8
* DataBytes
;
546 UINT32 ActualDataSize
;
547 BOOLEAN ValueIsNegative
;
549 NULL_CHECK(CreateStruct
);
553 DEBUG ((DEBUG_INFO
, "invalid DataSize=0\n"));
554 return TcgResultFailure
;
557 DataBytes
= (const UINT8
*)Data
;
559 // integer should be represented by smallest atom possible
560 // so calculate real Data Size
561 ValueIsNegative
= SignedInteger
&& DataBytes
[ DataSize
- 1 ] & 0x80;
563 // assumes native Data is little endian
564 // shorten Data to smallest byte representation
565 for (ActualDataSize
= DataSize
; ActualDataSize
> 1; ActualDataSize
--) {
566 // ignore sign extended FFs
567 if (ValueIsNegative
&& (DataBytes
[ActualDataSize
- 1] != 0xFF)) {
569 } else if (!ValueIsNegative
&& (DataBytes
[ActualDataSize
- 1] != 0)) {
570 // ignore extended 00s
575 return TcgAddAtom(CreateStruct
, Data
, ActualDataSize
, TCG_ATOM_TYPE_INTEGER
, SignedInteger
? 1 : 0);
579 Adds an 8-bit unsigned integer to the Data structure.
581 @param[in/out] CreateStruct Structure used to add the integer
582 @param[in] Value Integer Value to add
588 TCG_CREATE_STRUCT
*CreateStruct
,
592 return TcgAddInteger(CreateStruct
, &Value
, sizeof(Value
), FALSE
);
597 Adds a 16-bit unsigned integer to the Data structure.
599 @param[in/out] CreateStruct Structure used to add the integer
600 @param[in] Value Integer Value to add
606 TCG_CREATE_STRUCT
*CreateStruct
,
610 return TcgAddInteger(CreateStruct
, &Value
, sizeof(Value
), FALSE
);
615 Adds a 32-bit unsigned integer to the Data structure.
617 @param[in/out] CreateStruct Structure used to add the integer
618 @param[in] Value Integer Value to add
624 TCG_CREATE_STRUCT
*CreateStruct
,
628 return TcgAddInteger(CreateStruct
, &Value
, sizeof(Value
), FALSE
);
634 Adds a 64-bit unsigned integer to the Data structure.
636 @param[in/out] CreateStruct Structure used to add the integer
637 @param[in] Value Integer Value to add
643 TCG_CREATE_STRUCT
*CreateStruct
,
647 return TcgAddInteger(CreateStruct
, &Value
, sizeof(Value
), FALSE
);
651 Adds a BOOLEAN to the Data structure.
653 @param[in/out] CreateStruct Structure used to add the integer
654 @param[in] Value BOOLEAN Value to add
660 TCG_CREATE_STRUCT
*CreateStruct
,
664 return TcgAddInteger(CreateStruct
, &Value
, sizeof(Value
), FALSE
);
670 @param [in/out] CreateStruct Structure used to add the integer
671 @param Uid Input uid info.
673 @retval return the action result.
679 TCG_CREATE_STRUCT
*CreateStruct
,
683 return TcgAddByteSequence(CreateStruct
, &Uid
, sizeof(TCG_UID
), FALSE
);
689 @param [in/out] CreateStruct Structure used to add the integer
691 @retval return the action result.
697 TCG_CREATE_STRUCT
*CreateStruct
700 return TcgAddRawByte(CreateStruct
, TCG_TOKEN_STARTLIST
);
706 @param [in/out] CreateStruct Structure used to add the integer
708 @retval return the action result.
714 TCG_CREATE_STRUCT
*CreateStruct
717 return TcgAddRawByte(CreateStruct
, TCG_TOKEN_ENDLIST
);
723 @param [in/out] CreateStruct Structure used to add the integer
725 @retval return the action result.
731 TCG_CREATE_STRUCT
*CreateStruct
734 return TcgAddRawByte(CreateStruct
, TCG_TOKEN_STARTNAME
);
740 @param [in/out] CreateStruct Structure used to add the integer
742 @retval return the action result.
748 TCG_CREATE_STRUCT
*CreateStruct
751 return TcgAddRawByte(CreateStruct
, TCG_TOKEN_ENDNAME
);
757 @param [in/out] CreateStruct Structure used to add the integer
759 @retval return the action result.
765 TCG_CREATE_STRUCT
*CreateStruct
768 return TcgAddRawByte(CreateStruct
, TCG_TOKEN_CALL
);
774 @param [in/out] CreateStruct Structure used to add the integer
776 @retval return the action result.
782 TCG_CREATE_STRUCT
*CreateStruct
785 return TcgAddRawByte(CreateStruct
, TCG_TOKEN_ENDDATA
);
791 @param [in/out] CreateStruct Structure used to add the integer
793 @retval return the action result.
799 TCG_CREATE_STRUCT
*CreateStruct
802 return TcgAddRawByte(CreateStruct
, TCG_TOKEN_ENDSESSION
);
806 Add start transaction.
808 @param [in/out] CreateStruct Structure used to add the integer
810 @retval return the action result.
815 TcgAddStartTransaction(
816 TCG_CREATE_STRUCT
*CreateStruct
819 return TcgAddRawByte(CreateStruct
, TCG_TOKEN_STARTTRANSACTION
);
825 @param [in/out] CreateStruct Structure used to add the integer
827 @retval return the action result.
832 TcgAddEndTransaction(
833 TCG_CREATE_STRUCT
*CreateStruct
836 return TcgAddRawByte(CreateStruct
, TCG_TOKEN_ENDTRANSACTION
);
840 Initial the tcg parse stucture.
842 @param ParseStruct Input parse structure.
843 @param Buffer Input buffer data.
844 @param BufferSize Input buffer size.
846 @retval return the action result.
851 TcgInitTcgParseStruct(
852 TCG_PARSE_STRUCT
*ParseStruct
,
857 UINT32 ComPacketLength
;
860 NULL_CHECK(ParseStruct
);
863 if (BufferSize
< sizeof(TCG_COM_PACKET
)) {
864 return (TcgResultFailureBufferTooSmall
);
867 ParseStruct
->ComPacket
= (TCG_COM_PACKET
*)Buffer
;
869 ComPacketLength
= SwapBytes32(ParseStruct
->ComPacket
->LengthBE
);
871 if ((BufferSize
- sizeof(TCG_COM_PACKET
)) < ComPacketLength
) {
872 DEBUG ((DEBUG_INFO
, "Buffer %u too small for ComPacket %u\n", BufferSize
, ComPacketLength
));
873 return (TcgResultFailureBufferTooSmall
);
876 ParseStruct
->BufferSize
= BufferSize
;
877 ParseStruct
->Buffer
= Buffer
;
879 ParseStruct
->CurPacket
= NULL
;
880 ParseStruct
->CurSubPacket
= NULL
;
881 ParseStruct
->CurPtr
= NULL
;
883 // if payload > 0, then must have a packet
884 if (ComPacketLength
!= 0) {
885 if (ComPacketLength
< sizeof(TCG_PACKET
)) {
886 DEBUG ((DEBUG_INFO
, "ComPacket too small for Packet\n"));
887 return (TcgResultFailureBufferTooSmall
);
889 ParseStruct
->CurPacket
= (TCG_PACKET
*)ParseStruct
->ComPacket
->Payload
;
891 PacketLength
= SwapBytes32(ParseStruct
->CurPacket
->LengthBE
);
893 if (PacketLength
> 0) {
894 if (PacketLength
< sizeof(TCG_SUB_PACKET
)) {
895 DEBUG ((DEBUG_INFO
, "Packet too small for SubPacket\n"));
896 return (TcgResultFailureBufferTooSmall
);
899 ParseStruct
->CurSubPacket
= (TCG_SUB_PACKET
*)ParseStruct
->CurPacket
->Payload
;
903 //TODO should check for method status list at this point?
905 return (TcgResultSuccess
);
911 @param ParseStruct Input parse structure info.
912 @param TcgToken return the tcg token info.
914 @retval return the action result.
920 TCG_PARSE_STRUCT
*ParseStruct
,
924 const UINT8
* EndOfSubPacket
;
927 TCG_SIMPLE_TOKEN_SHORT_ATOM
* TmpShort
;
928 const TCG_SIMPLE_TOKEN_MEDIUM_ATOM
* TmpMed
;
929 const TCG_SIMPLE_TOKEN_LONG_ATOM
* TmpLong
;
931 NULL_CHECK(ParseStruct
);
932 NULL_CHECK(TcgToken
);
934 if (ParseStruct
->ComPacket
== NULL
||
935 ParseStruct
->CurPacket
== NULL
||
936 ParseStruct
->CurSubPacket
== NULL
938 DEBUG ((DEBUG_INFO
, "unexpected state: ComPacket=%p CurPacket=%p CurSubPacket=%p\n", ParseStruct
->ComPacket
, ParseStruct
->CurPacket
, ParseStruct
->CurSubPacket
));
939 return TcgResultFailureInvalidAction
;
942 // initial call, start at sub packet
943 if (ParseStruct
->CurPtr
== NULL
) {
944 ParseStruct
->CurPtr
= ParseStruct
->CurSubPacket
->Payload
;
947 EndOfSubPacket
= ParseStruct
->CurSubPacket
->Payload
+ SwapBytes32(ParseStruct
->CurSubPacket
->LengthBE
);
950 // confirmed that subpacket Length falls within end of Buffer and TCG_COM_PACKET,
951 // so simply need to verify the loop stays within current subpacket
952 if (ParseStruct
->CurPtr
>= EndOfSubPacket
) {
953 DEBUG ((DEBUG_INFO
, "ParseStruct->CurPtr >= EndOfSubPacket\n"));
954 return (TcgResultFailureEndBuffer
);
957 Hdr
= *ParseStruct
->CurPtr
;
958 TcgToken
->HdrStart
= ParseStruct
->CurPtr
;
962 // tiny atom Header is only 1 byte, so don't need to verify Size before cast and access
963 TcgToken
->Type
= TcgTokenTypeTinyAtom
;
965 TokenEnd
= TcgToken
->HdrStart
+ sizeof(TCG_SIMPLE_TOKEN_TINY_ATOM
);
967 // verify caller will have enough Size to reference token
968 if (TokenEnd
>= EndOfSubPacket
) {
969 DEBUG ((DEBUG_INFO
, "Tiny Atom TokenEnd >= EndOfSubPacket\n"));
970 return (TcgResultFailureEndBuffer
);
974 else if (0x80 <= Hdr
&& Hdr
<= 0xBF) {
975 // short atom Header is only 1 byte, so don't need to verify Size before cast and access
976 TmpShort
= (TCG_SIMPLE_TOKEN_SHORT_ATOM
*)(ParseStruct
->CurPtr
);
977 TcgToken
->Type
= TcgTokenTypeShortAtom
;
979 TokenEnd
= (TcgToken
->HdrStart
+ sizeof(TCG_SIMPLE_TOKEN_SHORT_ATOM
) + TmpShort
->ShortAtomBits
.Length
);
981 // verify caller will have enough Size to reference token
982 if (TokenEnd
>= EndOfSubPacket
) {
983 DEBUG ((DEBUG_INFO
, "Short Atom TokenEnd >= EndOfSubPacket\n"));
984 return (TcgResultFailureEndBuffer
);
988 else if (0xC0 <= Hdr
&& Hdr
<= 0xDF) {
989 if (TcgToken
->HdrStart
+ sizeof(TCG_SIMPLE_TOKEN_MEDIUM_ATOM
) >= EndOfSubPacket
) {
990 return (TcgResultFailureEndBuffer
);
992 TmpMed
= (const TCG_SIMPLE_TOKEN_MEDIUM_ATOM
*)ParseStruct
->CurPtr
;
993 TcgToken
->Type
= TcgTokenTypeMediumAtom
;
994 TokenEnd
= TcgToken
->HdrStart
+ sizeof(TCG_SIMPLE_TOKEN_MEDIUM_ATOM
) +
995 ((TmpMed
->MediumAtomBits
.LengthHigh
<< TCG_MEDIUM_ATOM_LENGTH_HIGH_SHIFT
) |
996 TmpMed
->MediumAtomBits
.LengthLow
);
998 // verify caller will have enough Size to reference token
999 if (TokenEnd
>= EndOfSubPacket
) {
1000 DEBUG ((DEBUG_INFO
, "Medium Atom TokenEnd >= EndOfSubPacket\n"));
1001 return (TcgResultFailureEndBuffer
);
1005 else if (0xE0 <= Hdr
&& Hdr
<= 0xE3) {
1006 if (TcgToken
->HdrStart
+ sizeof(TCG_SIMPLE_TOKEN_LONG_ATOM
) >= EndOfSubPacket
) {
1007 return (TcgResultFailureEndBuffer
);
1009 TmpLong
= (const TCG_SIMPLE_TOKEN_LONG_ATOM
*)ParseStruct
->CurPtr
;
1010 TcgToken
->Type
= TcgTokenTypeLongAtom
;
1012 TokenEnd
= TcgToken
->HdrStart
+ sizeof(TCG_SIMPLE_TOKEN_LONG_ATOM
) +
1013 ((TmpLong
->LongAtomBits
.LengthHigh
<< TCG_LONG_ATOM_LENGTH_HIGH_SHIFT
) |
1014 (TmpLong
->LongAtomBits
.LengthMid
<< TCG_LONG_ATOM_LENGTH_MID_SHIFT
) |
1015 TmpLong
->LongAtomBits
.LengthLow
);
1017 // verify caller will have enough Size to reference token
1018 if (TokenEnd
>= EndOfSubPacket
) {
1019 DEBUG ((DEBUG_INFO
, "Long Atom TokenEnd >= EndOfSubPacket\n"));
1020 return (TcgResultFailureEndBuffer
);
1023 // single byte tokens
1025 case TCG_TOKEN_STARTLIST
:
1026 TcgToken
->Type
= TcgTokenTypeStartList
;
1028 case TCG_TOKEN_ENDLIST
:
1029 TcgToken
->Type
= TcgTokenTypeEndList
;
1031 case TCG_TOKEN_STARTNAME
:
1032 TcgToken
->Type
= TcgTokenTypeStartName
;
1034 case TCG_TOKEN_ENDNAME
:
1035 TcgToken
->Type
= TcgTokenTypeEndName
;
1037 case TCG_TOKEN_CALL
:
1038 TcgToken
->Type
= TcgTokenTypeCall
;
1040 case TCG_TOKEN_ENDDATA
:
1041 TcgToken
->Type
= TcgTokenTypeEndOfData
;
1043 case TCG_TOKEN_ENDSESSION
:
1044 TcgToken
->Type
= TcgTokenTypeEndOfSession
;
1046 case TCG_TOKEN_STARTTRANSACTION
:
1047 TcgToken
->Type
= TcgTokenTypeStartTransaction
;
1049 case TCG_TOKEN_ENDTRANSACTION
:
1050 TcgToken
->Type
= TcgTokenTypeEndTransaction
;
1052 case TCG_TOKEN_EMPTY
:
1053 TcgToken
->Type
= TcgTokenTypeEmptyAtom
;
1056 DEBUG ((DEBUG_INFO
, "WARNING: reserved token Type 0x%02X\n", Hdr
));
1057 TcgToken
->Type
= TcgTokenTypeReserved
;
1060 ParseStruct
->CurPtr
++;
1061 TokenEnd
= TcgToken
->HdrStart
+ 1;
1064 // increment curptr for next call
1065 ParseStruct
->CurPtr
= TokenEnd
;
1066 return (TcgResultSuccess
);
1072 @param TcgToken Input token info.
1073 @param HeaderLength return the header length.
1074 @param DataLength return the data length.
1075 @param ByteOrInt return the atom Type.
1076 @param SignOrCont return the sign or count info.
1078 @retval return the action result.
1084 const TCG_TOKEN
*TcgToken
,
1085 UINT32
*HeaderLength
,
1091 TCG_SIMPLE_TOKEN_TINY_ATOM
* TinyAtom
;
1092 TCG_SIMPLE_TOKEN_SHORT_ATOM
* ShortAtom
;
1093 TCG_SIMPLE_TOKEN_MEDIUM_ATOM
* MediumAtom
;
1094 TCG_SIMPLE_TOKEN_LONG_ATOM
* LongAtom
;
1096 NULL_CHECK(TcgToken
);
1097 NULL_CHECK(HeaderLength
);
1098 NULL_CHECK(DataLength
);
1099 NULL_CHECK(ByteOrInt
);
1100 NULL_CHECK(SignOrCont
);
1102 switch (TcgToken
->Type
) {
1103 case TcgTokenTypeTinyAtom
: {
1104 TinyAtom
= (TCG_SIMPLE_TOKEN_TINY_ATOM
*)TcgToken
->HdrStart
;
1105 *ByteOrInt
= TCG_ATOM_TYPE_INTEGER
;
1106 *SignOrCont
= TinyAtom
->TinyAtomBits
.Sign
;
1108 *DataLength
= 0; // tiny atom must be handled as a special case - Header and Data in the same byte
1109 return TcgResultSuccess
;
1112 case TcgTokenTypeShortAtom
: {
1113 ShortAtom
= (TCG_SIMPLE_TOKEN_SHORT_ATOM
*)TcgToken
->HdrStart
;
1114 *ByteOrInt
= ShortAtom
->ShortAtomBits
.ByteOrInt
;
1115 *SignOrCont
= ShortAtom
->ShortAtomBits
.SignOrCont
;
1116 *HeaderLength
= sizeof(TCG_SIMPLE_TOKEN_SHORT_ATOM
);
1117 *DataLength
= ShortAtom
->ShortAtomBits
.Length
;
1118 return TcgResultSuccess
;
1121 case TcgTokenTypeMediumAtom
: {
1122 MediumAtom
= (TCG_SIMPLE_TOKEN_MEDIUM_ATOM
*)TcgToken
->HdrStart
;
1123 *ByteOrInt
= MediumAtom
->MediumAtomBits
.ByteOrInt
;
1124 *SignOrCont
= MediumAtom
->MediumAtomBits
.SignOrCont
;
1125 *HeaderLength
= sizeof(TCG_SIMPLE_TOKEN_MEDIUM_ATOM
);
1126 *DataLength
= (MediumAtom
->MediumAtomBits
.LengthHigh
<< TCG_MEDIUM_ATOM_LENGTH_HIGH_SHIFT
) | MediumAtom
->MediumAtomBits
.LengthLow
;
1127 return TcgResultSuccess
;
1130 case TcgTokenTypeLongAtom
: {
1131 LongAtom
= (TCG_SIMPLE_TOKEN_LONG_ATOM
*)TcgToken
->HdrStart
;
1132 *ByteOrInt
= LongAtom
->LongAtomBits
.ByteOrInt
;
1133 *SignOrCont
= LongAtom
->LongAtomBits
.SignOrCont
;
1134 *HeaderLength
= sizeof(TCG_SIMPLE_TOKEN_LONG_ATOM
);
1135 *DataLength
= (LongAtom
->LongAtomBits
.LengthHigh
<< TCG_LONG_ATOM_LENGTH_HIGH_SHIFT
) |
1136 (LongAtom
->LongAtomBits
.LengthMid
<< TCG_LONG_ATOM_LENGTH_MID_SHIFT
) |
1137 LongAtom
->LongAtomBits
.LengthLow
;
1138 return TcgResultSuccess
;
1142 DEBUG ((DEBUG_INFO
, "Token Type is not simple atom (%d)\n", TcgToken
->Type
));
1143 return (TcgResultFailureInvalidType
);
1148 Get token specified value.
1150 @param TcgToken Input token info.
1151 @param Value return the value.
1153 @retval return the action result.
1159 const TCG_TOKEN
*TcgToken
,
1167 TCG_SIMPLE_TOKEN_TINY_ATOM
* TmpTiny
;
1171 NULL_CHECK(TcgToken
);
1176 ERROR_CHECK(TcgGetAtomInfo(TcgToken
, &HdrLength
, &DataLength
, &ByteOrInt
, &IsSigned
));
1178 if (ByteOrInt
!= TCG_ATOM_TYPE_INTEGER
) {
1179 DEBUG ((DEBUG_INFO
, "Invalid Type, expected integer not byte sequence\n"));
1180 return TcgResultFailureInvalidType
;
1183 if (IsSigned
!= 0) {
1184 DEBUG ((DEBUG_INFO
, "Integer is signed, expected unsigned\n"));
1185 return TcgResultFailureInvalidType
;
1188 // special case for tiny atom
1189 // Header and Data are in one byte, so extract only the Data bitfield
1190 if (TcgToken
->Type
== TcgTokenTypeTinyAtom
) {
1191 TmpTiny
= (TCG_SIMPLE_TOKEN_TINY_ATOM
*)TcgToken
->HdrStart
;
1192 *Value
= TmpTiny
->TinyAtomBits
.Data
;
1193 return TcgResultSuccess
;
1196 if (DataLength
> sizeof(UINT64
)) {
1197 DEBUG ((DEBUG_INFO
, "Length %d is greater than Size of UINT64\n", DataLength
));
1198 return TcgResultFailureBufferTooSmall
;
1201 // read big-endian integer
1202 Data
= TcgToken
->HdrStart
+ HdrLength
;
1203 for (Index
= 0; Index
< DataLength
; Index
++) {
1204 *Value
= LShiftU64(*Value
, 8) | Data
[Index
];
1207 return TcgResultSuccess
;
1211 Get token byte sequence.
1213 @param TcgToken Input token info.
1214 @param Length Input the length info.
1216 @retval Return the value data.
1221 TcgGetTokenByteSequence(
1222 const TCG_TOKEN
*TcgToken
,
1230 if (TcgToken
== NULL
|| Length
== NULL
) {
1235 if (TcgGetAtomInfo(TcgToken
, &HdrLength
, Length
, &ByteOrInt
, &SignOrCont
) != TcgResultSuccess
) {
1236 DEBUG ((DEBUG_INFO
, "Failed to get simple token info\n"));
1240 if (ByteOrInt
!= TCG_ATOM_TYPE_BYTE
) {
1241 DEBUG ((DEBUG_INFO
, "Invalid Type, expected byte sequence not integer\n"));
1245 return (TcgToken
->HdrStart
+ HdrLength
);
1249 Get next specify value.
1251 @param ParseStruct Input parse structure.
1252 @param Value Return value.
1254 @retval return the action result.
1260 TCG_PARSE_STRUCT
*ParseStruct
,
1269 ERROR_CHECK(TcgGetNextToken(ParseStruct
, &Tok
));
1270 ERROR_CHECK(TcgGetTokenUINT64(&Tok
, &Value64
));
1272 if (Value64
> MAX_UINT8
) {
1273 return TcgResultFailure
;
1276 *Value
= (UINT8
)Value64
;
1278 return TcgResultSuccess
;
1282 Get next specify value.
1284 @param ParseStruct Input parse structure.
1285 @param Value Return value.
1287 @retval return the action result.
1293 TCG_PARSE_STRUCT
*ParseStruct
,
1302 ERROR_CHECK(TcgGetNextToken(ParseStruct
, &Tok
));
1303 ERROR_CHECK(TcgGetTokenUINT64(&Tok
, &Value64
));
1305 if (Value64
> MAX_UINT16
) {
1306 return TcgResultFailure
;
1309 *Value
= (UINT16
)Value64
;
1311 return TcgResultSuccess
;
1315 Get next specify value.
1317 @param ParseStruct Input parse structure.
1318 @param Value Return value.
1320 @retval return the action result.
1326 TCG_PARSE_STRUCT
*ParseStruct
,
1335 ERROR_CHECK(TcgGetNextToken(ParseStruct
, &Tok
));
1336 ERROR_CHECK(TcgGetTokenUINT64(&Tok
, &Value64
));
1338 if (Value64
> MAX_UINT32
) {
1339 return TcgResultFailure
;
1342 *Value
= (UINT32
)Value64
;
1344 return TcgResultSuccess
;
1348 Get next specify value.
1350 @param ParseStruct Input parse structure.
1351 @param Value Return value.
1353 @retval return the action result.
1359 TCG_PARSE_STRUCT
*ParseStruct
,
1364 ERROR_CHECK(TcgGetNextToken(ParseStruct
, &Tok
));
1365 ERROR_CHECK(TcgGetTokenUINT64(&Tok
, Value
));
1366 return TcgResultSuccess
;
1370 Get next specify value.
1372 @param ParseStruct Input parse structure.
1373 @param Value Return value.
1375 @retval return the action result.
1381 TCG_PARSE_STRUCT
*ParseStruct
,
1390 ERROR_CHECK(TcgGetNextToken(ParseStruct
, &Tok
));
1391 ERROR_CHECK(TcgGetTokenUINT64(&Tok
, &Value64
));
1394 return TcgResultFailure
;
1397 *Value
= (BOOLEAN
)Value64
;
1399 return TcgResultSuccess
;
1403 Get next tcg uid info.
1405 @param ParseStruct Input parse structure.
1406 @param Uid Get the uid info.
1408 @retval return the action result.
1414 TCG_PARSE_STRUCT
*ParseStruct
,
1420 const UINT8
* ByteSeq
;
1424 ERROR_CHECK(TcgGetNextToken(ParseStruct
, &Tok
));
1425 ByteSeq
= TcgGetTokenByteSequence(&Tok
, &Length
);
1427 if (Length
!= sizeof(TCG_UID
)) {
1428 DEBUG ((DEBUG_INFO
, "Token Length %u != TCG_UID Size %u\n", Length
, (UINT32
)sizeof(TCG_UID
)));
1429 return TcgResultFailure
;
1432 ASSERT (ByteSeq
!= NULL
);
1434 CopyMem(Uid
, ByteSeq
, sizeof(TCG_UID
));
1436 return TcgResultSuccess
;
1440 Get next byte sequence.
1442 @param ParseStruct Input parse structure.
1443 @param Data return the data.
1444 @param Length return the length.
1446 @retval return the action result.
1451 TcgGetNextByteSequence(
1452 TCG_PARSE_STRUCT
*ParseStruct
,
1460 ERROR_CHECK(TcgGetNextToken(ParseStruct
, &Tok
));
1461 Bs
= TcgGetTokenByteSequence(&Tok
, Length
);
1464 return TcgResultFailure
;
1467 return TcgResultSuccess
;
1471 Get next token Type.
1473 @param ParseStruct Input parse structure.
1474 @param Type Input the type need to check.
1476 @retval return the action result.
1481 TcgGetNextTokenType(
1482 TCG_PARSE_STRUCT
*ParseStruct
,
1487 ERROR_CHECK(TcgGetNextToken(ParseStruct
, &Tok
));
1488 if (Tok
.Type
!= Type
) {
1489 DEBUG ((DEBUG_INFO
, "expected Type %u, got Type %u\n", Type
, Tok
.Type
));
1490 return TcgResultFailure
;
1492 return TcgResultSuccess
;
1496 Get next start list.
1498 @param ParseStruct Input parse structure.
1500 @retval return the action result.
1505 TcgGetNextStartList(
1506 TCG_PARSE_STRUCT
*ParseStruct
1509 return TcgGetNextTokenType(ParseStruct
, TcgTokenTypeStartList
);
1515 @param ParseStruct Input parse structure.
1517 @retval return the action result.
1523 TCG_PARSE_STRUCT
*ParseStruct
1526 return TcgGetNextTokenType(ParseStruct
, TcgTokenTypeEndList
);
1530 Get next start name.
1532 @param ParseStruct Input parse structure.
1534 @retval return the action result.
1539 TcgGetNextStartName(
1540 TCG_PARSE_STRUCT
*ParseStruct
1543 return TcgGetNextTokenType(ParseStruct
, TcgTokenTypeStartName
);
1549 @param ParseStruct Input parse structure.
1551 @retval return the action result.
1557 TCG_PARSE_STRUCT
*ParseStruct
1560 return TcgGetNextTokenType(ParseStruct
, TcgTokenTypeEndName
);
1566 @param ParseStruct Input parse structure.
1568 @retval return the action result.
1574 TCG_PARSE_STRUCT
*ParseStruct
1577 return TcgGetNextTokenType(ParseStruct
, TcgTokenTypeCall
);
1583 @param ParseStruct Input parse structure.
1585 @retval return the action result.
1590 TcgGetNextEndOfData(
1591 TCG_PARSE_STRUCT
*ParseStruct
1594 return TcgGetNextTokenType(ParseStruct
, TcgTokenTypeEndOfData
);
1598 Get next end of session.
1600 @param ParseStruct Input parse structure.
1602 @retval return the action result.
1607 TcgGetNextEndOfSession(
1608 TCG_PARSE_STRUCT
*ParseStruct
1611 return TcgGetNextTokenType(ParseStruct
, TcgTokenTypeEndOfSession
);
1615 Get next start transaction.
1617 @param ParseStruct Input parse structure.
1619 @retval return the action result.
1624 TcgGetNextStartTransaction(
1625 TCG_PARSE_STRUCT
*ParseStruct
1628 return TcgGetNextTokenType(ParseStruct
, TcgTokenTypeStartTransaction
);
1632 Get next end transaction.
1634 @param ParseStruct Input parse structure.
1636 @retval return the action result.
1641 TcgGetNextEndTransaction(
1642 TCG_PARSE_STRUCT
*ParseStruct
1645 return TcgGetNextTokenType(ParseStruct
, TcgTokenTypeEndTransaction
);