/* Finds the SMI entry for the requested handler type. */
SMI_ENTRY* EFIAPI SmmCoreFindSmiEntry(IN EFI_GUID *HandlerType, IN BOOLEAN Create)
/* Finds the SMI entry for the requested handler type. */
SMI_ENTRY* EFIAPI SmmCoreFindSmiEntry(IN EFI_GUID *HandlerType, IN BOOLEAN Create)
{
  LIST_ENTRY  *Link;
  SMI_ENTRY   *Item;
  SMI_ENTRY   *SmiEntry;
  SmiEntry = NULL;
  for (Link = mSmiEntryList.ForwardLink;
       Link != &mSmiEntryList;
       Link = Link->ForwardLink)
  {
    Item = CR (Link, SMI_ENTRY, AllEntries, SMI_ENTRY_SIGNATURE);
    if (CompareGuid (&Item->HandlerType, HandlerType)) {
      SmiEntry = Item;
      break;
    }
  }
  if ((SmiEntry == NULL) && Create) {
    SmiEntry = AllocatePool (sizeof (SMI_ENTRY));
    if (SmiEntry != NULL) {
      SmiEntry->Signature = SMI_ENTRY_SIGNATURE;
      CopyGuid ((VOID *)&SmiEntry->HandlerType, HandlerType);
      InitializeListHead (&SmiEntry->SmiHandlers);
      InsertTailList (&mSmiEntryList, &SmiEntry->AllEntries);
    }
  }
  return SmiEntry;
}