From owner-freebsd-hackers Thu May 24 10:47:20 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from peter3.wemm.org (c1315225-a.plstn1.sfba.home.com [65.0.135.147]) by hub.freebsd.org (Postfix) with ESMTP id E271137B42C for ; Thu, 24 May 2001 10:47:13 -0700 (PDT) (envelope-from peter@wemm.org) Received: from overcee.netplex.com.au (overcee.wemm.org [10.0.0.3]) by peter3.wemm.org (8.11.0/8.11.0) with ESMTP id f4OHlDM93081 for ; Thu, 24 May 2001 10:47:13 -0700 (PDT) (envelope-from peter@wemm.org) Received: from wemm.org (localhost [127.0.0.1]) by overcee.netplex.com.au (Postfix) with ESMTP id A9C03380C; Thu, 24 May 2001 10:47:13 -0700 (PDT) (envelope-from peter@wemm.org) X-Mailer: exmh version 2.3.1 01/18/2001 with nmh-1.0.4 To: SJ Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: Device driver questions In-Reply-To: <20010523003414.51600.qmail@web13405.mail.yahoo.com> Date: Thu, 24 May 2001 10:47:13 -0700 From: Peter Wemm Message-Id: <20010524174713.A9C03380C@overcee.netplex.com.au> Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG SJ wrote: > Hi all, > I am new to writing device drivers...so please excuse > my ignorance. > > I have a couple of questions regarding that: > > 1. "ioconf.c" contains struct config_resource and > config_device definitions for declarations in > "config" file. But I noticed that for some devices > e.g. device atadisk > device atapicd > ... > the corresponding lines in ioconf.c are missing?? Ignore ioconf.c. It is the old way of providing static driver info for things like the isa bus.. eg: what IO port to look for a device on. New isa drivers have all this pre-processed for them. There are only some special cases (eg: fd) that still use the resource_*() functions directly. > 2. Whats the use of device_ops structure and what does > "ops" stand for? Operations.. It is a list of functions or implementation methods that a device supports. > 3. File naming question: > whats the reasoning behind having "bus.h" and > "bus_private.h"....whats the significance of > "private" here. bus_private.h means you should ignore it. It exists only so that several different kernel files can share private information. Everything in there is 100% subject to change without notice. > 4. concept behind having devclasses...I know that > devclasses for a particular bus holds devices and > device drivers for that bus. But then whats the > need for defining a devclass for each driver we > write ? Devclasses keep track of unit numbers for drivers. It also allows you to get hold of another driver's device units by using it as a handle for devclass_get_device(). > 5. Any poniters to literature which explains the > design philosophy and code specific help for device > drivers in freebsd - I am referring to files > kern/subr_bus.c, bus.h, bus_private.h, isa/* etc. Paul Richards did an excellent primer on this stuff at BSDCon 2000. I wonder if the slides are around anywhere? Other than that, look at some drivers. Most of the drivers in sys/dev/* and sys/isa/* are newbus aware. Some are better examples than others though :-/. In a nutshell though, the new bus implementation is a dynamic, stackable, pseudo OO-like driver/bus framework. It is designed with the assumption that most present and future busses will be self identifying (eg: have device id's for devices). id's are discovered and offered to drivers in an auction-like fashion. Each node on the device/bus/whatever tree implements a set of methods (device_ops) that are expected by its parent and/or children. This means that a bus node expects its potential child drivers to implement the required set of device (probe/attach/etc) methods. The child drivers expect their parent to implement the expected set of methods to support that kind of driver (eg: bus_alloc_resource etc) This means that a given bus/driver pair are completely oblivious to how it is attached to the rest of the system.. eg: an isa bus can be on a pci->isa bridge or an old-style ISA-only system where the isa bus is at the root of the tree. The isa devices dont know (or care) that they may be sitting behind a PCI device on an Alpha that has a MMU-like device (scatter-gather map) that enables ISA devices there to access all 64bits of address space, not just the usual 24 bits of space. > thanks for your help, > SJ > > __________________________________________________ > Do You Yahoo!? > Yahoo! Auctions - buy the things you want at great prices > http://auctions.yahoo.com/ > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-hackers" in the body of the message > > Cheers, -Peter -- Peter Wemm - peter@FreeBSD.org; peter@yahoo-inc.com; peter@netplex.com.au "All of this is for nothing if we don't go to the stars" - JMS/B5 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message