From owner-freebsd-drivers@FreeBSD.ORG Tue Oct 18 15:12:55 2005 Return-Path: X-Original-To: freebsd-drivers@freebsd.org Delivered-To: freebsd-drivers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id ED68F16A41F for ; Tue, 18 Oct 2005 15:12:55 +0000 (GMT) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (vc4-2-0-87.dsl.netrack.net [199.45.160.85]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8A3A243D46 for ; Tue, 18 Oct 2005 15:12:55 +0000 (GMT) (envelope-from imp@bsdimp.com) Received: from localhost (localhost.village.org [127.0.0.1] (may be forged)) by harmony.bsdimp.com (8.13.3/8.13.3) with ESMTP id j9IFAHZi026200; Tue, 18 Oct 2005 09:10:17 -0600 (MDT) (envelope-from imp@bsdimp.com) Date: Tue, 18 Oct 2005 09:11:34 -0600 (MDT) Message-Id: <20051018.091134.85411642.imp@bsdimp.com> To: mayong@mail.com From: "M. Warner Losh" In-Reply-To: <200510180826.j9I8Quw26871@cal1-1.us4.outblaze.com> References: <200510180826.j9I8Quw26871@cal1-1.us4.outblaze.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 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.0 (harmony.bsdimp.com [127.0.0.1]); Tue, 18 Oct 2005 09:10:18 -0600 (MDT) Cc: freebsd-drivers@freebsd.org Subject: Re: Some Questions X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 Oct 2005 15:12:56 -0000 In message: <200510180826.j9I8Quw26871@cal1-1.us4.outblaze.com> "Yong Ma" writes: : 1)Some drivers declares the device_open() as int device_open(dev_t : dev,...),and some declare it as int device_open(struct cdev : *dev,...),sometimes the first one couldn't be : compliedsuccessfully,what's the difference? In 4.x, the former was used. In 5.x and newer, the latter is used. On 4.x you could get away with the latter because dev_t was typedefed to be struct cdev *. : 2) if (pci_get_vendor(dev) == 0x11c1) { ... : ~~~~~~~~how to get this number if I don't know it? (1) Ask the vendor of your device (2) Read the datasheet for your device (3) pciconf -l :-) : 3)Could the device on PCI slot be listed by /pciconf -l /without driver. Yes. : 4)The printf() seems not work under XWindow mode in functions like : deviec_prob or device_attach,how to make it work? It works. However, the output is sent to the console. Under X windows, the console is normally hidden from you somewhere. You can get the last bit of console output, however, using the dmesg command. : 5)If only the pseudo-device in /dev can be destroyed with : destroy_dev(sc->dev0) in detach() function in a KLD driver? I can't : do that! I'm afraid I don't understand this question. If you have, say, a global control device for all instances of the driver, you can keep a 'reference count' of the number of instances attached and then delete the device when the last one detaches. If it is something else, then I'll need more information. Warner