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 (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 22 /* 23 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #ifndef _ATA_DISK_H 28 #define _ATA_DISK_H 29 30 #ifdef __cplusplus 31 extern "C" { 32 #endif 33 34 /* 35 * ATA disk commands. 36 */ 37 38 #define ATC_SEEK 0x70 /* seek cmd, bottom 4 bits step rate */ 39 #define ATC_RDVER 0x40 /* read verify cmd */ 40 #define ATC_RDSEC 0x20 /* read sector cmd */ 41 #define ATC_RDLONG 0x23 /* read long without retry */ 42 #define ATC_WRSEC 0x30 /* write sector cmd */ 43 #define ATC_SETMULT 0xc6 /* set multiple mode */ 44 #define ATC_RDMULT 0xc4 /* read multiple */ 45 #define ATC_WRMULT 0xc5 /* write multiple */ 46 #define ATC_READ_DMA 0xc8 /* read (multiple) w/DMA */ 47 #define ATC_WRITE_DMA 0xca /* write (multiple) w/DMA */ 48 #define ATC_SETPARAM 0x91 /* set parameters command */ 49 #define ATC_ID_DEVICE 0xec /* IDENTIFY DEVICE command */ 50 #define ATC_ACK_MC 0xdb /* acknowledge media change */ 51 #define ATC_LOAD_FW 0x92 /* download microcode */ 52 /* ATA extended (48 bit) disk commands */ 53 #define ATC_RDSEC_EXT 0x24 /* read sector */ 54 #define ATC_RDMULT_EXT 0x29 /* read multiple */ 55 #define ATC_RDDMA_EXT 0x25 /* read DMA */ 56 #define ATC_WRSEC_EXT 0x34 /* write sector */ 57 #define ATC_WRMULT_EXT 0x39 /* write multiple */ 58 #define ATC_WRDMA_EXT 0x35 /* write DMA */ 59 60 /* 61 * Low bits for Read/Write commands... 62 */ 63 #define ATCM_ECCRETRY 0x01 /* Enable ECC and RETRY by controller */ 64 /* enabled if bit is CLEARED!!! */ 65 #define ATCM_LONGMODE 0x02 /* Use Long Mode (get/send data & ECC) */ 66 67 /* 68 * subcommand for DOWNLOAD MICROCODE command 69 */ 70 #define ATCM_FW_TEMP 0x01 /* immediate, temporary use */ 71 #define ATCM_FW_MULTICMD 0x03 /* immediate and future use */ 72 #define ATCM_FW_PERM 0x07 /* immediate and future use */ 73 74 #ifdef DADKIO_RWCMD_READ 75 #define RWCMDP(pktp) ((struct dadkio_rwcmd *)((pktp)->cp_bp->b_back)) 76 #endif 77 78 /* useful macros */ 79 80 #define CPKT2GCMD(cpkt) ((gcmd_t *)(cpkt)->cp_ctl_private) 81 #define CPKT2APKT(cpkt) (GCMD2APKT(CPKT2GCMD(cpkt))) 82 83 #define GCMD2CPKT(cmdp) ((struct cmpkt *)((cmdp)->cmd_pktp)) 84 #define APKT2CPKT(apkt) (GCMD2CPKT(APKT2GCMD(apkt))) 85 86 /* public function prototypes */ 87 88 int ata_disk_attach(ata_ctl_t *ata_ctlp); 89 void ata_disk_detach(ata_ctl_t *ata_ctlp); 90 int ata_disk_init_drive(ata_drv_t *ata_drvp); 91 void ata_disk_uninit_drive(ata_drv_t *ata_drvp); 92 int ata_disk_id(ddi_acc_handle_t io_hdl1, caddr_t ioaddr1, 93 ddi_acc_handle_t io_hdl2, caddr_t ioaddr2, 94 struct ata_id *ata_idp); 95 int ata_disk_bus_ctl(dev_info_t *d, dev_info_t *r, ddi_ctl_enum_t o, 96 void *a, void *v); 97 int ata_disk_setup_parms(ata_ctl_t *ata_ctlp, ata_drv_t *ata_drvp); 98 99 #ifdef __cplusplus 100 } 101 #endif 102 103 #endif /* _ATA_DISK_H */ 104