[Return to Library]  [TOC]  [PREV]  SECT--  [NEXT]  [INDEX] [Help]

4    Data Structures That VMEbus Device Drivers Use

Data structures are the mechanism used to pass information between the Digital UNIX kernel and device driver interfaces. VMEbus device driver writers must understand the data structures described in Writing Device Drivers: Tutorial, particularly the members of the controller and driver structures that are specific to the VMEbus, and the VMEbus-specific bus configuration structure VBA_Option. The following sections describe the controller, driver, and VBA_Option structures.


[Return to Library]  [TOC]  [PREV]  SECT--  [NEXT]  [INDEX] [Help]

4.1    The controller Structure Members Specific to the VMEbus

The controller structure represents an instance of a controller entity, one that connects logically to a bus. A controller can control devices that are directly connected or can perform some other controlling operation, such as a network interface or terminal controller operation. Table 4-1 lists the members of the controller structure specific to the VMEbus and their associated data types.


Table 4-1: Members of the controller Structure Specific to the VMEbus
Member NameData Type
bus_priority  int 
ivnum  int 
priority  int 

The bus_priority member represents the configured VMEbus priority level of the device. You (or the system manager) can specify the bus priority by using the VBA_Option entry in the /etc/sysconfigtab file or a sysconfigtab file fragment. (Section 4.3 describes the VBA_Option entry.) The autoconfiguration software initializes the bus_priority member of the controller structure with the value specified for the Bus_Priority field of VBA_Option. For example, the autoconfiguration software initializes the bus_priority member to the value 3, based on the following entry in /etc/sysconfigtab:

VBA_Option = ..., Vector - 0xc8, Bus_Priority - 3, ...

The ivnum member represents an interrupt vector number, which is initialized based on the Vector field of VBA_Option. Given the example VBA_Option line above, the autoconfiguration software initializes the ivnum member to the value 0xc8.

The priority member represents the system priority level (SPL) of the last interrupt handler installed using the handler_add interface. (SPL values can be specified in calls to the splx interface to block interrupts for a device.)


[Return to Library]  [TOC]  [PREV]  --SECT  SECT--  [NEXT]  [INDEX] [Help]

4.2    The driver Structure Members Specific to the VMEbus

The driver structure defines driver entry points and other driver-specific information. You declare and initialize an instance of this structure in the declarations section of the device driver. The bus configuration code uses the entry points defined in this structure during device autoconfiguration. The bus configuration code fills in the dev_list and ctlr_list arrays. The driver interfaces use these arrays (members of the device and controller structures) to get the structures for specific devices or controllers.

Table 4-2 lists the members of the driver structure specific to the VMEbus and their associated data types.


Table 4-2: Members of the driver Structure Specific to the VMEbus
Member NameData Type
addr1_size  int 
addr1_atype  int 
addr2_size  int 
addr2_atype  int 

The addr1_size member specifies the size (in bytes) of the first CSR area. This area is usually the control status register of the device. The addr1_atype member specifies the address space, access mode, transfer size, and swap mode of the first CSR area. Note that not all bus adapters use the transfer size.

The addr2_size member specifies the size (in bytes) of the second CSR area. This area is usually the data area that the system uses with devices that have two separate CSR areas. The addr2_atype member specifies the address space, access mode, transfer size, and swap mode of the second CSR area. Note that not all bus adapters use the transfer size.

You can set the addr1_atype and addr2_atype members to the bitwise inclusive OR of the valid bits described in Table 4-3. The /usr/sys/include/io/dec/vme/vbareg.h file defines these and other VMEbus-related bits.


Table 4-3: Bit Descriptions for addr1_atype and addr2_atype Members
Bit CategoryValueMeaning
Swap mode bits  VME_BS_NOSWAP  Specifies no byte swapping. 
  VME_BS_BYTE  Specifies byte swapping in bytes. 
  VME_BS_WORD  Specifies byte swapping in words. 
  VME_BS_LWORD  Specifies byte swapping in longwords. 
  VME_BS_QUAD  Specifies byte swapping in quadwords. 
Address space bits  VME_A16  Specifies a request for the 16-bit address space. 
  VME_A24  Specifies a request for the 24-bit address space. 
  VME_A32  Specifies a request for the 32-bit address space. 
  VME_A64  Specifies a request for the 64-bit address space. 
Transfer size bits  VME_D08  Specifies a request for the 8-bit data size. 
  VME_D16  Specifies a request for the 16-bit data size. 
  VME_D32  Specifies a request for the 32-bit data size. 
Access mode bits  VME_UDATA  Specifies user data. 
  VME_UPROG  Specifies a user program. 
  VME_SDATA  Specifies supervisory data. 
  VME_SPROG  Specifies a supervisory program. 
CPU allocation space bits    Depending on VMEbus adapter implementation, this bit may not be applicable. To specify dense space on a platform for which the default CPU allocation space is sparse, you use the VME_DENSE bit. 


[Return to Library]  [TOC]  [PREV]  --SECT  SECT--  [NEXT]  [INDEX] [Help]

4.3    The VBA_Option VMEbus Configuration Structure

The major VMEbus-specific component of the device driver configuration process described in the tutorial is the requirement to supply VMEbus configuration information in the /etc/sysconfigtab file or a /sysconfigtab file fragment. You do this by specifying a VBA_Option entry that describes the driver and its VMEbus configuration.

The VBA_Option entry you place in the /etc/sysconfigtab file or a sysconfigtab file fragment has the following general form:

VBA_Option = Manufact_Name - 'XXXXXXXX',
             Product_Name - 'XXXXXXXX',
             Bus_Instance - n,
             Driver_Name - xx,
             Driver_Instance - n,
             Csr1 - n, Csr2 - n,
             Vector - 0xnnnn, Bus_Priority - n,
             Type - C, Adpt_Config - N
You supply the VBA_Option information on a contiguous line with no newline characters inserted. (Line breaks were added above for clarity.)

The data following the dash (-) is the data for the specified field. The comma (,) separates the fields within VBA_Option. ASCII data fields are enclosed in single quotes (').

Table 4-4 describes in detail the fields that make up a VBA_Option entry.


Table 4-4: VBA_Option Fields
FieldUse and Restrictions
Manufact_Name  Specify a manufacturer name, up to 31 characters. Enclose the name in single quotes ('). 
Product_Name  Specify a product name, up to 31 characters, describing the product that the device driver is supporting. Enclose the name in single quotes ('). 
Bus_Instance  Specify the number of the vba bus on which this device driver is being installed. In most cases the Bus_Instance will be specified as zero. If the system consists of multiple VME buses, specify the appropriate bus instance, that is, 0, 1, 2, and so on. The bus numbers are associated with the physical order in which vba buses are detected. 
Driver_Name  Specify a device driver name, up to 15 characters. Enclose the name in single quotes ('). The Driver_Name must match the subsystem name used in the Version 4.0 single binary module interface create_controller_struct or the driver name specified in the configuration file fragment in previous versions of Digital UNIX. 
Driver_Instance  Specify the instance of the hardware device for which this device driver is being installed. If this is the first instance, specify 0. This value is used to match against the controller number assigned in the Version 4.0 single binary module when a controller structure is created, or the controller number specified in the configuration file in previous versions of Digital UNIX. You can install the same device driver multiple times to control different VMEbus device options of the same type. Typically, the only differences are the VMEbus device register addresses, interrupt vector, and possibly the interrupt request level. 
Csr1  Specify a VMEbus device register or memory address to map into CPU I/O space. A nonzero value in this field and the device driver's driver structure members addr1_size and addr1_atype will cause the autoconfiguration software to map the specified VMEbus address space into system I/O space. The controller structure member addr receives the resultant io_handle_t address. This value is passed to the device driver's probe interface. 
Csr2  Specify an optional VMEbus device register or memory address to map into CPU I/O space. A nonzero value in this field and the device driver's driver structure members addr2_size and addr2_atype will cause the autoconfiguration software to map the specified VMEbus address space into system I/O space. The controller structure member addr2 receives the resultant io_handle_t address. This value is not passed to the device driver's probe interface, but is available in the controller structure. 
Vector  Specify a VMEbus interrupt vector at which interrupts from the device interrupt the processor. This value is passed to the device driver in the ivnum member of the controller structure. The device driver's probe interface uses this value plus the VMEbus interrupt request level obtained in the next entry to add and enable VMEbus interrupt handlers via handler_add and handler_enable interfaces. 
Bus_Priority  Specify a VMEbus interrupt request level at which the device will present its hardware interrupt request. This value is passed to the device driver in the bus_priority member of the controller structure. The device driver's probe interface uses this interrupt request level and the specified vector to add and enable VMEbus interrupt handlers via handler_add and handler_enable interfaces. 
Type  Specify the character C to indicate the entry is for a controller. 
Adpt_Config  Specify the character N. This entry will be used in a future release of Digital UNIX. 


[Return to Library]  [TOC]  [PREV]  --SECT  SECT--  [NEXT]  [INDEX] [Help]

4.3.1    Example: dmaex Driver Configuration

The following VBA_Option entry is included in the /etc/sysconfigtab file or a sysconfigtab file fragment to provide VMEbus configuration information for the /dev/dmaex example driver used in this manual. (Line breaks have been added for clarity.)
VBA_Option = Manufact_Name - 'Digital', Product_Name - 'DMAEX Driver',
             Bus_Instance - 0, Driver_Name - dmaex, Driver_Instance - 0,
             Csr1 - 0x00800000, Csr2 - 0x0, Vector - 0xF0,
             Bus_Priority - 1, Type - C, Adpt_Config - N
This entry indicates that the manufacturer is Digital and that the product is the DMAEX driver. The bus instance number is 0, indicating the driver is being installed on the first instance of the VMEbus, bus vba0. The driver name is dmaex. The driver instance is 0, indicating the driver is controlling the first instance of the hardware device, dmaex0.

The device driver requires the bus autoconfiguration code to map eight (8) bytes of VMEbus address at address 0x00800000 in A24 User Data Mode address space into CPU I/O space. You do this by specifying the address to Csr1, while also specifying values for addr1_size and addr1_atype in the driver's driver data structure. From this information, the bus configuration code creates a mapped I/O space address (I/O handle), which is passed to the driver's probe interface, dmaexprobe, and stored in the addr member of the driver's controller data structure. The driver then can use this I/O handle to access its device control and status registers.

No VMEbus-to-CPU I/O space mapping is required for a second address, so in this example zero (0) is specified for Csr2. Correspondingly, zero (0) would be specified for the addr2_size member in the driver's driver data structure.

The Vector and Bus_Priority parameters indicate that the driver needs to add and enable interrupt handlers to vector 0xF0 with a VMEbus interrupt request level of 1. The specified vector and bus priority are passed to the device driver in the controller structure members ivnum and bus_priority. The device driver then installs two interrupt handlers at 0xF0 and 0xF1.


[Return to Library]  [TOC]  [PREV]  --SECT  SECT--  [NEXT]  [INDEX] [Help]

4.3.2    Example: vb Driver Configuration

The following VBA_Option entry is included in the /etc/sysconfigtab file or a sysconfigtab file fragment to provide VMEbus configuration information for the VMEbus Backplane (vb) Network Driver supported by Digital UNIX. (Line breaks have been added for clarity.)
VBA_Option = Manufact_Name - 'Digital',
             Product_Name - 'VME Backplane Network Driver',
             Bus_Instance - 0, Driver_Name - vb, Driver_Instance - 0,
             Csr1 - 0, Csr2 - 0, Vector - 0x1150, Bus_Priority - 7,
             Type - C, Adpt_Config - N
This entry indicates that the manufacturer is Digital and that the product is the VMEbus Backplane Network Driver. The bus instance number is 0, indicating the driver is being installed on the first instance of the VMEbus, bus vba0. The driver name is vb. The driver instance is 0, indicating the driver is controlling the first instance of the hardware device, vb0.

The device driver requires no device register or memory mapping by the autoconfiguration software, so zero (0) is specified for Csr1 and Csr2.

The Vector and Bus_Priority parameters indicate that the driver needs to add and enable an interrupt handler to vector 0x1150 with a VMEbus interrupt request level of 7. The specified vector and bus priority are passed to the device driver in the controller structure members ivnum and bus_priority. The device driver then installs an interrupt handler at 0x1150.