[HDAUDBUS] Implement FDO removal. CORE-14617

This commit is contained in:
Thomas Faber 2019-02-24 14:33:41 +01:00
parent b05e5b0340
commit c8c0fc8d64
No known key found for this signature in database
GPG key ID: 076E7C3D44720826
3 changed files with 69 additions and 1 deletions

View file

@ -563,6 +563,7 @@ HDA_FDOStartDevice(
if (Descriptor->Type == CmResourceTypeMemory)
{
DeviceExtension->RegLength = Descriptor->u.Memory.Length;
DeviceExtension->RegBase = (PUCHAR)MmMapIoSpace(Descriptor->u.Memory.Start, Descriptor->u.Memory.Length, MmNonCached);
if (DeviceExtension->RegBase == NULL)
{
@ -635,6 +636,60 @@ HDA_FDOStartDevice(
return Status;
}
NTSTATUS
NTAPI
HDA_FDORemoveDevice(
_In_ PDEVICE_OBJECT DeviceObject,
_Inout_ PIRP Irp)
{
NTSTATUS Status;
PHDA_FDO_DEVICE_EXTENSION DeviceExtension;
ULONG CodecIndex, AFGIndex;
PHDA_CODEC_ENTRY CodecEntry;
/* get device extension */
DeviceExtension = static_cast<PHDA_FDO_DEVICE_EXTENSION>(DeviceObject->DeviceExtension);
ASSERT(DeviceExtension->IsFDO == TRUE);
Irp->IoStatus.Status = STATUS_SUCCESS;
IoSkipCurrentIrpStackLocation(Irp);
Status = IoCallDriver(DeviceExtension->LowerDevice, Irp);
IoDetachDevice(DeviceExtension->LowerDevice);
if (DeviceExtension->RegBase != NULL)
{
MmUnmapIoSpace(DeviceExtension->RegBase,
DeviceExtension->RegLength);
}
if (DeviceExtension->Interrupt != NULL)
{
IoDisconnectInterrupt(DeviceExtension->Interrupt);
}
if (DeviceExtension->CorbBase != NULL)
{
MmFreeContiguousMemory(DeviceExtension->CorbBase);
}
for (CodecIndex = 0; CodecIndex < HDA_MAX_CODECS; CodecIndex++)
{
CodecEntry = DeviceExtension->Codecs[CodecIndex];
if (CodecEntry == NULL)
{
continue;
}
for (AFGIndex = 0; AFGIndex < CodecEntry->AudioGroupCount; AFGIndex++)
{
FreeItem(CodecEntry->AudioGroups[AFGIndex]);
}
FreeItem(CodecEntry);
}
IoDeleteDevice(DeviceObject);
return Status;
}
NTSTATUS
NTAPI
HDA_FDOQueryBusRelations(

View file

@ -50,6 +50,12 @@ HDA_FdoPnp(
Irp->IoStatus.Status = Status;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return Status;
case IRP_MN_REMOVE_DEVICE:
return HDA_FDORemoveDevice(DeviceObject, Irp);
case IRP_MN_QUERY_REMOVE_DEVICE:
case IRP_MN_CANCEL_REMOVE_DEVICE:
Irp->IoStatus.Status = STATUS_SUCCESS;
break;
case IRP_MN_QUERY_DEVICE_RELATIONS:
/* handle bus device relations */
if (IoStack->Parameters.QueryDeviceRelations.Type == BusRelations)

View file

@ -64,8 +64,9 @@ typedef struct
{
BOOLEAN IsFDO;
PDEVICE_OBJECT LowerDevice;
PUCHAR RegBase;
SIZE_T RegLength;
PKINTERRUPT Interrupt;
ULONG CorbLength;
@ -126,6 +127,12 @@ HDA_FDOStartDevice(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp);
NTSTATUS
NTAPI
HDA_FDORemoveDevice(
_In_ PDEVICE_OBJECT DeviceObject,
_Inout_ PIRP Irp);
NTSTATUS
NTAPI
HDA_FDOQueryBusRelations(