2006-06-30 16:56:18 +00:00
|
|
|
/*
|
|
|
|
* PROJECT: ReactOS Kernel
|
|
|
|
* LICENSE: GPL - See COPYING in the top level directory
|
2005-01-26 13:58:37 +00:00
|
|
|
* FILE: ntoskrnl/io/iowork.c
|
2006-06-30 16:56:18 +00:00
|
|
|
* PURPOSE: I/O Wrappers for the Executive Work Item Functions
|
|
|
|
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
|
2005-01-26 13:58:37 +00:00
|
|
|
* Robert Dickenson (odin@pnc.com.au)
|
2002-10-03 19:17:26 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* INCLUDES ******************************************************************/
|
|
|
|
|
2004-08-15 16:39:12 +00:00
|
|
|
#include <ntoskrnl.h>
|
2002-10-03 19:17:26 +00:00
|
|
|
#define NDEBUG
|
2008-08-30 16:31:06 +00:00
|
|
|
#include <debug.h>
|
2002-10-03 19:17:26 +00:00
|
|
|
|
2006-06-30 16:56:18 +00:00
|
|
|
/* PRIVATE FUNCTIONS *********************************************************/
|
2002-10-03 19:17:26 +00:00
|
|
|
|
2006-06-30 16:56:18 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
IopWorkItemCallback(IN PVOID Parameter)
|
2002-10-03 19:17:26 +00:00
|
|
|
{
|
2006-06-30 16:56:18 +00:00
|
|
|
PIO_WORKITEM IoWorkItem = (PIO_WORKITEM)Parameter;
|
|
|
|
PDEVICE_OBJECT DeviceObject = IoWorkItem->DeviceObject;
|
|
|
|
PAGED_CODE();
|
2002-10-03 19:17:26 +00:00
|
|
|
|
2006-06-30 16:56:18 +00:00
|
|
|
/* Call the work routine */
|
|
|
|
IoWorkItem->WorkerRoutine(DeviceObject, IoWorkItem->Context);
|
2002-10-03 19:17:26 +00:00
|
|
|
|
2008-08-16 17:53:28 +00:00
|
|
|
/* Dereference the device object */
|
2006-06-30 16:56:18 +00:00
|
|
|
ObDereferenceObject(DeviceObject);
|
2002-10-03 19:17:26 +00:00
|
|
|
}
|
|
|
|
|
2006-06-30 16:56:18 +00:00
|
|
|
/* PUBLIC FUNCTIONS **********************************************************/
|
|
|
|
|
2003-07-10 15:47:00 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2006-06-30 16:56:18 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
2005-05-09 01:38:29 +00:00
|
|
|
IoQueueWorkItem(IN PIO_WORKITEM IoWorkItem,
|
2006-06-30 16:56:18 +00:00
|
|
|
IN PIO_WORKITEM_ROUTINE WorkerRoutine,
|
|
|
|
IN WORK_QUEUE_TYPE QueueType,
|
|
|
|
IN PVOID Context)
|
2002-10-03 19:17:26 +00:00
|
|
|
{
|
2006-06-30 16:56:18 +00:00
|
|
|
/* Make sure we're called at DISPATCH or lower */
|
|
|
|
ASSERT_IRQL_LESS_OR_EQUAL(DISPATCH_LEVEL);
|
|
|
|
|
|
|
|
/* Reference the device object */
|
|
|
|
ObReferenceObject(IoWorkItem->DeviceObject);
|
|
|
|
|
|
|
|
/* Setup the work item */
|
|
|
|
IoWorkItem->WorkerRoutine = WorkerRoutine;
|
|
|
|
IoWorkItem->Context = Context;
|
|
|
|
|
|
|
|
/* Queue the work item */
|
|
|
|
ExQueueWorkItem(&IoWorkItem->Item, QueueType);
|
2002-10-03 19:17:26 +00:00
|
|
|
}
|
|
|
|
|
2003-07-10 15:47:00 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2006-06-30 16:56:18 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
IoFreeWorkItem(IN PIO_WORKITEM IoWorkItem)
|
2002-10-03 19:17:26 +00:00
|
|
|
{
|
2006-06-30 16:56:18 +00:00
|
|
|
/* Free the work item */
|
|
|
|
ExFreePool(IoWorkItem);
|
2002-10-03 19:17:26 +00:00
|
|
|
}
|
|
|
|
|
2003-07-10 15:47:00 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2006-06-30 16:56:18 +00:00
|
|
|
PIO_WORKITEM
|
|
|
|
NTAPI
|
|
|
|
IoAllocateWorkItem(IN PDEVICE_OBJECT DeviceObject)
|
2002-10-03 19:17:26 +00:00
|
|
|
{
|
2006-06-30 16:56:18 +00:00
|
|
|
PIO_WORKITEM IoWorkItem;
|
|
|
|
|
|
|
|
/* Allocate the work item */
|
|
|
|
IoWorkItem = ExAllocatePoolWithTag(NonPagedPool,
|
|
|
|
sizeof(IO_WORKITEM),
|
|
|
|
TAG_IOWI);
|
|
|
|
if (!IoWorkItem) return NULL;
|
|
|
|
|
|
|
|
/* Initialize it */
|
|
|
|
IoWorkItem->DeviceObject = DeviceObject;
|
|
|
|
ExInitializeWorkItem(&IoWorkItem->Item, IopWorkItemCallback, IoWorkItem);
|
|
|
|
|
|
|
|
/* Return it */
|
|
|
|
return IoWorkItem;
|
2002-10-03 19:17:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* EOF */
|