SecPlatformInformation.c 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /** @file
  2. Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>
  3. SPDX-License-Identifier: BSD-2-Clause-Patent
  4. **/
  5. #include <PiPei.h>
  6. #include <Ppi/SecPlatformInformation.h>
  7. #include <Ppi/TopOfTemporaryRam.h>
  8. #include <Library/BaseMemoryLib.h>
  9. #include <Library/DebugLib.h>
  10. /**
  11. This interface conveys state information out of the Security (SEC) phase into PEI.
  12. @param PeiServices Pointer to the PEI Services Table.
  13. @param StructureSize Pointer to the variable describing size of the input buffer.
  14. @param PlatformInformationRecord Pointer to the EFI_SEC_PLATFORM_INFORMATION_RECORD.
  15. @retval EFI_SUCCESS The data was successfully returned.
  16. @retval EFI_BUFFER_TOO_SMALL The buffer was too small.
  17. **/
  18. EFI_STATUS
  19. EFIAPI
  20. SecPlatformInformation (
  21. IN CONST EFI_PEI_SERVICES **PeiServices,
  22. IN OUT UINT64 *StructureSize,
  23. OUT EFI_SEC_PLATFORM_INFORMATION_RECORD *PlatformInformationRecord
  24. )
  25. {
  26. UINT32 *Bist;
  27. UINT32 Size;
  28. UINT32 Count;
  29. UINT32 TopOfTemporaryRam;
  30. VOID *TopOfTemporaryRamPpi;
  31. EFI_STATUS Status;
  32. DEBUG ((DEBUG_INFO, "SecPlatformInformation\n"));
  33. Status = (*PeiServices)->LocatePpi (
  34. PeiServices,
  35. &gTopOfTemporaryRamPpiGuid,
  36. 0,
  37. NULL,
  38. (VOID **) &TopOfTemporaryRamPpi
  39. );
  40. if (EFI_ERROR (Status)) {
  41. return EFI_NOT_FOUND;
  42. }
  43. //
  44. // The entries of BIST information, together with the number of them,
  45. // reside in the bottom of stack, left untouched by normal stack operation.
  46. // This routine copies the BIST information to the buffer pointed by
  47. // PlatformInformationRecord for output.
  48. //
  49. TopOfTemporaryRam = (UINT32)(UINTN)TopOfTemporaryRamPpi - sizeof (UINT32);
  50. TopOfTemporaryRam -= sizeof(UINT32) * 2;
  51. Count = *((UINT32 *)(UINTN) (TopOfTemporaryRam - sizeof (UINT32)));
  52. Size = Count * sizeof (IA32_HANDOFF_STATUS);
  53. if ((*StructureSize) < (UINT64) Size) {
  54. *StructureSize = Size;
  55. return EFI_BUFFER_TOO_SMALL;
  56. }
  57. *StructureSize = Size;
  58. Bist = (UINT32 *) (TopOfTemporaryRam - sizeof (UINT32) - Size);
  59. CopyMem (PlatformInformationRecord, Bist, Size);
  60. return EFI_SUCCESS;
  61. }