mirror of
https://github.com/reactos/reactos.git
synced 2025-08-01 18:43:30 +00:00
- Increase reference count on ISubdevice interface after successfully allocating the device header
- Delegate Create Request to Ks - Implement KSDISPATCH_TABLE for IPortTopology - KSDEVICE_HEADER must be the first item in the device extension svn path=/trunk/; revision=39541
This commit is contained in:
parent
07f2f9b0b0
commit
6d946b8941
4 changed files with 236 additions and 78 deletions
|
@ -12,6 +12,7 @@
|
|||
#include "private.h"
|
||||
#include <devguid.h>
|
||||
#include <initguid.h>
|
||||
#include <ksmedia.h>
|
||||
|
||||
/*
|
||||
This is called from DriverEntry so that PortCls can take care of some
|
||||
|
@ -199,58 +200,6 @@ PcAddAdapterDevice(
|
|||
return status;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
PciDriverDispatch(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
|
||||
ISubdevice * SubDevice;
|
||||
PPCLASS_DEVICE_EXTENSION DeviceExt;
|
||||
SUBDEVICE_ENTRY * Entry;
|
||||
KSDISPATCH_TABLE DispatchTable;
|
||||
|
||||
DPRINT1("PortClsSysControl called\n");
|
||||
|
||||
SubDevice = (ISubdevice*)Irp->Tail.Overlay.DriverContext[3];
|
||||
DeviceExt = (PPCLASS_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
||||
|
||||
if (!SubDevice || !DeviceExt)
|
||||
{
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
|
||||
Entry = AllocateItem(NonPagedPool, sizeof(SUBDEVICE_ENTRY), TAG_PORTCLASS);
|
||||
if (!Entry)
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
|
||||
/* initialize DispatchTable */
|
||||
RtlZeroMemory(&DispatchTable, sizeof(KSDISPATCH_TABLE));
|
||||
/* FIXME
|
||||
* initialize DispatchTable pointer
|
||||
* which call in turn ISubDevice
|
||||
*/
|
||||
|
||||
|
||||
Status = KsAllocateObjectHeader(&Entry->ObjectHeader, 1, NULL, Irp, &DispatchTable);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
FreeItem(Entry, TAG_PORTCLASS);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
InsertTailList(&DeviceExt->SubDeviceList, &Entry->Entry);
|
||||
|
||||
Irp->IoStatus.Status = STATUS_SUCCESS;
|
||||
Irp->IoStatus.Information = 0;
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
NTSTATUS NTAPI
|
||||
PcRegisterSubdevice(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
|
@ -283,8 +232,7 @@ PcRegisterSubdevice(
|
|||
/* the provided port driver doesnt support ISubdevice */
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
#if KS_IMPLEMENTED
|
||||
Status = KsAddObjectCreateItemToDeviceHeader(DeviceExt->KsDeviceHeader, PciDriverDispatch, (PVOID)SubDevice, Name, NULL);
|
||||
Status = KsAddObjectCreateItemToDeviceHeader(DeviceExt->KsDeviceHeader, PcCreateItemDispatch, (PVOID)SubDevice, Name, NULL);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
/* failed to attach */
|
||||
|
@ -292,8 +240,7 @@ PcRegisterSubdevice(
|
|||
DPRINT1("KsAddObjectCreateItemToDeviceHeader failed with %x\n", Status);
|
||||
return Status;
|
||||
}
|
||||
#endif
|
||||
|
||||
SubDevice->lpVtbl->AddRef(SubDevice);
|
||||
|
||||
Status = SubDevice->lpVtbl->GetDescriptor(SubDevice, &SubDeviceDescriptor);
|
||||
if (!NT_SUCCESS(Status))
|
||||
|
|
|
@ -49,13 +49,7 @@ PortClsCreate(
|
|||
{
|
||||
DPRINT1("PortClsCreate called\n");
|
||||
|
||||
/* TODO */
|
||||
|
||||
Irp->IoStatus.Status = STATUS_SUCCESS;
|
||||
Irp->IoStatus.Information = 0;
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
return KsDispatchIrp(DeviceObject, Irp);
|
||||
}
|
||||
|
||||
|
||||
|
@ -234,19 +228,8 @@ PcDispatchIrp(
|
|||
case IRP_MJ_SYSTEM_CONTROL :
|
||||
return PortClsSysControl(DeviceObject, Irp);
|
||||
|
||||
/* KS - TODO */
|
||||
|
||||
#if 0
|
||||
KsSetMajorFunctionHandler(DriverObject, IRP_MJ_CLOSE);
|
||||
KsSetMajorFunctionHandler(DriverObject, IRP_MJ_DEVICE_CONTROL);
|
||||
KsSetMajorFunctionHandler(DriverObject, IRP_MJ_FLUSH_BUFFERS);
|
||||
KsSetMajorFunctionHandler(DriverObject, IRP_MJ_QUERY_SECURITY);
|
||||
KsSetMajorFunctionHandler(DriverObject, IRP_MJ_READ);
|
||||
KsSetMajorFunctionHandler(DriverObject, IRP_MJ_SET_SECURITY);
|
||||
KsSetMajorFunctionHandler(DriverObject, IRP_MJ_WRITE);
|
||||
#endif
|
||||
|
||||
default :
|
||||
default:
|
||||
DPRINT1("Unhandled function %x\n", IoStack->MajorFunction);
|
||||
break;
|
||||
};
|
||||
|
||||
|
|
|
@ -433,6 +433,228 @@ static ISubdeviceVtbl vt_ISubdeviceVtbl =
|
|||
};
|
||||
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
ITopology_fnDeviceIoControl(
|
||||
PDEVICE_OBJECT DeviceObject,
|
||||
PIRP Irp)
|
||||
{
|
||||
DPRINT1("ITopology_fnDeviceIoControl called\n");
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
ITopology_fnRead(
|
||||
PDEVICE_OBJECT DeviceObject,
|
||||
PIRP Irp)
|
||||
{
|
||||
DPRINT1("ITopology_fnRead called\n");
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
ITopology_fnWrite(
|
||||
PDEVICE_OBJECT DeviceObject,
|
||||
PIRP Irp)
|
||||
{
|
||||
DPRINT1("ITopology_fnWrite called\n");
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
ITopology_fnFlush(
|
||||
PDEVICE_OBJECT DeviceObject,
|
||||
PIRP Irp)
|
||||
{
|
||||
DPRINT1("ITopology_fnFlush called\n");
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
ITopology_fnClose(
|
||||
PDEVICE_OBJECT DeviceObject,
|
||||
PIRP Irp)
|
||||
{
|
||||
DPRINT1("ITopology_fnClose called\n");
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
ITopology_fnQuerySecurity(
|
||||
PDEVICE_OBJECT DeviceObject,
|
||||
PIRP Irp)
|
||||
{
|
||||
DPRINT1("ITopology_fnQuerySecurity called\n");
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
ITopology_fnSetSecurity(
|
||||
PDEVICE_OBJECT DeviceObject,
|
||||
PIRP Irp)
|
||||
{
|
||||
DPRINT1("ITopology_fnSetSecurity called\n");
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
NTAPI
|
||||
ITopology_fnFastDeviceIoControl(
|
||||
PFILE_OBJECT FileObject,
|
||||
BOOLEAN Wait,
|
||||
PVOID InputBuffer,
|
||||
ULONG InputBufferLength,
|
||||
PVOID OutputBuffer,
|
||||
ULONG OutputBufferLength,
|
||||
ULONG IoControlCode,
|
||||
PIO_STATUS_BLOCK IoStatus,
|
||||
PDEVICE_OBJECT DeviceObject)
|
||||
{
|
||||
DPRINT1("ITopology_fnFastDeviceIoControl called\n");
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
BOOLEAN
|
||||
NTAPI
|
||||
ITopology_fnFastRead(
|
||||
PFILE_OBJECT FileObject,
|
||||
PLARGE_INTEGER FileOffset,
|
||||
ULONG Length,
|
||||
BOOLEAN Wait,
|
||||
ULONG LockKey,
|
||||
PVOID Buffer,
|
||||
PIO_STATUS_BLOCK IoStatus,
|
||||
PDEVICE_OBJECT DeviceObject)
|
||||
{
|
||||
DPRINT1("ITopology_fnFastRead called\n");
|
||||
|
||||
return TRUE;
|
||||
|
||||
}
|
||||
|
||||
BOOLEAN
|
||||
NTAPI
|
||||
ITopology_fnFastWrite(
|
||||
PFILE_OBJECT FileObject,
|
||||
PLARGE_INTEGER FileOffset,
|
||||
ULONG Length,
|
||||
BOOLEAN Wait,
|
||||
ULONG LockKey,
|
||||
PVOID Buffer,
|
||||
PIO_STATUS_BLOCK IoStatus,
|
||||
PDEVICE_OBJECT DeviceObject)
|
||||
{
|
||||
DPRINT1("ITopology_fnFastWrite called\n");
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static KSDISPATCH_TABLE DispatchTable =
|
||||
{
|
||||
ITopology_fnDeviceIoControl,
|
||||
ITopology_fnRead,
|
||||
ITopology_fnWrite,
|
||||
ITopology_fnFlush,
|
||||
ITopology_fnClose,
|
||||
ITopology_fnQuerySecurity,
|
||||
ITopology_fnSetSecurity,
|
||||
ITopology_fnFastDeviceIoControl,
|
||||
ITopology_fnFastRead,
|
||||
ITopology_fnFastWrite,
|
||||
};
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
PcCreateItemDispatch(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp)
|
||||
{
|
||||
NTSTATUS Status = STATUS_SUCCESS;
|
||||
|
||||
ISubdevice * SubDevice;
|
||||
PPCLASS_DEVICE_EXTENSION DeviceExt;
|
||||
SUBDEVICE_ENTRY * Entry;
|
||||
PKSOBJECT_CREATE_ITEM CreateItem;
|
||||
|
||||
DPRINT1("PcCreateItemDispatch called\n");
|
||||
|
||||
/* access the create item */
|
||||
CreateItem = KSCREATE_ITEM_IRP_STORAGE(Irp);
|
||||
if (!CreateItem)
|
||||
{
|
||||
DPRINT1("PcCreateItemDispatch no CreateItem\n");
|
||||
Status = STATUS_UNSUCCESSFUL;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
SubDevice = (ISubdevice*)CreateItem->Context;
|
||||
DeviceExt = (PPCLASS_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
||||
|
||||
if (!SubDevice || !DeviceExt)
|
||||
{
|
||||
DPRINT1("PcCreateItemDispatch SubDevice %p DeviceExt %p\n", SubDevice, DeviceExt);
|
||||
|
||||
Status = STATUS_UNSUCCESSFUL;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
Entry = AllocateItem(NonPagedPool, sizeof(SUBDEVICE_ENTRY), TAG_PORTCLASS);
|
||||
if (!Entry)
|
||||
{
|
||||
DPRINT1("PcCreateItemDispatch no memory\n");
|
||||
|
||||
Status = STATUS_INSUFFICIENT_RESOURCES;
|
||||
goto cleanup;
|
||||
}
|
||||
#if 0
|
||||
Status = KsReferenceSoftwareBusObject(DeviceExt->KsDeviceHeader);
|
||||
if (!NT_SUCCESS(Status) && Status != STATUS_NOT_IMPLEMENTED)
|
||||
{
|
||||
DPRINT1("PciCreateItemDispatch failed to reference device header\n");
|
||||
|
||||
FreeItem(Entry, TAG_PORTCLASS);
|
||||
goto cleanup;
|
||||
}
|
||||
#endif
|
||||
|
||||
Status = KsAllocateObjectHeader(&Entry->ObjectHeader, 0, NULL, Irp, &DispatchTable);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("KsAllocateObjectHeader failed with %x\n", Status);
|
||||
//KsDereferenceSoftwareBusObject(DeviceExt->KsDeviceHeader);
|
||||
FreeItem(Entry, TAG_PORTCLASS);
|
||||
return Status;
|
||||
}
|
||||
|
||||
InsertTailList(&DeviceExt->SubDeviceList, &Entry->Entry);
|
||||
|
||||
|
||||
cleanup:
|
||||
// Irp->IoStatus.Status = Status;
|
||||
// Irp->IoStatus.Information = 0;
|
||||
// IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
|
||||
DPRINT1("PcCreateItemDispatch Status %x\n", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
NTSTATUS
|
||||
NewPortTopology(
|
||||
OUT PPORT* OutPort)
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
#define YDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
#include <portcls.h>
|
||||
#include <dmusicks.h>
|
||||
|
||||
#include "interfaces.h"
|
||||
|
@ -118,10 +117,10 @@ typedef struct
|
|||
|
||||
typedef struct
|
||||
{
|
||||
KSDEVICE_HEADER KsDeviceHeader;
|
||||
PDEVICE_OBJECT PhysicalDeviceObject;
|
||||
PDEVICE_OBJECT PrevDeviceObject;
|
||||
PCPFNSTARTDEVICE StartDevice;
|
||||
KSDEVICE_HEADER KsDeviceHeader;
|
||||
IAdapterPowerManagement * AdapterPowerManagement;
|
||||
ULONG MaxSubDevices;
|
||||
KSOBJECT_CREATE_ITEM * CreateItems;
|
||||
|
@ -178,4 +177,11 @@ PcCreateSubdeviceDescriptor(
|
|||
IN KSEVENT_SET * EventSet,
|
||||
IN PPCFILTER_DESCRIPTOR FilterDescription);
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
PcCreateItemDispatch(
|
||||
IN PDEVICE_OBJECT DeviceObject,
|
||||
IN PIRP Irp);
|
||||
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue