/*++

    Copyright (c) Microsoft Corporation.  All rights reserved.

Rule Name:

    StorPortStartIo

Domain:

    storport

Rule ID:

    Not Applicable

Description:

    Data allocation must never be performed in the miniport's StartIo routine.
		
    Note: Need to update the list of DDIs that apply here.

Help Link:

    https://go.microsoft.com/fwlink/?LinkId=507244

--*/



#include "ntddk_slic.h"

state {
	enum {yes, no} insideStartIo = no;
}

fun_SP_HW_STARTIO.entry 
{
  if($2->Function == SRB_FUNCTION_EXECUTE_SCSI || $2->Function == SRB_FUNCTION_FLUSH)
  {
	    insideStartIo = yes;
	}
}

[
ExAllocatePool,
ExAllocatePoolWithQuota,
ExAllocatePoolWithQuotaTag,
ExAllocatePoolWithTag,
ExAllocatePoolWithTagPriority,
FsRtlAllocateFileLock,
IoAllocateController,
IoAllocateIrp,
IoWMIAllocateInstanceIds,
MmAllocateNonCachedMemory,
MmAllocatePagesForMdl,
ZwAllocateLocallyUniqueId,
ZwAllocateVirtualMemory
].entry
{
	if (insideStartIo == yes) {
		abort "Data or memory allocation must not be performed inside StartIo. BuildIo is a better place to do that.";
	}
}

/*[
StorPortStallExecution,
ExAcquireSharedWaitForExclusive,
KeWaitForMutexObject,
KeWaitForMultipleObjects,
KeWaitForSingleObject,
FsRtlCancellableWaitForMultipleObjects,
FsRtlCancellableWaitForSingleObject,
ExEnterCriticalRegionAndAcquireSharedWaitForExclusive,
ExWaitForRundownProtectionReleaseCacheAware,
ExWaitForRundownProtectionRelease,
ZwWaitForSingleObject,
FsRtlIncrementCcFastReadWait,
CcWaitForCurrentLazyWriterActivity,
IoReleaseRemoveLockAndWaitEx
].entry
{
	if (insideStartIo == yes) {
		abort "Warning: Waits must not be performed while in StartIo.";
	}
}*/
