/* This is the main worker function that manages the state of the interrupt handlers. It both installs and uninstalls interrupt handlers based on the value of NewCallback. If NewCallback is NULL, then uninstall is indicated. If NewCallback is non-NULL, then install is indicated. */
EFI_STATUS ManageIdtEntryTable(CALLBACK_FUNC NewCallback, EFI_EXCEPTION_TYPE ExceptionType)
/* This is the main worker function that manages the state of the interrupt handlers. It both installs and uninstalls interrupt handlers based on the value of NewCallback. If NewCallback is NULL, then uninstall is indicated. If NewCallback is non-NULL, then install is indicated. */
EFI_STATUS ManageIdtEntryTable(CALLBACK_FUNC NewCallback, EFI_EXCEPTION_TYPE ExceptionType)
{
  EFI_STATUS  Status;
  Status = EFI_SUCCESS;
  if (CompareMem (&IdtEntryTable[ExceptionType].NewDesc, &NullDesc, sizeof (IA32_IDT_GATE_DESCRIPTOR)) != 0) {
    if (NewCallback != NULL) {
      Status = EFI_ALREADY_STARTED;
    } else {
      UnhookEntry (ExceptionType);
    }
  } else {
    if (NewCallback == NULL) {
      Status = EFI_INVALID_PARAMETER;
    } else {
      HookEntry (ExceptionType, NewCallback);
    }
  }
  return Status;
}