Tpm12Ownership.c 1.2 KB

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