From owner-freebsd-arch Tue Oct 8 7:35:18 2002 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1382237B401 for ; Tue, 8 Oct 2002 07:35:17 -0700 (PDT) Received: from fed1mtao03.cox.net (fed1mtao03.cox.net [68.6.19.242]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8BD2543E65 for ; Tue, 8 Oct 2002 07:35:16 -0700 (PDT) (envelope-from dchrist@cox.net) Received: from linus ([68.4.176.221]) by fed1mtao03.cox.net (InterMail vM.5.01.04.05 201-253-122-122-105-20011231) with ESMTP id <20021008143514.BUES12156.fed1mtao03.cox.net@linus> for ; Tue, 8 Oct 2002 10:35:14 -0400 From: "David Christensen" To: Subject: Device Driver Overview Date: Tue, 8 Oct 2002 07:34:12 -0700 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.4024 Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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