SaveSecContext.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /** @file
  2. This PEIM will parse the hoblist from fsp and report them into pei core.
  3. This file contains the main entrypoint of the PEIM.
  4. Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>
  5. SPDX-License-Identifier: BSD-2-Clause-Patent
  6. **/
  7. #include <PiPei.h>
  8. #include <Library/DebugLib.h>
  9. #include <Ppi/TopOfTemporaryRam.h>
  10. #include <Ppi/SecPlatformInformation.h>
  11. /**
  12. Save BIST value before call FspInit.
  13. @param Bist BIST value.
  14. **/
  15. VOID
  16. AsmSaveBistValue (
  17. IN UINT32 Bist
  18. );
  19. /**
  20. Save Ticker value before call FspInit.
  21. @param Ticker Ticker value.
  22. **/
  23. VOID
  24. AsmSaveTickerValue (
  25. IN UINT64 Ticker
  26. );
  27. /**
  28. Save SEC context before call FspInit.
  29. @param PeiServices Pointer to PEI Services Table.
  30. **/
  31. VOID
  32. EFIAPI
  33. SaveSecContext (
  34. IN CONST EFI_PEI_SERVICES **PeiServices
  35. )
  36. {
  37. UINT32 *Bist;
  38. UINT64 *Ticker;
  39. UINT32 Size;
  40. UINT32 Count;
  41. UINT32 TopOfTemporaryRam;
  42. VOID *TopOfTemporaryRamPpi;
  43. EFI_STATUS Status;
  44. DEBUG ((DEBUG_INFO, "SaveSecContext - 0x%x\n", PeiServices));
  45. Status = (*PeiServices)->LocatePpi (
  46. PeiServices,
  47. &gTopOfTemporaryRamPpiGuid,
  48. 0,
  49. NULL,
  50. (VOID **) &TopOfTemporaryRamPpi
  51. );
  52. if (EFI_ERROR (Status)) {
  53. return ;
  54. }
  55. DEBUG ((DEBUG_INFO, "TopOfTemporaryRamPpi - 0x%x\n", TopOfTemporaryRamPpi));
  56. //
  57. // The entries of BIST information, together with the number of them,
  58. // reside in the bottom of stack, left untouched by normal stack operation.
  59. // This routine copies the BIST information to the buffer pointed by
  60. // PlatformInformationRecord for output.
  61. //
  62. // |--------------| <- TopOfTemporaryRam
  63. // |Number of BSPs|
  64. // |--------------|
  65. // | BIST |
  66. // |--------------|
  67. // | .... |
  68. // |--------------|
  69. // | TSC[63:32] |
  70. // |--------------|
  71. // | TSC[31:00] |
  72. // |--------------|
  73. //
  74. TopOfTemporaryRam = (UINT32)(UINTN)TopOfTemporaryRamPpi - sizeof(UINT32);
  75. TopOfTemporaryRam -= sizeof(UINT32) * 2;
  76. DEBUG ((DEBUG_INFO, "TopOfTemporaryRam - 0x%x\n", TopOfTemporaryRam));
  77. Count = *(UINT32 *)(UINTN)(TopOfTemporaryRam - sizeof(UINT32));
  78. DEBUG ((DEBUG_INFO, "Count - 0x%x\n", Count));
  79. Size = Count * sizeof (IA32_HANDOFF_STATUS);
  80. DEBUG ((DEBUG_INFO, "Size - 0x%x\n", Size));
  81. Bist = (UINT32 *)(UINTN)(TopOfTemporaryRam - sizeof(UINT32) - Size);
  82. DEBUG ((DEBUG_INFO, "Bist - 0x%x\n", *Bist));
  83. Ticker = (UINT64 *)(UINTN)(TopOfTemporaryRam - sizeof(UINT32) - Size - sizeof(UINT64));
  84. DEBUG ((DEBUG_INFO, "Ticker - 0x%lx\n", *Ticker));
  85. //
  86. // Just need record BSP
  87. //
  88. AsmSaveBistValue (*Bist);
  89. AsmSaveTickerValue (*Ticker);
  90. }