65#if defined (MDE_CPU_IA32)
68 UINT64 SmmFirmwareVendor;
69 UINT64 SmmFirmwareRevision;
80 UINT64 CurrentlyExecutingCpu;
82 UINT64 CpuSaveStateSize;
84 UINT64 NumberOfTableEntries;
85 UINT64 SmmConfigurationTable;
86} EFI_SMM_SYSTEM_TABLE2_64;
91} EFI_CONFIGURATION_TABLE64;
94#if defined (MDE_CPU_X64)
117 IN OUT VOID *CommBuffer,
124 (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
125 &gEfiPeiSmmCommunicationPpiGuid,
126 &mSmmCommunicationPpi
143 ASSERT (GuidHob !=
NULL);
147 return SmmCommunicationContext;
163 BufferSize =
sizeof (*SmmCommunicationContext);
165 &gEfiPeiSmmCommunicationPpiGuid,
170 CopyMem ((VOID *)Hob.Raw, SmmCommunicationContext, sizeof (*SmmCommunicationContext));
190 UINTN NumberOfTableEntries;
192 EFI_SMM_SYSTEM_TABLE2_64 *Smst64;
193 EFI_CONFIGURATION_TABLE64 *SmmConfigurationTable64;
195 if ((
sizeof (
UINTN) ==
sizeof (UINT32)) && (Signature == SMM_S3_RESUME_SMM_64)) {
199 Smst64 = (EFI_SMM_SYSTEM_TABLE2_64 *)Smst;
200 DEBUG ((DEBUG_INFO,
"InitCommunicationContext - SmmConfigurationTable: %x\n", Smst64->SmmConfigurationTable));
201 DEBUG ((DEBUG_INFO,
"InitCommunicationContext - NumberOfTableEntries: %x\n", Smst64->NumberOfTableEntries));
202 SmmConfigurationTable64 = (EFI_CONFIGURATION_TABLE64 *)(
UINTN)Smst64->SmmConfigurationTable;
203 NumberOfTableEntries = (
UINTN)Smst64->NumberOfTableEntries;
204 for (Index = 0; Index < NumberOfTableEntries; Index++) {
205 if (
CompareGuid (&SmmConfigurationTable64[Index].VendorGuid, VendorGuid)) {
206 return (VOID *)(
UINTN)SmmConfigurationTable64[Index].VendorTable;
212 DEBUG ((DEBUG_INFO,
"InitCommunicationContext - SmmConfigurationTable: %x\n", Smst->SmmConfigurationTable));
213 DEBUG ((DEBUG_INFO,
"InitCommunicationContext - NumberOfTableEntries: %x\n", Smst->NumberOfTableEntries));
214 SmmConfigurationTable = Smst->SmmConfigurationTable;
215 NumberOfTableEntries = Smst->NumberOfTableEntries;
216 for (Index = 0; Index < NumberOfTableEntries; Index++) {
217 if (
CompareGuid (&SmmConfigurationTable[Index].VendorGuid, VendorGuid)) {
218 return (VOID *)SmmConfigurationTable[Index].
VendorTable;
240 ASSERT (GuidHob !=
NULL);
244 DEBUG ((DEBUG_INFO,
"InitCommunicationContext - SmmS3ResumeState: %x\n", SmmS3ResumeState));
245 DEBUG ((DEBUG_INFO,
"InitCommunicationContext - Smst: %x\n", SmmS3ResumeState->Smst));
248 SmmS3ResumeState->Signature,
250 &gEfiPeiSmmCommunicationPpiGuid
252 ASSERT (SmmCommunicationContext !=
NULL);
277 IN OUT VOID *CommBuffer,
288 DEBUG ((DEBUG_INFO,
"PiSmmCommunicationPei Communicate Enter\n"));
290 if (CommBuffer ==
NULL) {
291 return EFI_INVALID_PARAMETER;
298 &gPeiSmmControlPpiGuid,
303 if (EFI_ERROR (Status)) {
304 return EFI_NOT_STARTED;
308 &gPeiSmmAccessPpiGuid,
313 if (EFI_ERROR (Status)) {
314 return EFI_NOT_STARTED;
320 if (!SmmAccess->LockState) {
321 DEBUG ((DEBUG_INFO,
"PiSmmCommunicationPei LockState - %x\n", (
UINTN)SmmAccess->LockState));
322 return EFI_NOT_STARTED;
326 DEBUG ((DEBUG_INFO,
"PiSmmCommunicationPei BufferPtrAddress - 0x%016lx, BufferPtr: 0x%016lx\n", SmmCommunicationContext->BufferPtrAddress, *(
EFI_PHYSICAL_ADDRESS *)(
UINTN)SmmCommunicationContext->BufferPtrAddress));
332 DEBUG ((DEBUG_INFO,
"PiSmmCommunicationPei CommBuffer - %x\n", (
UINTN)CommBuffer));
337 SmiCommand = (UINT8)SmmCommunicationContext->SwSmiNumber;
338 Size = sizeof (SmiCommand);
339 Status = SmmControl->Trigger (
354 DEBUG ((DEBUG_INFO,
"PiSmmCommunicationPei Communicate Exit\n"));
381 if (BootMode != BOOT_ON_S3_RESUME) {
382 return EFI_UNSUPPORTED;
386 &gPeiSmmAccessPpiGuid,
391 if (EFI_ERROR (Status)) {
392 return EFI_NOT_STARTED;
398 if (SmmAccess->LockState) {
399 DEBUG ((DEBUG_INFO,
"PiSmmCommunicationPei LockState - %x\n", (
UINTN)SmmAccess->LockState));
400 return EFI_ACCESS_DENIED;
406 for (Index = 0; !EFI_ERROR (Status); Index++) {
CONST EFI_PEI_SERVICES **EFIAPI GetPeiServicesTablePointer(VOID)
VOID *EFIAPI GetFirstGuidHob(IN CONST EFI_GUID *Guid)
VOID *EFIAPI BuildGuidHob(IN CONST EFI_GUID *Guid, IN UINTN DataLength)
EFI_BOOT_MODE EFIAPI GetBootModeHob(VOID)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
BOOLEAN EFIAPI CompareGuid(IN CONST GUID *Guid1, IN CONST GUID *Guid2)
EFI_STATUS EFIAPI PeiServicesLocatePpi(IN CONST EFI_GUID *Guid, IN UINTN Instance, IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor, IN OUT VOID **Ppi)
EFI_STATUS EFIAPI PeiServicesInstallPpi(IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList)
EFI_STATUS EFIAPI SmmInstallConfigurationTable(IN CONST EFI_SMM_SYSTEM_TABLE2 *SystemTable, IN CONST EFI_GUID *Guid, IN VOID *Table, IN UINTN TableSize)
EFI_STATUS EFIAPI SmmFreePages(IN EFI_PHYSICAL_ADDRESS Memory, IN UINTN NumberOfPages)
EFI_STATUS EFIAPI SmmAllocatePages(IN EFI_ALLOCATE_TYPE Type, IN EFI_MEMORY_TYPE MemoryType, IN UINTN NumberOfPages, OUT EFI_PHYSICAL_ADDRESS *Memory)
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG(Expression)
VOID * EFI_PEI_FILE_HANDLE
EFI_STATUS EFIAPI PiSmmCommunicationPeiEntryPoint(IN EFI_PEI_FILE_HANDLE FileHandle, IN CONST EFI_PEI_SERVICES **PeiServices)
VOID SetCommunicationContext(IN EFI_SMM_COMMUNICATION_CONTEXT *SmmCommunicationContext)
VOID * InternalSmstGetVendorTableByGuid(IN UINT64 Signature, IN EFI_SMM_SYSTEM_TABLE2 *Smst, IN EFI_GUID *VendorGuid)
VOID InitCommunicationContext(VOID)
EFI_STATUS EFIAPI Communicate(IN CONST EFI_PEI_SMM_COMMUNICATION_PPI *This, IN OUT VOID *CommBuffer, IN OUT UINTN *CommSize)
EFI_SMM_COMMUNICATION_CONTEXT * GetCommunicationContext(VOID)
EFI_STATUS EFIAPI SmmFreePool(IN VOID *Buffer)
EFI_STATUS EFIAPI SmmAllocatePool(IN EFI_MEMORY_TYPE PoolType, IN UINTN Size, OUT VOID **Buffer)
UINT64 EFI_PHYSICAL_ADDRESS
EFI_STATUS EFIAPI SmmStartupThisAp(IN EFI_AP_PROCEDURE Procedure, IN UINTN CpuIndex, IN OUT VOID *ProcArguments OPTIONAL)
EFI_PHYSICAL_ADDRESS CpuStart