2008-03-19 10:01:03 +01:00
|
|
|
/** @file
|
2008-07-16 11:40:06 +02:00
|
|
|
EFI PEI Core PPI services
|
|
|
|
|
2014-08-14 07:55:08 +02:00
|
|
|
Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
|
2010-04-24 11:49:11 +02:00
|
|
|
This program and the accompanying materials
|
2008-02-29 19:24:43 +01:00
|
|
|
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.
|
2007-07-04 09:51:48 +02:00
|
|
|
|
2008-07-16 11:40:06 +02:00
|
|
|
**/
|
2007-07-04 09:51:48 +02:00
|
|
|
|
2008-10-31 05:35:02 +01:00
|
|
|
#include "PeiMain.h"
|
2007-07-04 09:51:48 +02:00
|
|
|
|
2008-07-16 11:40:06 +02:00
|
|
|
/**
|
2007-07-04 09:51:48 +02:00
|
|
|
|
2008-07-16 11:40:06 +02:00
|
|
|
Initialize PPI services.
|
2007-07-04 09:51:48 +02:00
|
|
|
|
2008-07-16 11:40:06 +02:00
|
|
|
@param PrivateData Pointer to the PEI Core data.
|
|
|
|
@param OldCoreData Pointer to old PEI Core data.
|
|
|
|
NULL if being run in non-permament memory mode.
|
2007-07-04 09:51:48 +02:00
|
|
|
|
2008-07-16 11:40:06 +02:00
|
|
|
**/
|
2007-07-04 09:51:48 +02:00
|
|
|
VOID
|
|
|
|
InitializePpiServices (
|
2007-09-24 13:38:43 +02:00
|
|
|
IN PEI_CORE_INSTANCE *PrivateData,
|
2007-07-04 09:51:48 +02:00
|
|
|
IN PEI_CORE_INSTANCE *OldCoreData
|
|
|
|
)
|
|
|
|
{
|
|
|
|
if (OldCoreData == NULL) {
|
2014-08-14 07:55:08 +02:00
|
|
|
PrivateData->PpiData.NotifyListEnd = PcdGet32 (PcdPeiCoreMaxPpiSupported)-1;
|
|
|
|
PrivateData->PpiData.DispatchListEnd = PcdGet32 (PcdPeiCoreMaxPpiSupported)-1;
|
|
|
|
PrivateData->PpiData.LastDispatchedNotify = PcdGet32 (PcdPeiCoreMaxPpiSupported)-1;
|
2007-07-04 09:51:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-16 11:40:06 +02:00
|
|
|
/**
|
|
|
|
|
2013-11-15 03:05:11 +01:00
|
|
|
Migrate Single PPI Pointer from the temporary memory to PEI installed memory.
|
|
|
|
|
|
|
|
@param PpiPointer Pointer to Ppi
|
|
|
|
@param TempBottom Base of old temporary memory
|
|
|
|
@param TempTop Top of old temporary memory
|
|
|
|
@param Offset Offset of new memory to old temporary memory.
|
|
|
|
@param OffsetPositive Positive flag of Offset value.
|
|
|
|
|
|
|
|
**/
|
|
|
|
VOID
|
|
|
|
ConverSinglePpiPointer (
|
|
|
|
IN PEI_PPI_LIST_POINTERS *PpiPointer,
|
|
|
|
IN UINTN TempBottom,
|
|
|
|
IN UINTN TempTop,
|
|
|
|
IN UINTN Offset,
|
|
|
|
IN BOOLEAN OffsetPositive
|
|
|
|
)
|
|
|
|
{
|
|
|
|
if (((UINTN)PpiPointer->Raw < TempTop) &&
|
|
|
|
((UINTN)PpiPointer->Raw >= TempBottom)) {
|
|
|
|
//
|
|
|
|
// Convert the pointer to the PPI descriptor from the old TempRam
|
|
|
|
// to the relocated physical memory.
|
|
|
|
//
|
|
|
|
if (OffsetPositive) {
|
|
|
|
PpiPointer->Raw = (VOID *) ((UINTN)PpiPointer->Raw + Offset);
|
|
|
|
} else {
|
|
|
|
PpiPointer->Raw = (VOID *) ((UINTN)PpiPointer->Raw - Offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Only when the PEIM descriptor is in the old TempRam should it be necessary
|
|
|
|
// to try to convert the pointers in the PEIM descriptor
|
|
|
|
//
|
|
|
|
|
|
|
|
if (((UINTN)PpiPointer->Ppi->Guid < TempTop) &&
|
|
|
|
((UINTN)PpiPointer->Ppi->Guid >= TempBottom)) {
|
|
|
|
//
|
|
|
|
// Convert the pointer to the GUID in the PPI or NOTIFY descriptor
|
|
|
|
// from the old TempRam to the relocated physical memory.
|
|
|
|
//
|
|
|
|
if (OffsetPositive) {
|
|
|
|
PpiPointer->Ppi->Guid = (VOID *) ((UINTN)PpiPointer->Ppi->Guid + Offset);
|
|
|
|
} else {
|
|
|
|
PpiPointer->Ppi->Guid = (VOID *) ((UINTN)PpiPointer->Ppi->Guid - Offset);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Convert the pointer to the PPI interface structure in the PPI descriptor
|
|
|
|
// from the old TempRam to the relocated physical memory.
|
|
|
|
//
|
|
|
|
if ((UINTN)PpiPointer->Ppi->Ppi < TempTop &&
|
|
|
|
(UINTN)PpiPointer->Ppi->Ppi >= TempBottom) {
|
|
|
|
if (OffsetPositive) {
|
|
|
|
PpiPointer->Ppi->Ppi = (VOID *) ((UINTN)PpiPointer->Ppi->Ppi + Offset);
|
|
|
|
} else {
|
|
|
|
PpiPointer->Ppi->Ppi = (VOID *) ((UINTN)PpiPointer->Ppi->Ppi - Offset);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
Migrate PPI Pointers from the temporary memory stack to PEI installed memory.
|
2008-07-16 11:40:06 +02:00
|
|
|
|
2011-09-15 08:48:20 +02:00
|
|
|
@param SecCoreData Points to a data structure containing SEC to PEI handoff data, such as the size
|
|
|
|
and location of temporary RAM, the stack location and the BFV location.
|
|
|
|
@param PrivateData Pointer to PeiCore's private data structure.
|
2008-07-16 11:40:06 +02:00
|
|
|
|
|
|
|
**/
|
2007-07-04 09:51:48 +02:00
|
|
|
VOID
|
|
|
|
ConvertPpiPointers (
|
2011-09-15 08:48:20 +02:00
|
|
|
IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,
|
|
|
|
IN PEI_CORE_INSTANCE *PrivateData
|
2007-07-04 09:51:48 +02:00
|
|
|
)
|
|
|
|
{
|
|
|
|
UINT8 Index;
|
2013-11-15 03:05:11 +01:00
|
|
|
UINT8 IndexHole;
|
2007-07-04 09:51:48 +02:00
|
|
|
|
2014-08-14 07:55:08 +02:00
|
|
|
for (Index = 0; Index < PcdGet32 (PcdPeiCoreMaxPpiSupported); Index++) {
|
2013-11-15 03:05:11 +01:00
|
|
|
if (Index < PrivateData->PpiData.PpiListEnd || Index > PrivateData->PpiData.NotifyListEnd) {
|
|
|
|
//
|
|
|
|
// Convert PPI pointer in old Heap
|
|
|
|
//
|
|
|
|
ConverSinglePpiPointer (
|
|
|
|
&PrivateData->PpiData.PpiListPtrs[Index],
|
|
|
|
(UINTN)SecCoreData->PeiTemporaryRamBase,
|
|
|
|
(UINTN)SecCoreData->PeiTemporaryRamBase + SecCoreData->PeiTemporaryRamSize,
|
|
|
|
PrivateData->HeapOffset,
|
|
|
|
PrivateData->HeapOffsetPositive
|
|
|
|
);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Convert PPI pointer in old Stack
|
|
|
|
//
|
|
|
|
ConverSinglePpiPointer (
|
|
|
|
&PrivateData->PpiData.PpiListPtrs[Index],
|
|
|
|
(UINTN)SecCoreData->StackBase,
|
|
|
|
(UINTN)SecCoreData->StackBase + SecCoreData->StackSize,
|
|
|
|
PrivateData->StackOffset,
|
|
|
|
PrivateData->StackOffsetPositive
|
|
|
|
);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Convert PPI pointer in old TempRam Hole
|
|
|
|
//
|
|
|
|
for (IndexHole = 0; IndexHole < HOLE_MAX_NUMBER; IndexHole ++) {
|
|
|
|
if (PrivateData->HoleData[IndexHole].Size == 0) {
|
|
|
|
continue;
|
2011-09-20 11:17:48 +02:00
|
|
|
}
|
2013-11-15 03:05:11 +01:00
|
|
|
|
|
|
|
ConverSinglePpiPointer (
|
|
|
|
&PrivateData->PpiData.PpiListPtrs[Index],
|
|
|
|
(UINTN)PrivateData->HoleData[IndexHole].Base,
|
|
|
|
(UINTN)PrivateData->HoleData[IndexHole].Base + PrivateData->HoleData[IndexHole].Size,
|
|
|
|
PrivateData->HoleData[IndexHole].Offset,
|
|
|
|
PrivateData->HoleData[IndexHole].OffsetPositive
|
|
|
|
);
|
2007-07-04 09:51:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-16 11:40:06 +02:00
|
|
|
/**
|
2007-07-04 09:51:48 +02:00
|
|
|
|
2008-08-08 03:36:13 +02:00
|
|
|
This function installs an interface in the PEI PPI database by GUID.
|
|
|
|
The purpose of the service is to publish an interface that other parties
|
|
|
|
can use to call additional PEIMs.
|
2007-07-04 09:51:48 +02:00
|
|
|
|
2008-08-08 03:36:13 +02:00
|
|
|
@param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
|
|
|
|
@param PpiList Pointer to a list of PEI PPI Descriptors.
|
2008-07-16 11:40:06 +02:00
|
|
|
|
2008-08-08 03:36:13 +02:00
|
|
|
@retval EFI_SUCCESS if all PPIs in PpiList are successfully installed.
|
|
|
|
@retval EFI_INVALID_PARAMETER if PpiList is NULL pointer
|
2008-08-08 05:05:03 +02:00
|
|
|
if any PPI in PpiList is not valid
|
2008-08-08 03:36:13 +02:00
|
|
|
@retval EFI_OUT_OF_RESOURCES if there is no more memory resource to install PPI
|
2008-07-16 11:40:06 +02:00
|
|
|
|
|
|
|
**/
|
2007-07-04 09:51:48 +02:00
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
PeiInstallPpi (
|
2007-09-04 08:12:48 +02:00
|
|
|
IN CONST EFI_PEI_SERVICES **PeiServices,
|
|
|
|
IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList
|
2007-07-04 09:51:48 +02:00
|
|
|
)
|
|
|
|
{
|
|
|
|
PEI_CORE_INSTANCE *PrivateData;
|
|
|
|
INTN Index;
|
|
|
|
INTN LastCallbackInstall;
|
|
|
|
|
|
|
|
|
|
|
|
if (PpiList == NULL) {
|
|
|
|
return EFI_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS(PeiServices);
|
|
|
|
|
|
|
|
Index = PrivateData->PpiData.PpiListEnd;
|
|
|
|
LastCallbackInstall = Index;
|
|
|
|
|
|
|
|
//
|
|
|
|
// This is loop installs all PPI descriptors in the PpiList. It is terminated
|
|
|
|
// by the EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST being set in the last
|
|
|
|
// EFI_PEI_PPI_DESCRIPTOR in the list.
|
|
|
|
//
|
2008-02-29 19:24:43 +01:00
|
|
|
|
2007-07-04 09:51:48 +02:00
|
|
|
for (;;) {
|
|
|
|
//
|
2008-08-08 05:05:03 +02:00
|
|
|
// Since PpiData is used for NotifyList and PpiList, max resource
|
2007-07-04 09:51:48 +02:00
|
|
|
// is reached if the Install reaches the NotifyList
|
2009-03-05 06:05:57 +01:00
|
|
|
// PcdPeiCoreMaxPpiSupported can be set to a larger value in DSC to satisfy more PPI requirement.
|
2007-07-04 09:51:48 +02:00
|
|
|
//
|
|
|
|
if (Index == PrivateData->PpiData.NotifyListEnd + 1) {
|
|
|
|
return EFI_OUT_OF_RESOURCES;
|
|
|
|
}
|
|
|
|
//
|
2008-02-29 19:24:43 +01:00
|
|
|
// Check if it is a valid PPI.
|
2007-07-04 09:51:48 +02:00
|
|
|
// If not, rollback list to exclude all in this list.
|
|
|
|
// Try to indicate which item failed.
|
|
|
|
//
|
|
|
|
if ((PpiList->Flags & EFI_PEI_PPI_DESCRIPTOR_PPI) == 0) {
|
|
|
|
PrivateData->PpiData.PpiListEnd = LastCallbackInstall;
|
2008-10-27 11:13:00 +01:00
|
|
|
DEBUG((EFI_D_ERROR, "ERROR -> InstallPpi: %g %p\n", PpiList->Guid, PpiList->Ppi));
|
2007-07-04 09:51:48 +02:00
|
|
|
return EFI_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
|
2008-02-29 19:24:43 +01:00
|
|
|
DEBUG((EFI_D_INFO, "Install PPI: %g\n", PpiList->Guid));
|
|
|
|
PrivateData->PpiData.PpiListPtrs[Index].Ppi = (EFI_PEI_PPI_DESCRIPTOR*) PpiList;
|
2007-07-04 09:51:48 +02:00
|
|
|
PrivateData->PpiData.PpiListEnd++;
|
2008-02-29 19:24:43 +01:00
|
|
|
|
2007-07-04 09:51:48 +02:00
|
|
|
//
|
|
|
|
// Continue until the end of the PPI List.
|
|
|
|
//
|
2008-02-29 19:24:43 +01:00
|
|
|
if ((PpiList->Flags & EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) ==
|
2007-07-04 09:51:48 +02:00
|
|
|
EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
PpiList++;
|
|
|
|
Index++;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Dispatch any callback level notifies for newly installed PPIs.
|
|
|
|
//
|
|
|
|
DispatchNotify (
|
2007-09-24 13:38:43 +02:00
|
|
|
PrivateData,
|
2007-07-04 09:51:48 +02:00
|
|
|
EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK,
|
|
|
|
LastCallbackInstall,
|
|
|
|
PrivateData->PpiData.PpiListEnd,
|
2008-02-29 19:24:43 +01:00
|
|
|
PrivateData->PpiData.DispatchListEnd,
|
2007-07-04 09:51:48 +02:00
|
|
|
PrivateData->PpiData.NotifyListEnd
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2008-07-16 11:40:06 +02:00
|
|
|
/**
|
|
|
|
|
2008-08-08 03:36:13 +02:00
|
|
|
This function reinstalls an interface in the PEI PPI database by GUID.
|
|
|
|
The purpose of the service is to publish an interface that other parties can
|
|
|
|
use to replace an interface of the same name in the protocol database with a
|
|
|
|
different interface.
|
2008-07-16 11:40:06 +02:00
|
|
|
|
2008-08-08 03:36:13 +02:00
|
|
|
@param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
|
|
|
|
@param OldPpi Pointer to the old PEI PPI Descriptors.
|
|
|
|
@param NewPpi Pointer to the new PEI PPI Descriptors.
|
2007-07-04 09:51:48 +02:00
|
|
|
|
2008-08-08 03:36:13 +02:00
|
|
|
@retval EFI_SUCCESS if the operation was successful
|
|
|
|
@retval EFI_INVALID_PARAMETER if OldPpi or NewPpi is NULL
|
|
|
|
@retval EFI_INVALID_PARAMETER if NewPpi is not valid
|
|
|
|
@retval EFI_NOT_FOUND if the PPI was not in the database
|
2008-07-16 11:40:06 +02:00
|
|
|
|
|
|
|
**/
|
2007-07-04 09:51:48 +02:00
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
PeiReInstallPpi (
|
2007-09-04 08:12:48 +02:00
|
|
|
IN CONST EFI_PEI_SERVICES **PeiServices,
|
|
|
|
IN CONST EFI_PEI_PPI_DESCRIPTOR *OldPpi,
|
|
|
|
IN CONST EFI_PEI_PPI_DESCRIPTOR *NewPpi
|
2007-07-04 09:51:48 +02:00
|
|
|
)
|
|
|
|
{
|
|
|
|
PEI_CORE_INSTANCE *PrivateData;
|
|
|
|
INTN Index;
|
|
|
|
|
|
|
|
|
|
|
|
if ((OldPpi == NULL) || (NewPpi == NULL)) {
|
|
|
|
return EFI_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((NewPpi->Flags & EFI_PEI_PPI_DESCRIPTOR_PPI) == 0) {
|
|
|
|
return EFI_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS(PeiServices);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Find the old PPI instance in the database. If we can not find it,
|
|
|
|
// return the EFI_NOT_FOUND error.
|
|
|
|
//
|
|
|
|
for (Index = 0; Index < PrivateData->PpiData.PpiListEnd; Index++) {
|
|
|
|
if (OldPpi == PrivateData->PpiData.PpiListPtrs[Index].Ppi) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (Index == PrivateData->PpiData.PpiListEnd) {
|
|
|
|
return EFI_NOT_FOUND;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Remove the old PPI from the database, add the new one.
|
2008-02-29 19:24:43 +01:00
|
|
|
//
|
2007-07-04 09:51:48 +02:00
|
|
|
DEBUG((EFI_D_INFO, "Reinstall PPI: %g\n", NewPpi->Guid));
|
2014-08-14 07:55:08 +02:00
|
|
|
ASSERT (Index < (INTN)(PcdGet32 (PcdPeiCoreMaxPpiSupported)));
|
2007-09-04 08:12:48 +02:00
|
|
|
PrivateData->PpiData.PpiListPtrs[Index].Ppi = (EFI_PEI_PPI_DESCRIPTOR *) NewPpi;
|
2007-07-04 09:51:48 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// Dispatch any callback level notifies for the newly installed PPI.
|
|
|
|
//
|
|
|
|
DispatchNotify (
|
2007-09-24 13:38:43 +02:00
|
|
|
PrivateData,
|
2007-07-04 09:51:48 +02:00
|
|
|
EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK,
|
|
|
|
Index,
|
|
|
|
Index+1,
|
2008-02-29 19:24:43 +01:00
|
|
|
PrivateData->PpiData.DispatchListEnd,
|
2007-07-04 09:51:48 +02:00
|
|
|
PrivateData->PpiData.NotifyListEnd
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2008-07-16 11:40:06 +02:00
|
|
|
/**
|
|
|
|
|
|
|
|
Locate a given named PPI.
|
|
|
|
|
2007-07-04 09:51:48 +02:00
|
|
|
|
2008-08-08 03:36:13 +02:00
|
|
|
@param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
|
|
|
|
@param Guid Pointer to GUID of the PPI.
|
|
|
|
@param Instance Instance Number to discover.
|
|
|
|
@param PpiDescriptor Pointer to reference the found descriptor. If not NULL,
|
|
|
|
returns a pointer to the descriptor (includes flags, etc)
|
|
|
|
@param Ppi Pointer to reference the found PPI
|
2008-07-16 11:40:06 +02:00
|
|
|
|
|
|
|
@retval EFI_SUCCESS if the PPI is in the database
|
|
|
|
@retval EFI_NOT_FOUND if the PPI is not in the database
|
|
|
|
|
|
|
|
**/
|
2007-07-04 09:51:48 +02:00
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
PeiLocatePpi (
|
2007-09-04 08:12:48 +02:00
|
|
|
IN CONST EFI_PEI_SERVICES **PeiServices,
|
|
|
|
IN CONST EFI_GUID *Guid,
|
2008-08-08 03:36:13 +02:00
|
|
|
IN UINTN Instance,
|
|
|
|
IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor,
|
|
|
|
IN OUT VOID **Ppi
|
2007-07-04 09:51:48 +02:00
|
|
|
)
|
|
|
|
{
|
|
|
|
PEI_CORE_INSTANCE *PrivateData;
|
|
|
|
INTN Index;
|
|
|
|
EFI_GUID *CheckGuid;
|
|
|
|
EFI_PEI_PPI_DESCRIPTOR *TempPtr;
|
|
|
|
|
2008-02-29 19:24:43 +01:00
|
|
|
|
2007-07-04 09:51:48 +02:00
|
|
|
PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS(PeiServices);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Search the data base for the matching instance of the GUIDed PPI.
|
|
|
|
//
|
|
|
|
for (Index = 0; Index < PrivateData->PpiData.PpiListEnd; Index++) {
|
|
|
|
TempPtr = PrivateData->PpiData.PpiListPtrs[Index].Ppi;
|
|
|
|
CheckGuid = TempPtr->Guid;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Don't use CompareGuid function here for performance reasons.
|
|
|
|
// Instead we compare the GUID as INT32 at a time and branch
|
|
|
|
// on the first failed comparison.
|
|
|
|
//
|
|
|
|
if ((((INT32 *)Guid)[0] == ((INT32 *)CheckGuid)[0]) &&
|
|
|
|
(((INT32 *)Guid)[1] == ((INT32 *)CheckGuid)[1]) &&
|
|
|
|
(((INT32 *)Guid)[2] == ((INT32 *)CheckGuid)[2]) &&
|
|
|
|
(((INT32 *)Guid)[3] == ((INT32 *)CheckGuid)[3])) {
|
|
|
|
if (Instance == 0) {
|
|
|
|
|
|
|
|
if (PpiDescriptor != NULL) {
|
|
|
|
*PpiDescriptor = TempPtr;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Ppi != NULL) {
|
|
|
|
*Ppi = TempPtr->Ppi;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
Instance--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return EFI_NOT_FOUND;
|
|
|
|
}
|
|
|
|
|
2008-07-16 11:40:06 +02:00
|
|
|
/**
|
2007-07-04 09:51:48 +02:00
|
|
|
|
2008-08-08 03:36:13 +02:00
|
|
|
This function installs a notification service to be called back when a given
|
|
|
|
interface is installed or reinstalled. The purpose of the service is to publish
|
|
|
|
an interface that other parties can use to call additional PPIs that may materialize later.
|
2008-07-16 11:40:06 +02:00
|
|
|
|
2008-08-08 03:36:13 +02:00
|
|
|
@param PeiServices An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.
|
|
|
|
@param NotifyList Pointer to list of Descriptors to notify upon.
|
2008-07-16 11:40:06 +02:00
|
|
|
|
|
|
|
@retval EFI_SUCCESS if successful
|
|
|
|
@retval EFI_OUT_OF_RESOURCES if no space in the database
|
|
|
|
@retval EFI_INVALID_PARAMETER if not a good decriptor
|
|
|
|
|
|
|
|
**/
|
2007-07-04 09:51:48 +02:00
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
PeiNotifyPpi (
|
2007-09-04 08:12:48 +02:00
|
|
|
IN CONST EFI_PEI_SERVICES **PeiServices,
|
|
|
|
IN CONST EFI_PEI_NOTIFY_DESCRIPTOR *NotifyList
|
2007-07-04 09:51:48 +02:00
|
|
|
)
|
|
|
|
{
|
|
|
|
PEI_CORE_INSTANCE *PrivateData;
|
|
|
|
INTN Index;
|
|
|
|
INTN NotifyIndex;
|
|
|
|
INTN LastCallbackNotify;
|
|
|
|
EFI_PEI_NOTIFY_DESCRIPTOR *NotifyPtr;
|
|
|
|
UINTN NotifyDispatchCount;
|
|
|
|
|
|
|
|
|
|
|
|
NotifyDispatchCount = 0;
|
|
|
|
|
|
|
|
if (NotifyList == NULL) {
|
|
|
|
return EFI_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS(PeiServices);
|
|
|
|
|
|
|
|
Index = PrivateData->PpiData.NotifyListEnd;
|
|
|
|
LastCallbackNotify = Index;
|
|
|
|
|
|
|
|
//
|
|
|
|
// This is loop installs all Notify descriptors in the NotifyList. It is
|
|
|
|
// terminated by the EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST being set in the last
|
|
|
|
// EFI_PEI_NOTIFY_DESCRIPTOR in the list.
|
|
|
|
//
|
|
|
|
|
|
|
|
for (;;) {
|
|
|
|
//
|
|
|
|
// Since PpiData is used for NotifyList and InstallList, max resource
|
|
|
|
// is reached if the Install reaches the PpiList
|
2009-03-05 06:05:57 +01:00
|
|
|
// PcdPeiCoreMaxPpiSupported can be set to a larger value in DSC to satisfy more Notify PPIs requirement.
|
2007-07-04 09:51:48 +02:00
|
|
|
//
|
|
|
|
if (Index == PrivateData->PpiData.PpiListEnd - 1) {
|
|
|
|
return EFI_OUT_OF_RESOURCES;
|
|
|
|
}
|
2008-02-29 19:24:43 +01:00
|
|
|
|
2007-07-04 09:51:48 +02:00
|
|
|
//
|
|
|
|
// If some of the PPI data is invalid restore original Notify PPI database value
|
|
|
|
//
|
|
|
|
if ((NotifyList->Flags & EFI_PEI_PPI_DESCRIPTOR_NOTIFY_TYPES) == 0) {
|
|
|
|
PrivateData->PpiData.NotifyListEnd = LastCallbackNotify;
|
2008-10-27 11:13:00 +01:00
|
|
|
DEBUG((EFI_D_ERROR, "ERROR -> InstallNotify: %g %p\n", NotifyList->Guid, NotifyList->Notify));
|
2007-07-04 09:51:48 +02:00
|
|
|
return EFI_INVALID_PARAMETER;
|
|
|
|
}
|
2008-02-29 19:24:43 +01:00
|
|
|
|
2007-07-04 09:51:48 +02:00
|
|
|
if ((NotifyList->Flags & EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH) != 0) {
|
2008-02-29 19:24:43 +01:00
|
|
|
NotifyDispatchCount ++;
|
|
|
|
}
|
|
|
|
|
|
|
|
PrivateData->PpiData.PpiListPtrs[Index].Notify = (EFI_PEI_NOTIFY_DESCRIPTOR *) NotifyList;
|
|
|
|
|
2007-07-04 09:51:48 +02:00
|
|
|
PrivateData->PpiData.NotifyListEnd--;
|
|
|
|
DEBUG((EFI_D_INFO, "Register PPI Notify: %g\n", NotifyList->Guid));
|
|
|
|
if ((NotifyList->Flags & EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) ==
|
|
|
|
EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
//
|
|
|
|
// Go the next descriptor. Remember the NotifyList moves down.
|
|
|
|
//
|
|
|
|
NotifyList++;
|
|
|
|
Index--;
|
|
|
|
}
|
2008-02-29 19:24:43 +01:00
|
|
|
|
2007-07-04 09:51:48 +02:00
|
|
|
//
|
2008-02-29 19:24:43 +01:00
|
|
|
// If there is Dispatch Notify PPI installed put them on the bottom
|
2007-07-04 09:51:48 +02:00
|
|
|
//
|
|
|
|
if (NotifyDispatchCount > 0) {
|
2008-02-29 19:24:43 +01:00
|
|
|
for (NotifyIndex = LastCallbackNotify; NotifyIndex > PrivateData->PpiData.NotifyListEnd; NotifyIndex--) {
|
2007-07-04 09:51:48 +02:00
|
|
|
if ((PrivateData->PpiData.PpiListPtrs[NotifyIndex].Notify->Flags & EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH) != 0) {
|
|
|
|
NotifyPtr = PrivateData->PpiData.PpiListPtrs[NotifyIndex].Notify;
|
2008-02-29 19:24:43 +01:00
|
|
|
|
2007-07-04 09:51:48 +02:00
|
|
|
for (Index = NotifyIndex; Index < PrivateData->PpiData.DispatchListEnd; Index++){
|
|
|
|
PrivateData->PpiData.PpiListPtrs[Index].Notify = PrivateData->PpiData.PpiListPtrs[Index + 1].Notify;
|
|
|
|
}
|
|
|
|
PrivateData->PpiData.PpiListPtrs[Index].Notify = NotifyPtr;
|
2008-02-29 19:24:43 +01:00
|
|
|
PrivateData->PpiData.DispatchListEnd--;
|
2007-07-04 09:51:48 +02:00
|
|
|
}
|
|
|
|
}
|
2008-02-29 19:24:43 +01:00
|
|
|
|
|
|
|
LastCallbackNotify -= NotifyDispatchCount;
|
2007-07-04 09:51:48 +02:00
|
|
|
}
|
2008-02-29 19:24:43 +01:00
|
|
|
|
2007-07-04 09:51:48 +02:00
|
|
|
//
|
|
|
|
// Dispatch any callback level notifies for all previously installed PPIs.
|
|
|
|
//
|
|
|
|
DispatchNotify (
|
2007-09-24 13:38:43 +02:00
|
|
|
PrivateData,
|
2007-07-04 09:51:48 +02:00
|
|
|
EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK,
|
|
|
|
0,
|
|
|
|
PrivateData->PpiData.PpiListEnd,
|
|
|
|
LastCallbackNotify,
|
|
|
|
PrivateData->PpiData.NotifyListEnd
|
|
|
|
);
|
2008-02-29 19:24:43 +01:00
|
|
|
|
2007-07-04 09:51:48 +02:00
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-07-16 11:40:06 +02:00
|
|
|
/**
|
2007-07-04 09:51:48 +02:00
|
|
|
|
|
|
|
Process the Notify List at dispatch level.
|
|
|
|
|
2008-07-16 11:40:06 +02:00
|
|
|
@param PrivateData PeiCore's private data structure.
|
2007-07-04 09:51:48 +02:00
|
|
|
|
2008-07-16 11:40:06 +02:00
|
|
|
**/
|
|
|
|
VOID
|
|
|
|
ProcessNotifyList (
|
|
|
|
IN PEI_CORE_INSTANCE *PrivateData
|
|
|
|
)
|
2007-07-04 09:51:48 +02:00
|
|
|
{
|
|
|
|
INTN TempValue;
|
2008-02-29 19:24:43 +01:00
|
|
|
|
2007-07-04 09:51:48 +02:00
|
|
|
while (TRUE) {
|
|
|
|
//
|
|
|
|
// Check if the PEIM that was just dispatched resulted in any
|
|
|
|
// Notifies getting installed. If so, go process any dispatch
|
|
|
|
// level Notifies that match the previouly installed PPIs.
|
2008-02-29 19:24:43 +01:00
|
|
|
// Use "while" instead of "if" since DispatchNotify can modify
|
2007-07-04 09:51:48 +02:00
|
|
|
// DispatchListEnd (with NotifyPpi) so we have to iterate until the same.
|
|
|
|
//
|
|
|
|
while (PrivateData->PpiData.LastDispatchedNotify != PrivateData->PpiData.DispatchListEnd) {
|
|
|
|
TempValue = PrivateData->PpiData.DispatchListEnd;
|
|
|
|
DispatchNotify (
|
2007-09-24 13:38:43 +02:00
|
|
|
PrivateData,
|
2007-07-04 09:51:48 +02:00
|
|
|
EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH,
|
|
|
|
0,
|
|
|
|
PrivateData->PpiData.LastDispatchedInstall,
|
|
|
|
PrivateData->PpiData.LastDispatchedNotify,
|
|
|
|
PrivateData->PpiData.DispatchListEnd
|
|
|
|
);
|
|
|
|
PrivateData->PpiData.LastDispatchedNotify = TempValue;
|
|
|
|
}
|
2008-02-29 19:24:43 +01:00
|
|
|
|
|
|
|
|
2007-07-04 09:51:48 +02:00
|
|
|
//
|
|
|
|
// Check if the PEIM that was just dispatched resulted in any
|
|
|
|
// PPIs getting installed. If so, go process any dispatch
|
|
|
|
// level Notifies that match the installed PPIs.
|
2008-02-29 19:24:43 +01:00
|
|
|
// Use "while" instead of "if" since DispatchNotify can modify
|
2007-07-04 09:51:48 +02:00
|
|
|
// PpiListEnd (with InstallPpi) so we have to iterate until the same.
|
|
|
|
//
|
|
|
|
while (PrivateData->PpiData.LastDispatchedInstall != PrivateData->PpiData.PpiListEnd) {
|
|
|
|
TempValue = PrivateData->PpiData.PpiListEnd;
|
|
|
|
DispatchNotify (
|
2007-09-24 13:38:43 +02:00
|
|
|
PrivateData,
|
2007-07-04 09:51:48 +02:00
|
|
|
EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH,
|
|
|
|
PrivateData->PpiData.LastDispatchedInstall,
|
|
|
|
PrivateData->PpiData.PpiListEnd,
|
2014-08-14 07:55:08 +02:00
|
|
|
PcdGet32 (PcdPeiCoreMaxPpiSupported)-1,
|
2007-07-04 09:51:48 +02:00
|
|
|
PrivateData->PpiData.DispatchListEnd
|
|
|
|
);
|
|
|
|
PrivateData->PpiData.LastDispatchedInstall = TempValue;
|
|
|
|
}
|
2008-02-29 19:24:43 +01:00
|
|
|
|
2007-07-04 09:51:48 +02:00
|
|
|
if (PrivateData->PpiData.LastDispatchedNotify == PrivateData->PpiData.DispatchListEnd) {
|
|
|
|
break;
|
|
|
|
}
|
2008-02-29 19:24:43 +01:00
|
|
|
}
|
2007-07-04 09:51:48 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-07-16 11:40:06 +02:00
|
|
|
/**
|
|
|
|
|
|
|
|
Dispatch notifications.
|
|
|
|
|
|
|
|
@param PrivateData PeiCore's private data structure
|
|
|
|
@param NotifyType Type of notify to fire.
|
|
|
|
@param InstallStartIndex Install Beginning index.
|
|
|
|
@param InstallStopIndex Install Ending index.
|
|
|
|
@param NotifyStartIndex Notify Beginning index.
|
|
|
|
@param NotifyStopIndex Notify Ending index.
|
|
|
|
|
|
|
|
**/
|
2007-07-04 09:51:48 +02:00
|
|
|
VOID
|
|
|
|
DispatchNotify (
|
2007-09-24 13:38:43 +02:00
|
|
|
IN PEI_CORE_INSTANCE *PrivateData,
|
2007-07-04 09:51:48 +02:00
|
|
|
IN UINTN NotifyType,
|
|
|
|
IN INTN InstallStartIndex,
|
|
|
|
IN INTN InstallStopIndex,
|
|
|
|
IN INTN NotifyStartIndex,
|
|
|
|
IN INTN NotifyStopIndex
|
|
|
|
)
|
|
|
|
{
|
|
|
|
INTN Index1;
|
|
|
|
INTN Index2;
|
|
|
|
EFI_GUID *SearchGuid;
|
|
|
|
EFI_GUID *CheckGuid;
|
|
|
|
EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Remember that Installs moves up and Notifies moves down.
|
|
|
|
//
|
|
|
|
for (Index1 = NotifyStartIndex; Index1 > NotifyStopIndex; Index1--) {
|
|
|
|
NotifyDescriptor = PrivateData->PpiData.PpiListPtrs[Index1].Notify;
|
|
|
|
|
|
|
|
CheckGuid = NotifyDescriptor->Guid;
|
|
|
|
|
|
|
|
for (Index2 = InstallStartIndex; Index2 < InstallStopIndex; Index2++) {
|
|
|
|
SearchGuid = PrivateData->PpiData.PpiListPtrs[Index2].Ppi->Guid;
|
|
|
|
//
|
|
|
|
// Don't use CompareGuid function here for performance reasons.
|
|
|
|
// Instead we compare the GUID as INT32 at a time and branch
|
|
|
|
// on the first failed comparison.
|
|
|
|
//
|
|
|
|
if ((((INT32 *)SearchGuid)[0] == ((INT32 *)CheckGuid)[0]) &&
|
|
|
|
(((INT32 *)SearchGuid)[1] == ((INT32 *)CheckGuid)[1]) &&
|
|
|
|
(((INT32 *)SearchGuid)[2] == ((INT32 *)CheckGuid)[2]) &&
|
|
|
|
(((INT32 *)SearchGuid)[3] == ((INT32 *)CheckGuid)[3])) {
|
2008-10-27 11:13:00 +01:00
|
|
|
DEBUG ((EFI_D_INFO, "Notify: PPI Guid: %g, Peim notify entry point: %p\n",
|
2008-02-29 19:24:43 +01:00
|
|
|
SearchGuid,
|
2007-07-04 09:51:48 +02:00
|
|
|
NotifyDescriptor->Notify
|
|
|
|
));
|
|
|
|
NotifyDescriptor->Notify (
|
2008-10-17 10:42:33 +02:00
|
|
|
(EFI_PEI_SERVICES **) GetPeiServicesTablePointer (),
|
2007-07-04 09:51:48 +02:00
|
|
|
NotifyDescriptor,
|
|
|
|
(PrivateData->PpiData.PpiListPtrs[Index2].Ppi)->Ppi
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|