Tpm12SelfTest.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /** @file
  2. Implement TPM1.2 NV Self Test related commands.
  3. Copyright (c) 2016 - 2017, Intel Corporation. All rights reserved. <BR>
  4. (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
  5. SPDX-License-Identifier: BSD-2-Clause-Patent
  6. **/
  7. #include <PiPei.h>
  8. #include <Library/Tpm12CommandLib.h>
  9. #include <Library/BaseLib.h>
  10. #include <Library/DebugLib.h>
  11. #include <Library/Tpm12DeviceLib.h>
  12. /**
  13. Send TPM_ContinueSelfTest command to TPM.
  14. @retval EFI_SUCCESS Operation completed successfully.
  15. @retval EFI_TIMEOUT The register can't run into the expected status in time.
  16. @retval EFI_BUFFER_TOO_SMALL Response data buffer is too small.
  17. @retval EFI_DEVICE_ERROR Unexpected device behavior.
  18. **/
  19. EFI_STATUS
  20. EFIAPI
  21. Tpm12ContinueSelfTest (
  22. VOID
  23. )
  24. {
  25. EFI_STATUS Status;
  26. TPM_RQU_COMMAND_HDR Command;
  27. TPM_RSP_COMMAND_HDR Response;
  28. UINT32 Length;
  29. //
  30. // send Tpm command TPM_ORD_ContinueSelfTest
  31. //
  32. Command.tag = SwapBytes16 (TPM_TAG_RQU_COMMAND);
  33. Command.paramSize = SwapBytes32 (sizeof (Command));
  34. Command.ordinal = SwapBytes32 (TPM_ORD_ContinueSelfTest);
  35. Length = sizeof (Response);
  36. Status = Tpm12SubmitCommand (sizeof (Command), (UINT8 *)&Command, &Length, (UINT8 *)&Response);
  37. if (EFI_ERROR (Status)) {
  38. return Status;
  39. }
  40. if (SwapBytes32 (Response.returnCode) != TPM_SUCCESS) {
  41. DEBUG ((DEBUG_ERROR, "Tpm12ContinueSelfTest: Response Code error! 0x%08x\r\n", SwapBytes32 (Response.returnCode)));
  42. return EFI_DEVICE_ERROR;
  43. }
  44. return Status;
  45. }