SecMain.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /** @file
  2. Copyright (c) 2014 - 2022, Intel Corporation. All rights reserved.<BR>
  3. SPDX-License-Identifier: BSD-2-Clause-Patent
  4. **/
  5. #ifndef _SEC_CORE_H_
  6. #define _SEC_CORE_H_
  7. #include <PiPei.h>
  8. #include <Ppi/TemporaryRamSupport.h>
  9. #include <Library/BaseLib.h>
  10. #include <Library/IoLib.h>
  11. #include <Library/DebugLib.h>
  12. #include <Library/PcdLib.h>
  13. #include <Library/BaseMemoryLib.h>
  14. #include <Library/PciCf8Lib.h>
  15. #include <Library/SerialPortLib.h>
  16. #include <Library/FspSwitchStackLib.h>
  17. #include <Library/FspCommonLib.h>
  18. #include <Library/CpuLib.h>
  19. #include <Library/UefiCpuLib.h>
  20. #include <FspEas.h>
  21. typedef
  22. VOID
  23. (EFIAPI *PEI_CORE_ENTRY)(
  24. IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,
  25. IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList
  26. );
  27. typedef struct _SEC_IDT_TABLE {
  28. //
  29. // Reserved 8 bytes preceding IDT to store EFI_PEI_SERVICES**, since IDT base
  30. // address should be 8-byte alignment.
  31. // Note: For IA32, only the 4 bytes immediately preceding IDT is used to store
  32. // EFI_PEI_SERVICES**
  33. //
  34. UINT64 PeiService;
  35. IA32_IDT_GATE_DESCRIPTOR IdtTable[FixedPcdGet8 (PcdFspMaxInterruptSupported)];
  36. } SEC_IDT_TABLE;
  37. /**
  38. Switch the stack in the temporary memory to the one in the permanent memory.
  39. This function must be invoked after the memory migration immediately. The relative
  40. position of the stack in the temporary and permanent memory is same.
  41. @param[in] TemporaryMemoryBase Base address of the temporary memory.
  42. @param[in] PermenentMemoryBase Base address of the permanent memory.
  43. **/
  44. VOID
  45. EFIAPI
  46. SecSwitchStack (
  47. IN UINTN TemporaryMemoryBase,
  48. IN UINTN PermenentMemoryBase
  49. );
  50. /**
  51. This service of the TEMPORARY_RAM_SUPPORT_PPI that migrates temporary RAM into
  52. permanent memory.
  53. @param[in] PeiServices Pointer to the PEI Services Table.
  54. @param[in] TemporaryMemoryBase Source Address in temporary memory from which the SEC or PEIM will copy the
  55. Temporary RAM contents.
  56. @param[in] PermanentMemoryBase Destination Address in permanent memory into which the SEC or PEIM will copy the
  57. Temporary RAM contents.
  58. @param[in] CopySize Amount of memory to migrate from temporary to permanent memory.
  59. @retval EFI_SUCCESS The data was successfully returned.
  60. @retval EFI_INVALID_PARAMETER PermanentMemoryBase + CopySize > TemporaryMemoryBase when
  61. TemporaryMemoryBase > PermanentMemoryBase.
  62. **/
  63. EFI_STATUS
  64. EFIAPI
  65. SecTemporaryRamSupport (
  66. IN CONST EFI_PEI_SERVICES **PeiServices,
  67. IN EFI_PHYSICAL_ADDRESS TemporaryMemoryBase,
  68. IN EFI_PHYSICAL_ADDRESS PermanentMemoryBase,
  69. IN UINTN CopySize
  70. );
  71. /**
  72. Entry point to the C language phase of SEC. After the SEC assembly
  73. code has initialized some temporary memory and set up the stack,
  74. the control is transferred to this function.
  75. @param[in] SizeOfRam Size of the temporary memory available for use.
  76. @param[in] TempRamBase Base address of temporary ram
  77. @param[in] BootFirmwareVolume Base address of the Boot Firmware Volume.
  78. @param[in] PeiCore PeiCore entry point.
  79. @param[in] BootLoaderStack BootLoader stack.
  80. @param[in] ApiIdx the index of API.
  81. @return This function never returns.
  82. **/
  83. VOID
  84. EFIAPI
  85. SecStartup (
  86. IN UINT32 SizeOfRam,
  87. IN UINT32 TempRamBase,
  88. IN VOID *BootFirmwareVolume,
  89. IN PEI_CORE_ENTRY PeiCore,
  90. IN UINTN BootLoaderStack,
  91. IN UINT32 ApiIdx
  92. );
  93. /**
  94. Autogenerated function that calls the library constructors for all of the module's
  95. dependent libraries. This function must be called by the SEC Core once a stack has
  96. been established.
  97. **/
  98. VOID
  99. EFIAPI
  100. ProcessLibraryConstructorList (
  101. VOID
  102. );
  103. /**
  104. Return value of esp.
  105. @return value of esp.
  106. **/
  107. UINTN
  108. EFIAPI
  109. AsmReadStackPointer (
  110. VOID
  111. );
  112. #endif