alder_lake_bios/Insyde/InsydeModulePkg/Library/PeiChipsetSvcLib/PeiCsSvcEnableFdWrites.c

78 lines
2.4 KiB
C

/** @file
PEI Chipset Services Library.
This file contains only one function that is PeiCsSvcEnableFdWrites().
The function PeiCsSvcEnableFdWrites() use chipset services to enable/disable
flash device write access.
***************************************************************************
* Copyright (c) 2012 - 2015, Insyde Software Corp. All Rights Reserved.
*
* You may not reproduce, distribute, publish, display, perform, modify, adapt,
* transmit, broadcast, present, recite, release, license or otherwise exploit
* any part of this publication in any form, by any means, without the prior
* written permission of Insyde Software Corporation.
*
******************************************************************************
*/
#include <PiPei.h>
#include <Library/DebugLib.h>
#include <Library/PeiServicesLib.h>
#include <Ppi/H2OPeiChipsetServices.h>
STATIC H2O_CHIPSET_SERVICES_PPI *mChipsetSvcPpi = NULL;
/**
Platform specific function to enable/disable flash device write access.
@param[in] EnableWrites TRUE - Enable
FALSE - Disable
@retval EFI_SUCCESS Function returns successfully
@retval EFI_UNSUPPORTED If the function is not implemented.
*/
EFI_STATUS
EFIAPI
PeiCsSvcEnableFdWrites (
IN BOOLEAN EnableWrites
)
{
EFI_STATUS Status;
H2O_CHIPSET_SERVICES_PPI *ChipsetSvcPpi;
if (mChipsetSvcPpi == NULL) {
ChipsetSvcPpi = NULL;
Status = PeiServicesLocatePpi (
&gH2OChipsetServicesPpiGuid,
0,
NULL,
(VOID **)&ChipsetSvcPpi
);
if (EFI_ERROR(Status)) {
DEBUG ((EFI_D_ERROR, "H2O PEI Chipset Services can not be found!\n"));
return EFI_UNSUPPORTED;
}
mChipsetSvcPpi = ChipsetSvcPpi;
} else {
ChipsetSvcPpi = mChipsetSvcPpi;
}
//
// Verify that the PPI interface structure contains the function
// pointer and whether that function pointer is non-NULL. If not, return
// an error.
//
if (ChipsetSvcPpi == NULL ||
ChipsetSvcPpi->Size < (OFFSET_OF (H2O_CHIPSET_SERVICES_PPI, EnableFdWrites) + sizeof (VOID*)) ||
ChipsetSvcPpi->EnableFdWrites == NULL) {
DEBUG ((EFI_D_ERROR, "H2O PEI Chipset Services is NULL or member EnableFdWrites() isn't implement!\n"));
return EFI_UNSUPPORTED;
}
return ChipsetSvcPpi->EnableFdWrites (EnableWrites);
}