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 /* 23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #ifndef _SYS_DKTP_DADK_H 28 #define _SYS_DKTP_DADK_H 29 30 #pragma ident "%Z%%M% %I% %E% SMI" 31 32 #ifdef __cplusplus 33 extern "C" { 34 #endif 35 36 #include <sys/dktp/tgcom.h> 37 38 struct dadk { 39 struct tgdk_ext *dad_extp; /* back pointer to ext data */ 40 struct scsi_device *dad_sd; /* back pointer to SCSI_DEVICE */ 41 42 struct tgdk_geom dad_logg; /* logical disk geometry */ 43 struct tgdk_geom dad_phyg; /* physical disk geometry */ 44 45 unsigned dad_rmb : 1; /* removable device */ 46 unsigned dad_rdonly : 1; /* read only device */ 47 unsigned dad_cdrom : 1; /* cdrom device */ 48 unsigned dad_resv : 5; 49 unsigned char dad_type; /* device type */ 50 unsigned char dad_ctype; /* controller type */ 51 52 short dad_secshf; 53 short dad_blkshf; 54 55 opaque_t dad_bbhobjp; /* bbh object ptr */ 56 opaque_t dad_flcobjp; /* flow control object ptr */ 57 opaque_t dad_ctlobjp; /* controller object ptr */ 58 struct tgcom_obj dad_com; /* com object for flowctrl */ 59 enum dkio_state dad_iostate; /* ejected/inserted */ 60 kmutex_t dad_mutex; /* protect dad_state */ 61 kcondvar_t dad_state_cv; /* condition variable for state */ 62 uchar_t dad_thread_cnt; /* reference count on removable */ 63 /* - disk state watcher thread */ 64 }; 65 66 #define DAD_SECSIZ dad_phyg.g_secsiz 67 68 /* 69 * Local definitions, for clarity of code 70 */ 71 72 /* 73 * Parameters 74 */ 75 #define DADK_BSY_TIMEOUT (drv_usectohz(5 * 1000000)) 76 #define DADK_IO_TIME 35 77 #define DADK_RETRY_COUNT 5 78 #define DADK_SILENT 1 79 80 #define PKT2DADK(pktp) ((struct dadk *)(pktp)->cp_dev_private) 81 82 /* 83 * packet action codes 84 */ 85 #define COMMAND_DONE 0 86 #define COMMAND_DONE_ERROR 1 87 #define QUE_COMMAND 2 88 #define QUE_SENSE 3 89 #define JUST_RETURN 4 90 91 int dadk_init(opaque_t objp, opaque_t devp, opaque_t flcobjp, 92 opaque_t queobjp, opaque_t bbhobjp, void *lkarg); 93 int dadk_free(struct tgdk_obj *dkobjp); 94 int dadk_probe(opaque_t objp, int kmsflg); 95 int dadk_attach(opaque_t objp); 96 int dadk_open(opaque_t objp, int flag); 97 int dadk_close(opaque_t objp); 98 int dadk_ioctl(opaque_t objp, dev_t dev, int cmd, intptr_t arg, 99 int flag, cred_t *cred_p, int *rval_p); 100 int dadk_strategy(opaque_t objp, struct buf *bp); 101 int dadk_setgeom(opaque_t objp, struct tgdk_geom *dkgeom_p); 102 int dadk_getgeom(opaque_t objp, struct tgdk_geom *dkgeom_p); 103 struct tgdk_iob *dadk_iob_alloc(opaque_t objp, daddr_t blkno, 104 ssize_t xfer, int kmsflg); 105 int dadk_iob_free(opaque_t objp, struct tgdk_iob *iobp); 106 caddr_t dadk_iob_htoc(opaque_t objp, struct tgdk_iob *iobp); 107 caddr_t dadk_iob_xfer(opaque_t objp, struct tgdk_iob *iobp, int rw); 108 int dadk_dump(opaque_t objp, struct buf *bp); 109 int dadk_getphygeom(opaque_t objp, struct tgdk_geom *dkgeom_p); 110 int dadk_set_bbhobj(opaque_t objp, opaque_t bbhobjp); 111 int dadk_check_media(opaque_t objp, int *state); 112 static void dadk_watch_thread(struct dadk *dadkp); 113 int dadk_inquiry(opaque_t objp, opaque_t *inqpp); 114 void dadk_cleanup(struct tgdk_obj *dkobjp); 115 116 #ifdef __cplusplus 117 } 118 #endif 119 120 #endif /* _SYS_DKTP_DADK_H */ 121