IoReportResourceForDetection question

First of all sorry for bothering you. I know that my question is not related directly to file systems, but I just don’t know who can help me. May be you can at least forward me to the right place to ask the question.

I’m trying to write virtual device driver for WinXP that will handle some interrupt. As far as I understood it I need to claim interrupt resource using IoReportResourceForDetection, then register my device using IoReportDetectedDevice and then connect ISR to the interrupt vector using IoConnectInterrupt.
My problem starts with IoReportResourceForDetection - I tried any vector 32-255 and always received the same answer - conflicts detected. My interrupt is level and shared. Here is the code excerpt:

BOOLEAN Reserve_Vector( IN PDRIVER_OBJECT DriverObject,
OUT PCM_RESOURCE_LIST ReservedInterrupt )
{
NTSTATUS Status;
BOOLEAN ConflictFound = FALSE;

DbgPrint(“TestDevice Reserve_Vector: try to reserve recommended vector %d\r\n”, RECOMMENDED_VECTOR);

if (! ReservedInterrupt)
{
return FALSE;
}

// init resource list with the only resource - interrupt vector
ReservedInterrupt->Count = 1;
ReservedInterrupt->List[0].InterfaceType = InterfaceTypeUndefined;
ReservedInterrupt->List[0].BusNumber = 0;
ReservedInterrupt->List[0].PartialResourceList.Version = 1;
ReservedInterrupt->List[0].PartialResourceList.Revision = 1;
ReservedInterrupt->List[0].PartialResourceList.Count = 1;
ReservedInterrupt->List[0].PartialResourceList.PartialDescriptors[0].Type = CmResourceTypeInterrupt;
ReservedInterrupt->List[0].PartialResourceList.PartialDescriptors[0].ShareDisposition = CmResourceShareShared;
ReservedInterrupt->List[0].PartialResourceList.PartialDescriptors[0].Flags = CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE;
ReservedInterrupt->List[0].PartialResourceList.PartialDescriptors[0].u.Interrupt.Level = DISPATCH_LEVEL+1;
ReservedInterrupt->List[0].PartialResourceList.PartialDescriptors[0].u.Interrupt.Vector = RECOMMENDED_VECTOR;
ReservedInterrupt->List[0].PartialResourceList.PartialDescriptors[0].u.Interrupt.Affinity = (ULONG)-1;

// try recommended first
Status = IoReportResourceForDetection( DriverObject,
ReservedInterrupt,
sizeof(CM_RESOURCE_LIST),
NULL,
NULL,
0,
&ConflictFound);

if ((Status == STATUS_SUCCESS) && (!ConflictFound))
{
// recommended reserved
return TRUE;
}

if ((Status == STATUS_CONFLICTING_ADDRESSES) && ConflictFound)
{
DbgPrint(“TestDevice Reserve_Vector: recommended vector reservation %d is conflicting. Try other\r\n”, RECOMMENDED_VECTOR);
return FALSE;
}


?? Dmitry Kaptsenel, Intel Software Solutions Group

Instead of doing it this way, why don’t you write a PNP driver and use the
INF file with a LogConfig section to specify the interrupt? This is the
clean way to do this. Also, what kind of device has an interrupt and no
other resources? How in the world can you determin if your device
interrupted with this design?


Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
Remove StopSpam from the email to reply

“Kaptsenel, Dmitry” wrote in message
news:xxxxx@ntfsd…
First of all sorry for bothering you. I know that my question is not related
directly to file systems, but I just don’t know who can help me. May be you
can at least forward me to the right place to ask the question.

I’m trying to write virtual device driver for WinXP that will handle some
interrupt. As far as I understood it I need to claim interrupt resource
using IoReportResourceForDetection, then register my device using
IoReportDetectedDevice and then connect ISR to the interrupt vector using
IoConnectInterrupt.
My problem starts with IoReportResourceForDetection - I tried any vector
32-255 and always received the same answer - conflicts detected. My
interrupt is level and shared. Here is the code excerpt:

BOOLEAN Reserve_Vector( IN PDRIVER_OBJECT DriverObject,
OUT PCM_RESOURCE_LIST ReservedInterrupt )
{
NTSTATUS Status;
BOOLEAN ConflictFound = FALSE;

DbgPrint(“TestDevice Reserve_Vector: try to reserve recommended vector
%d\r\n”, RECOMMENDED_VECTOR);

if (! ReservedInterrupt)
{
return FALSE;
}

// init resource list with the only resource - interrupt vector
ReservedInterrupt->Count = 1;
ReservedInterrupt->List[0].InterfaceType = InterfaceTypeUndefined;
ReservedInterrupt->List[0].BusNumber = 0;
ReservedInterrupt->List[0].PartialResourceList.Version = 1;
ReservedInterrupt->List[0].PartialResourceList.Revision = 1;
ReservedInterrupt->List[0].PartialResourceList.Count = 1;
ReservedInterrupt->List[0].PartialResourceList.PartialDescriptors[0].Type
= CmResourceTypeInterrupt;
ReservedInterrupt->List[0].PartialResourceList.PartialDescriptors[0].ShareDisposition
= CmResourceShareShared;
ReservedInterrupt->List[0].PartialResourceList.PartialDescriptors[0].Flags
= CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE;
ReservedInterrupt->List[0].PartialResourceList.PartialDescriptors[0].u.Interrupt.Level
= DISPATCH_LEVEL+1;
ReservedInterrupt->List[0].PartialResourceList.PartialDescriptors[0].u.Interrupt.Vector
= RECOMMENDED_VECTOR;
ReservedInterrupt->List[0].PartialResourceList.PartialDescriptors[0].u.Interrupt.Affinity
= (ULONG)-1;

// try recommended first
Status = IoReportResourceForDetection( DriverObject,
ReservedInterrupt,
sizeof(CM_RESOURCE_LIST),
NULL,
NULL,
0,
&ConflictFound);

if ((Status == STATUS_SUCCESS) && (!ConflictFound))
{
// recommended reserved
return TRUE;
}

if ((Status == STATUS_CONFLICTING_ADDRESSES) && ConflictFound)
{
DbgPrint(“TestDevice Reserve_Vector: recommended vector reservation %d
is conflicting. Try other\r\n”, RECOMMENDED_VECTOR);
return FALSE;
}




Dmitry Kaptsenel, Intel Software Solutions Group

The device is actually some processor extension. Processor has some set
of instructions that allow me to read/write the extension’s registers.
All what I need is to assign it with some interrupt vector so when the
extension needs an attention it will raise an interrupt and ISR will
check it’s attention flag.

Actually I *DO* want to write PnP driver but my device cannot be
enumerated by any HAL/bus driver. So what I try to do is to treat it as
a legacy device and write a PnP driver for it.
Reasons I do not use an INF file is because:

  1. I do not want to enforce some predefined vector but can use any one
    that OS will assign to.
  2. In any case I need to call IoReportDetectedDevice() and it assumes
    that device was detected with some set of resources and this resources
    should be first reserved with IoReportResourceForDetection() (according
    to the documentation)


Dmitry Kaptsenel, Intel Software Solutions Group Israel (SSGi)

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Don Burn
Sent: Monday, January 02, 2006 5:17 PM
To: Windows File Systems Devs Interest List
Subject: Re:[ntfsd] IoReportResourceForDetection question

Instead of doing it this way, why don’t you write a PNP driver and use
the
INF file with a LogConfig section to specify the interrupt? This is the

clean way to do this. Also, what kind of device has an interrupt and no

other resources? How in the world can you determin if your device
interrupted with this design?


Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
Remove StopSpam from the email to reply

“Kaptsenel, Dmitry” wrote in message
news:xxxxx@ntfsd…
First of all sorry for bothering you. I know that my question is not
related
directly to file systems, but I just don’t know who can help me. May be
you
can at least forward me to the right place to ask the question.

I’m trying to write virtual device driver for WinXP that will handle
some
interrupt. As far as I understood it I need to claim interrupt resource
using IoReportResourceForDetection, then register my device using
IoReportDetectedDevice and then connect ISR to the interrupt vector
using
IoConnectInterrupt.
My problem starts with IoReportResourceForDetection - I tried any vector

32-255 and always received the same answer - conflicts detected. My
interrupt is level and shared. Here is the code excerpt:

BOOLEAN Reserve_Vector( IN PDRIVER_OBJECT DriverObject,
OUT PCM_RESOURCE_LIST ReservedInterrupt )
{
NTSTATUS Status;
BOOLEAN ConflictFound = FALSE;

DbgPrint(“TestDevice Reserve_Vector: try to reserve recommended vector

%d\r\n”, RECOMMENDED_VECTOR);

if (! ReservedInterrupt)
{
return FALSE;
}

// init resource list with the only resource - interrupt vector
ReservedInterrupt->Count = 1;
ReservedInterrupt->List[0].InterfaceType = InterfaceTypeUndefined;
ReservedInterrupt->List[0].BusNumber = 0;
ReservedInterrupt->List[0].PartialResourceList.Version = 1;
ReservedInterrupt->List[0].PartialResourceList.Revision = 1;
ReservedInterrupt->List[0].PartialResourceList.Count = 1;

ReservedInterrupt->List[0].PartialResourceList.PartialDescriptors[0].Typ
e
= CmResourceTypeInterrupt;

ReservedInterrupt->List[0].PartialResourceList.PartialDescriptors[0].Sha
reDisposition
= CmResourceShareShared;

ReservedInterrupt->List[0].PartialResourceList.PartialDescriptors[0].Fla
gs
= CM_RESOURCE_INTERRUPT_LEVEL_SENSITIVE;

ReservedInterrupt->List[0].PartialResourceList.PartialDescriptors[0].u.I
nterrupt.Level
= DISPATCH_LEVEL+1;

ReservedInterrupt->List[0].PartialResourceList.PartialDescriptors[0].u.I
nterrupt.Vector
= RECOMMENDED_VECTOR;

ReservedInterrupt->List[0].PartialResourceList.PartialDescriptors[0].u.I
nterrupt.Affinity
= (ULONG)-1;

// try recommended first
Status = IoReportResourceForDetection( DriverObject,
ReservedInterrupt,
sizeof(CM_RESOURCE_LIST),
NULL,
NULL,
0,
&ConflictFound);

if ((Status == STATUS_SUCCESS) && (!ConflictFound))
{
// recommended reserved
return TRUE;
}

if ((Status == STATUS_CONFLICTING_ADDRESSES) && ConflictFound)
{
DbgPrint(“TestDevice Reserve_Vector: recommended vector reservation
%d
is conflicting. Try other\r\n”, RECOMMENDED_VECTOR);
return FALSE;
}




Dmitry Kaptsenel, Intel Software Solutions Group


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: xxxxx@intel.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

If there is no HAL/bus driver that will enumerate your device, then install
it as a root-enumerated device. A root-enumerated device is a device that
is enumerated by the PNP manager itself. See the Toaster example in the DDK
for details. Also, look at src\setup in the DDK, for examples of how to
install instances of root-enumerated devices. The “devcon” example will
allow you to do this, like so:

devcon install myinf.inf root\mydevice

myinf.inf must have a device section for the “root\mydevice” device type.
devcon will create a root-enumerated device instance, and will then install
the driver from your INF file on that device instance.

You can do this manually, of course, using the SetupDi* API.

– arlie

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Kaptsenel, Dmitry
Sent: Monday, January 02, 2006 10:41 AM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] IoReportResourceForDetection question

The device is actually some processor extension. Processor has some set of
instructions that allow me to read/write the extension’s registers.
All what I need is to assign it with some interrupt vector so when the
extension needs an attention it will raise an interrupt and ISR will check
it’s attention flag.

Actually I *DO* want to write PnP driver but my device cannot be enumerated
by any HAL/bus driver. So what I try to do is to treat it as a legacy device
and write a PnP driver for it.
Reasons I do not use an INF file is because:

  1. I do not want to enforce some predefined vector but can use any one that
    OS will assign to.
  2. In any case I need to call IoReportDetectedDevice() and it assumes that
    device was detected with some set of resources and this resources should be
    first reserved with IoReportResourceForDetection() (according to the
    documentation)


Dmitry Kaptsenel, Intel Software Solutions Group Israel (SSGi)

>I’m trying to write virtual device driver for WinXP that will handle some
interrupt.

As far as I understood it I need to claim interrupt resource using
IoReportResourceForDetection, then register my device using
IoReportDetectedDevice and then connect ISR to the interrupt vector using
IoConnectInterrupt.

What is virtual device? Hardware-less? Then sorry, forget IoConnectInterrupt
forever. Hardware-less kernel modules have nothing to do with
IoConnectInterrupt.

And, if you have hardware, then use PnP instead of all this dancing with the
tambourine. IoReportResourceForDetection and IoReportDetectedDevice are
intended only for drivers on non-PnP busses (ancient ISA) and for hardware
detection mode only.

Surely I’m not speaking about calling IoReportDetectedDevice with all NULLs
here, which creates a perfectly valid PDO and differs from IoCreateDevice only
in the fact the device will be a valid PDO, so you can, say, register the
device interface symlinks to it.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

>1. I do not want to enforce some predefined vector but can use any one

that OS will assign to.

Sorry, but you can only use the vector to which the hardware IRQ wire of your
device is connected.

Is it a PCI device?

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

No, this is not a PCI device. There is no IO device at all. It is just a
set of processor instructions and registers.


Dmitry Kaptsenel, Intel Software Solutions Group Israel (SSGi),
(972)-4-8655719

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Maxim S. Shatskih
Sent: Monday, January 02, 2006 9:15 PM
To: Windows File Systems Devs Interest List
Subject: Re: [ntfsd] IoReportResourceForDetection question

  1. I do not want to enforce some predefined vector but can use any one
    that OS will assign to.

Sorry, but you can only use the vector to which the hardware IRQ wire of
your
device is connected.

Is it a PCI device?

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: xxxxx@intel.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

Thank you. I tried this but …
I wrote an INF file with LogConfig section with IRQConfig directive like
the following:
IRQConfig=LS:15,14,13,12,11,10,9,8,7,6,5,4,3,2,1 ; Level Sensitive
Sharable Interrupt on any of 1-15 IRQ lines

Or
IRQConfig=LS:15

Devcon with this INF has created the node in the Device Manager but the
device was signed as disabled and not working and not holding any
resources. When I tried to load the driver from the application the
IoReportDetectedDevice() failed with the resource conflicts error -
exactly like without the INF at all.

Does the driver is get loaded immediately during the devcon execution
and AddDevice() is called at this time ? I set the break point in the
WinDbg in DriverEntry but it was not called.


Dmitry Kaptsenel, Intel Software Solutions Group Israel (SSGi),
(972)-4-8655719

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Arlie Davis
Sent: Monday, January 02, 2006 6:58 PM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] IoReportResourceForDetection question

If there is no HAL/bus driver that will enumerate your device, then
install
it as a root-enumerated device. A root-enumerated device is a device
that
is enumerated by the PNP manager itself. See the Toaster example in the
DDK
for details. Also, look at src\setup in the DDK, for examples of how to
install instances of root-enumerated devices. The “devcon” example will
allow you to do this, like so:

devcon install myinf.inf root\mydevice

myinf.inf must have a device section for the “root\mydevice” device
type.
devcon will create a root-enumerated device instance, and will then
install
the driver from your INF file on that device instance.

You can do this manually, of course, using the SetupDi* API.

– arlie

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Kaptsenel,
Dmitry
Sent: Monday, January 02, 2006 10:41 AM
To: Windows File Systems Devs Interest List
Subject: RE: [ntfsd] IoReportResourceForDetection question

The device is actually some processor extension. Processor has some set
of
instructions that allow me to read/write the extension’s registers.
All what I need is to assign it with some interrupt vector so when the
extension needs an attention it will raise an interrupt and ISR will
check
it’s attention flag.

Actually I *DO* want to write PnP driver but my device cannot be
enumerated
by any HAL/bus driver. So what I try to do is to treat it as a legacy
device
and write a PnP driver for it.
Reasons I do not use an INF file is because:

  1. I do not want to enforce some predefined vector but can use any one
    that
    OS will assign to.
  2. In any case I need to call IoReportDetectedDevice() and it assumes
    that
    device was detected with some set of resources and this resources should
    be
    first reserved with IoReportResourceForDetection() (according to the
    documentation)


Dmitry Kaptsenel, Intel Software Solutions Group Israel (SSGi)


Questions? First check the IFS FAQ at
https://www.osronline.com/article.cfm?id=17

You are currently subscribed to ntfsd as: xxxxx@intel.com
To unsubscribe send a blank email to xxxxx@lists.osr.com