X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=EdkNt32Pkg%2FPei%2FMonoStatusCode%2FPlatformStatusCode.c;fp=EdkNt32Pkg%2FPei%2FMonoStatusCode%2FPlatformStatusCode.c;h=919ab05ee74e59eb2bc4e407034c72e59a6b025c;hb=29d19b7f2053f33ed48df49c9eae81cd3f214b0e;hp=0000000000000000000000000000000000000000;hpb=9b362fe72daa9e6e626c603c4e5dc2709396e81c;p=mirror_edk2.git diff --git a/EdkNt32Pkg/Pei/MonoStatusCode/PlatformStatusCode.c b/EdkNt32Pkg/Pei/MonoStatusCode/PlatformStatusCode.c new file mode 100644 index 0000000000..919ab05ee7 --- /dev/null +++ b/EdkNt32Pkg/Pei/MonoStatusCode/PlatformStatusCode.c @@ -0,0 +1,164 @@ +/*++ + +Copyright (c) 2006, Intel Corporation +All rights reserved. This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +Module Name: + + PlatformStatusCode.c + +Abstract: + + Contains NT32 specific implementations required to use status codes. + +--*/ + +#include "MonoStatusCode.h" + + +BOOLEAN gRunningFromMemory = FALSE; +// +// Platform definitions +// +EFI_PEI_REPORT_STATUS_CODE mSecReportStatusCode = NULL; + +extern EFI_PEI_PROGRESS_CODE_PPI mStatusCodePpi; + +// +// Function implementations +// +EFI_STATUS +EFIAPI +PlatformReportStatusCode ( + IN EFI_PEI_SERVICES **PeiServices, + IN EFI_STATUS_CODE_TYPE CodeType, + IN EFI_STATUS_CODE_VALUE Value, + IN UINT32 Instance, + IN EFI_GUID * CallerId, + IN EFI_STATUS_CODE_DATA * Data OPTIONAL + ) +/*++ + +Routine Description: + + Call all status code listeners in the MonoStatusCode. + +Arguments: + + Same as ReportStatusCode service + +Returns: + + EFI_SUCCESS Always returns success. + +--*/ +{ + if (mSecReportStatusCode != NULL) { + mSecReportStatusCode (PeiServices, CodeType, Value, Instance, CallerId, Data); + } + MemoryReportStatusCode (CodeType, Value, Instance, CallerId, Data); + return EFI_SUCCESS; +} + +VOID +PlatformInitializeStatusCode ( + IN EFI_FFS_FILE_HEADER *FfsHeader, + IN EFI_PEI_SERVICES **PeiServices + ) +/*++ + +Routine Description: + + Initialize the status code listeners. This consists of locating the + listener produced by SecMain.exe. + +Arguments: + + FfsHeader - FV this PEIM was loaded from. + PeiServices - General purpose services available to every PEIM. + +Returns: + + None + +--*/ +{ + EFI_STATUS Status; + EFI_PEI_PROGRESS_CODE_PPI *ReportStatusCodePpi; + EFI_PEI_PPI_DESCRIPTOR *ReportStatusCodeDescriptor; + + // + // Cache the existing status code listener installed by the SEC core. + // We should actually do a heap allocate, install a PPI, etc, but since we + // know that we are running from a DLL, we can use global variables, and + // directly update the status code PPI descriptor + // + // + // Locate SEC status code PPI + // + Status = (*PeiServices)->LocatePpi ( + PeiServices, + &gEfiPeiStatusCodePpiGuid, + 0, + &ReportStatusCodeDescriptor, + &ReportStatusCodePpi + ); + if (EFI_ERROR (Status)) { + return ; + } + + mSecReportStatusCode = ReportStatusCodePpi->ReportStatusCode; + ReportStatusCodeDescriptor->Ppi = &mStatusCodePpi; + + // + // Always initialize memory status code listener. + // + MemoryStatusCodeInitialize (FfsHeader, PeiServices); + +} + +EFI_STATUS +EFIAPI +InstallMonoStatusCode ( + IN EFI_FFS_FILE_HEADER *FfsHeader, + IN EFI_PEI_SERVICES **PeiServices + ) +/*++ + +Routine Description: + + Install the PEIM. Publish the DXE callback as well. + +Arguments: + + FfsHeader - FV this PEIM was loaded from. + PeiServices - General purpose services available to every PEIM. + +Returns: + + EFI_SUCCESS The function always returns success. + +--*/ +{ + if (!gRunningFromMemory) { + // + // First pass, running from flash, initialize everything + // + InitializeMonoStatusCode (FfsHeader, PeiServices); + } else { + // + // Second pass, running from memory, initialize memory listener and + // publish the DXE listener in a HOB. + // + MemoryStatusCodeInitialize (FfsHeader, PeiServices); + InitializeDxeReportStatusCode (PeiServices); + } + + return EFI_SUCCESS; +}