Subject: Re: Driver development question
To: Steven Grunza <steven.grunza@dgms.com>
From: Bill Studenmund <wrstuden@nas.nasa.gov>
List: port-sparc
Date: 07/01/1999 14:58:24
On Thu, 1 Jul 1999, Steven Grunza wrote:

> I've gone through the following steps in order to create a 
> pseudo-device driver and now I'm stuck.  If any one has any ideas, I 
> would appreciate hearing them....
> 
> The driver is called testdata and is based on the test data 
> pseudo-driver from "Writing Unix Device Drivers" by George Pajari.
> 
> 
> Step 1)  Modified /sys/conf/files to add the following two lines:
> 
> pseudo-device td
> 
> file dev/testdata.c		td
> 
> 
> Step 2)  Modified /sys/arch/sparc/conf/{my_machine} to add the 
> following line:
> pseudo-device	td
> 
> Step 3)  Ran config {my_machine} in the /sys/arch/sparc/conf 
> directory
> 
> Step 4)  Added the following lines to the appropriate places in 
> /sys/arch/sparc/sparc/conf.c:
> 
> #include "td.h"
> 
> cdev_td_init(NTD,td),		/* 122: test data pseudo-device */

You also need a cdev_decl() too to prototype your routines.

> Step 5)  Added the following line to /sys/sys/conf.h:
> 
> #define cdev_td_init(c,n)       cdev__ocrwip_init(c,n)
> 
> 
> Step 6)  Created /sys/arch/sparc/compile/{my_machine}/td.h which 
> contains the following line:
> 
> #define NTD	0

NTD is the NUMBER of TD's. You want more than one defined.

If you look at /sys/sys/conf.h you'll see that cdev__ocrwip_int uses
dev_init. That in turn returns "0" if the number, NTD, is zero.

> Step 7)  Created a symlink from {my_directory}/testdata.c to 
> /sys/dev/testdata.c
> 
> Step 8)  Changed to the /sys/arch/sparc/compile/{my_machine} 
> directory and ran make >& make.log

Take care,

Bill