From owner-freebsd-hackers@FreeBSD.ORG Tue Feb 24 07:29:03 2004 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 0B3B716A4CE for ; Tue, 24 Feb 2004 07:29:03 -0800 (PST) Received: from nexlab.it (danex.i-m-c.it [213.198.155.21]) by mx1.FreeBSD.org (Postfix) with SMTP id 0965843D1F for ; Tue, 24 Feb 2004 07:29:02 -0800 (PST) (envelope-from thefly@acaro.org) Received: (qmail 26556 invoked by uid 1220); 24 Feb 2004 15:29:00 -0000 Message-ID: <20040224152900.26555.qmail@nexlab.it> From: "Claudio Martella" To: freebsd-hackers@freebsd.org Date: Tue, 24 Feb 2004 16:29:00 +0100 Mime-Version: 1.0 Content-Type: text/plain; format=flowed; charset="utf-8" Content-Transfer-Encoding: 7bit X-Mailman-Approved-At: Wed, 25 Feb 2004 05:14:45 -0800 Subject: [Driver] SC1100 watchdog driver X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Feb 2004 15:29:03 -0000 I'm writing a driver for Geode SC1100's watchdog for FreeBSD-4.8. It's my frist device driver for this operating system and i've got one question: I'm willing to write the driver as a module: i wrote both struct cdevsw and struct device_method_t as struct driver_t. For the first i wrote just the d_ioctl, d_open and d_close, for the second i implemented the attach() and probe(). Through the DEV_MODULE() macro i defined the loading routine and used DRIVER_MODULE() macro to define the pci driver. My first doubt is if it's legal to use both of them in the same file/driver. Should i use just one of the two ways just the load routine and the ioctl/open/close routines, or the ioctl/open/close routines and the attach/probe routines? The problem exists because i don't know where to put my init stuff, the make_dev() calls etc etc, if in the loading routine, or in attach() or wherever? My second question is kindly connected to the first one. In my driver i've got to access some registers of the device through PCI. I find the bus_space_read|write routines & C really annoying. Isn't there an easy way to just read a double word from the register? And: As long as i don't know how initialization of my driver works (if through attach() or loading routine or whatever) i'm still confused on how to actually attach to the device: if it's through the attach() it's no problem, i've got the dev pointer, but if it's through the loading routing, do i have to do something like pci_find_device(vendor_id, device_id)? Thanks in advance Claudio Martella