From owner-freebsd-current@FreeBSD.ORG Sun Jun 5 17:06:09 2005 Return-Path: X-Original-To: freebsd-current@freebsd.org Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 866F316A41C; Sun, 5 Jun 2005 17:06:09 +0000 (GMT) (envelope-from imp@bsdimp.com) Received: from harmony.village.org (berlin-qwest.village.org [168.103.84.175]) by mx1.FreeBSD.org (Postfix) with ESMTP id 531BA43D49; Sun, 5 Jun 2005 17:06:08 +0000 (GMT) (envelope-from imp@bsdimp.com) Received: from localhost (warner@rover2.village.org [10.0.0.1]) by harmony.village.org (8.13.3/8.13.1) with ESMTP id j55H4LPr067527; Sun, 5 Jun 2005 11:04:21 -0600 (MDT) (envelope-from imp@bsdimp.com) Date: Sun, 05 Jun 2005 11:05:08 -0600 (MDT) Message-Id: <20050605.110508.101566419.imp@bsdimp.com> To: fierykylin@gmail.com From: "M. Warner Losh" In-Reply-To: <87ab37ab05060108167dee1d6@mail.gmail.com> References: <87ab37ab05060108167dee1d6@mail.gmail.com> X-Mailer: Mew version 3.3 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Cc: freebsd-current@freebsd.org, freebsd-questions@freebsd.org Subject: Re: what is the init entrance for pci bus scan in FREEbsd? X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 05 Jun 2005 17:06:09 -0000 In message: <87ab37ab05060108167dee1d6@mail.gmail.com> kylin 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 functionality. 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 such changes. BTW, Which chipsets and hotplugging methods do you support? Warner