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 5*d29f5a71Szhigang lu - Sun Microsystems - Beijing China * Common Development and Distribution License (the "License"). 6*d29f5a71Szhigang lu - Sun Microsystems - Beijing China * 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 * 21*d29f5a71Szhigang lu - Sun Microsystems - Beijing China * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 227c478bd9Sstevel@tonic-gate * Use is subject to license terms. 237c478bd9Sstevel@tonic-gate */ 247c478bd9Sstevel@tonic-gate 257c478bd9Sstevel@tonic-gate #ifndef _SYS_USB_USBPRN_H 267c478bd9Sstevel@tonic-gate #define _SYS_USB_USBPRN_H 277c478bd9Sstevel@tonic-gate 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #ifdef __cplusplus 307c478bd9Sstevel@tonic-gate extern "C" { 317c478bd9Sstevel@tonic-gate #endif 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate #include <sys/usb/usba/usbai_private.h> 347c478bd9Sstevel@tonic-gate 357c478bd9Sstevel@tonic-gate /* 367c478bd9Sstevel@tonic-gate * This header file contains internal driver structures info 377c478bd9Sstevel@tonic-gate * 387c478bd9Sstevel@tonic-gate * Write timeout values for 1K of data transfer 397c478bd9Sstevel@tonic-gate */ 407c478bd9Sstevel@tonic-gate #define USBPRN_XFER_TIMEOUT 90 /* default timeout is 90 seconds */ 417c478bd9Sstevel@tonic-gate #define USBPRN_XFER_TIMEOUT_MIN 1 /* min timeout is 1 second */ 427c478bd9Sstevel@tonic-gate #define USBPRN_XFER_TIMEOUT_MAX 300 /* max timeout is 5 minutes */ 437c478bd9Sstevel@tonic-gate 447c478bd9Sstevel@tonic-gate /* ps_flags values */ 457c478bd9Sstevel@tonic-gate #define USBPRN_PS_IDLE 0x00 /* no activity on any pipe */ 467c478bd9Sstevel@tonic-gate #define USBPRN_PS_NEED_TO_XFER 0x01 /* transfer to start */ 477c478bd9Sstevel@tonic-gate 487c478bd9Sstevel@tonic-gate /* Maximum transfer size */ 497c478bd9Sstevel@tonic-gate #define USBPRN_MAX_XFER_SIZE (8 * 1024) 507c478bd9Sstevel@tonic-gate 517c478bd9Sstevel@tonic-gate /* 527c478bd9Sstevel@tonic-gate * Per pipe state information 537c478bd9Sstevel@tonic-gate */ 547c478bd9Sstevel@tonic-gate typedef struct usbprn_ps { 557c478bd9Sstevel@tonic-gate usb_ep_descr_t ps_ept_descr; /* endpoint descriptor */ 567c478bd9Sstevel@tonic-gate usb_pipe_handle_t ps_handle; /* pipe handle */ 577c478bd9Sstevel@tonic-gate usb_pipe_policy_t ps_policy; /* pipe policy */ 587c478bd9Sstevel@tonic-gate int ps_flags; /* state flags */ 597c478bd9Sstevel@tonic-gate int ps_cr; /* save last cr */ 607c478bd9Sstevel@tonic-gate } usbprn_ps_t; 617c478bd9Sstevel@tonic-gate 627c478bd9Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("USBA", usbprn_ps::ps_handle)) 637c478bd9Sstevel@tonic-gate 647c478bd9Sstevel@tonic-gate /* 657c478bd9Sstevel@tonic-gate * PM support 667c478bd9Sstevel@tonic-gate */ 677c478bd9Sstevel@tonic-gate typedef struct usbprn_power { 687c478bd9Sstevel@tonic-gate /* device busy accounting */ 697c478bd9Sstevel@tonic-gate int usbprn_pm_busy; 707c478bd9Sstevel@tonic-gate uint8_t usbprn_wakeup_enabled; 717c478bd9Sstevel@tonic-gate 727c478bd9Sstevel@tonic-gate /* this is the bit mask of the power states that device has */ 737c478bd9Sstevel@tonic-gate uint8_t usbprn_pwr_states; 747c478bd9Sstevel@tonic-gate 757c478bd9Sstevel@tonic-gate /* wakeup and power transistion capabilites of an interface */ 767c478bd9Sstevel@tonic-gate uint8_t usbprn_pm_capabilities; 777c478bd9Sstevel@tonic-gate 787c478bd9Sstevel@tonic-gate uint8_t usbprn_current_power; 797c478bd9Sstevel@tonic-gate } usbprn_power_t; 807c478bd9Sstevel@tonic-gate 817c478bd9Sstevel@tonic-gate 827c478bd9Sstevel@tonic-gate /* 837c478bd9Sstevel@tonic-gate * State structure 847c478bd9Sstevel@tonic-gate */ 857c478bd9Sstevel@tonic-gate typedef struct usbprn_state { 867c478bd9Sstevel@tonic-gate dev_info_t *usbprn_dip; /* per-device info handle */ 877c478bd9Sstevel@tonic-gate int usbprn_dev_state; /* USB device state */ 887c478bd9Sstevel@tonic-gate kmutex_t usbprn_mutex; /* for general locking */ 897c478bd9Sstevel@tonic-gate int usbprn_instance; /* instance number */ 907c478bd9Sstevel@tonic-gate int usbprn_flags; 917c478bd9Sstevel@tonic-gate 927c478bd9Sstevel@tonic-gate usb_client_dev_data_t *usbprn_dev_data; /* registration data */ 937c478bd9Sstevel@tonic-gate 947c478bd9Sstevel@tonic-gate size_t usbprn_max_bulk_xfer_size; /* max txfer size */ 957c478bd9Sstevel@tonic-gate char *usbprn_device_id; /* Device id string */ 967c478bd9Sstevel@tonic-gate int usbprn_device_id_len; /* Device id length */ 977c478bd9Sstevel@tonic-gate 987c478bd9Sstevel@tonic-gate /* serialize access */ 997c478bd9Sstevel@tonic-gate usb_serialization_t usbprn_ser_acc; 1007c478bd9Sstevel@tonic-gate usb_serialization_t usbprn_write_acc; 1017c478bd9Sstevel@tonic-gate usb_serialization_t usbprn_dev_acc; 1027c478bd9Sstevel@tonic-gate 1037c478bd9Sstevel@tonic-gate /* mblk_t that contains the data to be sent */ 1047c478bd9Sstevel@tonic-gate mblk_t *usbprn_bulk_mp; 1057c478bd9Sstevel@tonic-gate 1067c478bd9Sstevel@tonic-gate struct buf *usbprn_bp; /* Buffer ptr for strategy */ 1077c478bd9Sstevel@tonic-gate 1087c478bd9Sstevel@tonic-gate usb_pipe_handle_t usbprn_def_ph; /* default pipe handle */ 1097c478bd9Sstevel@tonic-gate 1107c478bd9Sstevel@tonic-gate usbprn_ps_t usbprn_bulk_out; /* bulk out info */ 1117c478bd9Sstevel@tonic-gate usbprn_ps_t usbprn_bulk_in; /* bulk in info */ 1127c478bd9Sstevel@tonic-gate 1137c478bd9Sstevel@tonic-gate usb_log_handle_t usbprn_log_handle; /* log handle */ 1147c478bd9Sstevel@tonic-gate usb_cfg_descr_t usbprn_config_descr; /* config desc */ 1157c478bd9Sstevel@tonic-gate usb_if_descr_t usbprn_if_descr; /* interface descr */ 1167c478bd9Sstevel@tonic-gate 1177c478bd9Sstevel@tonic-gate char usbprn_last_status; /* last port status */ 1187c478bd9Sstevel@tonic-gate 1197c478bd9Sstevel@tonic-gate usbprn_power_t *usbprn_pm; /* Power components */ 1207c478bd9Sstevel@tonic-gate 1217c478bd9Sstevel@tonic-gate struct ecpp_transfer_parms usbprn_setparms; /* Set xfer parameters */ 1227c478bd9Sstevel@tonic-gate struct prn_timeouts usbprn_prn_timeouts; /* prnio timeouts */ 1237c478bd9Sstevel@tonic-gate 1247c478bd9Sstevel@tonic-gate usb_ugen_hdl_t usbprn_ugen_hdl; /* ugen support */ 1257c478bd9Sstevel@tonic-gate } usbprn_state_t; 1267c478bd9Sstevel@tonic-gate 1277c478bd9Sstevel@tonic-gate /* warlock directives, stable data */ 1287c478bd9Sstevel@tonic-gate _NOTE(MUTEX_PROTECTS_DATA(usbprn_state_t::usbprn_mutex, usbprn_state_t)) 1297c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usbprn_state_t::usbprn_dip)) 1307c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usbprn_state_t::usbprn_ugen_hdl)) 1317c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usbprn_state_t::usbprn_pm)) 1327c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usbprn_state_t::usbprn_instance)) 1337c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usbprn_state_t::usbprn_log_handle)) 1347c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usbprn_state_t::usbprn_if_descr)) 1357c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usbprn_state_t::usbprn_dev_data)) 1367c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usbprn_state_t::usbprn_ser_acc)) 1377c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usbprn_state_t::usbprn_write_acc)) 1387c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usbprn_state_t::usbprn_dev_acc)) 1397c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usbprn_state_t::usbprn_def_ph)) 1407c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usbprn_state_t::usbprn_device_id)) 1417c478bd9Sstevel@tonic-gate _NOTE(DATA_READABLE_WITHOUT_LOCK(usbprn_state_t::usbprn_device_id_len)) 1427c478bd9Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("stable data", usb_pipe_policy)) 1437c478bd9Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("unshared data", mblk_t)) 1447c478bd9Sstevel@tonic-gate _NOTE(SCHEME_PROTECTS_DATA("unshared data", usb_bulk_req)) 1457c478bd9Sstevel@tonic-gate 1467c478bd9Sstevel@tonic-gate 1477c478bd9Sstevel@tonic-gate /* Values for usbprn_flags */ 1487c478bd9Sstevel@tonic-gate #define USBPRN_LOCKS_INIT_DONE 0x01 /* locks have been init'ed */ 1497c478bd9Sstevel@tonic-gate #define USBPRN_OPEN 0x02 /* Device is open */ 1507c478bd9Sstevel@tonic-gate 1517c478bd9Sstevel@tonic-gate 1527c478bd9Sstevel@tonic-gate /* Macros */ 1537c478bd9Sstevel@tonic-gate 1547c478bd9Sstevel@tonic-gate /* 1557c478bd9Sstevel@tonic-gate * Check if it the device is not being closed 1567c478bd9Sstevel@tonic-gate * or not being disconnected or not being suspended 1577c478bd9Sstevel@tonic-gate */ 1587c478bd9Sstevel@tonic-gate #define USBPRN_DEVICE_ACCESS_OK(s) \ 1597c478bd9Sstevel@tonic-gate (((s)->usbprn_flags & USBPRN_OPEN) && \ 1607c478bd9Sstevel@tonic-gate (((s)->usbprn_dev_state == USB_DEV_ONLINE))) 1617c478bd9Sstevel@tonic-gate 1627c478bd9Sstevel@tonic-gate /* Check if the pipes are idle or closed */ 1637c478bd9Sstevel@tonic-gate #define USBPRN_PIPES_BUSY(s) \ 1647c478bd9Sstevel@tonic-gate (((s)->usbprn_default.ps_flags != USBPRN_PS_IDLE) || \ 1657c478bd9Sstevel@tonic-gate ((s)->usbprn_bulk_out.ps_flags != USBPRN_PS_IDLE) || \ 1667c478bd9Sstevel@tonic-gate ((s)->usbprn_bulk_in.ps_flags != USBPRN_PS_IDLE)) 1677c478bd9Sstevel@tonic-gate 1687c478bd9Sstevel@tonic-gate /* 1697c478bd9Sstevel@tonic-gate * Debug message Masks 1707c478bd9Sstevel@tonic-gate */ 1717c478bd9Sstevel@tonic-gate #define PRINT_MASK_ATTA 0x00000001 /* attach/detach */ 1727c478bd9Sstevel@tonic-gate #define PRINT_MASK_OPEN 0x00000002 1737c478bd9Sstevel@tonic-gate #define PRINT_MASK_CLOSE 0x00000004 1747c478bd9Sstevel@tonic-gate #define PRINT_MASK_EVENTS 0x00000008 1757c478bd9Sstevel@tonic-gate #define PRINT_MASK_PM 0x00000010 1767c478bd9Sstevel@tonic-gate #define PRINT_MASK_CPR 0x00000020 1777c478bd9Sstevel@tonic-gate #define PRINT_MASK_ALL 0xFFFFFFFF 1787c478bd9Sstevel@tonic-gate 1797c478bd9Sstevel@tonic-gate /* log message breakup */ 1807c478bd9Sstevel@tonic-gate #define USBPRN_PRINT_MAXLINE 80 1817c478bd9Sstevel@tonic-gate 1827c478bd9Sstevel@tonic-gate /* max device id length */ 1837c478bd9Sstevel@tonic-gate #define USBPRN_MAX_DEVICE_ID_LENGTH 1024 1847c478bd9Sstevel@tonic-gate 1857c478bd9Sstevel@tonic-gate /* ugen support */ 1867c478bd9Sstevel@tonic-gate #define USBPRN_MINOR_UGEN_BITS_MASK 0xff 1877c478bd9Sstevel@tonic-gate #define USBPRN_MINOR_INSTANCE_SHIFT 8 1887c478bd9Sstevel@tonic-gate #define USBPRN_MINOR_INSTANCE_MASK ~USBPRN_MINOR_UGEN_BITS_MASK 1897c478bd9Sstevel@tonic-gate #define USBPRN_MINOR_TO_INSTANCE(minor) \ 1907c478bd9Sstevel@tonic-gate (((minor) & USBPRN_MINOR_INSTANCE_MASK) >> \ 1917c478bd9Sstevel@tonic-gate USBPRN_MINOR_INSTANCE_SHIFT) 1927c478bd9Sstevel@tonic-gate 1937c478bd9Sstevel@tonic-gate 1947c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1957c478bd9Sstevel@tonic-gate } 1967c478bd9Sstevel@tonic-gate #endif 1977c478bd9Sstevel@tonic-gate 1987c478bd9Sstevel@tonic-gate #endif /* _SYS_USB_USBPRN_H */ 199