mirror of
https://github.com/reactos/reactos.git
synced 2025-04-25 16:10:29 +00:00
- Store DeviceObject before calling IMiniportWaveCyclic as the driver might immediately call port functions
- Pass the PhysicalDeviceObject to IoGetDmaAdapter svn path=/trunk/; revision=38857
This commit is contained in:
parent
51d20d699d
commit
f781b11878
2 changed files with 27 additions and 14 deletions
|
@ -484,15 +484,20 @@ PcNewDmaChannel(
|
|||
ULONG MapRegisters;
|
||||
INTERFACE_TYPE BusType;
|
||||
ULONG ResultLength;
|
||||
PCExtension* DeviceExt;
|
||||
|
||||
IDmaChannelSlaveImpl * This;
|
||||
|
||||
DPRINT1("OutDmaChannel %p OuterUnknown %p PoolType %p DeviceDescription %p DeviceObject %p\n",
|
||||
OutDmaChannel, OuterUnknown, PoolType, DeviceDescription, DeviceObject);
|
||||
|
||||
This = AllocateItem(PoolType, sizeof(IDmaChannelSlaveImpl), TAG_PORTCLASS);
|
||||
if (!This)
|
||||
{
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
}
|
||||
|
||||
DeviceExt = (PCExtension*) DeviceObject->DeviceExtension;
|
||||
|
||||
Status = IoGetDeviceProperty(DeviceObject, DevicePropertyLegacyBusType, sizeof(BusType), (PVOID)&BusType, &ResultLength);
|
||||
if (NT_SUCCESS(Status))
|
||||
|
@ -500,7 +505,9 @@ PcNewDmaChannel(
|
|||
DeviceDescription->InterfaceType = BusType;
|
||||
}
|
||||
|
||||
Adapter = IoGetDmaAdapter(DeviceObject, DeviceDescription, &MapRegisters);
|
||||
DPRINT1("Calling IoGetDmaAdapter\n");
|
||||
|
||||
Adapter = IoGetDmaAdapter(DeviceExt->PhysicalDeviceObject, DeviceDescription, &MapRegisters);
|
||||
if (!Adapter)
|
||||
{
|
||||
FreeItem(This, TAG_PORTCLASS);
|
||||
|
@ -516,7 +523,7 @@ PcNewDmaChannel(
|
|||
This->MaxMapRegisters = MapRegisters;
|
||||
|
||||
*OutDmaChannel = (PVOID)(&This->lpVtbl);
|
||||
|
||||
DPRINT1("PcNewDmaChannel result %p\n", *OutDmaChannel);
|
||||
return STATUS_SUCCESS;
|
||||
|
||||
}
|
||||
|
|
|
@ -139,6 +139,8 @@ IPortWaveCyclic_fnInit(
|
|||
PPOWERNOTIFY PowerNotify;
|
||||
IPortWaveCyclicImpl * This = (IPortWaveCyclicImpl*)iface;
|
||||
|
||||
DPRINT1("IPortWaveCyclic_Init entered\n");
|
||||
|
||||
if (This->bInitialized)
|
||||
{
|
||||
DPRINT("IPortWaveCyclic_Init called again\n");
|
||||
|
@ -152,11 +154,21 @@ IPortWaveCyclic_fnInit(
|
|||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
/* Initialize port object */
|
||||
This->pMiniport = Miniport;
|
||||
This->pDeviceObject = DeviceObject;
|
||||
This->bInitialized = TRUE;
|
||||
This->pResourceList = ResourceList;
|
||||
|
||||
/* increment reference on miniport adapter */
|
||||
Miniport->lpVtbl->AddRef(Miniport);
|
||||
|
||||
Status = Miniport->lpVtbl->Init(Miniport, UnknownAdapter, ResourceList, iface);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT("IMiniportWaveCyclic_Init failed with %x\n", Status);
|
||||
Miniport->lpVtbl->Release(Miniport);
|
||||
This->bInitialized = FALSE;
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -172,6 +184,7 @@ IPortWaveCyclic_fnInit(
|
|||
Status = Miniport->lpVtbl->GetDescription(Miniport, &This->pDescriptor);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("failed to get description\n");
|
||||
Miniport->lpVtbl->Release(Miniport);
|
||||
return Status;
|
||||
}
|
||||
|
@ -188,18 +201,11 @@ IPortWaveCyclic_fnInit(
|
|||
This->pPowerNotify = NULL;
|
||||
}
|
||||
|
||||
|
||||
/* Initialize port object */
|
||||
This->pMiniport = Miniport;
|
||||
This->pDeviceObject = DeviceObject;
|
||||
This->bInitialized = TRUE;
|
||||
This->pResourceList = ResourceList;
|
||||
|
||||
/* increment reference on miniport adapter */
|
||||
Miniport->lpVtbl->AddRef(Miniport);
|
||||
/* increment reference on resource list */
|
||||
ResourceList->lpVtbl->AddRef(ResourceList);
|
||||
|
||||
|
||||
DPRINT1("IPortWaveCyclic successfully initialized\n");
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -314,7 +320,7 @@ IPortWaveCyclic_fnNotify(
|
|||
ServiceGroup->lpVtbl->RequestService (ServiceGroup);
|
||||
}
|
||||
|
||||
static const IPortWaveCyclicVtbl vt_IPortWaveCyclicVtbl =
|
||||
static IPortWaveCyclicVtbl vt_IPortWaveCyclicVtbl =
|
||||
{
|
||||
IPortWaveCyclic_fnQueryInterface,
|
||||
IPortWaveCyclic_fnAddRef,
|
||||
|
@ -506,8 +512,8 @@ NewPortWaveCyclic(
|
|||
if (!This)
|
||||
return STATUS_INSUFFICIENT_RESOURCES;
|
||||
|
||||
This->lpVtbl = (IPortWaveCyclicVtbl*)&vt_IPortWaveCyclicVtbl;
|
||||
This->lpVtblSubDevice = (ISubdeviceVtbl*)&vt_ISubdeviceVtbl;
|
||||
This->lpVtbl = &vt_IPortWaveCyclicVtbl;
|
||||
This->lpVtblSubDevice = &vt_ISubdeviceVtbl;
|
||||
This->ref = 1;
|
||||
*OutPort = (PPORT)(&This->lpVtbl);
|
||||
|
||||
|
|
Loading…
Reference in a new issue