1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * Copyright (c) 1996 Sun Microsystems, Inc. All Rights Reserved. 3*7c478bd9Sstevel@tonic-gate */ 4*7c478bd9Sstevel@tonic-gate 5*7c478bd9Sstevel@tonic-gate #ifndef _ATAPI_H 6*7c478bd9Sstevel@tonic-gate #define _ATAPI_H 7*7c478bd9Sstevel@tonic-gate 8*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 9*7c478bd9Sstevel@tonic-gate 10*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 11*7c478bd9Sstevel@tonic-gate extern "C" { 12*7c478bd9Sstevel@tonic-gate #endif 13*7c478bd9Sstevel@tonic-gate 14*7c478bd9Sstevel@tonic-gate #include <sys/scsi/scsi.h> 15*7c478bd9Sstevel@tonic-gate 16*7c478bd9Sstevel@tonic-gate /* 17*7c478bd9Sstevel@tonic-gate * Additional atapi status bits (redefinitions) 18*7c478bd9Sstevel@tonic-gate */ 19*7c478bd9Sstevel@tonic-gate #define ATE_ILI 0x01 /* Illegal length indication */ 20*7c478bd9Sstevel@tonic-gate #define ATE_EOM 0x02 /* End of media detected */ 21*7c478bd9Sstevel@tonic-gate #define ATE_MCR 0x08 /* Media change requested */ 22*7c478bd9Sstevel@tonic-gate #define ATS_SERVICE 0x10 /* overlap operation needs service */ 23*7c478bd9Sstevel@tonic-gate #define ATS_SENSE_KEY 0xf0 /* 4 bit sense key -see ata_sense_table */ 24*7c478bd9Sstevel@tonic-gate 25*7c478bd9Sstevel@tonic-gate #define ATS_SENSE_KEY_SHIFT 4 /* shift to get to ATS_SENSE_KEY */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate /* 28*7c478bd9Sstevel@tonic-gate * Status bits from ATAPI Interrupt reason register (AT_COUNT) register 29*7c478bd9Sstevel@tonic-gate */ 30*7c478bd9Sstevel@tonic-gate #define ATI_COD 0x01 /* Command or Data */ 31*7c478bd9Sstevel@tonic-gate #define ATI_IO 0x02 /* IO direction */ 32*7c478bd9Sstevel@tonic-gate #define ATI_RELEASE 0x04 /* Release for ATAPI overlap */ 33*7c478bd9Sstevel@tonic-gate 34*7c478bd9Sstevel@tonic-gate /* ATAPI feature reg definitions */ 35*7c478bd9Sstevel@tonic-gate 36*7c478bd9Sstevel@tonic-gate #define ATF_OVERLAP 0x02 37*7c478bd9Sstevel@tonic-gate 38*7c478bd9Sstevel@tonic-gate /* 39*7c478bd9Sstevel@tonic-gate * ATAPI commands. 40*7c478bd9Sstevel@tonic-gate */ 41*7c478bd9Sstevel@tonic-gate #define ATC_PI_SRESET 0x08 /* ATAPI soft reset */ 42*7c478bd9Sstevel@tonic-gate #define ATC_PI_ID_DEV 0xa1 /* ATAPI identify device */ 43*7c478bd9Sstevel@tonic-gate #define ATC_PI_PKT 0xa0 /* ATAPI packet command */ 44*7c478bd9Sstevel@tonic-gate #define ATC_PI_SERVICE 0xa2 /* ATAPI overlap service command */ 45*7c478bd9Sstevel@tonic-gate 46*7c478bd9Sstevel@tonic-gate /* 47*7c478bd9Sstevel@tonic-gate * ATAPI IDENTIFY_DRIVE configuration word 48*7c478bd9Sstevel@tonic-gate */ 49*7c478bd9Sstevel@tonic-gate #define ATAPI_ID_CFG_PKT_SZ 0x3 50*7c478bd9Sstevel@tonic-gate #define ATAPI_ID_CFG_PKT_12B 0x0 51*7c478bd9Sstevel@tonic-gate #define ATAPI_ID_CFG_PKT_16B 0x1 52*7c478bd9Sstevel@tonic-gate #define ATAPI_ID_CFG_DRQ_TYPE 0x60 53*7c478bd9Sstevel@tonic-gate #define ATAPI_ID_CFG_DRQ_INTR 0x20 54*7c478bd9Sstevel@tonic-gate #define ATAPI_ID_CFG_DEV_TYPE 0x0f00 55*7c478bd9Sstevel@tonic-gate #define ATAPI_ID_CFG_DEV_SHFT 8 56*7c478bd9Sstevel@tonic-gate 57*7c478bd9Sstevel@tonic-gate /* 58*7c478bd9Sstevel@tonic-gate * ATAPI IDENTIFY_DRIVE capabilities word 59*7c478bd9Sstevel@tonic-gate */ 60*7c478bd9Sstevel@tonic-gate #define ATAPI_ID_CAP_DMA 0x0100 61*7c478bd9Sstevel@tonic-gate #define ATAPI_ID_CAP_OVERLAP 0x2000 62*7c478bd9Sstevel@tonic-gate 63*7c478bd9Sstevel@tonic-gate /* 64*7c478bd9Sstevel@tonic-gate * ATAPI SET FEATURE commands 65*7c478bd9Sstevel@tonic-gate */ 66*7c478bd9Sstevel@tonic-gate #define ATAPI_FEAT_RELEASE_INTR 0x5d 67*7c478bd9Sstevel@tonic-gate #define ATAPI_FEAT_SERVICE_INTR 0x5e 68*7c478bd9Sstevel@tonic-gate 69*7c478bd9Sstevel@tonic-gate /* 70*7c478bd9Sstevel@tonic-gate * ATAPI bits 71*7c478bd9Sstevel@tonic-gate */ 72*7c478bd9Sstevel@tonic-gate #define ATAPI_SIG_HI 0xeb /* in high cylinder register */ 73*7c478bd9Sstevel@tonic-gate #define ATAPI_SIG_LO 0x14 /* in low cylinder register */ 74*7c478bd9Sstevel@tonic-gate 75*7c478bd9Sstevel@tonic-gate #define ATAPIDRV(X) ((X)->ad_flags & AD_ATAPI) 76*7c478bd9Sstevel@tonic-gate #define ATAPIPKT(X) ((X)->ap_flags & AP_ATAPI) 77*7c478bd9Sstevel@tonic-gate 78*7c478bd9Sstevel@tonic-gate #define ATAPI_SECTOR_SIZE 2048 79*7c478bd9Sstevel@tonic-gate #define ATAPI_MAX_BYTES_PER_DRQ 0xf800 /* 16 bits - 2KB ie 62KB */ 80*7c478bd9Sstevel@tonic-gate #define ATAPI_HEADS 64 81*7c478bd9Sstevel@tonic-gate #define ATAPI_SECTORS_PER_TRK 32 82*7c478bd9Sstevel@tonic-gate 83*7c478bd9Sstevel@tonic-gate /* 84*7c478bd9Sstevel@tonic-gate * Useful macros 85*7c478bd9Sstevel@tonic-gate */ 86*7c478bd9Sstevel@tonic-gate #define TRAN2CTL(tran) ((struct ata_controller *)((tran)->tran_hba_private)) 87*7c478bd9Sstevel@tonic-gate #define ADDR2CTL(ap) (TRAN2CTL(ADDR2TRAN(ap))) 88*7c478bd9Sstevel@tonic-gate 89*7c478bd9Sstevel@tonic-gate #define SPKT2APKT(spkt) (GCMD2APKT(PKTP2GCMDP(spkt))) 90*7c478bd9Sstevel@tonic-gate #define APKT2SPKT(apkt) (GCMDP2PKTP(APKT2GCMD(apkt))) 91*7c478bd9Sstevel@tonic-gate 92*7c478bd9Sstevel@tonic-gate #define SADR2CHNO(ap) (((ap)->a_target > 1) ? 1 : 0) 93*7c478bd9Sstevel@tonic-gate 94*7c478bd9Sstevel@tonic-gate 95*7c478bd9Sstevel@tonic-gate /* 96*7c478bd9Sstevel@tonic-gate * public function prototypes 97*7c478bd9Sstevel@tonic-gate */ 98*7c478bd9Sstevel@tonic-gate int atapi_init(struct ata_controller *ata_ctlp); 99*7c478bd9Sstevel@tonic-gate void atapi_destroy(struct ata_controller *ata_ctlp); 100*7c478bd9Sstevel@tonic-gate int atapi_init_drive(struct ata_drive *ata_drvp); 101*7c478bd9Sstevel@tonic-gate void atapi_destroy_drive(struct ata_drive *ata_drvp); 102*7c478bd9Sstevel@tonic-gate 103*7c478bd9Sstevel@tonic-gate int atapi_id(ddi_acc_handle_t handle, uint8_t *ioaddr, ushort_t *buf); 104*7c478bd9Sstevel@tonic-gate int atapi_signature(ddi_acc_handle_t handle, uint8_t *ioaddr); 105*7c478bd9Sstevel@tonic-gate 106*7c478bd9Sstevel@tonic-gate int atapi_reset_drive(struct ata_drive *ata_drvp); 107*7c478bd9Sstevel@tonic-gate 108*7c478bd9Sstevel@tonic-gate int atapi_ccballoc(gtgt_t *gtgtp, gcmd_t *gcmdp, int cmdlen, 109*7c478bd9Sstevel@tonic-gate int statuslen, int tgtlen, int ccblen); 110*7c478bd9Sstevel@tonic-gate void atapi_ccbfree(gcmd_t *gcmdp); 111*7c478bd9Sstevel@tonic-gate 112*7c478bd9Sstevel@tonic-gate #ifdef DSC_OVERLAP_SUPPORT 113*7c478bd9Sstevel@tonic-gate void atapi_dsc_poll(struct ata_drive *ata_drvp); 114*7c478bd9Sstevel@tonic-gate #endif 115*7c478bd9Sstevel@tonic-gate 116*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 117*7c478bd9Sstevel@tonic-gate } 118*7c478bd9Sstevel@tonic-gate #endif 119*7c478bd9Sstevel@tonic-gate 120*7c478bd9Sstevel@tonic-gate #endif /* _ATAPI_H */ 121