/* Internal helper notify function in which update the result of the non-blocking SCSI Read/Write commands and signal caller event. */
VOID EFIAPI ScsiLibNotify(IN EFI_EVENT Event, IN VOID *Context)
/* Internal helper notify function in which update the result of the non-blocking SCSI Read/Write commands and signal caller event. */
VOID EFIAPI ScsiLibNotify(IN EFI_EVENT Event, IN VOID *Context)
{
  EFI_SCSI_LIB_ASYNC_CONTEXT       *LibContext;
  EFI_SCSI_IO_SCSI_REQUEST_PACKET  *CommandPacket;
  EFI_EVENT                        CallerEvent;
  LibContext    = (EFI_SCSI_LIB_ASYNC_CONTEXT *)Context;
  CommandPacket = &LibContext->CommandPacket;
  CallerEvent   = LibContext->CallerEvent;
  *LibContext->SenseDataLength   = CommandPacket->SenseDataLength;
  *LibContext->HostAdapterStatus = CommandPacket->HostAdapterStatus;
  *LibContext->TargetStatus      = CommandPacket->TargetStatus;
  if (CommandPacket->InDataBuffer != NULL) {
    *LibContext->DataLength = CommandPacket->InTransferLength;
  } else {
    *LibContext->DataLength = CommandPacket->OutTransferLength;
  }
  if (CommandPacket->Cdb != NULL) {
    FreePool (CommandPacket->Cdb);
  }
  FreePool (Context);
  gBS->CloseEvent (Event);
  gBS->SignalEvent (CallerEvent);
}