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
75 all HCD drivers are required to implement these functions and vector
77 .Xr usba_hubdi_open 9F ,
78 .Xr usba_hubdi_ioctl 9F ,
80 .Xr usba_hubdi_close 9F
82 For background information on these functions and how they interact in the
83 broader operating system, please see the general manual pages
89 The arguments between the two types of functions are slightly different.
92 section provides a sketch for how most HCD drivers should perform those
95 One important distinction from the traditional character routines is
96 that the USBA controls a bit more of the minor space.
97 Therefore, the driver needs to take extra care around the values encoded in the
99 and it should not perform any cloning or renumbering in its
103 The following example is adapated from the
105 driver which shows how an HCD driver might arrange things.
106 This assumes that a driver is following the recommendations in
108 and has initialized a soft state structure through the
109 .Xr ddi_soft_state_init 9F
111 This design also requires that the soft state structure contains a pointer to
115 .Xr attach 9E callback.
117 This example does not stand alone, it will need to be adapted for a
120 #include <sys/types.h>
121 #include <sys/file.h>
122 #include <sys/errno.h>
123 #include <sys/open.h>
124 #include <sys/cred.h>
126 #include <sys/sunddi.h>
128 static void *prefix_soft_state;
131 * Per-instance structure
133 typedef struct prefix {
134 dev_info_t *prefix_dev_info;
139 prefix_get_dip(dev_t dev)
142 int instance = getminor(dev) & ~HUBD_IS_ROOT_HUB;
144 p = ddi_get_soft_state(prefix_soft_state, instance);
146 return (p->prefix_dip);
151 prefix_open(dev_t *devp, int flags, int otyp, cred_t *credp)
153 dev_info_t *dip = prefix_get_dip(*devp);
155 return (usba_hubdi_open(dip, devp, flags, otyp, credp));
159 prefix_ioctl(dev_t dev, int cmd, intptr_t arg, int mode, cred_t *credp,
162 dev_info_t *dip = prefix_get_dip(dev);
164 /* Potentially handle private ioctls */
166 return (usba_hubdi_ioctl(dip, dev, cmd, arg, mode, credp, rvalp));
170 prefix_close(dev_t dev, int flag, int otyp, cred_t *credp)
172 dev_info_t *dip = prefix_get_dip(dev);
174 return (usba_hubdi_close(dip, dev, flag, otyp, credp));
178 prefix_attach(dev_info_t *dip, ddi_attach_cmd_t cmd)
183 /* Perform normal checking of cmd */
185 instance = ddi_get_instance(dip);
186 if (ddi_soft_state_zalloc(prefix_soft_state, inst) != 0)
187 return (DDI_FAILURE);
188 p = ddi_get_soft_state(prefix_soft_state, instance);
189 p->prefix_dev_info = dip;
191 /* Continue with normal attach(9E) initialization */
199 if ((ret = ddi_soft_state_init(&prefx_soft_state, sizeof (prefx_t),
204 /* Perform normal module initialization here */
213 /* Perform normal module teardown first */
215 ddi_soft_state_fini(&prefix_soft_state);
227 .Xr ddi_soft_state_init 9F ,
228 .Xr usba_hubdi_close 9F ,
229 .Xr usba_hubdi_ioctl 9F ,
230 .Xr usba_hubdi_open 9F