From owner-freebsd-hackers@FreeBSD.ORG Sat Aug 23 06:49:29 2008 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E681A106566C for ; Sat, 23 Aug 2008 06:49:29 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (bsdimp.com [199.45.160.85]) by mx1.freebsd.org (Postfix) with ESMTP id A674B8FC0A for ; Sat, 23 Aug 2008 06:49:29 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from localhost (localhost [127.0.0.1]) by harmony.bsdimp.com (8.14.2/8.14.1) with ESMTP id m7N6lLWf087391; Sat, 23 Aug 2008 00:47:22 -0600 (MDT) (envelope-from imp@bsdimp.com) Date: Sat, 23 Aug 2008 00:47:53 -0600 (MDT) Message-Id: <20080823.004753.1477561239.imp@bsdimp.com> To: ahornung@gmail.com From: "M. Warner Losh" In-Reply-To: <10fba67b0808220034t2b9598cekbad7c976eed6975f@mail.gmail.com> References: <10fba67b0808220034t2b9598cekbad7c976eed6975f@mail.gmail.com> X-Mailer: Mew version 5.2 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-hackers@freebsd.org Subject: Re: Driver accessing other drivers/devices ? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 Aug 2008 06:49:30 -0000 In message: <10fba67b0808220034t2b9598cekbad7c976eed6975f@mail.gmail.com> "Alex Hornung" writes: : Hello, : : I need to access the hard disk from within a driver that is not a FS. : I would also need to get a list of PCI devices connected. Is there a : way I can access these devices directly, at least in the first case, : issuing directly ATA/IDE commands to the hard disk? There's always ata_if.m... : In the case of PCI it would be even nicer to be able to communicate : with the pci driver... but if that's not possible, it's also ok if I : can access the PCI bus controller directly. The driver I'm writing is : not a PCI or PCI device driver either. : : Hope someone can help me out on this one, it's important that there's : no user-space code... Generally, you don't want to scan the PCI bus to look for drivers to talk to. That's bad kharma and likely begging to be abused. Having said that, I've had cooperative drivers in the kernel before. They usually look for each other and send messages to each other with kobj. It is better to look for "friend0" that you know can receive messages. kobj adds a layer of protection since it will gracefully give an error when you can't do it. Hey, wait, ata_if is kobj... You could likely expand it to allow queueing of commands and such. Warner