1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 * 22 * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26 #ifndef _SYS_USB_USB_MIDVAR_H 27 #define _SYS_USB_USB_MIDVAR_H 28 29 #pragma ident "%Z%%M% %I% %E% SMI" 30 31 #ifdef __cplusplus 32 extern "C" { 33 #endif 34 35 #include <sys/usb/usba/usbai_private.h> 36 37 typedef struct usb_mid_power_struct { 38 void *mip_usb_mid; /* points back to usb_mid_t */ 39 40 uint8_t mip_wakeup_enabled; 41 42 /* this is the bit mask of the power states that device has */ 43 uint8_t mip_pwr_states; 44 45 /* wakeup and power transistion capabilites of an interface */ 46 uint8_t mip_pm_capabilities; 47 48 uint8_t mip_current_power; /* current power level */ 49 } usb_mid_power_t; 50 51 /* warlock directives, stable data */ 52 _NOTE(DATA_READABLE_WITHOUT_LOCK(usb_mid_power_t::mip_usb_mid)) 53 _NOTE(DATA_READABLE_WITHOUT_LOCK(usb_mid_power_t::mip_wakeup_enabled)) 54 _NOTE(DATA_READABLE_WITHOUT_LOCK(usb_mid_power_t::mip_pwr_states)) 55 _NOTE(DATA_READABLE_WITHOUT_LOCK(usb_mid_power_t::mip_pm_capabilities)) 56 57 58 /* 59 * soft state information for this usb_mid 60 */ 61 typedef struct usb_mid { 62 int mi_instance; 63 64 uint_t mi_init_state; 65 uint_t mi_ugen_open_count; 66 67 kmutex_t mi_mutex; 68 69 /* 70 * dev_info_t reference 71 */ 72 dev_info_t *mi_dip; 73 74 /* pointer to usb_mid_power_t */ 75 usb_mid_power_t *mi_pm; 76 77 /* 78 * save the usba_device pointer 79 */ 80 usba_device_t *mi_usba_device; 81 82 int mi_softstate; 83 84 int mi_dev_state; 85 86 int mi_n_ifs; 87 88 /* track event registration of children */ 89 uint8_t *mi_child_events; 90 /* 91 * mi_children_dips is a array for holding 92 * each child dip indexed by interface number 93 */ 94 dev_info_t **mi_children_dips; 95 boolean_t mi_removed_children; 96 97 size_t mi_cd_list_length; 98 int mi_attach_count; 99 100 /* logging of messages */ 101 usb_log_handle_t mi_log_handle; 102 103 /* usb registration */ 104 usb_client_dev_data_t *mi_dev_data; 105 106 /* event support */ 107 ndi_event_hdl_t mi_ndi_event_hdl; 108 109 /* ugen support */ 110 usb_ugen_hdl_t mi_ugen_hdl; 111 112 } usb_mid_t; 113 114 _NOTE(MUTEX_PROTECTS_DATA(usb_mid::mi_mutex, usb_mid)) 115 _NOTE(MUTEX_PROTECTS_DATA(usb_mid::mi_mutex, usb_mid_power_t)) 116 _NOTE(DATA_READABLE_WITHOUT_LOCK(usb_mid::mi_instance 117 usb_mid::mi_ndi_event_hdl 118 usb_mid::mi_dev_data 119 usb_mid::mi_log_handle 120 usb_mid::mi_ugen_hdl 121 usb_mid::mi_dip 122 usb_mid::mi_pm)) 123 124 #define USB_MID_MINOR_UGEN_BITS_MASK 0x1ff 125 #define USB_MID_MINOR_INSTANCE_SHIFT 9 126 #define USB_MID_MINOR_INSTANCE_MASK ~USB_MID_MINOR_UGEN_BITS_MASK 127 #define USB_MID_MINOR_TO_INSTANCE(minor) \ 128 (((minor) & USB_MID_MINOR_INSTANCE_MASK) >> \ 129 USB_MID_MINOR_INSTANCE_SHIFT) 130 131 /* init state */ 132 #define USB_MID_LOCK_INIT 0x0001 133 #define USB_MID_MINOR_NODE_CREATED 0x0002 134 #define USB_MID_EVENTS_REGISTERED 0x0004 135 136 /* Tracking events registered by children */ 137 #define USB_MID_CHILD_EVENT_DISCONNECT 0x01 138 #define USB_MID_CHILD_EVENT_PRESUSPEND 0x02 139 140 /* 141 * Debug printing 142 * Masks 143 */ 144 #define DPRINT_MASK_ATTA 0x00000001 145 #define DPRINT_MASK_CBOPS 0x00000002 146 #define DPRINT_MASK_EVENTS 0x00000004 147 #define DPRINT_MASK_DUMPING 0x00000008 /* usb_mid dump mask */ 148 #define DPRINT_MASK_PM 0x00000010 149 #define DPRINT_MASK_ALL 0xFFFFFFFF 150 151 152 #ifdef __cplusplus 153 } 154 #endif 155 156 #endif /* _SYS_USB_USB_MIDVAR_H */ 157