VxWorks
Device Driver Developer's Guide, 6.7
In this table, the rtl8169VxbEnd driver declares that it supports three parameters, named rxQueue00, txQueue00, and jumboEnable. When the driver registers with
VxWorks, it provides a pointer to these parameters as part of its driver registration data structure. For example:
LOCAL struct vxbPciRegister rtgDevPciRegistration =
{
{
/* . */ rtgParamDefaults
/* . */
}
/* pParamDefaults */
};
Using this information, VxWorks stores the driver's default values for each of its parameters. Unless the parameters are changed by the BSP or application, the default driver values are the values that are returned when the driver calls
vxbInstParamByNameGet( )
.
There are two methods that can be used to override the default value of a parameter for a driver:
■
The BSP can provide a different default value in its hwconf.c file. or
■
A call can be made to vxbInstParamSet( ), to change the value of the parameter at runtime.
When the BSP provides a different default value for a parameter, the BSP default value replaces the driver-provided value for the parameter. This replacement occurs as soon as the driver registers with VxWorks, therefore there is no period of time where the driver default can be returned using vxbInstParamByNameGet( ).
In addition to the BSP override method, the default value of a parameter can also be changed at runtime through a call to vxbInstParamSet( ). vxbInstParamSet( ) can be used to modify the default values for a driver parameter.
For complete information on vxbInstParamByNameGet( ) and
vxbInstParamSet( )
, see the reference entries for these routines.
Responding to Changes in Device Parameters
When a call is made to vxbInstParamSet( ), the parameter value for a driver is altered. However, unless special steps are taken by the device driver, the updated value may not be noticed by the driver. For example, consider the following steps:
56
3 Device Driver Fundamentals
3.6 Services Available to Drivers
1.
The driver registers with VxWorks, its default parameter values are stored by
VxWorks.
2.
The driver is bound to a device, creating a hardware instance. The driver uses the stored values for its parameters to configure the instance.
3.
An application calls vxbInstParamSet( ) to change the parameters used by the driver. However, because the driver is already initialized when
vxbInstParamSet( )
occurs, the call to vxbInstParamSet( ) has no effect within the driver.
To address this scenario, device drivers are given the option to be informed of any changes to their parameter list that occur through a call to vxbInstParamSet( ).
VxWorks provides a special driver method that can be implemented for any device driver that needs to monitor changes to its parameter list. To implement this method in your driver, the driver must publish the {instParamModify}( ) driver method. If the driver publishes this method, the method's callback function is invoked whenever a change occurs to the driver parameters.
Support for the {instParamModify}( ) method is optional, and is not required for most drivers. In practice, driver parameters are generally expected to be overridden by the BSP hwconf.c file, rather than at runtime.
3.6.2 Memory Allocation
When a VxBus model device driver is connected to a device to form an instance, the driver typically stores information about this instance in a memory-resident data structure. This data structure can be declared statically within the driver source file, or the driver can allocate the structure dynamically at runtime using one of the available memory allocation libraries offered by VxWorks. For example, a simple driver might declare the following data structure to allocate memory for its data structures:
LOCAL simpleDriver_t simpleDriverInstanceStore[MAX_INSTANCES];
While a driver can use this method to reserve the memory for its instance data, this method is not recommended for two reasons:
■
■
The number of simultaneous instances that the driver can support is artificially restricted.
When the driver is used less than the maximum number of instances, the memory for the unused instances is wasted.
57