DDI_CREATE_MINOR_NODE(9F) | Kernel Functions for Drivers | DDI_CREATE_MINOR_NODE(9F) |
ddi_create_minor_node - Create a minor node for this device
#include <sys/stat.h> #include <sys/sunddi.h> int ddi_create_minor_node(dev_info_t *dip, const char *name,
int spec_type, minor_t minor_num, const char *node_type,
int flag);
illumos DDI specific (illumos DDI).
dip
name
spec_type
minor_num
node_type
DDI_NT_SERIAL
DDI_NT_SERIAL_MB
DDI_NT_SERIAL_DO
DDI_NT_SERIAL_MB_DO
DDI_NT_BLOCK
DDI_NT_BLOCK_CHAN
DDI_NT_CD
DDI_NT_CD_CHAN
DDI_NT_FD
DDI_NT_TAPE
DDI_NT_NET
DDI_NT_DISPLAY
DDI_PSEUDO
flag
ddi_create_minor_node() provides the necessary information to enable the system to create the /dev and /devices hierarchies. The name is used to create the minor name of the block or character special file under the /devices hierarchy. At-sign (@), slash (/), and space are not allowed. The spec_type specifies whether this is a block or character device. The minor_num is the minor number for the device. The node_type is used to create the names in the /dev hierarchy that refers to the names in the /devices hierarchy. See disks(8), ports(8), tapes(8), devlinks(8). Finally flag determines if this is a clone device or not, and what device class the node belongs to.
ddi_create_minor_node() returns:
DDI_SUCCESS
DDI_FAILURE
The ddi_create_minor_node() function can be called from user context. It is typically called from attach(9E) or ioctl(9E).
Example 1 Create Data Structure Describing Minor Device with Minor Number of 0
The following example creates a data structure describing a minor device called foo which has a minor number of 0. It is of type DDI_NT_BLOCK (a block device) and it is not a clone device.
ddi_create_minor_node(dip, "foo", S_IFBLK, 0, DDI_NT_BLOCK, 0);
add_drv(8), devlinks(8), disks(8), drvconfig(8), ports(8), tapes(8), attach(9E), ddi_remove_minor_node(9F)
Writing Device Drivers
If the driver is for a network device (node_type DDI_NT_NET), note that the driver name will undergo the driver name constraints identified in the NOTES section of dlpi(4P). Additionally, the minor name must match the driver name for a DLPI style 2 provider. If the driver is a DLPI style 1 provider, the minor name must also match the driver name with the exception that the ppa is appended to the minor name.
Non-gld(4D)-based DLPI network streams drivers are encouraged to switch to gld(4D). Failing this, a driver that creates DLPI style-2 minor nodes must specify CLONE_DEV for its style-2 ddi_create_minor_node() nodes and use qassociate(9F). A driver that supports both style-1 and style-2 minor nodes should return DDI_FAILURE for DDI_INFO_DEVT2INSTANCE and DDI_INFO_DEVT2DEVINFO getinfo(9E) calls to style-2 minor nodes. (The correct association is already established by qassociate(9F)). A driver that only supports style-2 minor nodes can use ddi_no_info(9F) for its getinfo(9E) implementation. For drivers that do not follow these rules, the results of a modunload(8) of the driver or a cfgadm(8) remove of hardware controlled by the driver are undefined.
Drivers must remove references to GLOBAL_DEV, NODEBOUND_DEV, NODESPECIFIC_DEV, and ENUMERATED_DEV to compile.
May 1, 2020 | OmniOS |