hwgraph.dev(D3X)
hwgraph.dev: hwgraph_block_device_add, hwgraph_char_device_add, hwgraph_chmod, device_info_set, device_info_get - create and use device vertex
As shipped in IRIX 6.5.30. Unchanged since IRIX 6.5.
NAME hwgraph.dev: hwgraph_block_device_add, hwgraph_char_device_add, hwgraph_chmod, device_info_set, device_info_get - create and use device vertex SYNOPSIS #include <sys/types.h> #include <sys/hwgraph.h> #include <sys/ddi.h> graph_error_t hwgraph_block_device_add(vertex_hdl_t from_vhdl, char *path, char *driver_prefix, vertex_hdl_t *vhdl_ptr); graph_error_t hwgraph_char_device_add(vertex_hdl_t from_vhdl, char *path, char *driver_prefix, vertex_hdl_t *vhdl_ptr); void device_info_set(vertex_hdl_t device, void *info); void * device_info_get(vertex_hdl_t device); void hwgraph_chmod(vertex_hdl_t vhdl, mode_t mode); Arguments device Vertex handle of a device vertex, typically one created by hwgraph_block_device_add() or hwgraph_char_device_add(). driver_prefix The device driver character string prefix of the device driver that is to manage the newly-created device. from_vhdl Vertex handle that is the connection point of the device to be described. Typically the vertex handle passed to the attach entry point of a device driver. mode A standard file protection mode as declared in sys/stat.h. path An edge name, or a sequence of edge names separated by slashes (which looks exactly like a relative pathname in the /hw filesystem). vhdl A vertex handle of a device in the hwgraph. vhdl_ptr A pointer to a field where a new vertex handle is returned. DESCRIPTION The device_add functions operate on the hardware graph to add a new vertex that represents a block or a char device. The new vertex is visible in /hw as a character or block device special file. The device is controlled by the device driver that is identified by prefix, so that prefix_open() is called when the new vertex is opened. When it is opened, the dev_t passed to the driver's open entry point matches the vertex_hdl_t returned in vhdl_ptr. The device_info_set() function associates a pointer-sized piece of information with a specified dev_t for later retrieval by device_info_get(). Typically, this information is a pointer to a per- device data structure allocated by the driver in its attach entry point. Caution: A device driver should never change the device-info of any vertex that the device driver did not create. In particular, the vertex that is passed to the attach() entry point of a PCI driver is owned by the PCI infrastructure. If the driver sets the device-info of that connection-point vertex, the PCI infrastructure is likely to crash. A driver is always free to change the device-info of a vertex that the driver itself creates using the device_add functions. hwgraph_chmod() sets the initial (default) access mode of the /hw representation of the specified vertex. DIAGNOSTICS The *_device_add functions return GRAPH_SUCCESS when the operation completes successfully, or a failure code as listed in hwgraph(D3X) when the operation does not complete successfully. device_info_set() always succeeds and has no return value. It is the caller's responsibility to pass a valid device; that is, a dev_t that represents a vertex in the hardware graph. device_info_get() returns the pointer-sized piece of information associated with the specified device. This value is unpredictable until device_info_set() has been called. SEE ALSO hwgraph.inv(D3X), hwgraph.intro(D4X).