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