{
PEXTENDED_DEVOBJ_EXTENSION DeviceExtension;
PDEVICE_OBJECT_POWER_EXTENSION Dope;
KIRQLOldIrql;
PAGED_CODE();
/* If the device already has the dope, return it */
DeviceExtension = IoGetDevObjExtension(DeviceObject);
if (DeviceExtension->Dope) goto Return;
/* Allocate some dope for the device */
Dope = ExAllocatePoolWithTag(NonPagedPool,
sizeof(DEVICE_OBJECT_POWER_EXTENSION),
'Dope');
if (!Dope) goto Return;
/* Initialize the initial contents of the dope */RtlZeroMemory(Dope, sizeof(DEVICE_OBJECT_POWER_EXTENSION));
Dope->DeviceObject = DeviceObject;
Dope->State = PowerDeviceUnspecified;
InitializeListHead(&Dope->IdleList);
/* Make sure only one caller can assign dope to a device */KeAcquireSpinLock(&PopDopeGlobalLock, &OldIrql);
/* Make sure the device still has no dope */if (!DeviceExtension->Dope)
{
/* Give the local dope to this device, and remember we won the race */
DeviceExtension->Dope = (PVOID)Dope;
Dope = NULL;
}
/* Allow other dope transactions now */KeReleaseSpinLock(&PopDopeGlobalLock, OldIrql);
/* Check if someone other than us already assigned the dope, so free ours */if (Dope) ExFreePoolWithTag(Dope, 'Dope');
/* Return the dope to the caller */
Return:
return (PDEVICE_OBJECT_POWER_EXTENSION)DeviceExtension->Dope;
}
Generated on Sun May 27 2012 06:08:34 for ReactOS by
1.7.6.1
ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.