17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5d73ae94eSgc * Common Development and Distribution License (the "License"). 6d73ae94eSgc * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22de6f998eSrui wang - Sun Microsystems - Beijing China * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #ifndef _SYS_USB_USBA_USBA_IMPL_H 277c478bd9Sstevel@tonic-gate #define _SYS_USB_USBA_USBA_IMPL_H 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate #include <sys/usb/usba.h> 317c478bd9Sstevel@tonic-gate #include <sys/usb/usba/hcdi.h> 327c478bd9Sstevel@tonic-gate #include <sys/usb/usba/hubdi.h> 337c478bd9Sstevel@tonic-gate #include <sys/usb/usba/usba_private.h> 347c478bd9Sstevel@tonic-gate #include <sys/usb/usba/usba_types.h> 357c478bd9Sstevel@tonic-gate #include <sys/taskq.h> 367c478bd9Sstevel@tonic-gate #include <sys/disp.h> 377c478bd9Sstevel@tonic-gate 387c478bd9Sstevel@tonic-gate #ifdef __cplusplus 397c478bd9Sstevel@tonic-gate extern "C" { 407c478bd9Sstevel@tonic-gate #endif 417c478bd9Sstevel@tonic-gate 427c478bd9Sstevel@tonic-gate 437c478bd9Sstevel@tonic-gate /* 447c478bd9Sstevel@tonic-gate * UGEN binding values specified in <hcd>.conf files 457c478bd9Sstevel@tonic-gate */ 467c478bd9Sstevel@tonic-gate #define USBA_UGEN_DEVICE_BINDING 1 477c478bd9Sstevel@tonic-gate #define USBA_UGEN_INTERFACE_BINDING 2 48d73ae94eSgc #define USBA_UGEN_INTERFACE_ASSOCIATION_BINDING 3 497c478bd9Sstevel@tonic-gate 507c478bd9Sstevel@tonic-gate /* 517c478bd9Sstevel@tonic-gate * Allocating a USB address 527c478bd9Sstevel@tonic-gate */ 537c478bd9Sstevel@tonic-gate #define USBA_MAX_ADDRESS 127 547c478bd9Sstevel@tonic-gate #define USBA_ADDRESS_ARRAY_SIZE ((USBA_MAX_ADDRESS+8)/8) 557c478bd9Sstevel@tonic-gate 567c478bd9Sstevel@tonic-gate /* 577c478bd9Sstevel@tonic-gate * async execution of usb_pipe_* functions which have a 587c478bd9Sstevel@tonic-gate * completion callback parameter (eg. usb_pipe_close(), 597c478bd9Sstevel@tonic-gate * usb_pipe_reset(), usb_pipe_stop_*_polling() 607c478bd9Sstevel@tonic-gate */ 617c478bd9Sstevel@tonic-gate typedef struct usba_pipe_async_req { 627c478bd9Sstevel@tonic-gate dev_info_t *dip; 637c478bd9Sstevel@tonic-gate struct usba_ph_impl *ph_impl; 647c478bd9Sstevel@tonic-gate usb_opaque_t arg; 657c478bd9Sstevel@tonic-gate usb_flags_t usb_flags; 667c478bd9Sstevel@tonic-gate void (*callback)( 677c478bd9Sstevel@tonic-gate usb_pipe_handle_t ph, 687c478bd9Sstevel@tonic-gate usb_opaque_t callback_arg, 697c478bd9Sstevel@tonic-gate int rval, 707c478bd9Sstevel@tonic-gate usb_cb_flags_t error_code); 717c478bd9Sstevel@tonic-gate usb_opaque_t callback_arg; 727c478bd9Sstevel@tonic-gate int (*sync_func)(dev_info_t *, 737c478bd9Sstevel@tonic-gate usba_ph_impl_t *, 747c478bd9Sstevel@tonic-gate struct usba_pipe_async_req *, 757c478bd9Sstevel@tonic-gate usb_flags_t); 767c478bd9Sstevel@tonic-gate } usba_pipe_async_req_t; 777c478bd9Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("unique per call", usba_pipe_async_req_t)) 787c478bd9Sstevel@tonic-gate 797c478bd9Sstevel@tonic-gate /* per-pipe taskq */ 807c478bd9Sstevel@tonic-gate int usba_async_ph_req(usba_pipe_handle_data_t *, void (*func)(void *), 817c478bd9Sstevel@tonic-gate void *, usb_flags_t); 827c478bd9Sstevel@tonic-gate 837c478bd9Sstevel@tonic-gate /* 847c478bd9Sstevel@tonic-gate * usb wrapper around pm_request_power_change to allow for 857c478bd9Sstevel@tonic-gate * non blocking behavior 867c478bd9Sstevel@tonic-gate */ 877c478bd9Sstevel@tonic-gate typedef struct usba_pm_req { 887c478bd9Sstevel@tonic-gate dev_info_t *dip; 897c478bd9Sstevel@tonic-gate int comp; 907c478bd9Sstevel@tonic-gate int old_level; 917c478bd9Sstevel@tonic-gate int level; 927c478bd9Sstevel@tonic-gate void (*cb)(void *, int); 937c478bd9Sstevel@tonic-gate void *arg; 947c478bd9Sstevel@tonic-gate uint_t flags; 957c478bd9Sstevel@tonic-gate } usba_pm_req_t; 967c478bd9Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("unique per call", usba_pm_req_t)) 977c478bd9Sstevel@tonic-gate 987c478bd9Sstevel@tonic-gate 997c478bd9Sstevel@tonic-gate /* 1007c478bd9Sstevel@tonic-gate * Request wrappers for control/bulk/interrupt and isoch pipes 1017c478bd9Sstevel@tonic-gate * These are hidden from client driver. They serve as place-holders 1027c478bd9Sstevel@tonic-gate * for doing callbacks 1037c478bd9Sstevel@tonic-gate * 1047c478bd9Sstevel@tonic-gate * Request allocation: wrapper + usb_*_req_t alloc'ed together: 1057c478bd9Sstevel@tonic-gate * 1067c478bd9Sstevel@tonic-gate * +-----------------------+ 1077c478bd9Sstevel@tonic-gate * | wr_queue | for callbacks 1087c478bd9Sstevel@tonic-gate * +-----------------------+ 1097c478bd9Sstevel@tonic-gate * | wr_req |-------+ wr_req points to 1107c478bd9Sstevel@tonic-gate * +-----------------------+ | the req below. 1117c478bd9Sstevel@tonic-gate * | | | 1127c478bd9Sstevel@tonic-gate * | .... | | 1137c478bd9Sstevel@tonic-gate * | req_wrapper_t | | 1147c478bd9Sstevel@tonic-gate * | | | 1157c478bd9Sstevel@tonic-gate * +-----------------------+<------+ 1167c478bd9Sstevel@tonic-gate * | | 1177c478bd9Sstevel@tonic-gate * | .... | 1187c478bd9Sstevel@tonic-gate * | ctrl/bulk/intr/isoch | 1197c478bd9Sstevel@tonic-gate * | req_t | 1207c478bd9Sstevel@tonic-gate * | | 1217c478bd9Sstevel@tonic-gate * | | 1227c478bd9Sstevel@tonic-gate * +-----------------------+ 1237c478bd9Sstevel@tonic-gate */ 1247c478bd9Sstevel@tonic-gate typedef struct usba_req_wrapper { 1257c478bd9Sstevel@tonic-gate /* queueing in either a request or callback queue */ 1267c478bd9Sstevel@tonic-gate usba_list_entry_t wr_queue; 1277c478bd9Sstevel@tonic-gate 1287c478bd9Sstevel@tonic-gate /* 1297c478bd9Sstevel@tonic-gate * The request could be control/bulk/intr/isoc 1307c478bd9Sstevel@tonic-gate * See usbai.h usb_ctrl_req_t/usb_bulk_req_t 1317c478bd9Sstevel@tonic-gate * usb_intr_req_t/usb_isoc_req_t 1327c478bd9Sstevel@tonic-gate */ 1337c478bd9Sstevel@tonic-gate usb_opaque_t wr_req; 1347c478bd9Sstevel@tonic-gate 1357c478bd9Sstevel@tonic-gate /* for allocation tracking in usba_device_t */ 1367c478bd9Sstevel@tonic-gate usba_list_entry_t wr_allocated_list; 1377c478bd9Sstevel@tonic-gate 1387c478bd9Sstevel@tonic-gate /* 1397c478bd9Sstevel@tonic-gate * All reqs that are synchronous sleep on this cv 1407c478bd9Sstevel@tonic-gate * for completion notification. 1417c478bd9Sstevel@tonic-gate * In hcdi soft interrupt handler we call cv_signal() 1427c478bd9Sstevel@tonic-gate */ 1437c478bd9Sstevel@tonic-gate kcondvar_t wr_cv; 1447c478bd9Sstevel@tonic-gate 1457c478bd9Sstevel@tonic-gate /* 1467c478bd9Sstevel@tonic-gate * This goes hand-in-hand with wr_cv. It is set by the soft intr hdlr 1477c478bd9Sstevel@tonic-gate * before doing a cv_signal 1487c478bd9Sstevel@tonic-gate */ 1497c478bd9Sstevel@tonic-gate boolean_t wr_done; 1507c478bd9Sstevel@tonic-gate dev_info_t *wr_dip; /* owner */ 1517c478bd9Sstevel@tonic-gate 1527c478bd9Sstevel@tonic-gate usb_opaque_t wr_hcd_private; /* for HCD's use */ 1537c478bd9Sstevel@tonic-gate 1547c478bd9Sstevel@tonic-gate usba_pipe_handle_data_t *wr_ph_data; /* ptr to pipe handle */ 1557c478bd9Sstevel@tonic-gate 1567c478bd9Sstevel@tonic-gate usb_cr_t wr_cr; /* save cr from HCDI */ 1577c478bd9Sstevel@tonic-gate usb_cb_flags_t wr_cb_flags; /* save cb_flags */ 1587c478bd9Sstevel@tonic-gate usb_flags_t wr_usb_flags; /* save usb flags from HCDI */ 1597c478bd9Sstevel@tonic-gate usb_req_attrs_t wr_attrs; /* save attrs from HCDI */ 1607c478bd9Sstevel@tonic-gate 1617c478bd9Sstevel@tonic-gate /* total lenght of wrapper and request */ 1627c478bd9Sstevel@tonic-gate size_t wr_length; 1637c478bd9Sstevel@tonic-gate } usba_req_wrapper_t; 1647c478bd9Sstevel@tonic-gate 1657c478bd9Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("method", usba_req_wrapper)) 1667c478bd9Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("method", usb_ctrl_req)) 1677c478bd9Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("method", usb_bulk_req)) 1687c478bd9Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("method", usb_intr_req)) 1697c478bd9Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("method", usb_isoc_req)) 1707c478bd9Sstevel@tonic-gate 1717c478bd9Sstevel@tonic-gate /* additional flag for wr_usb_flags */ 1727c478bd9Sstevel@tonic-gate #define USBA_WRP_FLAGS_WAIT 0x01 1737c478bd9Sstevel@tonic-gate 1747c478bd9Sstevel@tonic-gate /* additional usb flags, not exposed to clients */ 1757c478bd9Sstevel@tonic-gate #define USBA_FLAGS_PRIVILEGED 0x02 /* for default pipe operations */ 1767c478bd9Sstevel@tonic-gate 1777c478bd9Sstevel@tonic-gate /* Macros to convert wrapper to different request and vice-versa */ 1787c478bd9Sstevel@tonic-gate 1797c478bd9Sstevel@tonic-gate /* to get the wr->wr_req field */ 1807c478bd9Sstevel@tonic-gate #define USBA_WRP2REQ(wrp) ((wrp)->wr_req) 1817c478bd9Sstevel@tonic-gate 1827c478bd9Sstevel@tonic-gate /* to get the wrapper form the wr_req field */ 1837c478bd9Sstevel@tonic-gate #define USBA_REQ2WRP(req) (usba_req_wrapper_t *)\ 1847c478bd9Sstevel@tonic-gate ((uintptr_t)(req) - sizeof (usba_req_wrapper_t)) 1857c478bd9Sstevel@tonic-gate 1867c478bd9Sstevel@tonic-gate /* to set the the address in the wr_req field */ 1877c478bd9Sstevel@tonic-gate #define USBA_SETREQ_ADDR(wrp) ((uintptr_t)(wrp) + sizeof (*(wrp))) 1887c478bd9Sstevel@tonic-gate 1897c478bd9Sstevel@tonic-gate /* to get the 4 xfer type requests */ 1907c478bd9Sstevel@tonic-gate #define USBA_WRP2CTRL_REQ(wrp) ((usb_ctrl_req_t *)USBA_WRP2REQ((wrp))) 1917c478bd9Sstevel@tonic-gate #define USBA_WRP2INTR_REQ(wrp) ((usb_intr_req_t *)USBA_WRP2REQ((wrp))) 1927c478bd9Sstevel@tonic-gate #define USBA_WRP2BULK_REQ(wrp) ((usb_bulk_req_t *)USBA_WRP2REQ((wrp))) 1937c478bd9Sstevel@tonic-gate #define USBA_WRP2ISOC_REQ(wrp) ((usb_isoc_req_t *)USBA_WRP2REQ((wrp))) 1947c478bd9Sstevel@tonic-gate 1957c478bd9Sstevel@tonic-gate /* to get pipe_handle from the wrapper */ 1967c478bd9Sstevel@tonic-gate #define USBA_WRP2PH_DATA(wrp) \ 1977c478bd9Sstevel@tonic-gate (usba_pipe_handle_data_t *)((wrp)->wr_ph_data) 1987c478bd9Sstevel@tonic-gate 1997c478bd9Sstevel@tonic-gate /* to get to the wr_queue from the wrapper */ 2007c478bd9Sstevel@tonic-gate #define USBA_WRQUEUE2WRP(queue) (usba_req_wrapper_t *)(queue) 2017c478bd9Sstevel@tonic-gate 2027c478bd9Sstevel@tonic-gate /* to get to the wr_allocated queue from the wrapper */ 2037c478bd9Sstevel@tonic-gate #define USBA_ALLOCQ2WRP(queue) (usba_req_wrapper_t *)((uintptr_t) \ 2047c478bd9Sstevel@tonic-gate (queue) - sizeof (usba_list_entry_t) - sizeof (usb_opaque_t)) 2057c478bd9Sstevel@tonic-gate 2067c478bd9Sstevel@tonic-gate 2077c478bd9Sstevel@tonic-gate /* alias for pipe handle member p_usba_private */ 2087c478bd9Sstevel@tonic-gate #define p_active_cntrl_req_wrp p_usba_private 2097c478bd9Sstevel@tonic-gate 2107c478bd9Sstevel@tonic-gate /* 2117c478bd9Sstevel@tonic-gate * This function is used to get the HCD private field maintained by USBA. 2127c478bd9Sstevel@tonic-gate * HCD calls this function. 2137c478bd9Sstevel@tonic-gate */ 2147c478bd9Sstevel@tonic-gate usb_opaque_t usba_hcdi_get_ctrl_req_hcd_private(usb_ctrl_req_t *); 2157c478bd9Sstevel@tonic-gate 2167c478bd9Sstevel@tonic-gate /* 2177c478bd9Sstevel@tonic-gate * This function is used to set the HCD private field maintained by USBA. 2187c478bd9Sstevel@tonic-gate * HCD calls this function. 2197c478bd9Sstevel@tonic-gate */ 2207c478bd9Sstevel@tonic-gate void usba_hcdi_set_ctrl_req_hcd_private(usb_ctrl_req_t *, usb_opaque_t); 2217c478bd9Sstevel@tonic-gate 2227c478bd9Sstevel@tonic-gate int usba_set_usb_address(usba_device_t *); 2237c478bd9Sstevel@tonic-gate void usba_unset_usb_address(usba_device_t *); 2247c478bd9Sstevel@tonic-gate 2257c478bd9Sstevel@tonic-gate /* 2267c478bd9Sstevel@tonic-gate * Per Hub Data Structures 2277c478bd9Sstevel@tonic-gate */ 2287c478bd9Sstevel@tonic-gate typedef struct usba_hubdi { 2297c478bd9Sstevel@tonic-gate usba_list_entry_t hubdi_list; /* linking in hubdi list */ 2307c478bd9Sstevel@tonic-gate 2317c478bd9Sstevel@tonic-gate dev_info_t *hubdi_dip; /* ptr to devinfo struct */ 2327c478bd9Sstevel@tonic-gate 2337c478bd9Sstevel@tonic-gate int hubdi_flags; /* flag options */ 2347c478bd9Sstevel@tonic-gate 2357c478bd9Sstevel@tonic-gate } usba_hubdi_t; 2367c478bd9Sstevel@tonic-gate 2377c478bd9Sstevel@tonic-gate /* 2387c478bd9Sstevel@tonic-gate * usba_get_mfg_prod_sn_str: 2397c478bd9Sstevel@tonic-gate * Return a string containing mfg, product, serial number strings. 2407c478bd9Sstevel@tonic-gate * Remove duplicates if some strings are the same. 2417c478bd9Sstevel@tonic-gate */ 2427c478bd9Sstevel@tonic-gate char *usba_get_mfg_prod_sn_str(dev_info_t *, char *, int); 2437c478bd9Sstevel@tonic-gate 2447c478bd9Sstevel@tonic-gate /* return value when user doesn't specify configuration index */ 2457c478bd9Sstevel@tonic-gate #define USBA_DEV_CONFIG_INDEX_UNDEFINED -1 2467c478bd9Sstevel@tonic-gate 2477c478bd9Sstevel@tonic-gate /* 2487c478bd9Sstevel@tonic-gate * prototypes 2497c478bd9Sstevel@tonic-gate */ 2507c478bd9Sstevel@tonic-gate void usba_usba_initialization(); 2517c478bd9Sstevel@tonic-gate void usba_usba_destroy(); 2527c478bd9Sstevel@tonic-gate 2537c478bd9Sstevel@tonic-gate void usba_usbai_register_initialization(); 2547c478bd9Sstevel@tonic-gate void usba_usbai_register_destroy(); 2557c478bd9Sstevel@tonic-gate 2567c478bd9Sstevel@tonic-gate void usba_usbai_initialization(); 2577c478bd9Sstevel@tonic-gate void usba_usbai_destroy(); 2587c478bd9Sstevel@tonic-gate 2597c478bd9Sstevel@tonic-gate void usba_hubdi_initialization(); 2607c478bd9Sstevel@tonic-gate void usba_hubdi_destroy(); 2617c478bd9Sstevel@tonic-gate 2627c478bd9Sstevel@tonic-gate void usba_devdb_initialization(); 2637c478bd9Sstevel@tonic-gate void usba_devdb_destroy(); 2647c478bd9Sstevel@tonic-gate 265ff0e937bSRaymond Chen int usba_hubdi_register(dev_info_t *, uint_t); 266ff0e937bSRaymond Chen int usba_hubdi_unregister(dev_info_t *); 267ff0e937bSRaymond Chen 268ff0e937bSRaymond Chen void usba_whcdi_initialization(); 269ff0e937bSRaymond Chen void usba_whcdi_destroy(); 270ff0e937bSRaymond Chen 2717c478bd9Sstevel@tonic-gate int usba_is_root_hub(dev_info_t *dip); 272ff0e937bSRaymond Chen int usba_is_wa(dev_info_t *dip); 273ff0e937bSRaymond Chen int usba_is_hwa(dev_info_t *dip); 2747c478bd9Sstevel@tonic-gate 2757c478bd9Sstevel@tonic-gate usba_device_t *usba_alloc_usba_device(dev_info_t *); 276ff0e937bSRaymond Chen void usba_free_wireless_data(usba_wireless_data_t *wireless_data); 2777c478bd9Sstevel@tonic-gate void usba_free_usba_device(usba_device_t *usba_device_t); 2787c478bd9Sstevel@tonic-gate void usba_clear_data_toggle(usba_device_t *usba_device); 2797c478bd9Sstevel@tonic-gate 2807c478bd9Sstevel@tonic-gate void usba_start_next_req(usba_pipe_handle_data_t *ph); 2817c478bd9Sstevel@tonic-gate 2827c478bd9Sstevel@tonic-gate int usba_pipe_check_handle(usba_pipe_handle_data_t *); 2837c478bd9Sstevel@tonic-gate int usba_drain_cbs(usba_pipe_handle_data_t *, usb_cb_flags_t, 2847c478bd9Sstevel@tonic-gate usb_cr_t); 2857c478bd9Sstevel@tonic-gate int usba_pipe_setup_func_call(dev_info_t *, 2867c478bd9Sstevel@tonic-gate int (*sync_func)(dev_info_t *, 2877c478bd9Sstevel@tonic-gate usba_ph_impl_t *, usba_pipe_async_req_t *, 2887c478bd9Sstevel@tonic-gate usb_flags_t), 2897c478bd9Sstevel@tonic-gate usba_ph_impl_t *, 2907c478bd9Sstevel@tonic-gate usb_opaque_t, 2917c478bd9Sstevel@tonic-gate usb_flags_t, 2927c478bd9Sstevel@tonic-gate void (*cb)(usb_pipe_handle_t, usb_opaque_t, 2937c478bd9Sstevel@tonic-gate int, usb_cb_flags_t), 2947c478bd9Sstevel@tonic-gate usb_opaque_t); 2957c478bd9Sstevel@tonic-gate 2967c478bd9Sstevel@tonic-gate 2977c478bd9Sstevel@tonic-gate void usba_pipe_new_state(usba_pipe_handle_data_t *, usb_pipe_state_t); 2987c478bd9Sstevel@tonic-gate 299de6f998eSrui wang - Sun Microsystems - Beijing China void usba_add_root_hub(dev_info_t *dip); 300de6f998eSrui wang - Sun Microsystems - Beijing China void usba_rem_root_hub(dev_info_t *dip); 3017c478bd9Sstevel@tonic-gate 3027c478bd9Sstevel@tonic-gate /* 3037c478bd9Sstevel@tonic-gate * retrieve string descriptors for manufacturer, vendor and serial 3047c478bd9Sstevel@tonic-gate * number 3057c478bd9Sstevel@tonic-gate */ 3067c478bd9Sstevel@tonic-gate void usba_get_dev_string_descrs(dev_info_t *, usba_device_t *); 3077c478bd9Sstevel@tonic-gate 3087c478bd9Sstevel@tonic-gate /* 3097c478bd9Sstevel@tonic-gate * Check if we are not in interrupt context and have 3107c478bd9Sstevel@tonic-gate * USB_FLAGS_SLEEP flags set. 3117c478bd9Sstevel@tonic-gate */ 3127c478bd9Sstevel@tonic-gate #define USBA_CHECK_CONTEXT() ASSERT(!(servicing_interrupt())) 3137c478bd9Sstevel@tonic-gate 3147c478bd9Sstevel@tonic-gate /* 3157c478bd9Sstevel@tonic-gate * USBA module Masks 3167c478bd9Sstevel@tonic-gate */ 3177c478bd9Sstevel@tonic-gate #define DPRINT_MASK_USBA 0x00000001 3187c478bd9Sstevel@tonic-gate #define DPRINT_MASK_USBAI 0x00000002 3197c478bd9Sstevel@tonic-gate #define DPRINT_MASK_HUBDI 0x00000004 3207c478bd9Sstevel@tonic-gate #define DPRINT_MASK_HCDI 0x00000008 3217c478bd9Sstevel@tonic-gate #define DPRINT_MASK_HCDI_DUMPING 0x00000010 3227c478bd9Sstevel@tonic-gate #define DPRINT_MASK_HUBDI_DUMPING 0x00000020 3237c478bd9Sstevel@tonic-gate #define DPRINT_MASK_REGISTER 0x00000040 3247c478bd9Sstevel@tonic-gate #define DPRINT_MASK_DEVDB 0x00000080 325ff0e937bSRaymond Chen #define DPRINT_MASK_WHCDI 0x00000100 3267c478bd9Sstevel@tonic-gate #define DPRINT_MASK_ALL 0xFFFFFFFF 3277c478bd9Sstevel@tonic-gate 3287c478bd9Sstevel@tonic-gate typedef struct usba_log_handle_impl { 3297c478bd9Sstevel@tonic-gate dev_info_t *lh_dip; 3307c478bd9Sstevel@tonic-gate char *lh_name; 3317c478bd9Sstevel@tonic-gate uint_t *lh_errlevel; 3327c478bd9Sstevel@tonic-gate uint_t *lh_mask; 3337c478bd9Sstevel@tonic-gate uint_t *lh_instance_filter; 3347c478bd9Sstevel@tonic-gate uint_t lh_flags; 3357c478bd9Sstevel@tonic-gate } usba_log_handle_impl_t; 3367c478bd9Sstevel@tonic-gate 3377c478bd9Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("USBA managed data", usba_log_handle_impl)) 3387c478bd9Sstevel@tonic-gate 3397c478bd9Sstevel@tonic-gate /* 3407c478bd9Sstevel@tonic-gate * Miscellaneous definitions. 3417c478bd9Sstevel@tonic-gate */ 3427c478bd9Sstevel@tonic-gate 3437c478bd9Sstevel@tonic-gate /* possible strlen of a USB driver's name */ 3447c478bd9Sstevel@tonic-gate #define USBA_DRVNAME_LEN 40 3457c478bd9Sstevel@tonic-gate 3467c478bd9Sstevel@tonic-gate /* strings passed to usb_dprintfN() are this long */ 3477c478bd9Sstevel@tonic-gate #define USBA_PRINT_BUF_LEN 256 3487c478bd9Sstevel@tonic-gate 3497c478bd9Sstevel@tonic-gate /* 3507c478bd9Sstevel@tonic-gate * usba_set_node_name() sets a device info node name 3517c478bd9Sstevel@tonic-gate * according to class, subclass, and protocol. 3527c478bd9Sstevel@tonic-gate * a subclass == -1 or protocol == -1 is considered a "don't care". 3537c478bd9Sstevel@tonic-gate */ 3547c478bd9Sstevel@tonic-gate #define DONTCARE ((int16_t)-1) 3557c478bd9Sstevel@tonic-gate #define FLAG_INTERFACE_NODE 0 3567c478bd9Sstevel@tonic-gate #define FLAG_DEVICE_NODE 1 3577c478bd9Sstevel@tonic-gate #define FLAG_COMBINED_NODE 2 358d73ae94eSgc #define FLAG_INTERFACE_ASSOCIATION_NODE 3 3597c478bd9Sstevel@tonic-gate 3607c478bd9Sstevel@tonic-gate typedef struct node_name_entry { 3617c478bd9Sstevel@tonic-gate int16_t class; 3627c478bd9Sstevel@tonic-gate int16_t subclass; 3637c478bd9Sstevel@tonic-gate int16_t protocol; 3647c478bd9Sstevel@tonic-gate char *name; 3657c478bd9Sstevel@tonic-gate } node_name_entry_t; 3667c478bd9Sstevel@tonic-gate 3677c478bd9Sstevel@tonic-gate 3687c478bd9Sstevel@tonic-gate /* 3697c478bd9Sstevel@tonic-gate * USB enumeration statistics support 3707c478bd9Sstevel@tonic-gate */ 3717c478bd9Sstevel@tonic-gate 3727c478bd9Sstevel@tonic-gate /* Flags telling which stats usba_update_hotplug_stats should update */ 3737c478bd9Sstevel@tonic-gate #define USBA_TOTAL_HOTPLUG_SUCCESS 0x01 3747c478bd9Sstevel@tonic-gate #define USBA_HOTPLUG_SUCCESS 0x02 3757c478bd9Sstevel@tonic-gate #define USBA_TOTAL_HOTPLUG_FAILURE 0x04 3767c478bd9Sstevel@tonic-gate #define USBA_HOTPLUG_FAILURE 0x08 3777c478bd9Sstevel@tonic-gate 3787c478bd9Sstevel@tonic-gate /* 3797c478bd9Sstevel@tonic-gate * Increment enumeration stats indicated by the flags 3807c478bd9Sstevel@tonic-gate */ 3817c478bd9Sstevel@tonic-gate void usba_update_hotplug_stats(dev_info_t *, usb_flags_t); 3827c478bd9Sstevel@tonic-gate 3837c478bd9Sstevel@tonic-gate /* Retrieve the current enumeration hotplug statistics */ 3847c478bd9Sstevel@tonic-gate void usba_get_hotplug_stats(dev_info_t *, 3857c478bd9Sstevel@tonic-gate ulong_t *, ulong_t *, ulong_t *, 3867c478bd9Sstevel@tonic-gate ulong_t *, uchar_t *); 3877c478bd9Sstevel@tonic-gate 3887c478bd9Sstevel@tonic-gate /* Reset the resetable hotplug stats */ 3897c478bd9Sstevel@tonic-gate void usba_reset_hotplug_stats(dev_info_t *); 3907c478bd9Sstevel@tonic-gate 3917c478bd9Sstevel@tonic-gate 3927c478bd9Sstevel@tonic-gate extern usb_log_handle_t usbai_log_handle; 3937c478bd9Sstevel@tonic-gate extern kmutex_t usbai_mutex; 3947c478bd9Sstevel@tonic-gate 3957c478bd9Sstevel@tonic-gate void usba_req_normal_cb(usba_req_wrapper_t *); 3967c478bd9Sstevel@tonic-gate void usba_req_exc_cb(usba_req_wrapper_t *, usb_cr_t, usb_cb_flags_t); 3977c478bd9Sstevel@tonic-gate void usba_do_req_exc_cb(usba_req_wrapper_t *, usb_cr_t, 3987c478bd9Sstevel@tonic-gate usb_cb_flags_t); 3997c478bd9Sstevel@tonic-gate void usba_req_set_cb_flags(usba_req_wrapper_t *, usb_cb_flags_t); 4007c478bd9Sstevel@tonic-gate 4017c478bd9Sstevel@tonic-gate /* 4027c478bd9Sstevel@tonic-gate * Creating/Destroying children (root hub, and hub children) 4037c478bd9Sstevel@tonic-gate */ 4047c478bd9Sstevel@tonic-gate int usba_create_child_devi(dev_info_t *, char *, usba_hcdi_ops_t *, 4057c478bd9Sstevel@tonic-gate dev_info_t *, usb_port_status_t, 4067c478bd9Sstevel@tonic-gate usba_device_t *, dev_info_t **); 4077c478bd9Sstevel@tonic-gate 4087c478bd9Sstevel@tonic-gate int usba_destroy_child_devi(dev_info_t *, uint_t); 4097c478bd9Sstevel@tonic-gate 4107c478bd9Sstevel@tonic-gate /* utility function to map rval to a meaningful cr */ 4117c478bd9Sstevel@tonic-gate usb_cr_t usba_rval2cr(int); 4127c478bd9Sstevel@tonic-gate 4137c478bd9Sstevel@tonic-gate /* various conversion functions */ 4147c478bd9Sstevel@tonic-gate usb_pipe_handle_t usba_get_dflt_pipe_handle(dev_info_t *); 4157c478bd9Sstevel@tonic-gate dev_info_t *usba_get_dip(usb_pipe_handle_t); 4167c478bd9Sstevel@tonic-gate usb_pipe_handle_t usba_usbdev_to_dflt_pipe_handle(usba_device_t *); 4177c478bd9Sstevel@tonic-gate usb_pipe_handle_t usba_get_pipe_handle(usba_pipe_handle_data_t *); 4187c478bd9Sstevel@tonic-gate usba_pipe_handle_data_t *usba_get_ph_data(usb_pipe_handle_t); 4197c478bd9Sstevel@tonic-gate usb_pipe_state_t usba_get_ph_state(usba_pipe_handle_data_t *); 4207c478bd9Sstevel@tonic-gate int usba_get_ph_ref_count(usba_pipe_handle_data_t *); 4217c478bd9Sstevel@tonic-gate 4227c478bd9Sstevel@tonic-gate /* increment and decrement ref_count */ 4237c478bd9Sstevel@tonic-gate usba_pipe_handle_data_t *usba_hold_ph_data(usb_pipe_handle_t); 4247c478bd9Sstevel@tonic-gate void usba_release_ph_data(usba_ph_impl_t *); 4257c478bd9Sstevel@tonic-gate 4267c478bd9Sstevel@tonic-gate /* close all pipe and mark them persistent */ 4277c478bd9Sstevel@tonic-gate void usba_persistent_pipe_close(usba_device_t *); 4287c478bd9Sstevel@tonic-gate 4297c478bd9Sstevel@tonic-gate /* reopen pipes that are marked persistent */ 4307c478bd9Sstevel@tonic-gate int usba_persistent_pipe_open(usba_device_t *); 4317c478bd9Sstevel@tonic-gate 4327c478bd9Sstevel@tonic-gate /* check for leaks in hubd and usb_mid */ 4337c478bd9Sstevel@tonic-gate void usba_check_for_leaks(usba_device_t *); 4347c478bd9Sstevel@tonic-gate 4357c478bd9Sstevel@tonic-gate /* free request wrappers */ 4367c478bd9Sstevel@tonic-gate void usba_req_wrapper_free(usba_req_wrapper_t *); 4377c478bd9Sstevel@tonic-gate 438*a7df97baSStrony Zhang - Solaris China Team /* usb device capture for the specific client driver */ 439*a7df97baSStrony Zhang - Solaris China Team typedef struct usb_dev_cap { 440*a7df97baSStrony Zhang - Solaris China Team dev_info_t *dip; 441*a7df97baSStrony Zhang - Solaris China Team usb_dev_driver_callback_t usba_dev_driver_cb; 442*a7df97baSStrony Zhang - Solaris China Team } usb_dev_cap_t; 443*a7df97baSStrony Zhang - Solaris China Team 444*a7df97baSStrony Zhang - Solaris China Team usb_dev_cap_t usb_cap; 445*a7df97baSStrony Zhang - Solaris China Team _NOTE(SCHEME_PROTECTS_DATA("unique device capture data", usb_cap)) 446*a7df97baSStrony Zhang - Solaris China Team 4477c478bd9Sstevel@tonic-gate #ifdef __cplusplus 4487c478bd9Sstevel@tonic-gate } 4497c478bd9Sstevel@tonic-gate #endif 4507c478bd9Sstevel@tonic-gate 4517c478bd9Sstevel@tonic-gate #endif /* _SYS_USB_USBA_USBA_IMPL_H */ 452