2 .\" This file and its contents are supplied under the terms of the
3 .\" Common Development and Distribution License ("CDDL"), version 1.0.
4 .\" You may only use this file in accordance with the terms of version
7 .\" A full copy of the text of the CDDL should have accompanied this
8 .\" source. A copy of the CDDL is also available via the Internet at
9 .\" http://www.illumos.org/license/CDDL.
12 .\" Copyright 2016 Joyent, Inc.
15 .Dt USBA_HCDI_CB_OPS 9E
18 .Nm usba_hcdi_cb_ops ,
19 .Nm usba_hcdi_cb_open ,
20 .Nm usba_hcdi_cb_ioctl ,
21 .Nm usba_hcdi_cb_close
22 .Nd USBA HCD Character Device character functions
56 illumos USB HCD private function
58 This describes private interfaces that are not part of the stable DDI.
59 This may be removed or changed at any time.
61 For parameter descriptions, see
67 The entry points listed here are the traditional character device
72 entry points. As discussed in
74 all HCD drivers are required to implement these functions and vector
76 .Xr usba_hubdi_open 9F ,
77 .Xr usba_hubdi_ioctl 9F ,
79 .Xr usba_hubdi_close 9F
80 respectively. For background information on these functions and how they
81 interact in the broader operating system, please see the general manual pages
87 The arguments between the two types of functions are slightly different.
90 section provides a sketch for how most HCD drivers should perform those
93 One important distinction from the traditional character routines is
94 that the USBA controls a bit more of the minor space. Therefore, the
95 driver needs to take extra care around the values encoded in the
97 and it should not perform any cloning or renumbering in its
101 The following example is adapated from the
103 driver which shows how an HCD driver might arrange things. This assumes
104 that a driver is following the recommendations in
106 and has initialized a soft state structure through the
107 .Xr ddi_soft_state_init 9F
108 function. This design also requires that the soft state structure
109 contains a pointer to the
112 .Xr attach 9E callback.
114 This example does not stand alone, it will need to be adapted for a
117 #include <sys/types.h>
118 #include <sys/file.h>
119 #include <sys/errno.h>
120 #include <sys/open.h>
121 #include <sys/cred.h>
123 #include <sys/sunddi.h>
125 static void *prefix_soft_state;
128 * Per-instance structure
130 typedef struct prefix {
131 dev_info_t *prefix_dev_info;
136 prefix_get_dip(dev_t dev)
139 int instance = getminor(dev) & ~HUBD_IS_ROOT_HUB;
141 p = ddi_get_soft_state(prefix_soft_state, instance);
143 return (p->prefix_dip);
148 prefix_open(dev_t *devp, int flags, int otyp, cred_t *credp)
150 dev_info_t *dip = prefix_get_dip(*devp);
152 return (usba_hubdi_open(dip, devp, flags, otyp, credp));
156 prefix_ioctl(dev_t dev, int cmd, intptr_t arg, int mode, cred_t *credp,
159 dev_info_t *dip = prefix_get_dip(dev);
161 /* Potentially handle private ioctls */
163 return (usba_hubdi_ioctl(dip, dev, cmd, arg, mode, credp, rvalp));
167 prefix_close(dev_t dev, int flag, int otyp, cred_t *credp)
169 dev_info_t *dip = prefix_get_dip(dev);
171 return (usba_hubdi_close(dip, dev, flag, otyp, credp));
175 prefix_attach(dev_info_t *dip, ddi_attach_cmd_t cmd)
180 /* Perform normal checking of cmd */
182 instance = ddi_get_instance(dip);
183 if (ddi_soft_state_zalloc(prefix_soft_state, inst) != 0)
184 return (DDI_FAILURE);
185 p = ddi_get_soft_state(prefix_soft_state, instance);
186 p->prefix_dev_info = dip;
188 /* Continue with normal attach(9E) initialization */
196 if ((ret = ddi_soft_state_init(&prefx_soft_state, sizeof (prefx_t),
201 /* Perform normal module initialization here */
210 /* Perform normal module teardown first */
212 ddi_soft_state_fini(&prefix_soft_state);
224 .Xr ddi_soft_state_init 9F ,
225 .Xr usba_hubdi_close 9F ,
226 .Xr usba_hubdi_ioctl 9F ,
227 .Xr usba_hubdi_open 9F