usba_impl.h revision ff0e937b36dcde1a47ff7b00aa76a491c0dc07a8
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _SYS_USB_USBA_USBA_IMPL_H
#define _SYS_USB_USBA_USBA_IMPL_H
#ifdef __cplusplus
extern "C" {
#endif
/*
* UGEN binding values specified in <hcd>.conf files
*/
#define USBA_UGEN_DEVICE_BINDING 1
#define USBA_UGEN_INTERFACE_BINDING 2
#define USBA_UGEN_INTERFACE_ASSOCIATION_BINDING 3
/*
* Allocating a USB address
*/
#define USBA_MAX_ADDRESS 127
/*
* async execution of usb_pipe_* functions which have a
* completion callback parameter (eg. usb_pipe_close(),
* usb_pipe_reset(), usb_pipe_stop_*_polling()
*/
typedef struct usba_pipe_async_req {
struct usba_ph_impl *ph_impl;
void (*callback)(
int rval,
int (*sync_func)(dev_info_t *,
struct usba_pipe_async_req *,
/* per-pipe taskq */
void *, usb_flags_t);
/*
* usb wrapper around pm_request_power_change to allow for
* non blocking behavior
*/
typedef struct usba_pm_req {
int comp;
int old_level;
int level;
void (*cb)(void *, int);
void *arg;
/*
* These are hidden from client driver. They serve as place-holders
* for doing callbacks
*
* Request allocation: wrapper + usb_*_req_t alloc'ed together:
*
* +-----------------------+
* | wr_queue | for callbacks
* +-----------------------+
* | wr_req |-------+ wr_req points to
* +-----------------------+ | the req below.
* | | |
* | .... | |
* | req_wrapper_t | |
* | | |
* +-----------------------+<------+
* | |
* | .... |
* | req_t |
* | |
* | |
* +-----------------------+
*/
typedef struct usba_req_wrapper {
/* queueing in either a request or callback queue */
/*
*/
/* for allocation tracking in usba_device_t */
/*
* All reqs that are synchronous sleep on this cv
* for completion notification.
* In hcdi soft interrupt handler we call cv_signal()
*/
/*
* This goes hand-in-hand with wr_cv. It is set by the soft intr hdlr
* before doing a cv_signal
*/
/* total lenght of wrapper and request */
/* additional flag for wr_usb_flags */
#define USBA_WRP_FLAGS_WAIT 0x01
/* additional usb flags, not exposed to clients */
/* Macros to convert wrapper to different request and vice-versa */
/* to get the wr->wr_req field */
/* to get the wrapper form the wr_req field */
/* to set the the address in the wr_req field */
/* to get the 4 xfer type requests */
/* to get pipe_handle from the wrapper */
#define USBA_WRP2PH_DATA(wrp) \
/* to get to the wr_queue from the wrapper */
/* to get to the wr_allocated queue from the wrapper */
/* alias for pipe handle member p_usba_private */
#define p_active_cntrl_req_wrp p_usba_private
/*
* This function is used to get the HCD private field maintained by USBA.
* HCD calls this function.
*/
/*
* This function is used to set the HCD private field maintained by USBA.
* HCD calls this function.
*/
int usba_set_usb_address(usba_device_t *);
void usba_unset_usb_address(usba_device_t *);
/*
* Per Hub Data Structures
*/
typedef struct usba_hubdi {
int hubdi_flags; /* flag options */
} usba_hubdi_t;
/*
* usba_get_mfg_prod_sn_str:
* Return a string containing mfg, product, serial number strings.
* Remove duplicates if some strings are the same.
*/
char *usba_get_mfg_prod_sn_str(dev_info_t *, char *, int);
/* return value when user doesn't specify configuration index */
#define USBA_DEV_CONFIG_INDEX_UNDEFINED -1
/*
* prototypes
*/
void usba_usba_initialization();
void usba_usba_destroy();
void usba_usbai_register_destroy();
void usba_usbai_initialization();
void usba_usbai_destroy();
void usba_hubdi_initialization();
void usba_hubdi_destroy();
void usba_devdb_initialization();
void usba_devdb_destroy();
int usba_hubdi_unregister(dev_info_t *);
void usba_whcdi_initialization();
void usba_whcdi_destroy();
usb_cr_t);
int (*sync_func)(dev_info_t *,
int, usb_cb_flags_t),
/*
* retrieve string descriptors for manufacturer, vendor and serial
* number
*/
/*
* Check if we are not in interrupt context and have
* USB_FLAGS_SLEEP flags set.
*/
/*
* USBA module Masks
*/
#define DPRINT_MASK_USBA 0x00000001
#define DPRINT_MASK_USBAI 0x00000002
#define DPRINT_MASK_HUBDI 0x00000004
#define DPRINT_MASK_HCDI 0x00000008
#define DPRINT_MASK_HCDI_DUMPING 0x00000010
#define DPRINT_MASK_HUBDI_DUMPING 0x00000020
#define DPRINT_MASK_REGISTER 0x00000040
#define DPRINT_MASK_DEVDB 0x00000080
#define DPRINT_MASK_WHCDI 0x00000100
#define DPRINT_MASK_ALL 0xFFFFFFFF
typedef struct usba_log_handle_impl {
char *lh_name;
/*
* Miscellaneous definitions.
*/
/* possible strlen of a USB driver's name */
#define USBA_DRVNAME_LEN 40
/* strings passed to usb_dprintfN() are this long */
#define USBA_PRINT_BUF_LEN 256
/*
* usba_set_node_name() sets a device info node name
* according to class, subclass, and protocol.
* a subclass == -1 or protocol == -1 is considered a "don't care".
*/
#define FLAG_INTERFACE_NODE 0
#define FLAG_DEVICE_NODE 1
#define FLAG_COMBINED_NODE 2
#define FLAG_INTERFACE_ASSOCIATION_NODE 3
typedef struct node_name_entry {
char *name;
/*
* USB enumeration statistics support
*/
/* Flags telling which stats usba_update_hotplug_stats should update */
#define USBA_TOTAL_HOTPLUG_SUCCESS 0x01
#define USBA_HOTPLUG_SUCCESS 0x02
#define USBA_TOTAL_HOTPLUG_FAILURE 0x04
#define USBA_HOTPLUG_FAILURE 0x08
/*
* Increment enumeration stats indicated by the flags
*/
/* Retrieve the current enumeration hotplug statistics */
void usba_get_hotplug_stats(dev_info_t *,
/* Reset the resetable hotplug stats */
void usba_reset_hotplug_stats(dev_info_t *);
extern usb_log_handle_t usbai_log_handle;
extern kmutex_t usbai_mutex;
void usba_req_normal_cb(usba_req_wrapper_t *);
/*
* Creating/Destroying children (root hub, and hub children)
*/
usba_device_t *, dev_info_t **);
/* utility function to map rval to a meaningful cr */
usb_cr_t usba_rval2cr(int);
/* various conversion functions */
/* increment and decrement ref_count */
void usba_release_ph_data(usba_ph_impl_t *);
/* close all pipe and mark them persistent */
void usba_persistent_pipe_close(usba_device_t *);
/* reopen pipes that are marked persistent */
/* check for leaks in hubd and usb_mid */
void usba_check_for_leaks(usba_device_t *);
/* free request wrappers */
void usba_req_wrapper_free(usba_req_wrapper_t *);
#ifdef __cplusplus
}
#endif
#endif /* _SYS_USB_USBA_USBA_IMPL_H */