]> git.proxmox.com Git - mirror_edk2.git/blob - SecurityPkg/Library/Tpm12CommandLib/Tpm12Ownership.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / SecurityPkg / Library / Tpm12CommandLib / Tpm12Ownership.c
1 /** @file
2 Implement TPM1.2 Ownership related command.
3
4 Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved. <BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7 **/
8
9 #include <PiPei.h>
10 #include <Library/BaseMemoryLib.h>
11 #include <Library/BaseLib.h>
12 #include <Library/Tpm12DeviceLib.h>
13
14 /**
15 Send ForceClear command to TPM1.2.
16
17 @retval EFI_SUCCESS Operation completed successfully.
18 @retval EFI_DEVICE_ERROR Unexpected device behavior.
19 **/
20 EFI_STATUS
21 EFIAPI
22 Tpm12ForceClear (
23 VOID
24 )
25 {
26 EFI_STATUS Status;
27 TPM_RQU_COMMAND_HDR Command;
28 TPM_RSP_COMMAND_HDR Response;
29 UINT32 Length;
30
31 //
32 // send Tpm command TPM_ORD_ForceClear
33 //
34 Command.tag = SwapBytes16 (TPM_TAG_RQU_COMMAND);
35 Command.paramSize = SwapBytes32 (sizeof (Command));
36 Command.ordinal = SwapBytes32 (TPM_ORD_ForceClear);
37 Length = sizeof (Response);
38
39 Status = Tpm12SubmitCommand (sizeof (Command), (UINT8 *)&Command, &Length, (UINT8 *)&Response);
40 if (EFI_ERROR (Status)) {
41 return Status;
42 }
43 switch (SwapBytes32 (Response.returnCode)) {
44 case TPM_SUCCESS:
45 return EFI_SUCCESS;
46 default:
47 return EFI_DEVICE_ERROR;
48 }
49 }