TianoCore EDK2
master
Loading...
Searching...
No Matches
Tpm2Context.c
Go to the documentation of this file.
1
9
#include <
IndustryStandard/UefiTcgPlatform.h
>
10
#include <
Library/Tpm2CommandLib.h
>
11
#include <
Library/Tpm2DeviceLib.h
>
12
#include <
Library/BaseMemoryLib.h
>
13
#include <
Library/BaseLib.h
>
14
#include <
Library/DebugLib.h
>
15
16
#pragma pack(1)
17
18
typedef
struct
{
19
TPM2_COMMAND_HEADER
Header;
20
TPMI_DH_CONTEXT FlushHandle;
21
}
TPM2_FLUSH_CONTEXT_COMMAND
;
22
23
typedef
struct
{
24
TPM2_RESPONSE_HEADER
Header;
25
}
TPM2_FLUSH_CONTEXT_RESPONSE
;
26
27
#pragma pack()
28
37
EFI_STATUS
38
EFIAPI
39
Tpm2FlushContext
(
40
IN
TPMI_DH_CONTEXT FlushHandle
41
)
42
{
43
EFI_STATUS
Status;
44
TPM2_FLUSH_CONTEXT_COMMAND
SendBuffer;
45
TPM2_FLUSH_CONTEXT_RESPONSE
RecvBuffer;
46
UINT32 SendBufferSize;
47
UINT32 RecvBufferSize;
48
49
//
50
// Construct command
51
//
52
SendBuffer.Header.tag =
SwapBytes16
(TPM_ST_NO_SESSIONS);
53
SendBuffer.Header.commandCode =
SwapBytes32
(TPM_CC_FlushContext);
54
55
SendBuffer.FlushHandle =
SwapBytes32
(FlushHandle);
56
57
SendBufferSize = (UINT32)
sizeof
(SendBuffer);
58
SendBuffer.Header.paramSize =
SwapBytes32
(SendBufferSize);
59
60
//
61
// send Tpm command
62
//
63
RecvBufferSize =
sizeof
(RecvBuffer);
64
Status =
Tpm2SubmitCommand
(SendBufferSize, (UINT8 *)&SendBuffer, &RecvBufferSize, (UINT8 *)&RecvBuffer);
65
if
(EFI_ERROR (Status)) {
66
return
Status;
67
}
68
69
if
(RecvBufferSize <
sizeof
(
TPM2_RESPONSE_HEADER
)) {
70
DEBUG
((DEBUG_ERROR,
"Tpm2FlushContext - RecvBufferSize Error - %x\n"
, RecvBufferSize));
71
return
EFI_DEVICE_ERROR;
72
}
73
74
if
(
SwapBytes32
(RecvBuffer.Header.responseCode) != TPM_RC_SUCCESS) {
75
DEBUG
((DEBUG_ERROR,
"Tpm2FlushContext - responseCode - %x\n"
,
SwapBytes32
(RecvBuffer.Header.responseCode)));
76
return
EFI_DEVICE_ERROR;
77
}
78
79
return
EFI_SUCCESS
;
80
}
BaseLib.h
SwapBytes16
UINT16 EFIAPI SwapBytes16(IN UINT16 Value)
Definition:
SwapBytes16.c:25
SwapBytes32
UINT32 EFIAPI SwapBytes32(IN UINT32 Value)
Definition:
SwapBytes32.c:25
BaseMemoryLib.h
IN
#define IN
Definition:
Base.h:279
DebugLib.h
DEBUG
#define DEBUG(Expression)
Definition:
DebugLib.h:434
Tpm2CommandLib.h
Tpm2FlushContext
EFI_STATUS EFIAPI Tpm2FlushContext(IN TPMI_DH_CONTEXT FlushHandle)
Definition:
Tpm2Context.c:39
Tpm2DeviceLib.h
Tpm2SubmitCommand
EFI_STATUS EFIAPI Tpm2SubmitCommand(IN UINT32 InputParameterBlockSize, IN UINT8 *InputParameterBlock, IN OUT UINT32 *OutputParameterBlockSize, IN UINT8 *OutputParameterBlock)
Definition:
Tpm2DeviceLibDTpm.c:66
EFI_STATUS
RETURN_STATUS EFI_STATUS
Definition:
UefiBaseType.h:29
EFI_SUCCESS
#define EFI_SUCCESS
Definition:
UefiBaseType.h:112
UefiTcgPlatform.h
TPM2_COMMAND_HEADER
Definition:
Tpm20.h:1790
TPM2_FLUSH_CONTEXT_COMMAND
Definition:
Tpm2Context.c:18
TPM2_FLUSH_CONTEXT_RESPONSE
Definition:
Tpm2Context.c:23
TPM2_RESPONSE_HEADER
Definition:
Tpm20.h:1796
SecurityPkg
Library
Tpm2CommandLib
Tpm2Context.c
Generated on Fri Nov 15 2024 18:01:23 for TianoCore EDK2 by
1.9.6