/* Finds the MMI entry for the requested handler type. */
MMI_ENTRY* EFIAPI MmCoreFindMmiEntry(IN EFI_GUID *HandlerType, IN BOOLEAN Create)
/* Finds the MMI entry for the requested handler type. */
MMI_ENTRY* EFIAPI MmCoreFindMmiEntry(IN EFI_GUID *HandlerType, IN BOOLEAN Create)
{
  LIST_ENTRY  *Link;
  MMI_ENTRY   *Item;
  MMI_ENTRY   *MmiEntry;
  MmiEntry = NULL;
  for (Link = mMmiEntryList.ForwardLink;
       Link != &mMmiEntryList;
       Link = Link->ForwardLink)
  {
    Item = CR (Link, MMI_ENTRY, AllEntries, MMI_ENTRY_SIGNATURE);
    if (CompareGuid (&Item->HandlerType, HandlerType)) {
      MmiEntry = Item;
      break;
    }
  }
  if ((MmiEntry == NULL) && Create) {
    MmiEntry = AllocatePool (sizeof (MMI_ENTRY));
    if (MmiEntry != NULL) {
      MmiEntry->Signature = MMI_ENTRY_SIGNATURE;
      CopyGuid ((VOID *)&MmiEntry->HandlerType, HandlerType);
      InitializeListHead (&MmiEntry->MmiHandlers);
      InsertTailList (&mMmiEntryList, &MmiEntry->AllEntries);
    }
  }
  return MmiEntry;
}