Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 24 Feb 2004 16:29:00 +0100
From:      "Claudio Martella" <thefly@acaro.org>
To:        freebsd-hackers@freebsd.org
Subject:   [Driver] SC1100 watchdog driver
Message-ID:  <20040224152900.26555.qmail@nexlab.it>

next in thread | raw e-mail | index | archive | help
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 



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