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