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 2002 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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 /*
37  * ATA disk commands.
38  */
39 
40 #define	ATC_SEEK	0x70    /* seek cmd, bottom 4 bits step rate 	*/
41 #define	ATC_RDVER	0x40	/* read verify cmd			*/
42 #define	ATC_RDSEC	0x20    /* read sector cmd			*/
43 #define	ATC_RDLONG	0x23    /* read long without retry		*/
44 #define	ATC_WRSEC	0x30    /* write sector cmd			*/
45 #define	ATC_SETMULT	0xc6	/* set multiple mode			*/
46 #define	ATC_RDMULT	0xc4	/* read multiple			*/
47 #define	ATC_WRMULT	0xc5	/* write multiple			*/
48 #define	ATC_READ_DMA	0xc8	/* read (multiple) w/DMA		*/
49 #define	ATC_WRITE_DMA	0xca	/* write (multiple) w/DMA		*/
50 #define	ATC_SETPARAM	0x91	/* set parameters command 		*/
51 #define	ATC_ID_DEVICE	0xec    /* IDENTIFY DEVICE command 		*/
52 #define	ATC_ACK_MC	0xdb	/* acknowledge media change		*/
53 	/* ATA extended (48 bit) disk commands */
54 #define	ATC_RDSEC_EXT	0x24	/* read sector */
55 #define	ATC_RDMULT_EXT	0x29	/* read multiple */
56 #define	ATC_RDDMA_EXT	0x25	/* read DMA */
57 #define	ATC_WRSEC_EXT	0x34	/* write sector */
58 #define	ATC_WRMULT_EXT	0x39	/* write multiple */
59 #define	ATC_WRDMA_EXT	0x35	/* write DMA */
60 
61 /*
62  * Low bits for Read/Write commands...
63  */
64 #define	ATCM_ECCRETRY	0x01    /* Enable ECC and RETRY by controller 	*/
65 				/* enabled if bit is CLEARED!!! 	*/
66 #define	ATCM_LONGMODE	0x02    /* Use Long Mode (get/send data & ECC) 	*/
67 
68 #ifdef  DADKIO_RWCMD_READ
69 #define	RWCMDP(pktp)  ((struct dadkio_rwcmd *)((pktp)->cp_bp->b_back))
70 #endif
71 
72 /* useful macros */
73 
74 #define	CPKT2GCMD(cpkt)	((gcmd_t *)(cpkt)->cp_ctl_private)
75 #define	CPKT2APKT(cpkt)  (GCMD2APKT(CPKT2GCMD(cpkt)))
76 
77 #define	GCMD2CPKT(cmdp)	((struct cmpkt *)((cmdp)->cmd_pktp))
78 #define	APKT2CPKT(apkt) (GCMD2CPKT(APKT2GCMD(apkt)))
79 
80 /* public function prototypes */
81 
82 int	ata_disk_attach(ata_ctl_t *ata_ctlp);
83 void	ata_disk_detach(ata_ctl_t *ata_ctlp);
84 int	ata_disk_init_drive(ata_drv_t *ata_drvp);
85 void	ata_disk_uninit_drive(ata_drv_t *ata_drvp);
86 int	ata_disk_id(ddi_acc_handle_t io_hdl1, caddr_t ioaddr1,
87 		ddi_acc_handle_t io_hdl2, caddr_t ioaddr2,
88 		struct ata_id *ata_idp);
89 int	ata_disk_bus_ctl(dev_info_t *d, dev_info_t *r, ddi_ctl_enum_t o,
90 		void *a, void *v);
91 int	ata_disk_setup_parms(ata_ctl_t *ata_ctlp, ata_drv_t *ata_drvp);
92 
93 #ifdef	__cplusplus
94 }
95 #endif
96 
97 #endif /* _ATA_DISK_H */
98