Discussion:
VaryingResourceMap and mf.sys problem
(too old to reply)
Slawomir
2004-02-05 19:02:08 UTC
Permalink
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. However, when I get
IRP_MN_START_DEVICE, the CmResourceTypeMemory resource in
pIrpStack->Parameters.StartDevice.AllocatedResourcesTranslated->
List[0].PartialResourceList has u.Memory.Start 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.
The line in the inf file where I define the Varying Resource Map looks
as follows:

HKR,Child01,VaryingResourceMap,1,00, 00,01,00,00, 80,00,00,00

I understand that this means that I want memory on BAR0 at offset
0x100 bytes of length 0x80 bytes to be assigned to Child01. The full
inf file is included at the end of this post.

When I get IRP_MN_QUERY_RESOURCE_REQUIREMENTS I fill the memory
resource requirement as follows:

descriptor->Type = CmResourceTypeMemory;
descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
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.
What can I be doing wrong?
Any help is appreciated.

Slawek

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 "
Eliyas Yakub [MSFT]
2004-02-06 00:39:25 UTC
Permalink
How can you get IRP_MN_QUERY_RESOURCE_REQUIREMENTS? That's targeted at the
PDO enumerated by MF.SYS.
--
-Eliyas
This posting is provided "AS IS" with no warranties, and confers no rights.
http://www.microsoft.com/whdc/hwdev/driver/kb-drv.mspx
Post by Slawomir
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. However, when I get
IRP_MN_START_DEVICE, the CmResourceTypeMemory resource in
pIrpStack->Parameters.StartDevice.AllocatedResourcesTranslated->
List[0].PartialResourceList has u.Memory.Start 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.
The line in the inf file where I define the Varying Resource Map looks
HKR,Child01,VaryingResourceMap,1,00, 00,01,00,00, 80,00,00,00
I understand that this means that I want memory on BAR0 at offset
0x100 bytes of length 0x80 bytes to be assigned to Child01. The full
inf file is included at the end of this post.
When I get IRP_MN_QUERY_RESOURCE_REQUIREMENTS I fill the memory
descriptor->Type = CmResourceTypeMemory;
descriptor->ShareDisposition = CmResourceShareDeviceExclusive;
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.
What can I be doing wrong?
Any help is appreciated.
Slawek
; 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 "
Slawomir
2004-02-07 00:25:17 UTC
Permalink
Post by Eliyas Yakub [MSFT]
How can you get IRP_MN_QUERY_RESOURCE_REQUIREMENTS? That's targeted at the
PDO enumerated by MF.SYS.
Since all 4 serial ports are implemented as a single PCI function I
use mf.sys to enumerate the PDO's for the ports. I give the ports a
custom hardware ID in line

HKR,Child00,HardwareID,,MyCompanyXR16C854PORT

(see the inf file in the original post), that I refere to in a
separate port inf file as follows:

%xrsioDesc%=xrsio_Inst,MyCompanyXR16C854PORT

I include the full inf file for the single port driver at the end of
this post.
PnPManager prompts me to provide the driver for those PDO's and I
point it to that separate single port inf file. This inf file installs
xrsio.sys as a driver for each child (it is not a standard serial port
that can be serviced by serial.sys).
It is in that driver (xrsio.sys) that I get
IRP_MN_QUERY_RESOURCE_REQUIREMENTS.
My problem is that the translated resources I get in the port driver
are the same for each child. 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 of the
PCI card, as defined by the
VaryingResourceMap entries in the card inf file. Was my expectation
correct?
If so, what can be the reason the PnP manager assigns the last 80
bytes of the PCI card range to each PDO enumerated by mf.sys?

Thanks for looking into this,

Slawek

Here is the inf file for the ports on the PCI card (PDO's enumerated
by mf.sys):

; xrsioport.inf
;
; Windows XP driver for serial ports on MYCOMPANY cards
;
; Copyright 2004, MYCOMPANY 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
Eliyas Yakub [MSFT]
2004-02-08 02:04:11 UTC
Permalink
I'm totally surprised that your function driver (xrio.sys) is getting
IRP_MN_QUERY_RESOURCE_REQUIREMENTS. It would be nice if you set a break
point in the PNP dispatch handler and post the stack trace when you get this
IRP. AFIK, this IRP is sent to the PDO before the function driver is loaded.

Anyways, your function driver shouldn't handle this IRP. This one is meant
for bus driver, and in your case, MF knows how to respond to that. So remove
this code and try again.
--
-Eliyas
This posting is provided "AS IS" with no warranties, and confers no rights.
Slawomir
2004-02-09 23:12:50 UTC
Permalink
Post by Eliyas Yakub [MSFT]
I'm totally surprised that your function driver (xrio.sys) is getting
IRP_MN_QUERY_RESOURCE_REQUIREMENTS. It would be nice if you set a break
point in the PNP dispatch handler and post the stack trace when you get this
IRP.
OK. Here it is:

# ChildEBP RetAddr Args to Child
00 fc9138a0 804ea221 ffbce040 ffbd29c0 00000000
xrsio!SerialPnpDispatch(struct _DEVICE_OBJECT * PDevObj = 0xffbce040,
struct _IRP * PIrp = 0xffbd29c0)+0x45f (FPO: [Non-Fpo]) (CONV:
stdcall) [d:\users\skolodynski\v3\ntdriver\pci\wdm-xrsio\pnp.c @ 619]
01 fc9138f0 804ea221 ffbdacf0 ffbd29c0 fc91396c nt!IopfCallDriver+0x31
(FPO: [0,0,1])
02 fc913900 8056f1ce fc91396c fc9139dc e14aa7b4 nt!IopfCallDriver+0x31
(FPO: [0,0,1])
03 fc91392c 8056f7f9 ffbdacf0 fc913948 fc9139dc
nt!IopSynchronousCall+0xb8 (FPO: [Non-Fpo])
04 fc91396c 8056fb4b 80ce9eb8 fc9139dc 80d4a948
nt!PpIrpQueryResourceRequirements+0x2d (FPO: [Non-Fpo])
05 fc9139d0 80573fcd 80ce9eb8 00000000 e14aa7b4
nt!IopQueryDeviceResources+0x133 (FPO: [Non-Fpo])
06 fc9139fc 805747fb e14aa7a0 00000009 fc913a4c
nt!IopGetResourceRequirementsForAssignTable+0xd5 (FPO: [Non-Fpo])
07 fc913a58 80577399 fc913aa8 fc913aac 00000000
nt!IopAllocateResources+0x4d (FPO: [Non-Fpo])
08 fc913aa0 805774e8 00000009 e14aa7a0 00000001
nt!IopAssignResourcesToDevices+0xef (FPO: [Non-Fpo])
09 fc913ad8 8056e910 80e7d3d0 00000000 fc913d21
nt!IopProcessAssignResources+0xd4 (FPO: [Non-Fpo])
0a fc913d24 8056ee50 80e7d3d0 00000001 00000000
nt!PipProcessDevNodeTree+0x6e (FPO: [Non-Fpo])
0b fc913d4c 804f112a 00000003 805416c0 805464dc
nt!PiProcessStartSystemDevices+0x38 (FPO: [Non-Fpo])
0c fc913d74 805258ee 00000000 00000000 80e8e020
nt!PipDeviceActionWorker+0x158 (FPO: [Non-Fpo])
0d fc913dac 805aa2b6 00000000 00000000 00000000
nt!ExpWorkerThread+0xfe (FPO: [Non-Fpo])
0e fc913ddc 805319c6 805257f0 00000001 00000000
nt!PspSystemThreadStartup+0x34 (FPO: [Non-Fpo])
0f 00000000 00000000 00000000 00000000 00000000
nt!KiThreadStartup+0x16
Post by Eliyas Yakub [MSFT]
Anyways, your function driver shouldn't handle this IRP. ...
So remove
this code and try again.
I removed the code that handles this IRP so that it is passed to the
lower driver as follows:

//
// Pass to driver beneath us
//

IoSkipCurrentIrpStackLocation(PIrp);
status = SerialIoCallDriver(pDevExt, pLowerDevObj, PIrp);

SerialIoCallDriver() is function that does
IoCallDriver(pLowerDevObj,PIrp) plus some IRP counting (I base my
xrsio.sys driver on serial.c DDK sample).

The result is that IRP_MN_QUERY_RESOURCE_REQUIREMENTS is the last IRP
I get. I never get IRP_MN_START_DEVICE. The Device Manager says
"This device can not find free resources that it can use (code 12)"
when I right-click on my port entry and select Properties.

Slawek
Eliyas Yakub [MSFT]
2004-02-12 20:41:07 UTC
Permalink
During resource rebalancing, IRP_MN_QUERY_RESOURCE_REQUIREMENTS does get
sent thru the functional stack, but the function driver should never touch
that. So forwarding the IRP to the bus driver is the right thing to do. I
don't know why you are getting code 12. There is some information in the
WINDBG docs on how to debug resource conflicts. You can install your
function driver directly on the PCI device (without MF) and see if you are
getting resource conflict. If that works then there is something wrong in
the way MF is trying to split the resources.
--
-Eliyas
This posting is provided "AS IS" with no warranties, and confers no rights.
http://www.microsoft.com/whdc/hwdev/driver/kb-drv.mspx
Slawomir
2004-02-17 18:21:19 UTC
Permalink
I decided to write my own bus driver instead of using mf.sys. This is
a more correct solution anyway since my card has a global interrupt
status and enable registers. Thanks for your help.

Slawek
Post by Eliyas Yakub [MSFT]
During resource rebalancing, IRP_MN_QUERY_RESOURCE_REQUIREMENTS does get
sent thru the functional stack, but the function driver should never touch
that. So forwarding the IRP to the bus driver is the right thing to do. I
don't know why you are getting code 12. There is some information in the
WINDBG docs on how to debug resource conflicts. You can install your
function driver directly on the PCI device (without MF) and see if you are
getting resource conflict. If that works then there is something wrong in
the way MF is trying to split the resources.
Eliyas Yakub [MSFT]
2004-02-12 20:43:15 UTC
Permalink
During resource rebalancing, IRP_MN_QUERY_RESOURCE_REQUIREMENTS does get
sent thru the functional stack, but the function driver should never touch
that. So forwarding the IRP to the bus driver is the right thing to do. I
don't know why you are getting code 12. There is some information in the
WINDBG docs on how to debug resource conflicts. You can install your
function driver directly on the PCI device (without MF) and see if you are
getting resource conflict. If that works then there is something wrong in
the way MF is splitting the resources. Contact MS tech support.
--
-Eliyas
This posting is provided "AS IS" with no warranties, and confers no rights.
http://www.microsoft.com/whdc/hwdev/driver/kb-drv.mspx
Loading...