Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 8 Oct 2002 07:34:12 -0700
From:      "David Christensen" <dchrist@cox.net>
To:        <arch@FreeBSD.ORG>
Subject:   Device Driver Overview
Message-ID:  <B1154A80CE56844B9EA4F77FAD2BA951F5B7@hobbes.drc.dhs.org>

next in thread | raw e-mail | index | archive | help
I'm new to FreeBSD and I'm porting a disk controller over from Linux.
So far the module is loading and the controller is being initialized, so
the next step is adding drives.  

I can't seem to find a good overview of how the device driver is
supposed to be structured so I'm piecing one together to get a feel on
how things are supposed to work (I've been looking at the 3Ware IDE RAID
controller as an example under sys/twe on FreeBSD 4.6-RELEASE).  Here's
what I understand so far:

1) Load the kernel module
2) The kernel will call the device_probe method for the controller (as
defined in the device_method_t table) for any unattached devices on the
parent bus (PCI in this case) looking for a match.
3) If the device_probe returns true, the controller's device_attach
method is called, which sets up the device (claiming resources,
initializing data structures, etc).
4) During the controller's device_attach method, if any drives are
found, they added into the system through calls to device_add_child(),
device_set_ivars(), and bus_generic_attach().
5) The newly created disks generate a call to the drive's device_probe
method.
6) If the drive's device_probe returns true (which it always does for
the 3Ware controller), the drive's device_attach module is called, which
adds the drive through calls to devstat_add_entry, and disk_create().

Assuming the above is correct (if I'm missing something or I've got
anything wrong I'd appreciate hearing about it), a couple of questions
come to mind.  

1) After completing step 6, is the disk usable (accessible through its
device node)? 
2) In the cdevsw structure for the drives, what do the physread and
physwrite entries mean?
3) How do actual read/write requests make it to the device driver?


David Christensen



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?B1154A80CE56844B9EA4F77FAD2BA951F5B7>