This article describes how an Unconfigure device method works. It also suggests guidelines for programmers writing their own Unconfigure device configuration method.
The Unconfigure method takes an Available device (available for use in the system) to a Defined state (not available for use in the system). All the customized information about the device is retained in the database so that the device can be configured again exactly as it was before.
The actual operations required to make a device defined depend on how the Configure method made the device available in the first place. For example, if the device has a device driver, the Configure method must have loaded a device driver in the kernel and described the device to the driver through a device dependent structure (DDS). Then, the Unconfigure method must tell the driver to delete the device instance and request an unload of the driver.
If the device is an intermediate device, the Unconfigure method must check the states of the child devices. If any child device is in the Available state, the Unconfigure method fails and leaves the device configured. To ensure proper system operation, all child devices must be unconfigured before the parent can be unconfigured.
Although the Unconfigure method checks child devices, it does not check the device dependencies recorded in the Customized Dependency (CuDep) object class. See "Understanding Device Dependencies and Child Devices" in AIX Kernel Extensions and Device Support Programming Concepts.
The Unconfigure method also fails if the device is currently open. In this case, the device driver returns a value for the errno global variable of EBUSY to the Unconfigure method when the method requests the driver to delete the device. The device driver is the only component at that instant that knows the device is open. As in the case of configured child devices, the Unconfigure method fails and leaves the device configured.
When requesting the device driver to terminate the device, the errno global variable values other than EBUSY can be returned. The driver should return ENODEV if it does not know about the device. Under the best circumstances, however, this case should not occur. If ENODEV is returned, the Unconfigure method should unconfigure the device so that the database and device driver are in agreement. If the device driver returns any other errno global value, it deletes any stored characteristics for the specified device instance. The Unconfigure method indicates that the device is unconfigured by setting the state to Defined.
The Unconfigure method does not generally release the major and minor number assignments for a device, or delete the device's special files in the /dev directory.
By convention, the first four characters of the name of the Unconfigure method should be ucfg. The remainder of the name (Dev) can be any characters, subject to operating system file-name restrictions, that identify the device or group of devices that use the method.
|-l Name||Identifies the logical name of the device to be unconfigured.|
This list of tasks is intended as a guideline for writing an Unconfigure method. When you write a method for a specific device, some tasks may be omitted. For example, if a device is not an intermediate device or does not have a driver, the method can be written accordingly. The device may have special needs that are not listed in these tasks.
The Unconfigure method must:
If the device has a device driver, the Unconfigure method needs to include the following tasks:
|/usr/include/sysmacros.h||Contains macro definitions.|
Writing a Device Method Overview.
ODM Device Configuration Object Classes.
The mkdev command.
The genmajor subroutine, getminor subroutine, loadext subroutine, odm_initialize subroutine, odm_lock subroutine, sysconfig subroutine.
Writing a Configure Method, Loading A Device Driver, Writing a Define Method.
Customized Devices (CuDv) object class, Predefined Devices (PdDv) object class.
Object Data Manager (ODM) Overview for Programmers in AIX General Programming Concepts: Writing and Debugging Programs.
The Device Dependent Structure (DDS) Overview in AIX Kernel Extensions and Device Support Programming Concepts.
Understanding Device States, Understanding Device Dependencies and Child Devices, Loading a Device Driver in AIX Kernel Extensions and Device Support Programming Concepts.