WDF - how to share interrupt between two driver those are in the same stack?



Hi all,

I have a PCI card and I need to create a KMDF bus driver and create a
static KMDF child driver above that bus driver.

The bus driver can get hardware resources and the WDF automatically
connects and disconnects interrupts for the driver .

In the WDM, I can create a IOCTL to get interrupt resource from bus
driver and connect/disconnect the interrupt in the child driver.

I have no idea how to do that in WDF, because WDF will do that
automatically. My KMDF child driver never get any hardware resouces
when loaded.

I try this method below, but it can't work. The child report there is
no available resources and fail to load the driver.

May you hlep me? Thanks. ^_^

Step1:
Copy the CM_PARTIAL_RESOURCE_DESCRIPTOR about interrupt into the bus
driver's device extension.

Step2:
//----------------------------------------------------------------------
// When the bus driver create PDO for that child
//----------------------------------------------------------------------
WDF_PDO_EVENT_CALLBACKS_INIT(&pdoCallbacks);
pdoCallbacks.EvtDeviceResourceRequirementsQuery =
BusPdo_EvtDeviceResourceRequirementsQuery;
WdfPdoInitSetEventCallbacks(pDeviceInit, &pdoCallbacks);

Step3

In the BusPdo_EvtDeviceResourceRequirementsQuery function,
I try to copy the interrupt resource from step 2. Like this

//-----------------------------------------------------------------------
NTSTATUS status = STATUS_SUCCESS;
WDFIORESLIST logConfig;
IO_RESOURCE_DESCRIPTOR descriptor;

status = WdfIoResourceListCreate(
IoResourceRequirementsList,
WDF_NO_OBJECT_ATTRIBUTES,
&logConfig
);
if(!NT_SUCCESS(status)){
return status;
}

RtlZeroMemory(&descriptor, sizeof(descriptor));

descriptor.Option = 0;
descriptor.Type = CmResourceTypeInterrupt;
descriptor.ShareDisposition = CmResourceShareShared
descriptor.Flags= RESOURCE_INTERRUPT_LEVEL_SENSITIVE
descriptor.u.Interrupt.MinimumVector =
fdoData->InterruptDescriptor.u.Interrupt.Vector;

descriptor.u.Interrupt.MaximumVector =
fdoData->InterruptDescriptor.u.Interrupt.Vector;

descriptor.u.Interrupt.TargetedProcessors=
fdoData->InterruptDescriptor.u.Interrupt.Affinity;

descriptor.u.Interrupt.AffinityPolicy= IrqPolicyMachineDefault;
descriptor.u.Interrupt.PriorityPolicy = IrqPriorityUndefined;

status = WdfIoResourceListAppendDescriptor(logConfig, &descriptor);
if(!NT_SUCCESS(status)){
return status;
}

status = WdfIoResourceRequirementsListAppendIoResList(

IoResourceRequirementsList,
logConfig
);

status = WdfIoResourceListAppendDescriptor(logConfig, &descriptor);
if(!NT_SUCCESS(status)){
return status;
}

return status;


.



Relevant Pages

  • Re: Problem while linking sdbus.lib file, also AddDevice is crahsing when a call to IoAttachDeviceTo
    ... ntStatus = STATUS_SUCCESS; ... // Initialize the driver object with this driver's entry points. ... // can send an ioctl to the bus driver. ...
    (microsoft.public.development.device.drivers)
  • Re: An Architectural Question
    ... a bus dirver does not help for individual instances of the hardware since ... > under the control of the particular driver and a collection of device ... > am wondering if the bus driver approach will be cleaner. ... >> If you mean multiple instances of the same device, ...
    (microsoft.public.development.device.drivers)
  • Re: Elite student 1, Bus-driver 0
    ... Based on what I read it was the bus driver who first got physical. ... However the bus driver decided to break the law. ... the Singapore laws to detain anyone. ...
    (soc.culture.singapore)
  • Re: Bus driver leaves four-year-old at strangers house
    ... house to return and pick him up later. ... Now a Dayton ISD bus driver is suspended for what happened ... That bus driver is in hot water for leaving the child alone while ... Cameron was apparently crying when he told his school bus driver he had ...
    (alt.true-crime)
  • Re: Receiving IOCTLs in a KMDF bus driver
    ... devices for IOCTL handling, so your child drivers were sending the IOCTL to ... the PDO and you were processing it. ... queue handler to the bus driver so that PDO can see IOCTL's. ...
    (microsoft.public.development.device.drivers)