This article describes how a Define device method works. It also suggests guidelines for programmers writing their own Define device configuration methods.
defDev -c Class -s SubClass -t Type [ -p Parent -w Connection ] [ -l Name ]
The Define method is responsible for creating a customized device in the Customized database. It does this by adding an object for the device into the Customized Devices (CuDv) object class. The Define method is invoked either by the mkdev configuration command, by a node configuration program, or by the Configure method of a device that is detecting and defining child devices.
The Define method uses information supplied as input, as well as information in the Predefined database, for filling in the CuDv object. If the method is written to support a single device, it can ignore the class, subclass, and type options. In contrast, if the method supports multiple devices, it may need to use these options to obtain the PdDv device object for the type of device being customized.
By convention, the first three characters of the name of the Define method should be def. The remainder of the name (Dev) can be any characters that identify the device or group of devices that use the method, subject to operating system file-name restrictions.
-c Class | Specifies the class of the device being defined. Class, subclass, and type are required to identify the Predefined Device object in the Predefined Device (PdDv) object class for which a customized device instance is to be created. |
-s SubClass | Specifies the subclass of the device being defined. Class, subclass, and type are required to identify the Predefined Device object in the PdDv object class for which a customized device instance is to be created. |
-t Type | Specifies the type of the device being defined. Class, subclass, and type are required to identify the predefined device object in the PdDv object class for which a customized device instance is to be created. |
-p Parent | Specifies the logical name of the parent device. This logical name is required for devices that connect to a parent device. This option does not apply to devices that do not have parents; for example, most pseudo-devices. |
-w Connection | Specifies where the device connects to the parent. This option applies only to devices that connect to a parent device. |
-l Name | Passed by the mkdev command, specifies the name for the device if the user invoking the command is defining a new device and wants to select the name for the device. The Define method assigns this name as the logical name of the device in the Customized Devices (CuDv) object, if the name is not already in use. If this option is not specified, the Define method generates a name for the device. Not all devices support or need to support this option. |
This list of tasks is meant to serve as a guideline for writing a Define method. In writing a method for a specific device, some tasks may be omitted. For instance, if a device does not have a parent, there is no need to include all of the parent and connection validation tasks. Additionally, a device may have special needs that are not listed in these tasks.
#include <cf.h> if (odm_initialize() < 0) exit(E_ODMINIT); /* initialization failed */ if (odm_lock("/etc/objrepos/config_lock",0) == -1) { odm_terminate(); exit(E_ODMLOCK); /* database lock failed */ }
If the Define method is to generate a name, it can do so by obtaining the prefix name from the Prefix Name descriptor of the device's PdDv device object and invoking the genseq subroutine to obtain a unique sequence number for this prefix. Appending the sequence number to the prefix name results in a unique name. The genseq routine looks in the CuDv object class to ensure that it assigns a sequence number that has not been used with the specified prefix to form a device name.
In some cases, a Define method may need to ensure that only one device of a particular type has been defined. For example, there can only be one pty device customized in the CuDv object class. The pty Define method does this by querying the CuDv object class to see if a device by the name pty0 exists. If it does, the pty device has already been defined. Otherwise, the Define method proceeds to define the pty device using the name pty0.
Set the CuDv object descriptors as follows:
Device name | Use the name as determined in step 6. |
Device status flag | Set to the Defined state. |
Change status flag | Set to the same value as that found in the Change Status Flag descriptor in the device's PdDv object. |
Device driver instance | Set to the same value as the Device Driver Name descriptor in the device's PdDv object. This value may be used later by the Configure method. |
Device location code | Set to a null string if the device does not have a location code. Otherwise, set it to the value computed. |
Parent device logical name | Set to a null string if the device does not have a parent. Otherwise, set this descriptor to the parent name as specified by the parent option. |
Location where connected on parent device | Set to a null string if the device does not have a parent. Otherwise, set this descriptor to the value specified by the connection option. |
Link to predefined devices object class | Set to the value obtained from the Unique Type descriptor of the device's PdDv object. |
ODM Device Configuration Object Classes.
The mkdev command.
The genseq device configuration subroutine, odm_initialize subroutine, odm_lock subroutine.
Writing an Undefine Method , Writing a Configure Method .
Customized Devices (CuDv) object class, Predefined Devices Writing_DefineMethod.htm object class, Predefined Connection object class, Predefined Attribute (PdAt) object class, Customized Attribute (CuAt) object class.
Understanding Device States, Understanding Device Classes, Subclasses, and Types, Understanding Device Dependencies and Child Devices, Loading A Device Driver Configuration Manager Overview, Understanding System Boot Processing, Writing a Device Method in AIX Version 4.3 Kernel Extensions and Device Support Programming Concepts.
Object Data Manager (ODM) Overview for Programmers in AIX Version 4.3 General Programming Concepts: Writing and Debugging Programs.
Location Codes in AIX Version 4.3 System Management Concepts: Operating System and Devices.