xref: /freebsd/sys/dev/isci/scil/sati_mode_sense_10.c (revision 685dc743dc3b5645e34836464128e1c0558b404b)
1f11c7f63SJim Harris /*-
2*718cf2ccSPedro F. Giffuni  * SPDX-License-Identifier: BSD-2-Clause OR GPL-2.0
3*718cf2ccSPedro F. Giffuni  *
4f11c7f63SJim Harris  * This file is provided under a dual BSD/GPLv2 license.  When using or
5f11c7f63SJim Harris  * redistributing this file, you may do so under either license.
6f11c7f63SJim Harris  *
7f11c7f63SJim Harris  * GPL LICENSE SUMMARY
8f11c7f63SJim Harris  *
9f11c7f63SJim Harris  * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
10f11c7f63SJim Harris  *
11f11c7f63SJim Harris  * This program is free software; you can redistribute it and/or modify
12f11c7f63SJim Harris  * it under the terms of version 2 of the GNU General Public License as
13f11c7f63SJim Harris  * published by the Free Software Foundation.
14f11c7f63SJim Harris  *
15f11c7f63SJim Harris  * This program is distributed in the hope that it will be useful, but
16f11c7f63SJim Harris  * WITHOUT ANY WARRANTY; without even the implied warranty of
17f11c7f63SJim Harris  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18f11c7f63SJim Harris  * General Public License for more details.
19f11c7f63SJim Harris  *
20f11c7f63SJim Harris  * You should have received a copy of the GNU General Public License
21f11c7f63SJim Harris  * along with this program; if not, write to the Free Software
22f11c7f63SJim Harris  * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
23f11c7f63SJim Harris  * The full GNU General Public License is included in this distribution
24f11c7f63SJim Harris  * in the file called LICENSE.GPL.
25f11c7f63SJim Harris  *
26f11c7f63SJim Harris  * BSD LICENSE
27f11c7f63SJim Harris  *
28f11c7f63SJim Harris  * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
29f11c7f63SJim Harris  * All rights reserved.
30f11c7f63SJim Harris  *
31f11c7f63SJim Harris  * Redistribution and use in source and binary forms, with or without
32f11c7f63SJim Harris  * modification, are permitted provided that the following conditions
33f11c7f63SJim Harris  * are met:
34f11c7f63SJim Harris  *
35f11c7f63SJim Harris  *   * Redistributions of source code must retain the above copyright
36f11c7f63SJim Harris  *     notice, this list of conditions and the following disclaimer.
37f11c7f63SJim Harris  *   * Redistributions in binary form must reproduce the above copyright
38f11c7f63SJim Harris  *     notice, this list of conditions and the following disclaimer in
39f11c7f63SJim Harris  *     the documentation and/or other materials provided with the
40f11c7f63SJim Harris  *     distribution.
41f11c7f63SJim Harris  *
42f11c7f63SJim Harris  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
43f11c7f63SJim Harris  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
44f11c7f63SJim Harris  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
45f11c7f63SJim Harris  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
46f11c7f63SJim Harris  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
47f11c7f63SJim Harris  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
48f11c7f63SJim Harris  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
49f11c7f63SJim Harris  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
50f11c7f63SJim Harris  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
51f11c7f63SJim Harris  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
52f11c7f63SJim Harris  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
53f11c7f63SJim Harris  */
54f11c7f63SJim Harris 
55f11c7f63SJim Harris #include <sys/cdefs.h>
56f11c7f63SJim Harris /**
57f11c7f63SJim Harris  * @file
58f11c7f63SJim Harris  * @brief This file contains the method implementations required to
59f11c7f63SJim Harris  *        translate the SCSI mode sense 10-byte commands.
60f11c7f63SJim Harris  */
61f11c7f63SJim Harris 
62f11c7f63SJim Harris #if !defined(DISABLE_SATI_MODE_SENSE)
63f11c7f63SJim Harris 
64f11c7f63SJim Harris #include <dev/isci/scil/sati_mode_sense.h>
65f11c7f63SJim Harris #include <dev/isci/scil/sati_mode_sense_10.h>
66f11c7f63SJim Harris #include <dev/isci/scil/sati_mode_pages.h>
67f11c7f63SJim Harris #include <dev/isci/scil/sati_callbacks.h>
68f11c7f63SJim Harris #include <dev/isci/scil/sati_util.h>
69f11c7f63SJim Harris #include <dev/isci/scil/intel_scsi.h>
70f11c7f63SJim Harris #include <dev/isci/scil/intel_ata.h>
71f11c7f63SJim Harris 
72f11c7f63SJim Harris //******************************************************************************
73f11c7f63SJim Harris //* P R I V A T E   M E T H O D S
74f11c7f63SJim Harris //******************************************************************************
75f11c7f63SJim Harris 
76f11c7f63SJim Harris /**
77f11c7f63SJim Harris  * @brief This method builds the mode parameter header for a 10-byte SCSI
78f11c7f63SJim Harris  *        mode sense data response.  The parameter header is 4 bytes in
79f11c7f63SJim Harris  *        size.
80f11c7f63SJim Harris  *        For more information on the parameters passed to this method,
81f11c7f63SJim Harris  *        please reference sati_translate_command().
82f11c7f63SJim Harris  *
83f11c7f63SJim Harris  * @param[in] identify This parameter specifies the ATA remote device's
84f11c7f63SJim Harris  *            received IDENTIFY DEVICE data.
85f11c7f63SJim Harris  * @param[in] mode_data_length This parameter specifies the amount of data
86f11c7f63SJim Harris  *            to be returned as part of this mode sense request.
87f11c7f63SJim Harris  *
88f11c7f63SJim Harris  * @return This method returns the number of bytes written into the
89f11c7f63SJim Harris  *         mode sense data buffer.
90f11c7f63SJim Harris  */
91f11c7f63SJim Harris static
sati_mode_sense_10_build_header(SATI_TRANSLATOR_SEQUENCE_T * sequence,void * scsi_io,ATA_IDENTIFY_DEVICE_DATA_T * identify,U16 mode_data_length)92f11c7f63SJim Harris U32 sati_mode_sense_10_build_header(
93f11c7f63SJim Harris    SATI_TRANSLATOR_SEQUENCE_T * sequence,
94f11c7f63SJim Harris    void                       * scsi_io,
95f11c7f63SJim Harris    ATA_IDENTIFY_DEVICE_DATA_T * identify,
96f11c7f63SJim Harris    U16                          mode_data_length
97f11c7f63SJim Harris )
98f11c7f63SJim Harris {
99f11c7f63SJim Harris    U8 * cdb = sati_cb_get_cdb_address(scsi_io);
100f11c7f63SJim Harris 
101f11c7f63SJim Harris    // Fill in the length of the mode parameter data returned (do not include
102f11c7f63SJim Harris    // the size of the mode data length field in the total).  Adjust the
103f11c7f63SJim Harris    // mode data length to not include the mode data length fields itself
104f11c7f63SJim Harris    // (i.e. subtract 2).
105f11c7f63SJim Harris    mode_data_length -= 2;
106f11c7f63SJim Harris    sati_set_data_byte(sequence, scsi_io, 0, (U8)(mode_data_length >> 8) & 0xFF);
107f11c7f63SJim Harris    sati_set_data_byte(sequence, scsi_io, 1, (U8)(mode_data_length & 0xFF));
108f11c7f63SJim Harris 
109f11c7f63SJim Harris    // Medium Type is 0 for SBC devices
110f11c7f63SJim Harris    sati_set_data_byte(sequence, scsi_io, 2, SCSI_MODE_HEADER_MEDIUM_TYPE_SBC);
111f11c7f63SJim Harris 
112f11c7f63SJim Harris    // Write Protect (WP), Rsvd, DPOFUA, Rsvd
113f11c7f63SJim Harris    if (sequence->device->capabilities & SATI_DEVICE_CAP_DMA_FUA_ENABLE)
114f11c7f63SJim Harris       sati_set_data_byte(sequence,scsi_io,3,SCSI_MODE_SENSE_HEADER_FUA_ENABLE);
115f11c7f63SJim Harris    else
116f11c7f63SJim Harris       sati_set_data_byte(sequence, scsi_io, 3, 0);
117f11c7f63SJim Harris 
118f11c7f63SJim Harris    // Set the reserved bytes to 0.  The LONGLBA field in byte 4 is overridden
119f11c7f63SJim Harris    // later in this method if LLBAA is enabled.
120f11c7f63SJim Harris    sati_set_data_byte(sequence, scsi_io, 4, 0);
121f11c7f63SJim Harris    sati_set_data_byte(sequence, scsi_io, 5, 0);
122f11c7f63SJim Harris 
123f11c7f63SJim Harris    // The MSB for the block descriptor length is never used since the
124f11c7f63SJim Harris    // largest block descriptor in this translator is 16-bytes in size.
125f11c7f63SJim Harris    sati_set_data_byte(sequence, scsi_io, 6, 0);
126f11c7f63SJim Harris 
127f11c7f63SJim Harris    // Set the LSB block descriptor length if block descriptors are utilized.
128f11c7f63SJim Harris    if (sati_get_cdb_byte(cdb, 1) & SCSI_MODE_SENSE_DBD_ENABLE)
129f11c7f63SJim Harris       sati_set_data_byte(sequence, scsi_io, 7, 0);
130f11c7f63SJim Harris    else
131f11c7f63SJim Harris    {
132f11c7f63SJim Harris       // If Long Logical Block Address are allowed, then the block descriptor
133f11c7f63SJim Harris       // is larger (16 bytes total).
134f11c7f63SJim Harris       if (sati_get_cdb_byte(cdb, 1) & SCSI_MODE_SENSE_LLBAA_ENABLE)
135f11c7f63SJim Harris       {
136f11c7f63SJim Harris          sati_set_data_byte(sequence, scsi_io, 4, 1);
137f11c7f63SJim Harris          sati_set_data_byte(
138f11c7f63SJim Harris             sequence, scsi_io, 7, SCSI_MODE_SENSE_LLBA_BLOCK_DESCRIPTOR_LENGTH
139f11c7f63SJim Harris          );
140f11c7f63SJim Harris       }
141f11c7f63SJim Harris       else
142f11c7f63SJim Harris       {
143f11c7f63SJim Harris          sati_set_data_byte(
144f11c7f63SJim Harris             sequence, scsi_io, 7, SCSI_MODE_SENSE_STD_BLOCK_DESCRIPTOR_LENGTH
145f11c7f63SJim Harris          );
146f11c7f63SJim Harris       }
147f11c7f63SJim Harris    }
148f11c7f63SJim Harris 
149f11c7f63SJim Harris    return SCSI_MODE_SENSE_10_HEADER_LENGTH;
150f11c7f63SJim Harris }
151f11c7f63SJim Harris 
152f11c7f63SJim Harris static
sati_mode_sense_10_build_llba_block_descriptor(SATI_TRANSLATOR_SEQUENCE_T * sequence,void * scsi_io,ATA_IDENTIFY_DEVICE_DATA_T * identify,U32 offset)153f11c7f63SJim Harris U32 sati_mode_sense_10_build_llba_block_descriptor(
154f11c7f63SJim Harris    SATI_TRANSLATOR_SEQUENCE_T * sequence,
155f11c7f63SJim Harris    void                       * scsi_io,
156f11c7f63SJim Harris    ATA_IDENTIFY_DEVICE_DATA_T * identify,
157f11c7f63SJim Harris    U32                          offset
158f11c7f63SJim Harris )
159f11c7f63SJim Harris {
160f11c7f63SJim Harris    U32  lba_low     = 0;
161f11c7f63SJim Harris    U32  lba_high    = 0;
162f11c7f63SJim Harris    U32  sector_size = 0;
163f11c7f63SJim Harris 
164f11c7f63SJim Harris    // Extract the sector information (sector size, logical blocks) from
165f11c7f63SJim Harris    // the retrieved ATA identify device data.
166f11c7f63SJim Harris    sati_ata_identify_device_get_sector_info(
167f11c7f63SJim Harris       identify, &lba_low, &lba_high, &sector_size
168f11c7f63SJim Harris    );
169f11c7f63SJim Harris 
170f11c7f63SJim Harris    // Fill in the 8-byte logical block area
171f11c7f63SJim Harris    sati_set_data_byte(sequence, scsi_io, offset,   (U8)((lba_high>>24) & 0xFF));
172f11c7f63SJim Harris    sati_set_data_byte(sequence, scsi_io, offset+1, (U8)((lba_high>>16) & 0xFF));
173f11c7f63SJim Harris    sati_set_data_byte(sequence, scsi_io, offset+2, (U8)((lba_high>>8)  & 0xFF));
174f11c7f63SJim Harris    sati_set_data_byte(sequence, scsi_io, offset+3, (U8)(lba_high & 0xFF));
175f11c7f63SJim Harris    sati_set_data_byte(sequence, scsi_io, offset+4, (U8)((lba_low>>24) & 0xFF));
176f11c7f63SJim Harris    sati_set_data_byte(sequence, scsi_io, offset+5, (U8)((lba_low>>16) & 0xFF));
177f11c7f63SJim Harris    sati_set_data_byte(sequence, scsi_io, offset+6, (U8)((lba_low>>8)  & 0xFF));
178f11c7f63SJim Harris    sati_set_data_byte(sequence, scsi_io, offset+7, (U8)(lba_low & 0xFF));
179f11c7f63SJim Harris 
180f11c7f63SJim Harris    // Clear the reserved fields.
181f11c7f63SJim Harris    sati_set_data_byte(sequence, scsi_io, offset+8, 0);
182f11c7f63SJim Harris    sati_set_data_byte(sequence, scsi_io, offset+9, 0);
183f11c7f63SJim Harris    sati_set_data_byte(sequence, scsi_io, offset+10, 0);
184f11c7f63SJim Harris    sati_set_data_byte(sequence, scsi_io, offset+11, 0);
185f11c7f63SJim Harris 
186f11c7f63SJim Harris    // Fill in the four byte Block Length field
187f11c7f63SJim Harris    sati_set_data_byte(sequence,scsi_io, offset+12, (U8)((sector_size>>24) & 0xFF));
188f11c7f63SJim Harris    sati_set_data_byte(sequence,scsi_io, offset+13, (U8)((sector_size>>16) & 0xFF));
189f11c7f63SJim Harris    sati_set_data_byte(sequence,scsi_io, offset+14, (U8)((sector_size>>8)  & 0xFF));
190f11c7f63SJim Harris    sati_set_data_byte(sequence,scsi_io, offset+15, (U8)(sector_size & 0xFF));
191f11c7f63SJim Harris 
192f11c7f63SJim Harris    return SCSI_MODE_SENSE_LLBA_BLOCK_DESCRIPTOR_LENGTH;
193f11c7f63SJim Harris }
194f11c7f63SJim Harris 
195f11c7f63SJim Harris /**
196f11c7f63SJim Harris  * @brief This method perform the data translation common to all SCSI MODE
197f11c7f63SJim Harris  *        SENSE 10 byte commands.  This includes building the mode page
198f11c7f63SJim Harris  *        header and block descriptor (if requested).
199f11c7f63SJim Harris  *        For more information on the parameters passed to this method,
200f11c7f63SJim Harris  *        please reference sati_translate_command().
201f11c7f63SJim Harris  *
202f11c7f63SJim Harris  * @param[in] identify This parameter specifies the remote device's IDENTIFY
203f11c7f63SJim Harris  *            DEVICE data to be used during translation.
204f11c7f63SJim Harris  * @param[in] transfer_length This parameter specifies the size of the
205f11c7f63SJim Harris  *            mode page (including header & block descriptor).
206f11c7f63SJim Harris  *
207f11c7f63SJim Harris  * @return This method returns the number of bytes written into the user's
208f11c7f63SJim Harris  *         mode page data buffer.
209f11c7f63SJim Harris  */
210f11c7f63SJim Harris static
sati_mode_sense_10_translate_data(SATI_TRANSLATOR_SEQUENCE_T * sequence,ATA_IDENTIFY_DEVICE_DATA_T * identify,void * scsi_io,U16 transfer_length)211f11c7f63SJim Harris U32 sati_mode_sense_10_translate_data(
212f11c7f63SJim Harris    SATI_TRANSLATOR_SEQUENCE_T * sequence,
213f11c7f63SJim Harris    ATA_IDENTIFY_DEVICE_DATA_T * identify,
214f11c7f63SJim Harris    void                       * scsi_io,
215f11c7f63SJim Harris    U16                          transfer_length
216f11c7f63SJim Harris )
217f11c7f63SJim Harris {
218f11c7f63SJim Harris    U8  * cdb = sati_cb_get_cdb_address(scsi_io);
219f11c7f63SJim Harris    U32   offset;
220f11c7f63SJim Harris 
221f11c7f63SJim Harris    offset = sati_mode_sense_10_build_header(
222f11c7f63SJim Harris                sequence, scsi_io, identify, transfer_length
223f11c7f63SJim Harris             );
224f11c7f63SJim Harris 
225f11c7f63SJim Harris    // Determine if the caller disabled block descriptors (DBD).  If not,
226f11c7f63SJim Harris    // then generate a block descriptor.
227f11c7f63SJim Harris    if ((sati_get_cdb_byte(cdb, 1) & SCSI_MODE_SENSE_DBD_ENABLE) == 0)
228f11c7f63SJim Harris    {
229f11c7f63SJim Harris       // If the user requested the Long LBA format descriptor, then build
230f11c7f63SJim Harris       // it
231f11c7f63SJim Harris       if (sati_get_cdb_byte(cdb, 1) & SCSI_MODE_SENSE_LLBAA_ENABLE)
232f11c7f63SJim Harris          offset += sati_mode_sense_10_build_llba_block_descriptor(
233f11c7f63SJim Harris                       sequence, scsi_io, identify, offset
234f11c7f63SJim Harris                    );
235f11c7f63SJim Harris       else
236f11c7f63SJim Harris          offset += sati_mode_sense_build_std_block_descriptor(
237f11c7f63SJim Harris                       sequence, scsi_io, identify, offset
238f11c7f63SJim Harris                    );
239f11c7f63SJim Harris    }
240f11c7f63SJim Harris 
241f11c7f63SJim Harris    return offset;
242f11c7f63SJim Harris }
243f11c7f63SJim Harris 
244f11c7f63SJim Harris //******************************************************************************
245f11c7f63SJim Harris //* P R O T E C T E D   M E T H O D S
246f11c7f63SJim Harris //******************************************************************************
247f11c7f63SJim Harris 
248f11c7f63SJim Harris /**
249f11c7f63SJim Harris  * @brief This method will translate the SCSI mode sense 6 byte command
250f11c7f63SJim Harris  *        into corresponding ATA commands.  If the command is well-formed,
251f11c7f63SJim Harris  *        then the translation will result in an ATA IDENTIFY DEVICE
252f11c7f63SJim Harris  *        command.
253f11c7f63SJim Harris  *        For more information on the parameters passed to this method,
254f11c7f63SJim Harris  *        please reference sati_translate_command().
255f11c7f63SJim Harris  *
256f11c7f63SJim Harris  * @return Indicate if the command translation succeeded.
257f11c7f63SJim Harris  * @retval SCI_SUCCESS This is returned if the command translation was
258f11c7f63SJim Harris  *         successful.
259f11c7f63SJim Harris  * @retval SATI_FAILURE_CHECK_RESPONSE_DATA This value is returned if
260f11c7f63SJim Harris  *         sense data has been created as a result of something specified
261f11c7f63SJim Harris  *         in the CDB.
262f11c7f63SJim Harris  */
sati_mode_sense_10_translate_command(SATI_TRANSLATOR_SEQUENCE_T * sequence,void * scsi_io,void * ata_io)263f11c7f63SJim Harris SATI_STATUS sati_mode_sense_10_translate_command(
264f11c7f63SJim Harris    SATI_TRANSLATOR_SEQUENCE_T * sequence,
265f11c7f63SJim Harris    void                       * scsi_io,
266f11c7f63SJim Harris    void                       * ata_io
267f11c7f63SJim Harris )
268f11c7f63SJim Harris {
269f11c7f63SJim Harris    U8 * cdb = sati_cb_get_cdb_address(scsi_io);
270f11c7f63SJim Harris 
271f11c7f63SJim Harris    sequence->command_specific_data.scratch = 0;
272f11c7f63SJim Harris 
273f11c7f63SJim Harris    // Set the data length based on the allocation length field in the CDB.
274f11c7f63SJim Harris    sequence->allocation_length = (sati_get_cdb_byte(cdb, 7) << 8) |
275f11c7f63SJim Harris                                  (sati_get_cdb_byte(cdb, 8));
276f11c7f63SJim Harris 
277f11c7f63SJim Harris    return sati_mode_sense_translate_command(sequence, scsi_io, ata_io, 10);
278f11c7f63SJim Harris }
279f11c7f63SJim Harris 
280f11c7f63SJim Harris /**
281f11c7f63SJim Harris  * @brief This method will perform data translation from the supplied ATA
282f11c7f63SJim Harris  *        input data (i.e. an ATA IDENTIFY DEVICE block) into a CACHING
283f11c7f63SJim Harris  *        mode page format.  The data will be written into the user's mode
284f11c7f63SJim Harris  *        page data buffer.  This function operates specifically for MODE
285f11c7f63SJim Harris  *        SENSE 10 commands.
286f11c7f63SJim Harris  *        For more information on the parameters passed to this method,
287f11c7f63SJim Harris  *        please reference sati_translate_data().
288f11c7f63SJim Harris  *
289f11c7f63SJim Harris  * @return none.
290f11c7f63SJim Harris  */
sati_mode_sense_10_caching_translate_data(SATI_TRANSLATOR_SEQUENCE_T * sequence,void * ata_input_data,void * scsi_io)291f11c7f63SJim Harris void sati_mode_sense_10_caching_translate_data(
292f11c7f63SJim Harris    SATI_TRANSLATOR_SEQUENCE_T * sequence,
293f11c7f63SJim Harris    void                       * ata_input_data,
294f11c7f63SJim Harris    void                       * scsi_io
295f11c7f63SJim Harris )
296f11c7f63SJim Harris {
297f11c7f63SJim Harris    ATA_IDENTIFY_DEVICE_DATA_T * identify = (ATA_IDENTIFY_DEVICE_DATA_T*)
298f11c7f63SJim Harris                                            ata_input_data;
299f11c7f63SJim Harris    U16   data_length = sati_mode_sense_calculate_page_header(scsi_io, 10)
300f11c7f63SJim Harris                        + SCSI_MODE_PAGE_08_LENGTH;
301f11c7f63SJim Harris    U32   page_offset = sati_mode_sense_10_translate_data(
302f11c7f63SJim Harris                           sequence, identify, scsi_io, data_length
303f11c7f63SJim Harris                        );
304f11c7f63SJim Harris 
305f11c7f63SJim Harris    sati_mode_sense_caching_translate_data(
306f11c7f63SJim Harris       sequence, scsi_io, identify, page_offset
307f11c7f63SJim Harris    );
308f11c7f63SJim Harris }
309f11c7f63SJim Harris 
310f11c7f63SJim Harris /**
311f11c7f63SJim Harris  * @brief This method will perform data translation from the supplied ATA
312f11c7f63SJim Harris  *        input data (i.e. an ATA IDENTIFY DEVICE block) into a INFORMATIONAL
313f11c7f63SJim Harris  *        EXCEPTIONS CONTROL mode page format.  The data will be written
314f11c7f63SJim Harris  *        into the user's mode page data buffer.  This function operates
315f11c7f63SJim Harris  *        specifically for MODE SENSE 10 commands.
316f11c7f63SJim Harris  *        For more information on the parameters passed to this method,
317f11c7f63SJim Harris  *        please reference sati_translate_data().
318f11c7f63SJim Harris  *
319f11c7f63SJim Harris  * @return none.
320f11c7f63SJim Harris  */
sati_mode_sense_10_informational_excp_control_translate_data(SATI_TRANSLATOR_SEQUENCE_T * sequence,void * ata_input_data,void * scsi_io)321f11c7f63SJim Harris void sati_mode_sense_10_informational_excp_control_translate_data(
322f11c7f63SJim Harris    SATI_TRANSLATOR_SEQUENCE_T * sequence,
323f11c7f63SJim Harris    void                       * ata_input_data,
324f11c7f63SJim Harris    void                       * scsi_io
325f11c7f63SJim Harris )
326f11c7f63SJim Harris {
327f11c7f63SJim Harris    ATA_IDENTIFY_DEVICE_DATA_T * identify = (ATA_IDENTIFY_DEVICE_DATA_T*)
328f11c7f63SJim Harris                                            ata_input_data;
329f11c7f63SJim Harris    U16   data_length  = sati_mode_sense_calculate_page_header(scsi_io, 10)
330f11c7f63SJim Harris                         + SCSI_MODE_PAGE_1C_LENGTH;
331f11c7f63SJim Harris    U32   page_offset  = sati_mode_sense_10_translate_data(
332f11c7f63SJim Harris                            sequence, identify, scsi_io, data_length
333f11c7f63SJim Harris                         );
334f11c7f63SJim Harris 
335f11c7f63SJim Harris    sati_mode_sense_informational_excp_control_translate_data(
336f11c7f63SJim Harris       sequence, scsi_io, identify, page_offset
337f11c7f63SJim Harris    );
338f11c7f63SJim Harris }
339f11c7f63SJim Harris 
340f11c7f63SJim Harris /**
341f11c7f63SJim Harris * @brief This method will perform data translation from the supplied ATA
342f11c7f63SJim Harris *        input data (i.e. an ATA IDENTIFY DEVICE block) into a Read Write Error
343f11c7f63SJim Harris *         mode page format.  The data will be written
344f11c7f63SJim Harris *        into the user's mode page data buffer.  This function operates
345f11c7f63SJim Harris *        specifically for MODE SENSE 10 commands.
346f11c7f63SJim Harris *        For more information on the parameters passed to this method,
347f11c7f63SJim Harris *        please reference sati_translate_data().
348f11c7f63SJim Harris *
349f11c7f63SJim Harris * @return none.
350f11c7f63SJim Harris */
sati_mode_sense_10_read_write_error_translate_data(SATI_TRANSLATOR_SEQUENCE_T * sequence,void * ata_input_data,void * scsi_io)351f11c7f63SJim Harris void sati_mode_sense_10_read_write_error_translate_data(
352f11c7f63SJim Harris    SATI_TRANSLATOR_SEQUENCE_T * sequence,
353f11c7f63SJim Harris    void                       * ata_input_data,
354f11c7f63SJim Harris    void                       * scsi_io
355f11c7f63SJim Harris )
356f11c7f63SJim Harris {
357f11c7f63SJim Harris    ATA_IDENTIFY_DEVICE_DATA_T * identify = (ATA_IDENTIFY_DEVICE_DATA_T*)
358f11c7f63SJim Harris       ata_input_data;
359f11c7f63SJim Harris 
360f11c7f63SJim Harris    U16   data_length  = sati_mode_sense_calculate_page_header(scsi_io, 10)
361f11c7f63SJim Harris       + SCSI_MODE_PAGE_01_LENGTH;
362f11c7f63SJim Harris 
363f11c7f63SJim Harris    U32   page_offset  = sati_mode_sense_10_translate_data(
364f11c7f63SJim Harris                            sequence, identify, scsi_io, data_length
365f11c7f63SJim Harris                         );
366f11c7f63SJim Harris 
367f11c7f63SJim Harris    sati_mode_sense_read_write_error_translate_data(
368f11c7f63SJim Harris       sequence, scsi_io, identify, page_offset
369f11c7f63SJim Harris    );
370f11c7f63SJim Harris }
371f11c7f63SJim Harris 
372f11c7f63SJim Harris /**
373f11c7f63SJim Harris * @brief This method will perform data translation from the supplied ATA
374f11c7f63SJim Harris *        input data (i.e. an ATA IDENTIFY DEVICE block) into a Disconnect
375f11c7f63SJim Harris *        Reconnect mode page format.  The data will be written
376f11c7f63SJim Harris *        into the user's mode page data buffer.  This function operates
377f11c7f63SJim Harris *        specifically for MODE SENSE 10 commands.
378f11c7f63SJim Harris *        For more information on the parameters passed to this method,
379f11c7f63SJim Harris *        please reference sati_translate_data().
380f11c7f63SJim Harris *
381f11c7f63SJim Harris * @return none.
382f11c7f63SJim Harris */
sati_mode_sense_10_disconnect_reconnect_translate_data(SATI_TRANSLATOR_SEQUENCE_T * sequence,void * ata_input_data,void * scsi_io)383f11c7f63SJim Harris void sati_mode_sense_10_disconnect_reconnect_translate_data(
384f11c7f63SJim Harris    SATI_TRANSLATOR_SEQUENCE_T * sequence,
385f11c7f63SJim Harris    void                       * ata_input_data,
386f11c7f63SJim Harris    void                       * scsi_io
387f11c7f63SJim Harris )
388f11c7f63SJim Harris {
389f11c7f63SJim Harris    ATA_IDENTIFY_DEVICE_DATA_T * identify = (ATA_IDENTIFY_DEVICE_DATA_T*)
390f11c7f63SJim Harris       ata_input_data;
391f11c7f63SJim Harris 
392f11c7f63SJim Harris    U8   data_length = (U8) sati_mode_sense_calculate_page_header(scsi_io, 10)
393f11c7f63SJim Harris       + SCSI_MODE_PAGE_02_LENGTH;
394f11c7f63SJim Harris 
395f11c7f63SJim Harris    U32  page_offset = sati_mode_sense_10_translate_data(
396f11c7f63SJim Harris                         sequence, identify, scsi_io, data_length
397f11c7f63SJim Harris                       );
398f11c7f63SJim Harris 
399f11c7f63SJim Harris    sati_mode_sense_disconnect_reconnect_translate_data(
400f11c7f63SJim Harris       sequence, scsi_io, identify, page_offset
401f11c7f63SJim Harris    );
402f11c7f63SJim Harris }
403f11c7f63SJim Harris 
404f11c7f63SJim Harris /**
405f11c7f63SJim Harris * @brief This method will perform data translation from the supplied ATA
406f11c7f63SJim Harris *        input data (i.e. an ATA IDENTIFY DEVICE block) into a Control
407f11c7f63SJim Harris *         mode page format.  The data will be written
408f11c7f63SJim Harris *        into the user's mode page data buffer.  This function operates
409f11c7f63SJim Harris *        specifically for MODE SENSE 10 commands.
410f11c7f63SJim Harris *        For more information on the parameters passed to this method,
411f11c7f63SJim Harris *        please reference sati_translate_data().
412f11c7f63SJim Harris *
413f11c7f63SJim Harris * @return none.
414f11c7f63SJim Harris */
sati_mode_sense_10_control_translate_data(SATI_TRANSLATOR_SEQUENCE_T * sequence,void * ata_input_data,void * scsi_io)415f11c7f63SJim Harris void sati_mode_sense_10_control_translate_data(
416f11c7f63SJim Harris    SATI_TRANSLATOR_SEQUENCE_T * sequence,
417f11c7f63SJim Harris    void                       * ata_input_data,
418f11c7f63SJim Harris    void                       * scsi_io
419f11c7f63SJim Harris )
420f11c7f63SJim Harris {
421f11c7f63SJim Harris    ATA_IDENTIFY_DEVICE_DATA_T * identify = (ATA_IDENTIFY_DEVICE_DATA_T*)
422f11c7f63SJim Harris       ata_input_data;
423f11c7f63SJim Harris 
424f11c7f63SJim Harris    U8   data_length = (U8) sati_mode_sense_calculate_page_header(scsi_io, 10)
425f11c7f63SJim Harris       + SCSI_MODE_PAGE_0A_LENGTH;
426f11c7f63SJim Harris 
427f11c7f63SJim Harris    U32  page_offset = sati_mode_sense_10_translate_data(
428f11c7f63SJim Harris                          sequence, identify, scsi_io, data_length
429f11c7f63SJim Harris                       );
430f11c7f63SJim Harris 
431f11c7f63SJim Harris    sati_mode_sense_control_translate_data(
432f11c7f63SJim Harris       sequence, scsi_io, identify, page_offset
433f11c7f63SJim Harris    );
434f11c7f63SJim Harris }
435f11c7f63SJim Harris 
436f11c7f63SJim Harris /**
437f11c7f63SJim Harris * @brief This method will perform data translation from the supplied ATA
438f11c7f63SJim Harris *        input data (i.e. an ATA IDENTIFY DEVICE block) into a Power
439f11c7f63SJim Harris *        Condition mode page format.  The data will be written
440f11c7f63SJim Harris *        into the user's mode page data buffer.  This function operates
441f11c7f63SJim Harris *        specifically for MODE SENSE 10 commands.
442f11c7f63SJim Harris *        For more information on the parameters passed to this method,
443f11c7f63SJim Harris *        please reference sati_translate_data().
444f11c7f63SJim Harris *
445f11c7f63SJim Harris * @return none.
446f11c7f63SJim Harris */
sati_mode_sense_10_power_condition_translate_data(SATI_TRANSLATOR_SEQUENCE_T * sequence,void * ata_input_data,void * scsi_io)447f11c7f63SJim Harris void sati_mode_sense_10_power_condition_translate_data(
448f11c7f63SJim Harris    SATI_TRANSLATOR_SEQUENCE_T * sequence,
449f11c7f63SJim Harris    void                       * ata_input_data,
450f11c7f63SJim Harris    void                       * scsi_io
451f11c7f63SJim Harris )
452f11c7f63SJim Harris {
453f11c7f63SJim Harris    ATA_IDENTIFY_DEVICE_DATA_T * identify = (ATA_IDENTIFY_DEVICE_DATA_T*)
454f11c7f63SJim Harris       ata_input_data;
455f11c7f63SJim Harris 
456f11c7f63SJim Harris    U8 data_length;
457f11c7f63SJim Harris    U32  page_offset;
458f11c7f63SJim Harris 
459f11c7f63SJim Harris    data_length = (U8) sati_mode_sense_calculate_page_header(scsi_io, 10)
460f11c7f63SJim Harris       + SCSI_MODE_PAGE_1A_LENGTH;
461f11c7f63SJim Harris 
462f11c7f63SJim Harris    page_offset = sati_mode_sense_10_translate_data(
463f11c7f63SJim Harris       sequence, identify, scsi_io, data_length
464f11c7f63SJim Harris    );
465f11c7f63SJim Harris 
466f11c7f63SJim Harris    sati_mode_sense_power_condition_translate_data(
467f11c7f63SJim Harris       sequence, scsi_io, identify, page_offset
468f11c7f63SJim Harris    );
469f11c7f63SJim Harris }
470f11c7f63SJim Harris 
471f11c7f63SJim Harris 
472f11c7f63SJim Harris /**
473f11c7f63SJim Harris  * @brief This method will perform data translation from the supplied ATA
474f11c7f63SJim Harris  *        input data (i.e. an ATA IDENTIFY DEVICE block) into an ALL
475f11c7f63SJim Harris  *        PAGES mode page format.  The ALL PAGES mode page is basically a
476f11c7f63SJim Harris  *        conglomeration of all mode pages and sub-pages into a single
477f11c7f63SJim Harris  *        page.  The data will be written into the user's mode page
478f11c7f63SJim Harris  *        data buffer.  This function operates specifically for MODE
479f11c7f63SJim Harris  *        SENSE 10 commands.
480f11c7f63SJim Harris  *        For more information on the parameters passed to this method,
481f11c7f63SJim Harris  *        please reference sati_translate_data().
482f11c7f63SJim Harris  *
483f11c7f63SJim Harris  * @return none.
484f11c7f63SJim Harris  */
sati_mode_sense_10_all_pages_translate_data(SATI_TRANSLATOR_SEQUENCE_T * sequence,void * ata_input_data,void * scsi_io)485f11c7f63SJim Harris void sati_mode_sense_10_all_pages_translate_data(
486f11c7f63SJim Harris    SATI_TRANSLATOR_SEQUENCE_T * sequence,
487f11c7f63SJim Harris    void                       * ata_input_data,
488f11c7f63SJim Harris    void                       * scsi_io
489f11c7f63SJim Harris )
490f11c7f63SJim Harris {
491f11c7f63SJim Harris    ATA_IDENTIFY_DEVICE_DATA_T * identify = (ATA_IDENTIFY_DEVICE_DATA_T*)
492f11c7f63SJim Harris                                            ata_input_data;
493f11c7f63SJim Harris    U8   data_length = (U8) sati_mode_sense_calculate_page_header(scsi_io, 10)
494f11c7f63SJim Harris                            + SCSI_MODE_PAGE_01_LENGTH
495f11c7f63SJim Harris                            + SCSI_MODE_PAGE_02_LENGTH
496f11c7f63SJim Harris                            + SCSI_MODE_PAGE_08_LENGTH
497f11c7f63SJim Harris                            + SCSI_MODE_PAGE_0A_LENGTH
498f11c7f63SJim Harris                            + SCSI_MODE_PAGE_1C_LENGTH;
499f11c7f63SJim Harris    U32  page_offset = sati_mode_sense_10_translate_data(
500f11c7f63SJim Harris                          sequence, identify, scsi_io, data_length
501f11c7f63SJim Harris                       );
502f11c7f63SJim Harris 
503f11c7f63SJim Harris    sati_mode_sense_all_pages_translate_data(
504f11c7f63SJim Harris       sequence, scsi_io, identify, page_offset
505f11c7f63SJim Harris    );
506f11c7f63SJim Harris }
507f11c7f63SJim Harris 
508f11c7f63SJim Harris #endif // !defined(DISABLE_SATI_MODE_SENSE)
509f11c7f63SJim Harris 
510