WdfCmResourceListRemove ?

Hi,

My gold is remove a IO resource from a driver A and assign this resource
to a driver B.

Both drivers are hook with WdfFdoInitSetEventCallbacks.

The driver A:

WDF_FDO_EVENT_CALLBACKS WdfFdoEventCallBack;

WDF_FDO_EVENT_CALLBACKS_INIT(&WdfFdoEventCallBack);

WdfFdoEventCallBack.EvtDeviceFilterRemoveResourceRequirements =
AFilterRemoveResourceRequirements;

WdfFdoEventCallBack.EvtDeviceFilterAddResourceRequirements =
AFilterAddResourceRequirements;

WdfFdoEventCallBack.EvtDeviceRemoveAddedResources =
ARemoveAddedResources;

WdfFdoInitSetEventCallbacks(DeviceInit, &WdfFdoEventCallBack);

The driver B:

WDF_FDO_EVENT_CALLBACKS WdfFdoEventCallBack;

WDF_FDO_EVENT_CALLBACKS_INIT(&WdfFdoEventCallBack);

WdfFdoEventCallBack.EvtDeviceFilterRemoveResourceRequirements =
BFilterRemoveResourceRequirements;

WdfFdoEventCallBack.EvtDeviceFilterAddResourceRequirements =
BFilterAddResourceRequirements;

WdfFdoEventCallBack.EvtDeviceRemoveAddedResources =
BRemoveAddedResources;

WdfFdoInitSetEventCallbacks(DeviceInit, &WdfFdoEventCallBack);

In the function AFilterRemoveResourceRequirements:

if (descriptor->Type == CmResourceTypePort)

{

WdfIoResourceRequirementsListRemoveByIoResList(IoResourceRequirementsLis
t, reslist );

WdfIoResourceListRemove(reslist, i);

}

Also in function ARemoveAddedResources:

for (int i = 0; i < nres; i++)

{

prd = WdfCmResourceListGetDescriptor(ResourcesRaw, i);

if (prd->Type == CmResourceTypePort)

{

WdfCmResourceListRemove(ResourcesRaw, i);

WdfCmResourceListRemove(ResourcesTranslated, i);

break;

}

}

Here I expect the IO resource of driver A is not associated anymore to
this driver.

And in driver B in function: BFilterAddResourceRequirements

RtlZeroMemory( &descriptor, sizeof(descriptor) );

descriptor.Option = 0;

descriptor.Type = CmResourceTypePort;

descriptor.ShareDisposition = CmResourceShareDeviceExclusive;

descriptor.Flags = CM_RESOURCE_PORT_IO;

descriptor.u.Port.Length = (ULONG) BarSize;

descriptor.u.Port.Alignment = 0x01;

descriptor.u.Port.MinimumAddress.QuadPart = BAR IO of DRIVER A;

descriptor.u.Port.MaximumAddress.QuadPart = = BAR IO of DRIVER A +
Bar Size;

ntStatus = WdfIoResourceListAppendDescriptor( logConfig, &descriptor
);

if (NT_SUCCESS(ntStatus))

ntStatus =
WdfIoResourceRequirementsListAppendIoResList(IoResourceRequirementsList,
logConfig);

But the OS does not want to assign the IO resource to driver B.

What I forget to my implementation ?

Thanks Gilles.

You can’t arbitrarily claim the resources on another device, even if you relinquish that resource in A. the bus driver needs to understand that the resource should move. Are you sure that A’s flitering runs before B has started?

d

From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Gilles-Marie Perron
Sent: Thursday, October 9, 2014 12:20 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] WdfCmResourceListRemove ?

Hi,

My gold is remove a IO resource from a driver A and assign this resource to a driver B.

Both drivers are hook with WdfFdoInitSetEventCallbacks.

The driver A:
WDF_FDO_EVENT_CALLBACKS WdfFdoEventCallBack;
WDF_FDO_EVENT_CALLBACKS_INIT(&WdfFdoEventCallBack);
WdfFdoEventCallBack.EvtDeviceFilterRemoveResourceRequirements = AFilterRemoveResourceRequirements;
WdfFdoEventCallBack.EvtDeviceFilterAddResourceRequirements = AFilterAddResourceRequirements;
WdfFdoEventCallBack.EvtDeviceRemoveAddedResources = ARemoveAddedResources;
WdfFdoInitSetEventCallbacks(DeviceInit, &WdfFdoEventCallBack);

The driver B:
WDF_FDO_EVENT_CALLBACKS WdfFdoEventCallBack;
WDF_FDO_EVENT_CALLBACKS_INIT(&WdfFdoEventCallBack);
WdfFdoEventCallBack.EvtDeviceFilterRemoveResourceRequirements = BFilterRemoveResourceRequirements;
WdfFdoEventCallBack.EvtDeviceFilterAddResourceRequirements = BFilterAddResourceRequirements;
WdfFdoEventCallBack.EvtDeviceRemoveAddedResources = BRemoveAddedResources;
WdfFdoInitSetEventCallbacks(DeviceInit, &WdfFdoEventCallBack);

In the function AFilterRemoveResourceRequirements:

if (descriptor->Type == CmResourceTypePort)
{
WdfIoResourceRequirementsListRemoveByIoResList(IoResourceRequirementsList, reslist );
WdfIoResourceListRemove(reslist, i);
}

Also in function ARemoveAddedResources:

for (int i = 0; i < nres; i++)
{
prd = WdfCmResourceListGetDescriptor(ResourcesRaw, i);
if (prd->Type == CmResourceTypePort)
{
WdfCmResourceListRemove(ResourcesRaw, i);
WdfCmResourceListRemove(ResourcesTranslated, i);
break;
}
}

Here I expect the IO resource of driver A is not associated anymore to this driver.

And in driver B in function: BFilterAddResourceRequirements

RtlZeroMemory( &descriptor, sizeof(descriptor) );

descriptor.Option = 0;
descriptor.Type = CmResourceTypePort;
descriptor.ShareDisposition = CmResourceShareDeviceExclusive;
descriptor.Flags = CM_RESOURCE_PORT_IO;
descriptor.u.Port.Length = (ULONG) BarSize;
descriptor.u.Port.Alignment = 0x01;
descriptor.u.Port.MinimumAddress.QuadPart = BAR IO of DRIVER A;
descriptor.u.Port.MaximumAddress.QuadPart = = BAR IO of DRIVER A + Bar Size;

ntStatus = WdfIoResourceListAppendDescriptor( logConfig, &descriptor );

if (NT_SUCCESS(ntStatus))
ntStatus = WdfIoResourceRequirementsListAppendIoResList(IoResourceRequirementsList, logConfig);

But the OS does not want to assign the IO resource to driver B.

What I forget to my implementation ?

Thanks Gilles.


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

I trace from the start-up of my system.

I receive in that following order:

1 -ADriverEntry

2- ADriverAdd. (Register WDF_FDO_EVENT_CALLBACKS).

3- BDriverEntry.

4- BDriverAdd. . (Register WDF_FDO_EVENT_CALLBACKS).

5 -AFilterRemoveResourceRequirements.

6- BFilterRemoveResourceRequirements.

7- BFilterAddResourceRequirements

8- ARemoveAddedResources.

9- BEvtDevicePrepareHardware

In the ARemoveAddResources if I did WdfCmResourceListRemove, I do not
receive AEvtDevicePrepareHardware.

Also in BFilterAddResourceRequirements if the Descriptor range is exactly
the same range as the A IO descriptor, I get this error message:

The device cannot find enough free resources that it can use.

Gilles


From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Doron Holan
Sent: Thursday, October 09, 2014 3:53 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] WdfCmResourceListRemove ?

You can’t arbitrarily claim the resources on another device, even if you
relinquish that resource in A. the bus driver needs to understand that the
resource should move. Are you sure that A’s flitering runs before B has
started?

d

From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Gilles-Marie Perron
Sent: Thursday, October 9, 2014 12:20 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] WdfCmResourceListRemove ?

Hi,

My gold is remove a IO resource from a driver A and assign this resource to
a driver B.

Both drivers are hook with WdfFdoInitSetEventCallbacks.

The driver A:

WDF_FDO_EVENT_CALLBACKS WdfFdoEventCallBack;

WDF_FDO_EVENT_CALLBACKS_INIT(&WdfFdoEventCallBack);

WdfFdoEventCallBack.EvtDeviceFilterRemoveResourceRequirements =
AFilterRemoveResourceRequirements;

WdfFdoEventCallBack.EvtDeviceFilterAddResourceRequirements =
AFilterAddResourceRequirements;

WdfFdoEventCallBack.EvtDeviceRemoveAddedResources =
ARemoveAddedResources;

WdfFdoInitSetEventCallbacks(DeviceInit, &WdfFdoEventCallBack);

The driver B:

WDF_FDO_EVENT_CALLBACKS WdfFdoEventCallBack;

WDF_FDO_EVENT_CALLBACKS_INIT(&WdfFdoEventCallBack);

WdfFdoEventCallBack.EvtDeviceFilterRemoveResourceRequirements =
BFilterRemoveResourceRequirements;

WdfFdoEventCallBack.EvtDeviceFilterAddResourceRequirements =
BFilterAddResourceRequirements;

WdfFdoEventCallBack.EvtDeviceRemoveAddedResources =
BRemoveAddedResources;

WdfFdoInitSetEventCallbacks(DeviceInit, &WdfFdoEventCallBack);

In the function AFilterRemoveResourceRequirements:

if (descriptor->Type == CmResourceTypePort)

{

WdfIoResourceRequirementsListRemoveByIoResList(IoResourceRequirementsList,
reslist );

WdfIoResourceListRemove(reslist, i);

}

Also in function ARemoveAddedResources:

for (int i = 0; i < nres; i++)

{

prd = WdfCmResourceListGetDescriptor(ResourcesRaw, i);

if (prd->Type == CmResourceTypePort)

{

WdfCmResourceListRemove(ResourcesRaw, i);

WdfCmResourceListRemove(ResourcesTranslated, i);

break;

}

}

Here I expect the IO resource of driver A is not associated anymore to this
driver.

And in driver B in function: BFilterAddResourceRequirements

RtlZeroMemory( &descriptor, sizeof(descriptor) );

descriptor.Option = 0;

descriptor.Type = CmResourceTypePort;

descriptor.ShareDisposition = CmResourceShareDeviceExclusive;

descriptor.Flags = CM_RESOURCE_PORT_IO;

descriptor.u.Port.Length = (ULONG) BarSize;

descriptor.u.Port.Alignment = 0x01;

descriptor.u.Port.MinimumAddress.QuadPart = BAR IO of DRIVER A;

descriptor.u.Port.MaximumAddress.QuadPart = = BAR IO of DRIVER A + Bar
Size;

ntStatus = WdfIoResourceListAppendDescriptor( logConfig, &descriptor );

if (NT_SUCCESS(ntStatus))

ntStatus =
WdfIoResourceRequirementsListAppendIoResList(IoResourceRequirementsList,
logConfig);

But the OS does not want to assign the IO resource to driver B.

What I forget to my implementation ?

Thanks Gilles.


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer