/* Registers a function to be called from the processor interrupt handler. */
EFI_STATUS RegisterCpuInterruptHandlerWorker(IN EFI_EXCEPTION_TYPE InterruptType, IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler, IN EXCEPTION_HANDLER_DATA *ExceptionHandlerData)
/* Registers a function to be called from the processor interrupt handler. */
EFI_STATUS RegisterCpuInterruptHandlerWorker(IN EFI_EXCEPTION_TYPE InterruptType, IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler, IN EXCEPTION_HANDLER_DATA *ExceptionHandlerData)
{
  UINTN                      EnabledInterruptNum;
  RESERVED_VECTORS_DATA      *ReservedVectors;
  EFI_CPU_INTERRUPT_HANDLER  *ExternalInterruptHandler;
  EnabledInterruptNum      = ExceptionHandlerData->IdtEntryCount;
  ReservedVectors          = ExceptionHandlerData->ReservedVectors;
  ExternalInterruptHandler = ExceptionHandlerData->ExternalInterruptHandler;
  if ((InterruptType < 0) || (InterruptType >= (EFI_EXCEPTION_TYPE)EnabledInterruptNum) ||
      (ReservedVectors[InterruptType].Attribute == EFI_VECTOR_HANDOFF_DO_NOT_HOOK))
  {
    return EFI_UNSUPPORTED;
  }
  if ((InterruptHandler == NULL) && (ExternalInterruptHandler[InterruptType] == NULL)) {
    return EFI_INVALID_PARAMETER;
  }
  if ((InterruptHandler != NULL) && (ExternalInterruptHandler[InterruptType] != NULL)) {
    return EFI_ALREADY_STARTED;
  }
  ExternalInterruptHandler[InterruptType] = InterruptHandler;
  return EFI_SUCCESS;
}