what is the init entrance for pci bus scan in FREEbsd?
M. Warner Losh
imp at bsdimp.com
Sun Jun 5 17:06:09 GMT 2005
In message: <87ab37ab05060108167dee1d6 at mail.gmail.com>
kylin <fierykylin at gmail.com> writes:
: Now i am coding a fake pcihotplug module in Freebsd 5.3 release,
: it contains two parts ,the userplace using a ioctl way to communicate
: with an cdev in /dev, and the kernel module which
: mainly operates on the Devclasses ,devlist and driverlist ....but
: still in the enable function,i have to rescan the pci bus. BUT, i can
: not find the pci bus scan code in the freebsd,i guess it was just an
: entry of the startup table which is made by compiler,
: still some one told me to follow the pci_init() way in LINUX ,but , i
: find it too hard in the OO structure bus arch of Freebsd .so
: WHERE can i get some code to follow in order to finish my pci rescan function?
I'm not sure I understand what you are getting at here. First, devd
already provides 95% of the infrastructure to do things when devices
are added to the system.
Second, you assume that linux's way of doing things is how FreeBSD
does things. This isn't the case. FreeBSD scans the bus at pci bus
attach time and adds chilren nodes that it finds. In the Cardbus
case, it will add nodes as the card bus bridge tells us of children,
and then probe/attaches them. If you are implementing support for
bridges that announce new children, you should start by looking into
the pci bridge driver code (this will be in src/sys/dev/pci/pci_pci.c)
and add the approrpiate hooks there. Next, you should look at the
following routines in cardbus (located in src/sys/dev/cardbus and
dev/pccbb): cbb_insert will call CARD_ATTACH_CARD on cbdev. The
CARD_ATTACH_CARD method is implemented in cardbus.c's
cardbus_attach_card. There it will probe all the slots on the bus.
It might be better to abstract the guts of this function, and move it
down into sys/dev/pci/pci.c if other bridges could use the same
Finally, you should send me your work for review. I've been keen on
expanding pci bus support for a long time and would be happy to review
BTW, Which chipsets and hotplugging methods do you support?
More information about the freebsd-questions