1.2.3 Declaring and Initializing the driver Data Structure

The following code shows how the if_el device driver declares and initializes the driver data structure with the names of its entry points:

static struct driver eldriver = { el_probe,

0,

el_attach, 0, 0, 0, 0, 0,

"el", el_info, 0, 0, 0, 0, 0,

el_unattach, 0

};

1

1

Declares and initializes the driver data structure called eldriver. Because a network device driver does not have exposure to the file system, it does not provide open, close, read, write, and strategy interfaces. The members of the driver data structure that specify these entry points are initialized to 0 (zero).

The if_el driver initializes the following members to nonzero values:

probe, which specifies the driver’s probe interface, el_probe

cattach, which specifies the driver’s controller attach interface, el_attach

ctlr_name, which specifies the controller name, el

ctlr_list, which specifies a pointer to the array of pointers to controller data structures, el_info

ctlr_unattach, which specifies the driver’s controller unattach interface, el_unattach

1.2.4 Defining Driver-Specific Macros

To help you write more portable device drivers, Tru64 UNIX provides the following kernel routines, which allow you to read from and write to a control status register (CSR) address without directly accessing its device registers. These macros call the read_io_port( ) or write_io_port( ) generic routines.

Network Device Driver Environment 1–7

Page 25
Image 25
Compaq AA-RNG2A-TE manual Declaring and Initializing the driver Data Structure, Defining Driver-Specific Macros