/* A callback function must be unregistered before it is deallocated. It is important that any registered callbacks that are not runtime complaint be unregistered when ExitBootServices() is called. */
EFI_STATUS EFIAPI Unregister(IN EFI_RSC_HANDLER_CALLBACK Callback)
/* A callback function must be unregistered before it is deallocated. It is important that any registered callbacks that are not runtime complaint be unregistered when ExitBootServices() is called. */
EFI_STATUS EFIAPI Unregister(IN EFI_RSC_HANDLER_CALLBACK Callback)
{
  LIST_ENTRY                  *Link;
  RSC_HANDLER_CALLBACK_ENTRY  *CallbackEntry;
  if (Callback == NULL) {
    return EFI_INVALID_PARAMETER;
  }
  for (Link = GetFirstNode (&mCallbackListHead); !IsNull (&mCallbackListHead, Link); Link = GetNextNode (&mCallbackListHead, Link)) {
    CallbackEntry = CR (Link, RSC_HANDLER_CALLBACK_ENTRY, Node, RSC_HANDLER_CALLBACK_ENTRY_SIGNATURE);
    if (CallbackEntry->RscHandlerCallback == Callback) {
      if (CallbackEntry->Tpl != TPL_HIGH_LEVEL) {
        FreePool ((VOID *)(UINTN)CallbackEntry->StatusCodeDataBuffer);
        gBS->CloseEvent (CallbackEntry->Event);
      }
      RemoveEntryList (&CallbackEntry->Node);
      FreePool (CallbackEntry);
      return EFI_SUCCESS;
    }
  }
  return EFI_NOT_FOUND;
}