|
|||
Part I Designing Device Drivers for the Solaris Platform 1. Overview of Solaris Device Drivers 2. Solaris Kernel and Device Tree 5. Managing Events and Queueing Tasks 7. Device Access: Programmed I/O 10. Mapping Device and Kernel Memory 14. Layered Driver Interface (LDI) Part II Designing Specific Kinds of Device Drivers 15. Drivers for Character Devices 18. SCSI Host Bus Adapter Drivers 19. Drivers for Network Devices Part III Building a Device Driver 21. Compiling, Loading, Packaging, and Testing Drivers 22. Debugging, Testing, and Tuning Device Drivers 23. Recommended Coding Practices B. Summary of Solaris DDI/DKI Services C. Making a Device Driver 64-Bit Ready |
User InterfacesThe LDI includes user-level library and command interfaces to report device layering and usage information. Device Information Library Interfaces discusses the libdevinfo(3LIB) interfaces for reporting device layering information. Print System Configuration Command Interfaces discusses the prtconf(1M) interfaces for reporting kernel device usage information. Device User Command Interfaces discusses the fuser(1M) interfaces for reporting device consumer information. Device Information Library InterfacesThe LDI includes libdevinfo(3LIB) interfaces that report a snapshot of device layering information. Device layering occurs when one device in the system is a consumer of another device in the system. Device layering information is reported only if both the consumer and the target are bound to a device node that is contained within the snapshot. Device layering information is reported by the libdevinfo(3LIB) interfaces as a directed graph. An lnode is an abstraction that represents a vertex in the graph and is bound to a device node. You can use libdevinfo(3LIB) interfaces to access properties of an lnode, such as the name and device number of the node. The edges in the graph are represented by a link. A link has a source lnode that represents the device consumer. A link also has a target lnode that represents the target device. The following describes the libdevinfo(3LIB) device layering information interfaces:
The device layering information returned by the LDI can be quite complex. Therefore, the LDI provides interfaces to help you traverse the device tree and the device usage graph. These interfaces enable the consumer of a device tree snapshot to associate custom data pointers with different structures within the snapshot. For example, as an application traverses lnodes, the application can update the custom pointer associated with each lnode to mark which lnodes already have been seen. The following describes the libdevinfo(3LIB) node and link marking interfaces:
Print System Configuration Command InterfacesThe prtconf(1M) command is enhanced to display kernel device usage information. The default prtconf(1M) output is not changed. Device usage information is displayed when you specify the verbose option (-v) with the prtconf(1M) command. Usage information about a particular device is displayed when you specify a path to that device on the prtconf(1M) command line.
Example 14-6 Device Usage InformationWhen you want usage information about a particular device, the value of the path parameter can be any valid device path. % prtconf /dev/cfg/c0 SUNW,isptwo, instance #0 Example 14-7 Ancestor Node Usage InformationTo display usage information about a particular device and all device nodes that are ancestors of that particular device, specify the -a flag with the prtconf(1M) command. Ancestors include all nodes up to the root of the device tree. If you specify the -a flag with the prtconf(1M) command, then you must also specify a device path name. % prtconf -a /dev/cfg/c0 SUNW,Sun-Fire ssm, instance #0 pci, instance #0 pci, instance #0 SUNW,isptwo, instance #0 Example 14-8 Child Node Usage InformationTo display usage information about a particular device and all device nodes that are children of that particular device, specify the -c flag with the prtconf(1M) command. If you specify the -c flag with the prtconf(1M) command, then you must also specify a device path name. % prtconf -c /dev/cfg/c0 SUNW,isptwo, instance #0 sd (driver not attached) st (driver not attached) sd, instance #1 sd, instance #0 sd, instance #6 st, instance #1 (driver not attached) st, instance #0 (driver not attached) st, instance #2 (driver not attached) st, instance #3 (driver not attached) st, instance #4 (driver not attached) st, instance #5 (driver not attached) st, instance #6 (driver not attached) ses, instance #0 (driver not attached) ... Example 14-9 Layering and Device Minor Node Information – KeyboardTo display device layering and device minor node information about a particular device, specify the -v flag with the prtconf(1M) command. % prtconf -v /dev/kbd conskbd, instance #0 System properties: ... Device Layered Over: mod=kb8042 dev=(101,0) dev_path=/isa/i8042@1,60/keyboard@0 Device Minor Nodes: dev=(103,0) dev_path=/pseudo/conskbd@0:kbd spectype=chr type=minor dev_link=/dev/kbd dev=(103,1) dev_path=/pseudo/conskbd@0:conskbd spectype=chr type=internal Device Minor Layered Under: mod=wc accesstype=chr dev_path=/pseudo/wc@0 This example shows that the /dev/kbd device is layered on top of the hardware keyboard device (/isa/i8042@1,60/keyboard@0). This example also shows that the /dev/kbd device has two device minor nodes. The first minor node has a /dev link that can be used to access the node. The second minor node is an internal node that is not accessible through the file system. The second minor node has been opened by the wc driver, which is the workstation console. Compare the output from this example to the output from Example 14-12. Example 14-10 Layering and Device Minor Node Information – Network DeviceThis example shows which devices are using the currently plumbed network device. % prtconf -v /dev/iprb0 pci1028,145, instance #0 Hardware properties: ... Interrupt Specifications: ... Device Minor Nodes: dev=(27,1) dev_path=/pci@0,0/pci8086,244e@1e/pci1028,145@c:iprb0 spectype=chr type=minor alias=/dev/iprb0 dev=(27,4098) dev_path=<clone> Device Minor Layered Under: mod=udp6 accesstype=chr dev_path=/pseudo/udp6@0 dev=(27,4097) dev_path=<clone> Device Minor Layered Under: mod=udp accesstype=chr dev_path=/pseudo/udp@0 dev=(27,4096) dev_path=<clone> Device Minor Layered Under: mod=udp accesstype=chr dev_path=/pseudo/udp@0 This example shows that the iprb0 device has been linked under udp and udp6. Notice that no paths are shown to the minor nodes that udp and udp6 are using. No paths are shown in this case because the minor nodes were created through clone opens of the iprb driver, and therefore there are no file system paths by which these nodes can be accessed. Compare the output from this example to the output from Example 14-11. Device User Command InterfacesThe fuser(1M) command is enhanced to display device usage information. The fuser(1M) command displays device usage information only if path represents a device minor node. The -d flag is valid for the fuser(1M) command only if you specify a path that represents a device minor node.
Kernel device consumers are reported in one of the following four formats. Kernel device consumers always are surrounded by square brackets ([]). [kernel_module_name] [kernel_module_name,dev_path=path] [kernel_module_name,dev=(major,minor)] [kernel_module_name,dev=(major,minor),dev_path=path] When the fuser(1M) command displays file or device users, the output consists of a process ID on stdout followed by a character on stderr. The character on stderr describes how the file or device is being used. All kernel consumer information is displayed to stderr. No kernel consumer information is displayed to stdout. If you do not use the -d flag, then the fuser(1M) command reports consumers of only the device minor node that is specified by path. If you use the -d flag, then the fuser(1M) command reports consumers of the device node that underlies the minor node specified by path. The following example illustrates the difference in report output in these two cases. Example 14-11 Consumers of Underlying Device NodesMost network devices clone their minor node when the device is opened. If you request device usage information for the clone minor node, the usage information might show that no process is using the device. If instead you request device usage information for the underlying device node, the usage information might show that a process is using the device. In this example, no device consumers are reported when only a device path is passed to the fuser(1M) command. When the -d flag is used, the output shows that the device is being accessed by udp and udp6. % fuser /dev/iprb0 /dev/iprb0: % fuser -d /dev/iprb0 /dev/iprb0: [udp,dev_path=/pseudo/udp@0] [udp6,dev_path=/pseudo/udp6@0] Compare the output from this example to the output from Example 14-10. Example 14-12 Consumer of the Keyboard DeviceIn this example, a kernel consumer is accessing /dev/kbd. The kernel consumer that is accessing the /dev/kbd device is the workstation console driver. % fuser -d /dev/kbd /dev/kbd: [genunix] [wc,dev_path=/pseudo/wc@0] Compare the output from this example to the output from Example 14-9. |
||
|