VaryingResourceMap and mf.sys - why all children get the same resource?

I am writing an XP driver for a multiport serial PCI card. I am using
mf.sys and VaryingResourceMap to split the card BAR0 memory range
between the serial ports (memory mapped). I can see the ports enumerated in
Device Manager as expected.
I expected that when my port driver gets IRP_MN_START_DEVICE,
AllocatedResourcesTranslated will give me the physical address where
(after mapping to virtual memory) I can access the registers of the
port. It would be at some offset of BAR0, as defined by the
VaryingResourceMap
entry in the card inf file. However, when my port driver gets
IRP_MN_START_DEVICE,
u.Memory.Start in the CmResourceTypeMemory resource in
pIrpStack>Parameters.StartDevice.AllocatedResourcesTranslated->List[0].Parti
alResourceList is identical for all (four) child devices. The Length
member is 80, as expected.
It looks like PnP manager (or mf.sys?) assigns all child devices the
same memory range, that is last 80 bytes of the PCI card memory range.
What can I be doing wrong?
The line in the inf file where I define the Varying Resource Map looks
as follows:

HKR,Child00,HardwareID,MyCompanyXR16C854PORT
HKR,Child01,VaryingResourceMap,1,00, 00,01,00,00, 80,00,00,00

In the first line I define the custom hardware ID that I reference in
the inf file for the port driver.
In the second line I am asking for memory on BAR0 at offset 0x100 bytes of
length 0x80 bytes to be assigned to Child01. The full inf file for the card
is
included at the end of this post. I also include the inf file for the
port driver.
When I get IRP_MN_QUERY_RESOURCE_REQUIREMENTS I fill the memory
resource requirement as follows:

descriptor->Type = CmResourceTypeMemory;
descriptor->ShareDisposition = CmResourceShareDeviceExclusive; /* tried
also CmResourceShareShared */
descriptor->Flags = CM_RESOURCE_MEMORY_READ_WRITE;
descriptor->u.Memory.Length = SERIAL_REGISTER_SPAN +
SERIAL_STATUS_LENGTH; //7*0x10 + 1*0x10
descriptor->u.Memory.Alignment = 0x1;
descriptor->u.Memory.MinimumAddress.QuadPart = 0;
descriptor->u.Memory.MaximumAddress.QuadPart = 0xFFFFFFFFFFFFFFFF;

I do not modify this memory requirement when I get
IRP_MN_FILTER_RESOURCE_REQUIREMENTS.

Any help is appreciated.

Here is the full inf file:
; xrsio.inf
;
; Windows XP driver for MyCompany serial cards
;
; Copyright 2004, MyCompany, Inc.
[Version]
Signature = “$Windows NT$”
Class=Multifunction
ClassGUID={4d36e971-e325-11ce-bfc1-08002be10318}
Provider=%MyCompany%
LayoutFile=layout.inf
CatalogFile=cert.cat
DriverVer= 01/26/2004,1.0.0

[ControlFlags]
ExcludeFromSelect=*

[Manufacturer]
%MyCompany%=MyCompany
[MyCompany]
%POctalDesc%=POctal_Inst,PCI\VEN_124B&DEV_0001&SUBSYS_0308124B
%POctalDesc%=POctal_Inst,PCI\VEN_124B&DEV_0001&SUBSYS_0408124B
[POctal_Inst]
Include = mf.inf
Needs = MFINSTALL.mf

[POctal_Inst.HW]
AddReg=POctal_Inst.RegHW

[POctal_Inst.Services]
Include = mf.inf
Needs = MFINSTALL.mf.Services

[POctal_Inst.RegHW]
HKR,Child00,HardwareID,MyCompanyXR16C854PORT
HKR,Child00,VaryingResourceMap,1,00, 00,00,00,00, 80,00,00,00
HKR,Child00,ResourceMap,1,06
HKR,Child01,HardwareID,MyCompanyXR16C854PORT
HKR,Child01,VaryingResourceMap,1,00, 00,01,00,00, 80,00,00,00
HKR,Child01,ResourceMap,1,06
HKR,Child02,HardwareID,MyCompanyXR16C854PORT
HKR,Child02,VaryingResourceMap,1,00, 00,02,00,00, 80,00,00,00
HKR,Child02,ResourceMap,1,06
HKR,Child03,HardwareID,MyCompanyXR16C854PORT
HKR,Child03,VaryingResourceMap,1,00, 00,03,00,00, 80,00,00,00
HKR,Child03,ResourceMap,1,06
[Strings]

; *******Localizable Strings*******
MyCompany= “MyCompany, Inc.”
Desc_x860= “PETER”
POctalDesc= "P-Octal "
;********************** end of the card inf file
************************

Here is the inf file that I use to tell PnP Manager to use xrsio.sys
driver to service the MyCompanyXR16C854PORT hardware ID:

; xrsioport.inf
;
; Windows XP driver for MYCOMPANY P-Octal cards
;
; Copyright 2004, MYCOMPANY Technologies, Inc.

[Version]
Signature = “$Windows NT$”
Class=Ports
ClassGUID={4d36e978-e325-11ce-bfc1-08002be10318}
Provider=%MYCOMPANY%
CatalogFile=cert.cat
DriverVer= 01/16/2004,1.0.0

[DestinationDirs]
xrsio.Files.x86_12 = 12

[SourceDisksNames.x86]
0=%Desc_x860%

[SourceDisksNames.ia64]

[SourceDisksFiles.x86]
xrsio.sys=0,

[SourceDisksFiles.ia64]

[Manufacturer]
%MYCOMPANY%=MYCOMPANY

[MYCOMPANY]
%xrsioDesc%=xrsio_Inst,MYCOMPANYXR16C854PORT

[xrsio_Inst.ntx86]
CopyFiles = xrsio.Files.x86_12

[xrsio_Inst.ntx86.HW.AddReg]
HKR,“UpperFilters”,0x00010000,“serenum”

[xrsio_Inst.ntx86.HW]
AddReg=xrsio_Inst.ntx86.HW.AddReg

[xrsio_Inst.ntx86.Services]
AddService = xrsio,0x00000002,xrsio_Service_Instx86,
xrsio_EventLog_Inst

[xrsio_Service_Instx86]
ServiceType = %SERVICE_KERNEL_DRIVER%
StartType = %SERVICE_DEMAND_START%
ErrorControl = %SERVICE_ERROR_NORMAL%
ServiceBinary = %12%\xrsio.sys

[xrsio.Files.x86_12]
xrsio.sys

[xrsio_EventLog_Inst]
AddReg = xrsio_EventLog_Inst.AddReg

[xrsio_EventLog_Inst.AddReg]
HKR,EventMessageFile,%REG_EXPAND_SZ%,“%%SystemRoot%%\System32\IoLogMsg.dll”
HKR,TypesSupported,%REG_DWORD%,7

[Strings]

; *******Localizable Strings*******
MYCOMPANY= “MYCOMPANY Inc.”
Desc_x860= “MYCOMPANY Inc. driver”
xrsioDesc= “MYCOMPANY serial port”

; *******Non Localizable Strings*******

SERVICE_BOOT_START = 0x0
SERVICE_SYSTEM_START = 0x1
SERVICE_AUTO_START = 0x2
SERVICE_DEMAND_START = 0x3
SERVICE_DISABLED = 0x4

SERVICE_KERNEL_DRIVER = 0x1
SERVICE_ERROR_IGNORE = 0x0
SERVICE_ERROR_NORMAL = 0x1
SERVICE_ERROR_SEVERE = 0x2
SERVICE_ERROR_CRITICAL = 0x3

REG_EXPAND_SZ = 0x00020000
REG_DWORD = 0x00010001

Just a suggestion: try varying the names of the child device hardware ids.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Slawek
Sent: Friday, February 06, 2004 6:33 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] VaryingResourceMap and mf.sys - why all
children get the same resource?

I am writing an XP driver for a multiport serial PCI card. I
am using mf.sys and VaryingResourceMap to split the card BAR0
memory range between the serial ports (memory mapped). I can
see the ports enumerated in Device Manager as expected.
I expected that when my port driver gets IRP_MN_START_DEVICE,
AllocatedResourcesTranslated will give me the physical
address where (after mapping to virtual memory) I can access
the registers of the port. It would be at some offset of
BAR0, as defined by the VaryingResourceMap entry in the card
inf file. However, when my port driver gets
IRP_MN_START_DEVICE, u.Memory.Start in the
CmResourceTypeMemory resource in
pIrpStack>Parameters.StartDevice.AllocatedResourcesTranslated-
>List[0].P
pIrpStack>arti
alResourceList is identical for all (four) child devices. The
Length member is 80, as expected.
It looks like PnP manager (or mf.sys?) assigns all child
devices the same memory range, that is last 80 bytes of the
PCI card memory range.
What can I be doing wrong?
The line in the inf file where I define the Varying Resource
Map looks as follows:

HKR,Child00,HardwareID,MyCompanyXR16C854PORT
HKR,Child01,VaryingResourceMap,1,00, 00,01,00,00, 80,00,00,00

In the first line I define the custom hardware ID that I
reference in the inf file for the port driver.
In the second line I am asking for memory on BAR0 at offset
0x100 bytes of length 0x80 bytes to be assigned to Child01.
The full inf file for the card is included at the end of this
post. I also include the inf file for the port driver.
When I get IRP_MN_QUERY_RESOURCE_REQUIREMENTS I fill the
memory resource requirement as follows:

descriptor->Type = CmResourceTypeMemory;
descriptor->ShareDisposition =
CmResourceShareDeviceExclusive; /* tried also CmResourceShareShared */
descriptor->Flags = CM_RESOURCE_MEMORY_READ_WRITE;
descriptor->u.Memory.Length = SERIAL_REGISTER_SPAN +
SERIAL_STATUS_LENGTH; //7*0x10 + 1*0x10
descriptor->u.Memory.Alignment = 0x1;
descriptor->u.Memory.MinimumAddress.QuadPart = 0;
descriptor->u.Memory.MaximumAddress.QuadPart = 0xFFFFFFFFFFFFFFFF;

I do not modify this memory requirement when I get
IRP_MN_FILTER_RESOURCE_REQUIREMENTS.

Any help is appreciated.

Here is the full inf file:
; xrsio.inf
;
; Windows XP driver for MyCompany serial cards ; ; Copyright
2004, MyCompany, Inc.
[Version]
Signature = “$Windows NT$”
Class=Multifunction
ClassGUID={4d36e971-e325-11ce-bfc1-08002be10318}
Provider=%MyCompany%
LayoutFile=layout.inf
CatalogFile=cert.cat
DriverVer= 01/26/2004,1.0.0

[ControlFlags]
ExcludeFromSelect=*

[Manufacturer]
%MyCompany%=MyCompany
[MyCompany]
%POctalDesc%=POctal_Inst,PCI\VEN_124B&DEV_0001&SUBSYS_0308124B
%POctalDesc%=POctal_Inst,PCI\VEN_124B&DEV_0001&SUBSYS_0408124B
[POctal_Inst]
Include = mf.inf
Needs = MFINSTALL.mf

[POctal_Inst.HW]
AddReg=POctal_Inst.RegHW

[POctal_Inst.Services]
Include = mf.inf
Needs = MFINSTALL.mf.Services

[POctal_Inst.RegHW]
HKR,Child00,HardwareID,MyCompanyXR16C854PORT
HKR,Child00,VaryingResourceMap,1,00, 00,00,00,00, 80,00,00,00
HKR,Child00,ResourceMap,1,06
HKR,Child01,HardwareID,MyCompanyXR16C854PORT
HKR,Child01,VaryingResourceMap,1,00, 00,01,00,00, 80,00,00,00
HKR,Child01,ResourceMap,1,06
HKR,Child02,HardwareID,MyCompanyXR16C854PORT
HKR,Child02,VaryingResourceMap,1,00, 00,02,00,00, 80,00,00,00
HKR,Child02,ResourceMap,1,06
HKR,Child03,HardwareID,MyCompanyXR16C854PORT
HKR,Child03,VaryingResourceMap,1,00, 00,03,00,00, 80,00,00,00
HKR,Child03,ResourceMap,1,06
[Strings]

; *******Localizable Strings*******
MyCompany= “MyCompany, Inc.”
Desc_x860= “PETER”
POctalDesc= "P-Octal "
;********************** end of the card inf file
************************

Here is the inf file that I use to tell PnP Manager to use
xrsio.sys driver to service the MyCompanyXR16C854PORT hardware ID:

; xrsioport.inf
;
; Windows XP driver for MYCOMPANY P-Octal cards ; ; Copyright
2004, MYCOMPANY Technologies, Inc.

[Version]
Signature = “$Windows NT$”
Class=Ports
ClassGUID={4d36e978-e325-11ce-bfc1-08002be10318}
Provider=%MYCOMPANY%
CatalogFile=cert.cat
DriverVer= 01/16/2004,1.0.0

[DestinationDirs]
xrsio.Files.x86_12 = 12

[SourceDisksNames.x86]
0=%Desc_x860%

[SourceDisksNames.ia64]

[SourceDisksFiles.x86]
xrsio.sys=0,

[SourceDisksFiles.ia64]

[Manufacturer]
%MYCOMPANY%=MYCOMPANY

[MYCOMPANY]
%xrsioDesc%=xrsio_Inst,MYCOMPANYXR16C854PORT

[xrsio_Inst.ntx86]
CopyFiles = xrsio.Files.x86_12

[xrsio_Inst.ntx86.HW.AddReg]
HKR,“UpperFilters”,0x00010000,“serenum”

[xrsio_Inst.ntx86.HW]
AddReg=xrsio_Inst.ntx86.HW.AddReg

[xrsio_Inst.ntx86.Services]
AddService = xrsio,0x00000002,xrsio_Service_Instx86,
xrsio_EventLog_Inst

[xrsio_Service_Instx86]
ServiceType = %SERVICE_KERNEL_DRIVER%
StartType = %SERVICE_DEMAND_START%
ErrorControl = %SERVICE_ERROR_NORMAL%
ServiceBinary = %12%\xrsio.sys

[xrsio.Files.x86_12]
xrsio.sys

[xrsio_EventLog_Inst]
AddReg = xrsio_EventLog_Inst.AddReg

[xrsio_EventLog_Inst.AddReg]
HKR,EventMessageFile,%REG_EXPAND_SZ%,“%%SystemRoot%%\System32
\IoLogMsg.dll”
HKR,TypesSupported,%REG_DWORD%,7

[Strings]

; *******Localizable Strings*******
MYCOMPANY= “MYCOMPANY Inc.”
Desc_x860= “MYCOMPANY Inc. driver”
xrsioDesc= “MYCOMPANY serial port”

; *******Non Localizable Strings*******

SERVICE_BOOT_START = 0x0
SERVICE_SYSTEM_START = 0x1
SERVICE_AUTO_START = 0x2
SERVICE_DEMAND_START = 0x3
SERVICE_DISABLED = 0x4

SERVICE_KERNEL_DRIVER = 0x1
SERVICE_ERROR_IGNORE = 0x0
SERVICE_ERROR_NORMAL = 0x1
SERVICE_ERROR_SEVERE = 0x2
SERVICE_ERROR_CRITICAL = 0x3

REG_EXPAND_SZ = 0x00020000
REG_DWORD = 0x00010001


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

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

Thanks for the suggestion. I modified my card in file to contain something
like this:

HKR,Child00,HardwareID,MyCompanyXR16C854PORT1
HKR,Child00,VaryingResourceMap,1,00, 00,00,00,00, 80,00,00,00
HKR,Child00,ResourceMap,1,06
HKR,Child01,HardwareID,MyCompanyXR16C854PORT2
HKR,Child01,VaryingResourceMap,1,00, 00,01,00,00, 80,00,00,00
HKR,Child01,ResourceMap,1,06

and the port inf file:

[MyCompany]
%xrsioDesc%=xrsio_Inst,MyCompanyXR16C854PORT1
%xrsioDesc%=xrsio_Inst,MyCompanyXR16C854PORT2

I unistalled all devices and installed again with the updated inf files. The
card inf file installed OK. Device manager refused to install the port inf
file stating thet the file does not contain the information about the
hardware. I tried again after a reboot and this time the port inf file got
installed (4 times). However, this did not help: the driver for the port
still gets the same memory range for all port PDO’s.
thanks anyway
Slawek

“Mark Roddy” wrote in message news:xxxxx@ntdev…
> Just a suggestion: try varying the names of the child device hardware ids.
>
> > -----Original Message-----
> > From: xxxxx@lists.osr.com
> > [mailto:xxxxx@lists.osr.com] On Behalf Of Slawek
> > Sent: Friday, February 06, 2004 6:33 PM
> > To: Windows System Software Devs Interest List
> > Subject: [ntdev] VaryingResourceMap and mf.sys - why all
> > children get the same resource?
> >
> > I am writing an XP driver for a multiport serial PCI card. I
> > am using mf.sys and VaryingResourceMap to split the card BAR0
> > memory range between the serial ports (memory mapped). I can
> > see the ports enumerated in Device Manager as expected.
> > I expected that when my port driver gets IRP_MN_START_DEVICE,
> > AllocatedResourcesTranslated will give me the physical
> > address where (after mapping to virtual memory) I can access
> > the registers of the port. It would be at some offset of
> > BAR0, as defined by the VaryingResourceMap entry in the card
> > inf file. However, when my port driver gets
> > IRP_MN_START_DEVICE, u.Memory.Start in the
> > CmResourceTypeMemory resource in
> > pIrpStack>Parameters.StartDevice.AllocatedResourcesTranslated-
> > >List[0].P
> > pIrpStack>arti
> > alResourceList is identical for all (four) child devices.

Are you sure that the devices are being installed using the new INFs? This
can be tricky…

I’ve been playing around with Varying Resource Maps on XP, and I’ve found
that the best way to do this is to delete the old oem-renamed one(s) in
c:\winnt\inf (or c:\windows\inf) and increment the date or version of the
new INF (both steps may not be necessary, but I’m paranoid). It sounds like
you might be dealing with crusty inf data since your new files only involve
2 devices but you’re getting loaded for 4 (which you had in your old INF).

Megan

-----Original Message-----
From: Slawek [mailto:xxxxx@yahoo.com]
Sent: Friday, February 06, 2004 8:58 PM
To: Windows System Software Devs Interest List
Subject: Re:[ntdev] VaryingResourceMap and mf.sys - why all children get
the same resource?

Thanks for the suggestion. I modified my card in file to contain something
like this:

HKR,Child00,HardwareID,MyCompanyXR16C854PORT1
HKR,Child00,VaryingResourceMap,1,00, 00,00,00,00, 80,00,00,00
HKR,Child00,ResourceMap,1,06
HKR,Child01,HardwareID,MyCompanyXR16C854PORT2
HKR,Child01,VaryingResourceMap,1,00, 00,01,00,00, 80,00,00,00
HKR,Child01,ResourceMap,1,06

and the port inf file:

[MyCompany]
%xrsioDesc%=xrsio_Inst,MyCompanyXR16C854PORT1
%xrsioDesc%=xrsio_Inst,MyCompanyXR16C854PORT2

I unistalled all devices and installed again with the updated inf files. The
card inf file installed OK. Device manager refused to install the port inf
file stating thet the file does not contain the information about the
hardware. I tried again after a reboot and this time the port inf file got
installed (4 times). However, this did not help: the driver for the port
still gets the same memory range for all port PDO’s.
thanks anyway
Slawek

“Mark Roddy” wrote in message news:xxxxx@ntdev…
> Just a suggestion: try varying the names of the child device hardware ids.
>
> > -----Original Message-----
> > From: xxxxx@lists.osr.com
> > [mailto:xxxxx@lists.osr.com] On Behalf Of Slawek
> > Sent: Friday, February 06, 2004 6:33 PM
> > To: Windows System Software Devs Interest List
> > Subject: [ntdev] VaryingResourceMap and mf.sys - why all
> > children get the same resource?
> >
> > I am writing an XP driver for a multiport serial PCI card. I
> > am using mf.sys and VaryingResourceMap to split the card BAR0
> > memory range between the serial ports (memory mapped). I can
> > see the ports enumerated in Device Manager as expected.
> > I expected that when my port driver gets IRP_MN_START_DEVICE,
> > AllocatedResourcesTranslated will give me the physical
> > address where (after mapping to virtual memory) I can access
> > the registers of the port. It would be at some offset of
> > BAR0, as defined by the VaryingResourceMap entry in the card
> > inf file. However, when my port driver gets
> > IRP_MN_START_DEVICE, u.Memory.Start in the
> > CmResourceTypeMemory resource in
> > pIrpStack>Parameters.StartDevice.AllocatedResourcesTranslated-
> > >List[0].P
> > pIrpStack>arti
> > alResourceList is identical for all (four) child devices.


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

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

>It sounds like

you might be dealing with crusty inf data since your new files only
involve
2 devices but you’re getting loaded for 4 (which you had in your old INF).

Yes, I am rather sure I update my inf and driver correctly. I put a debug
printout in the driver entry routine that tells me the creation time of the
binary that is running. I also change the device description that shows up
during installation in inf.
I quoted only 2 lines instead of 4 from the inf file for brevity of the
post.
Anyway, I tried also to pass the IRP_MN_QUERY_RESOURCE_REQUIREMENTS to the
lower driver instead of handling it. As a result I never get
IRP_MN_START_DEVICE. The Device Manager says “This device can not find free
resources that it can use (code 12)”.

I decided to stop fighting with mf.sys and to write my own bus driver.
Thanks to all who tried to help.

Slawek

“Lally, Megan” wrote in message
news:xxxxx@ntdev…
> Are you sure that the devices are being installed using the new INFs?
This
> can be tricky…
>
> I’ve been playing around with Varying Resource Maps on XP, and I’ve found
> that the best way to do this is to delete the old oem-renamed one(s) in
> c:\winnt\inf (or c:\windows\inf) and increment the date or version of the
> new INF (both steps may not be necessary, but I’m paranoid). It sounds
like
> you might be dealing with crusty inf data since your new files only
involve
> 2 devices but you’re getting loaded for 4 (which you had in your old INF).
>
> Megan
>