xref: /titanic_50/usr/src/uts/common/sys/scsi/adapters/pmcs/atapi7v3.h (revision 4c06356b0f0fffb4fc1b6eccc8e5d8e2254a84d6)
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  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 /*
26  * ATAPI-7 Definitions (subset) that include Serial ATA
27  * ATA/ATAPI-7 V3 (d1532v3r4b-ATA-ATAPI-7)
28  */
29 #ifndef	_ATAPI7V3_H
30 #define	_ATAPI7V3_H
31 #ifdef	__cplusplus
32 extern "C" {
33 #endif
34 
35 /*
36  * Register - Host to Device FIS
37  */
38 typedef struct {
39 	uint8_t 	fis_type;
40 	uint8_t 	idcbits;
41 	uint8_t		cmd;
42 	uint8_t		features;
43 #define	FEATURE_LBA	0x40
44 	uint8_t		lba_low;
45 	uint8_t		lba_mid;
46 	uint8_t		lba_hi;
47 	uint8_t		device;
48 	uint8_t		lba_low_exp;
49 	uint8_t		lba_mid_exp;
50 	uint8_t		lba_hi_exp;
51 	uint8_t		features_exp;
52 	uint8_t		sector_count;
53 	uint8_t		sector_count_exp;
54 	uint8_t		reserved0;
55 	uint8_t		control;
56 	uint8_t		reserved1[4];
57 } register_h2d_fis_t;
58 
59 /*
60  * Register - Device to Host FIS
61  */
62 typedef struct {
63 	uint8_t		fis_type;
64 	uint8_t		idcbits;
65 	uint8_t		status;
66 	uint8_t		error;
67 	uint8_t		lba_low;
68 	uint8_t		lba_mid;
69 	uint8_t		lba_hi;
70 	uint8_t		device;
71 	uint8_t		lba_low_exp;
72 	uint8_t		lba_mid_exp;
73 	uint8_t		lba_hi_exp;
74 	uint8_t		reserved0;
75 	uint8_t		sector_count;
76 	uint8_t		sector_count_exp;
77 	uint8_t		reserved1[6];
78 } register_d2h_fis_t;
79 
80 typedef struct {
81 	uint8_t		fis_type;
82 	uint8_t		idcbits;
83 	uint8_t		status_bits;
84 #define	STATUS_HI_MASK	0xE
85 #define	STATUS_HI_SHIFT	4
86 #define	STATUS_LO_MASK	0x7
87 	uint8_t		error;
88 	uint8_t		reserved;
89 } set_device_bits_fis_t;
90 
91 typedef struct {
92 	uint8_t		fis_type;
93 	uint8_t		reserved[3];
94 } dma_activate_fis_type;
95 
96 typedef struct {
97 	uint8_t		fis_type;
98 	uint8_t		idcbits;
99 	uint8_t		reserved0[2];
100 	uint32_t	dma_buffer_id_lo;
101 	uint32_t	dma_buffer_id_hi;
102 	uint32_t	reserved1;
103 	uint32_t	dma_buffer_offset;
104 	uint32_t	dma_buffer_count;
105 	uint32_t	reserved2;
106 } dma_fpactivate_fis_t;
107 
108 typedef struct {
109 	uint8_t		fis_type;
110 	uint8_t		reserved0;
111 	uint8_t		bist_bits;
112 	uint8_t		reserved1;
113 	uint8_t		data[8];
114 } bist_activate_fis_t;
115 #define	BIST_T	0x80
116 #define	BIST_A	0x40
117 #define	BIST_S	0x20
118 #define	BIST_L	0x10
119 #define	BIST_F	0x08
120 #define	BIST_P	0x04
121 #define	BIST_V	0x01
122 
123 typedef struct {
124 	uint8_t		fis_type;
125 	uint8_t		idcbits;
126 	uint8_t		status;
127 	uint8_t		error;
128 	uint8_t		lba_low;
129 	uint8_t		lba_mid;
130 	uint8_t		lba_high;
131 	uint8_t		device;
132 	uint8_t		lba_low_exp;
133 	uint8_t		lba_mid_exp;
134 	uint8_t		lba_high_exp;
135 	uint8_t		reserved0;
136 	uint8_t		sector_count;
137 	uint8_t		sector_count_exp;
138 	uint8_t		reserved1;
139 	uint8_t		E_status;
140 	uint16_t	transfer_count;
141 	uint16_t	reserved2;
142 } pio_setup_fis_t;
143 
144 typedef struct {
145 	uint8_t		fis_type;
146 	uint32_t	dwords[1];
147 } bidirectional_fis_t;
148 
149 /*
150  * FIS Types
151  */
152 
153 #define	FIS_REG_H2DEV		0x27	/* 5 DWORDS */
154 #define	FIS_REG_D2H		0x34	/* 5 DWORDS */
155 #define	FIS_SET_DEVICE_BITS	0xA1	/* 2 DWORDS */
156 #define	FIS_DMA_ACTIVATE	0x39	/* 1 DWORD */
157 #define	FIS_DMA_FPSETUP		0x41	/* 7 DWORDS */
158 #define	FIS_BIST_ACTIVATE	0x58	/* 3 DWORDS */
159 #define	FIS_PIO_SETUP		0x5F	/* 5 DWORDS */
160 #define	FIS_BI			0x46	/* 1 DWORD min, 2048 DWORD max */
161 
162 /*
163  * IDC bits
164  */
165 #define	C_BIT	0x80
166 #define	I_BIT	0x40
167 #define	D_BIT	0x20
168 
169 /*
170  * 28-Bit Command Mapping from ACS to FIS
171  *
172  * ACS Field       	FIS Field
173  * --------------------------------------
174  * Feature (7:0)	-> Feature
175  * Count (7:0)		-> Sector Count
176  * LBA (7:0)		-> LBA Low
177  * LBA (15:8)		-> LBA Mid
178  * LBA (23:16)		-> LBA High
179  * LBA (27:24)		-> Device (3:0)
180  * Device (15:12)	-> Device (7:4)
181  * Command		-> Command
182  *
183  * 48- Bit Command Mapping from ACS to FIS
184  *
185  * ACS Field       	FIS Field
186  * --------------------------------------
187  * Feature (7:0)	-> Feature
188  * Feature (15:8)	-> Feature (exp)
189  * Count (7:0)		-> Sector Count
190  * Count (15:8)		-> Sector Count (exp)
191  * LBA (7:0)		-> LBA Low
192  * LBA (15:8)		-> LBA Mid
193  * LBA (23:16)		-> LBA High
194  * LBA (31:24)		-> LBA Low (exp)
195  * LBA (39:32)		-> LBA Mid (exp)
196  * LBA (47:40)		-> LBA High (exp)
197  * Device (15:12)	-> Device (7:4)
198  * Command		-> Command
199  *
200  * FIS (FIS_REG_H2DEV) layout:
201  *
202  * 31.........24 23...........16 15....................8.7.............0
203  * FEATURE	| COMMAND	| C R R RESERVED	| FIS TYPE 0x27
204  * DEVICE   	| LBA HIGH	| LBA MID		| LBA LOW
205  * FEATURE(exp)	| LBA HIGH(exp)	| LBA MID(exp)		| LBA LOW(exp)
206  * CONTROL	| RESERVED	| Sector Count(exp)	| Sector Count
207  * RESERVED 	| RESERVED	| RESERVED		| RESERVED
208  *
209  * FIS (FIS_REG_D2H) layout:
210  *
211  * 31.........24 23...........16 15....................8.7.............0
212  * ERROR        | STATUS        | R I R RESERVED	| FIS TYPE 0x34
213  * DEVICE   	| LBA HIGH	| LBA MID		| LBA LOW
214  * RESERVED	| LBA HIGH(exp)	| LBA MID(exp)		| LBA LOW(exp)
215  * RESERVED 	| RESERVED	| Sector Count(exp)	| Sector Count
216  * RESERVED 	| RESERVED	| RESERVED		| RESERVED
217  */
218 
219 
220 /*
221  * Reasonable size to reserve for holding the most common FIS types.
222  */
223 typedef	uint32_t fis_t[5];
224 
225 #ifdef	__cplusplus
226 }
227 #endif
228 #endif	/* _ATAPI7V3_H */
229