pci bus filter driver revisited

My company builds PCI bus expansion solutions. I need to write a PCI
bus filter driver so that I can make low level changes to the bridge
chip we are using. This is one area I have found the DDK to be a little
sparse in, are there any other resources I can use to get me started.
My driver may also need to make changes to configuration settings
upstream and downstream from my bridge. Are there any resources white
papers etc. that can give me a better understanding as to how to
register this type of driver? I know from others comments that there
is some complexity involved in the MN_QUERY_DEVICE_RELATIONS path.

Brian D. Stark

**********************************
CONFIDENTIALITY NOTICE: The information in this electronic mail transmission is legally privileged and confidential information intended only for the use of the individual or entity named above. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of the transmission is strictly prohibited. If you have received this transmission in error, delete the message and immediately notify us by telephone at 480.596.0061 or by responding to this email.
**********************************

I’ve written one standard PCI driver and one PCI Bus filter for a PCI Bridge/fabric product we use. Both were challenging but great learning experiences. The former is in a shipped product, but the later was a limited filter meant to address some functions that we later deemed unimportant and didn’t ship. Admittedly, I hadn’t done much with MN_QUERY_DEVICE_RELATIONS in my filter, other than parse & print args. I was more keen on filtering resources & powerstate, as I recall.

Look at the OSR ntdev list for hints. I think there may have been one or two examples that I found during my web trolling, but at the moment I don’t recall their location. I seem to recall Walter Oney’s book covering filter drivers as well, although not specifically PCI Bus Filters.

Aside: prior to debug consider getting intimately familar with devcon.exe (from the DDK) and regedit - they are your friends in this space. Also learn how to properly remove your filter and still have a bootable system. Initially, I found this akin to handling a rabid porcupine in a paper bag; it’s easy to get yourself full of quills: i.e. your system injured and unbootable. I’m sure others more ingrained in the habits of filter drivers treat this as second nature.

Mike Dailey

“Brian Stark” wrote in message news:xxxxx@windbg…
My company builds PCI bus expansion solutions. I need to write a PCI bus filter driver so that I can make low level changes to the bridge chip we are using. This is one area I have found the DDK to be a little sparse in, are there any other resources I can use to get me started. My driver may also need to make changes to configuration settings upstream and downstream from my bridge. Are there any resources white papers etc. that can give me a better understanding as to how to register this type of driver? I know from others comments that there is some complexity involved in the MN_QUERY_DEVICE_RELATIONS path.

Brian D. Stark


CONFIDENTIALITY NOTICE: The information in this electronic mail transmission is legally privileged and confidential information intended only for the use of the individual or entity named above. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of the transmission is strictly prohibited. If you have received this transmission in error, delete the message and immediately notify us by telephone at 480.596.0061 or by responding to this email.

If you only need to modify settings on one specific device (rather than
seeing all PCI devices), you should be able to add yourself as a
standard upper filter on the specific device rather than implementing a
bus filter (which is a whole different kettle of worms!)

Here’s (approximately) what we have in our inf file for a driver that
does this (I suspect that the way we get the PCI driver on the stack is
not entirely correct - we copied the definitions from the MS inf file -
but I don’t know of a better way that works). Note that we end up with
PCI.SYS as the function driver and our driver (srabid.sys) as an
upperfilter.

/simgr

[Manufacturer]

%STRATUS_MFG%=STRATUS_SYS

[STRATUS_SYS]

%Asic.DeviceDesc% = PARENT_PLUSINT_FLT_DRV, PCI\VEN_159C&DEV_1000

[PARENT_PLUSINT_FLT_DRV]

CopyFiles=srabid_copyfiles

[PARENT_PLUSINT_FLT_DRV.HW]

AddReg = srabid_addreg

[PARENT_PLUSINT_FLT_DRV.Services]

AddService = pci, %SPSVCINST_ASSOCSERVICE%, pci_ServiceInstallSection

AddService = srabid,srabid_service,srabid_eventlog

[pci_ServiceInstallSection]

DisplayName = %pci_svcdesc%

ServiceType = %SERVICE_KERNEL_DRIVER%

StartType = %SERVICE_BOOT_START%

ErrorControl = %SERVICE_ERROR_CRITICAL%

ServiceBinary = %12%\pci.sys

LoadOrderGroup = “Boot Bus Extender”

[srabid_copyfiles]

sracc.sys

srabid.sys

[srabid_addreg]

HKR,“UpperFilters”,%REG_MULTI_SZ_APPEND%,“srabid”

HKR,“DeviceType”,%REG_DWORD%,0x22

HKR,“Security”,“D:P(A;;GA;;;SY)(A;;GA;;;BA)” ; ACL allowing System
and Admin

[srabid_service]

DisplayName = %srabid_ServiceName%

Description = %srabid_ServiceDesc%

ServiceType = %SERVICE_KERNEL_DRIVER%

StartType = %SERVICE_BOOT_START%

ErrorControl = %SERVICE_ERROR_NORMAL%

ServiceBinary = %12%\srabid.sys

[srabid_eventlog]

AddReg = srabid_evtaddreg

[srabid_evtaddreg]

HKR,EventMessageFile, %REG_EXPAND_SZ%,
“%%SystemRoot%%\System32\IoLogMsg.dll;%%SystemRoot%%\System32\drivers\sr
acc.sys;%%SystemRoot%%\System32\drivers\srabid.sys”

HKR,ParameterMessageFile, %REG_EXPAND_SZ%,
%%SystemRoot%%\System32\drivers\sracc.sys

HKR,TypesSupported, %REG_DWORD%, 7

[Strings]

pci_svcdesc = “PCI Bus Driver”

;*******************************************

;device descriptions

STRATUS_MFG = “Stratus Technologies, Inc”

Asic.DeviceDesc = “Stratus Fault Tolerant PCI to PCI Bridge”

;*******************************************

;Handy macro substitutions (non-localizable)

SPSVCINST_ASSOCSERVICE = 0x00000002

SERVICE_KERNEL_DRIVER = 1

SERVICE_BOOT_START = 0

SERVICE_DEMAND_START = 3

SERVICE_ERROR_NORMAL = 1

SERVICE_ERROR_CRITICAL = 3

REG_EXPAND_SZ = 0x00020000

REG_MULTI_SZ_APPEND = 0x00010008

REG_MULTI_SZ = 0x00010000

REG_DWORD = 0x00010001

REG_DWORD_NOCLOBBER = 0x00010003

REG_BINARY = 0x00000001

srabid_ServiceName=“Stratus Board Instance Driver”

srabid_ServiceDesc=“Controls Stratus I/O and CPU Board Hardware”


From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of Brian Stark
Sent: Thursday, November 10, 2005 8:54 PM
To: Kernel Debugging Interest List
Subject: [windbg] pci bus filter driver revisited

My company builds PCI bus expansion solutions. I need to write a PCI
bus filter driver so that I can make low level changes to the bridge
chip we are using. This is one area I have found the DDK to be a little
sparse in, are there any other resources I can use to get me started.
My driver may also need to make changes to configuration settings
upstream and downstream from my bridge. Are there any resources white
papers etc. that can give me a better understanding as to how to
register this type of driver? I know from others comments that there
is some complexity involved in the MN_QUERY_DEVICE_RELATIONS path.

Brian D. Stark

**********************************
CONFIDENTIALITY NOTICE: The information in this electronic mail
transmission is legally privileged and confidential information intended
only for the use of the individual or entity named above. If the reader
of this message is not the intended recipient, you are hereby notified
that any dissemination, distribution or copying of the transmission is
strictly prohibited. If you have received this transmission in error,
delete the message and immediately notify us by telephone at
480.596.0061 or by responding to this email.
**********************************


You are currently subscribed to windbg as: unknown lmsubst tag argument:
‘’
To unsubscribe send a blank email to xxxxx@lists.osr.com

[snip]

Initially, I found this akin to handling a rabid porcupine in a paper
bag;
it’s easy to get yourself full of quills: i.e. your system injured and
unbootable.

Interesting analogy… :))