Help-Site Computer Manuals
Software
Hardware
Programming
Networking
  Algorithms & Data Structures   Programming Languages   Revision Control
  Protocols
  Cameras   Computers   Displays   Keyboards & Mice   Motherboards   Networking   Printers & Scanners   Storage
  Windows   Linux & Unix   Mac

Solaris::DeviceTree::Libdevinfo
Perl interface to the Solaris devinfo library

Solaris::DeviceTree::Libdevinfo - Perl interface to the Solaris devinfo library



NAME

Solaris::DeviceTree::Libdevinfo - Perl interface to the Solaris devinfo library


SYNOPSIS

Construction and destruction:


  use Solaris::DeviceTree::Libdevinfo;

  $tree = Solaris::DeviceTree::Libdevinfo->new;

Data access methods:


  $path = $node->devfs_path;

  $nodename = $node->node_name;

  $bindingname = $node->binding_name;

  $busaddr = $node->bus_addr;

  @cnames = $devtree->compatible_names;

  $drivername = $devtree->driver_name;

  %ops = $devtree->driver_ops;

  $inst = $node->instance;

  %state = $node->state;

  $id = $node->nodeid;

  if( $node->is_pseudo_node ) { ... }

  if( $node->is_sid_node ) { ... }

  if( $node->is_prom_node ) { ... }

  $props = $node->props;

  $promprops = $node->prom_props;

  @minor = $node->minor_nodes;


DESCRIPTION

This module implements the the Solaris::DeviceTree::Node manpage interface and allows access to the Solaris devinfo library libdevinfo(3lib). The devicetree is represented as a hierarchical collection of nodes in the kernel.

The implementation closely resembles the API of the C library. However, due to the object interface and the beauty of Perl there a few differences to keep in mind when using this library after reading the manual pages of the original libdevinfo(3lib):

  • The 'di_'-prefix of the function names from the C API has been stripped.

  • The functions di_init and di_fini for generation and destruction of devicetrees are now called implicitly during contruction and destruction repectively.

  • Accessing the nodes by driver via di_drv_first_node and di_drv_next_node is not implemented in favor of the much more expressive find_nodes added in Perl.

  • The function di_walk_node is not implemented because treewalking in Perl using child_nodes is much easier than in C and is therefore not needed.

  • Getting child nodes via subsequent calls to di_child_node has been simplified to a single call to child_nodes returning an array of all child nodes.

  • Access to di_devid is currently not implemented as the returned value is meaningless without access to libdevid(3lib), which I have not done (yet). Requests welcome.


     di_binding_name               di_bus_addr

     di_child_node                 di_compatible_names

     di_devfs_path                 di_devfs_path_free

     di_devid                      di_driver_name

     di_driver_ops                 di_drv_first_node

     di_drv_next_node              di_fini

     di_init                       di_instance

     di_minor_class                di_minor_devt

     di_minor_name                 di_minor_next

     di_minor_nodetype             di_minor_spectype

     di_minor_type                 di_node_name

     di_nodeid                     di_parent_node

     di_prom_fini                  di_prom_init

     di_prom_prop_data             di_prom_prop_lookup_bytes

     di_prom_prop_lookup_ints      di_prom_prop_lookup_strings

     di_prom_prop_name             di_prom_prop_next

     di_prop_bytes                 di_prop_devt

     di_prop_ints                  di_prop_lookup_bytes

     di_prop_lookup_ints           di_prop_lookup_strings

     di_prop_name                  di_prop_next

     di_prop_strings               di_prop_type

     di_sibling_node               di_state

     di_walk_minor                 di_walk_node


METHODS

For tree traversal methods see the base class the Solaris::DeviceTree::Node manpage.

The following methods are available:

new

The constructor returns a reference to the root node object, which is a the Solaris::DeviceTree::Libdevinfo manpage object. The methods are all read-only.

devfs_path

Returns the physical path assocatiated with this node.

node_name

Returns the name of the node.

binding_name

Returns the binding name for this node. The binding name is the name used by the system to select a driver for the device.

bus_addr

Returns the address on the bus for this node. undef is returned if a bus address has not been assigned to the device. A zero-length string may be returned and is considered a valid bus address.

compatible_names

Returns the list of names from compatible device for the current node. See the discussion of generic names in Writing Device Drivers for a description of how compatible names are used by Solaris to achieve driver binding for the node.

driver_name

Returns the name of the driver for the node or undef if the node is not bound to any driver.

driver_ops

Returns a hash whos keys indicate, which entry points of the device driver entry points are supported by the driver bound to this node. Possible keys are:


  BUS

  CB

  STREAM

instance

Returns the instance number for this node of the bound driver. undef is returned if no instance number has been assigned.

state

Returns the driver state attached to this node as hash. The presence of the keys in the hash represent the states of the driver. The following keys in the hash can be present:


  DRIVER_DETACHED

  DEVICE_OFFLINE

  DEVICE_DOWN

  BUS_QUIESCED

  BUS_DOWN

nodeid

Returns the type of the node. Three different strings identifying the types can be returned or undef if the type is unknown:


  PSEUDO

  SID

  PROM

Nodes of the type PROM may have additional PROM properties that are defined by the PROM. The properties can be accessed with prom_props.

is_pseudo_node =head2 is_sid_node =head2 is_prom_node

Returns true if the node is of type pseudo / SID / PROM or undef if not.

props

Returns a reference to a hash which maps property names to property values. The property values are of class the Solaris::DeviceTree::Libdevinfo::Property manpage.

prom_props

Returns a reference to a hash which maps PROM property names to property values. The property values are of class the Solaris::DeviceTree::Libdevinfo::PromProperty manpage. If the PROM device can not be opened (most likely because the process does not have the permission to access /dev/openprom) then undef is returned.

minor_nodes

Returns a reference to a list of all minor nodes which are associated with this node. The minor nodes are of class the Solaris::DeviceTree::Libdevinfo::MinorNode manpage.


AUTHOR

Copyright 1999-2003 Dagobert Michelsen.


SEE ALSO

libdevinfo(3devinfo), libdevinfo(3lib), the Solaris::DeviceTree::Libdevinfo::MinorNode manpage, the Solaris::DeviceTree::Libdevinfo::Property manpage, the Solaris::DeviceTree::Libdevinfo::PromProperty manpage.

Programminig
Wy
Wy
yW
Wy
Programming
Wy
Wy
Wy
Wy