/** Process the Notify List at dispatch level. @param PrivateData PeiCore's private data structure. **/ VOID ProcessNotifyList ( IN PEI_CORE_INSTANCE *PrivateData ) { INTN TempValue; 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. // Use "while" instead of "if" since DispatchNotify can modify // DispatchListEnd (with NotifyPpi) so we have to iterate until the same. // while (PrivateData->PpiData.LastDispatchedNotify != PrivateData->PpiData.DispatchListEnd) { TempValue = PrivateData->PpiData.DispatchListEnd; DispatchNotify ( PrivateData, EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH, 0, PrivateData->PpiData.LastDispatchedInstall, PrivateData->PpiData.LastDispatchedNotify, PrivateData->PpiData.DispatchListEnd ); PrivateData->PpiData.LastDispatchedNotify = TempValue; } // // 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. // Use "while" instead of "if" since DispatchNotify can modify // PpiListEnd (with InstallPpi) so we have to iterate until the same. // while (PrivateData->PpiData.LastDispatchedInstall != PrivateData->PpiData.PpiListEnd) { TempValue = PrivateData->PpiData.PpiListEnd; DispatchNotify ( PrivateData, EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH, PrivateData->PpiData.LastDispatchedInstall, PrivateData->PpiData.PpiListEnd, PcdGet32 (PcdPeiCoreMaxPpiSupported)-1, PrivateData->PpiData.DispatchListEnd ); PrivateData->PpiData.LastDispatchedInstall = TempValue; } if (PrivateData->PpiData.LastDispatchedNotify == PrivateData->PpiData.DispatchListEnd) { break; } } return; }
/** 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. @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. @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 **/ EFI_STATUS EFIAPI PeiReInstallPpi ( IN CONST EFI_PEI_SERVICES **PeiServices, IN CONST EFI_PEI_PPI_DESCRIPTOR *OldPpi, IN CONST EFI_PEI_PPI_DESCRIPTOR *NewPpi ) { 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. // DEBUG((EFI_D_INFO, "Reinstall PPI: %g\n", NewPpi->Guid)); ASSERT (Index < (INTN)(PcdGet32 (PcdPeiCoreMaxPpiSupported))); PrivateData->PpiData.PpiListPtrs[Index].Ppi = (EFI_PEI_PPI_DESCRIPTOR *) NewPpi; // // Dispatch any callback level notifies for the newly installed PPI. // DispatchNotify ( PrivateData, EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK, Index, Index+1, PrivateData->PpiData.DispatchListEnd, PrivateData->PpiData.NotifyListEnd ); return EFI_SUCCESS; }
/** 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. @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. @param Single TRUE if only single entry in the NotifyList. FALSE if the NotifyList is ended with an entry which has the EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST flag set in its Flags field. @retval EFI_SUCCESS if successful @retval EFI_OUT_OF_RESOURCES if no space in the database @retval EFI_INVALID_PARAMETER if not a good descriptor **/ EFI_STATUS InternalPeiNotifyPpi ( IN CONST EFI_PEI_SERVICES **PeiServices, IN CONST EFI_PEI_NOTIFY_DESCRIPTOR *NotifyList, IN BOOLEAN Single ) { 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 // PcdPeiCoreMaxPpiSupported can be set to a larger value in DSC to satisfy more Notify PPIs requirement. // if (Index == PrivateData->PpiData.PpiListEnd - 1) { return EFI_OUT_OF_RESOURCES; } // // 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; DEBUG((EFI_D_ERROR, "ERROR -> InstallNotify: %g %p\n", NotifyList->Guid, NotifyList->Notify)); return EFI_INVALID_PARAMETER; } if ((NotifyList->Flags & EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH) != 0) { NotifyDispatchCount ++; } PrivateData->PpiData.PpiListPtrs[Index].Notify = (EFI_PEI_NOTIFY_DESCRIPTOR *) NotifyList; PrivateData->PpiData.NotifyListEnd--; DEBUG((EFI_D_INFO, "Register PPI Notify: %g\n", NotifyList->Guid)); if (Single) { // // Only single entry in the NotifyList. // break; } else if ((NotifyList->Flags & EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) == EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) { // // Continue until the end of the Notify List. // break; } // // Go the next descriptor. Remember the NotifyList moves down. // NotifyList++; Index--; } // // If there is Dispatch Notify PPI installed put them on the bottom // if (NotifyDispatchCount > 0) { for (NotifyIndex = LastCallbackNotify; NotifyIndex > PrivateData->PpiData.NotifyListEnd; NotifyIndex--) { if ((PrivateData->PpiData.PpiListPtrs[NotifyIndex].Notify->Flags & EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH) != 0) { NotifyPtr = PrivateData->PpiData.PpiListPtrs[NotifyIndex].Notify; 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; PrivateData->PpiData.DispatchListEnd--; } } LastCallbackNotify -= NotifyDispatchCount; } // // Dispatch any callback level notifies for all previously installed PPIs. // DispatchNotify ( PrivateData, EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK, 0, PrivateData->PpiData.PpiListEnd, LastCallbackNotify, PrivateData->PpiData.NotifyListEnd ); return EFI_SUCCESS; }
/** 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. @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. @param Single TRUE if only single entry in the PpiList. FALSE if the PpiList is ended with an entry which has the EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST flag set in its Flags field. @retval EFI_SUCCESS if all PPIs in PpiList are successfully installed. @retval EFI_INVALID_PARAMETER if PpiList is NULL pointer if any PPI in PpiList is not valid @retval EFI_OUT_OF_RESOURCES if there is no more memory resource to install PPI **/ EFI_STATUS InternalPeiInstallPpi ( IN CONST EFI_PEI_SERVICES **PeiServices, IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList, IN BOOLEAN Single ) { 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. // for (;;) { // // Since PpiData is used for NotifyList and PpiList, max resource // is reached if the Install reaches the NotifyList // PcdPeiCoreMaxPpiSupported can be set to a larger value in DSC to satisfy more PPI requirement. // if (Index == PrivateData->PpiData.NotifyListEnd + 1) { return EFI_OUT_OF_RESOURCES; } // // Check if it is a valid PPI. // 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; DEBUG((EFI_D_ERROR, "ERROR -> InstallPpi: %g %p\n", PpiList->Guid, PpiList->Ppi)); return EFI_INVALID_PARAMETER; } DEBUG((EFI_D_INFO, "Install PPI: %g\n", PpiList->Guid)); PrivateData->PpiData.PpiListPtrs[Index].Ppi = (EFI_PEI_PPI_DESCRIPTOR*) PpiList; PrivateData->PpiData.PpiListEnd++; if (Single) { // // Only single entry in the PpiList. // break; } else if ((PpiList->Flags & EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) == EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) { // // Continue until the end of the PPI List. // break; } PpiList++; Index++; } // // Dispatch any callback level notifies for newly installed PPIs. // DispatchNotify ( PrivateData, EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK, LastCallbackInstall, PrivateData->PpiData.PpiListEnd, PrivateData->PpiData.DispatchListEnd, PrivateData->PpiData.NotifyListEnd ); return EFI_SUCCESS; }
void CDllMain::PluginNotify(int code, void* data, ulong parm1, ulong parm2) { DispatchNotify(code, data, parm1, parm2); }