/*++

    Copyright (c) Microsoft Corporation.  All rights reserved.

Rule Name:

    CancelSpinLock

Domain:

    storport

Rule ID:

    Not Applicable

Description:

    
    This rule verifies that each call to IoAcquireCancelSpinLock is 
    promptly followed by a call to IoReleaseCancelSpinlock. IoReleaseCancelSpinlock
    must not be called without acquiring the cancel spin lock first. In addition,
    when a miniport callback routine exits, it must not be holding any cancel spin locks.

Help Link:

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

--*/



#include "ntddk_slic.h"

state {
	enum {unlocked,locked} s = unlocked;
}

IoAcquireCancelSpinLock.exit {

	if(s==locked) {
		abort "The driver is calling $fname after already acquiring the cancel spinlock.";
	} else {
		s=locked;
	}
}

IoReleaseCancelSpinLock.exit {	
	
	if(s==unlocked) {
		abort "The driver is calling $fname without first acquiring the cancel spinlock.";
	} else {
		s=unlocked;
	}
}

[ALL_SP_CALLBACKS].exit {

	if(s==locked) {
		abort "The dispatch routine has returned without releasing the cancel spinlock.";
	}
}
