mirror of
https://github.com/reactos/reactos.git
synced 2025-05-28 21:48:19 +00:00
- Partly Implement StreamClassReadWriteConfig
- Allocate a HwInstance buffer which is passed to each instantiated filter instance svn path=/trunk/; revision=41725
This commit is contained in:
parent
645b22988a
commit
f6ef04567a
3 changed files with 120 additions and 1 deletions
|
@ -290,6 +290,7 @@ StreamClassGetDmaBuffer(
|
|||
IN PVOID HwDeviceExtension)
|
||||
{
|
||||
PSTREAM_DEVICE_EXTENSION DeviceExtension;
|
||||
|
||||
/* Get our DeviceExtension */
|
||||
DeviceExtension = (PSTREAM_DEVICE_EXTENSION) ((ULONG_PTR)HwDeviceExtension - sizeof(STREAM_DEVICE_EXTENSION));
|
||||
ASSERT(DeviceExtension->DeviceExtension == HwDeviceExtension);
|
||||
|
@ -297,3 +298,97 @@ StreamClassGetDmaBuffer(
|
|||
return DeviceExtension->DmaCommonBuffer;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
StreamClassRWCompletion(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp,
|
||||
IN PVOID Context)
|
||||
{
|
||||
PIO_STATUS_BLOCK IoStatusBlock = (PIO_STATUS_BLOCK)Context;
|
||||
|
||||
IoStatusBlock->Information = Irp->IoStatus.Information;
|
||||
IoStatusBlock->Status = Irp->IoStatus.Status;
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
/*
|
||||
*@implemented
|
||||
*/
|
||||
BOOLEAN
|
||||
STREAMAPI
|
||||
StreamClassReadWriteConfig(
|
||||
IN PVOID HwDeviceExtension,
|
||||
IN BOOLEAN Read,
|
||||
IN PVOID Buffer,
|
||||
IN ULONG OffSet,
|
||||
IN ULONG Length)
|
||||
{
|
||||
PIRP Irp;
|
||||
ULONG MajorFunction;
|
||||
KEVENT Event;
|
||||
PSTREAM_DEVICE_EXTENSION DeviceExtension;
|
||||
LARGE_INTEGER Offset;
|
||||
IO_STATUS_BLOCK StatusBlock;
|
||||
NTSTATUS Status;
|
||||
|
||||
/* Get our DeviceExtension */
|
||||
DeviceExtension = (PSTREAM_DEVICE_EXTENSION) ((ULONG_PTR)HwDeviceExtension - sizeof(STREAM_DEVICE_EXTENSION));
|
||||
ASSERT(DeviceExtension->DeviceExtension == HwDeviceExtension);
|
||||
|
||||
if (Read)
|
||||
{
|
||||
/* Zero input buffer */
|
||||
RtlZeroMemory(Buffer, Length);
|
||||
}
|
||||
|
||||
/* Set request type */
|
||||
MajorFunction = (Read ? IRP_MJ_READ : IRP_MJ_WRITE);
|
||||
|
||||
/* Initialize event */
|
||||
KeInitializeEvent(&Event, NotificationEvent, FALSE);
|
||||
|
||||
/* Set offset */
|
||||
Offset.QuadPart = OffSet;
|
||||
|
||||
/* Pre-init status block */
|
||||
StatusBlock.Status = STATUS_NOT_SUPPORTED;
|
||||
|
||||
/* Create Irp */
|
||||
Irp = IoBuildSynchronousFsdRequest(MajorFunction,
|
||||
DeviceExtension->LowerDeviceObject, /* Verify */
|
||||
Buffer,
|
||||
Length,
|
||||
&Offset,
|
||||
&Event,
|
||||
&StatusBlock);
|
||||
|
||||
if (!Irp)
|
||||
{
|
||||
/* Failed to allocate memory */
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Setup a completion routine */
|
||||
IoSetCompletionRoutine(Irp, StreamClassRWCompletion, (PVOID)&Event, TRUE, TRUE, TRUE);
|
||||
|
||||
/* Call driver */
|
||||
Status = IoCallDriver(DeviceExtension->LowerDeviceObject, Irp);
|
||||
|
||||
if (Status == STATUS_PENDING)
|
||||
{
|
||||
/* Request is pending, wait for result */
|
||||
KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
|
||||
/* Fetch result */
|
||||
Status = StatusBlock.Status;
|
||||
}
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* FIXME Handle Length != InputLength */
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -102,6 +102,7 @@ InitializeFilterWithKs(
|
|||
PKSOBJECT_CREATE_ITEM CreateItem;
|
||||
PIO_STACK_LOCATION IoStack;
|
||||
HW_STREAM_REQUEST_BLOCK_EXT RequestBlock;
|
||||
PVOID HwInstanceExtension = NULL;
|
||||
|
||||
/* Get device extension */
|
||||
DeviceExtension = (PSTREAM_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
||||
|
@ -120,10 +121,22 @@ InitializeFilterWithKs(
|
|||
/* driver supports more than one filter instance */
|
||||
RtlZeroMemory(&RequestBlock, sizeof(HW_STREAM_REQUEST_BLOCK_EXT));
|
||||
|
||||
/* allocate instance extension */
|
||||
HwInstanceExtension = ExAllocatePool(NonPagedPool, DeviceExtension->DriverExtension->Data.FilterInstanceExtensionSize);
|
||||
if (!HwInstanceExtension)
|
||||
{
|
||||
/* Not enough memory */
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
}
|
||||
|
||||
/* Zero instance extension */
|
||||
RtlZeroMemory(HwInstanceExtension, DeviceExtension->DriverExtension->Data.FilterInstanceExtensionSize);
|
||||
|
||||
/* set up request block */
|
||||
RequestBlock.Block.Command = SRB_OPEN_DEVICE_INSTANCE;
|
||||
RequestBlock.Block.HwDeviceExtension = DeviceExtension->DeviceExtension;
|
||||
RequestBlock.Block.Irp = Irp;
|
||||
RequestBlock.Block.HwInstanceExtension = HwInstanceExtension;
|
||||
KeInitializeEvent(&RequestBlock.Event, SynchronizationEvent, FALSE);
|
||||
|
||||
/*FIXME SYNCHRONIZATION */
|
||||
|
@ -139,6 +152,7 @@ InitializeFilterWithKs(
|
|||
if (!NT_SUCCESS(RequestBlock.Block.Status))
|
||||
{
|
||||
/* Resource is not available */
|
||||
ExFreePool(HwInstanceExtension);
|
||||
return RequestBlock.Block.Status;
|
||||
}
|
||||
}
|
||||
|
@ -162,8 +176,17 @@ InitializeFilterWithKs(
|
|||
{
|
||||
/* Failed to create header */
|
||||
ExFreePool(CreateItem);
|
||||
if (HwInstanceExtension)
|
||||
{
|
||||
/* free instance buffer */
|
||||
ExFreePool(HwInstanceExtension);
|
||||
}
|
||||
return Status;
|
||||
}
|
||||
|
||||
/* Store instance buffer in file object context */
|
||||
IoStack->FileObject->FsContext2 = HwInstanceExtension;
|
||||
|
||||
/* Increment total instance count */
|
||||
InterlockedIncrement(&DeviceExtension->InstanceCount);
|
||||
/* Return result */
|
||||
|
|
|
@ -5,4 +5,5 @@
|
|||
@ stdcall StreamClassDebugAssert(long long ptr long)
|
||||
@ cdecl StreamClassDebugPrint (long str)
|
||||
@ cdecl StreamClassDeviceNotification(long ptr)
|
||||
@ stdcall StreamClassGetDmaBuffer(ptr)
|
||||
@ stdcall StreamClassGetDmaBuffer(ptr)
|
||||
@ stdcall StreamClassReadWriteConfig(ptr long ptr long long)
|
Loading…
Reference in a new issue