2 * SPDX-License-Identifier: BSD-2-Clause OR GPL-2.0
4 * This file is provided under a dual BSD/GPLv2 license. When using or
5 * redistributing this file, you may do so under either license.
9 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of version 2 of the GNU General Public License as
13 * published by the Free Software Foundation.
15 * This program is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
23 * The full GNU General Public License is included in this distribution
24 * in the file called LICENSE.GPL.
28 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
29 * All rights reserved.
31 * Redistribution and use in source and binary forms, with or without
32 * modification, are permitted provided that the following conditions
35 * * Redistributions of source code must retain the above copyright
36 * notice, this list of conditions and the following disclaimer.
37 * * Redistributions in binary form must reproduce the above copyright
38 * notice, this list of conditions and the following disclaimer in
39 * the documentation and/or other materials provided with the
42 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
43 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
44 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
45 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
46 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
47 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
48 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
49 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
50 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
51 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
52 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
55 #include <sys/cdefs.h>
56 __FBSDID("$FreeBSD$");
60 * @brief This file contains the method implementations required to
61 * translate the SCSI mode sense (6 and 10-byte) commands.
64 #if !defined(DISABLE_SATI_MODE_SENSE)
66 #include <dev/isci/scil/sati_mode_sense.h>
67 #include <dev/isci/scil/sati_mode_pages.h>
68 #include <dev/isci/scil/sati_callbacks.h>
69 #include <dev/isci/scil/sati_util.h>
70 #include <dev/isci/scil/intel_scsi.h>
71 #include <dev/isci/scil/intel_ata.h>
73 //******************************************************************************
74 //* P R I V A T E M E T H O D S
75 //******************************************************************************
77 #define STANDBY_TIMER_DISABLED 0x00
78 #define STANDBY_TIMER_ENABLED 0x01
79 #define STANDBY_TIMER_SUPPORTED 0x2000
84 * @brief This method indicates if the supplied page control is supported
85 * by this translation implementation. Currently savable parameters
86 * (i.e. non-volatile) are not supported.
87 * For more information on the parameters passed to this method,
88 * please reference sati_translate_command().
90 * @return This method returns an indication of whether the page control
91 * specified in the SCSI CDB is supported.
92 * @retval SATI_SUCCESS This value is returned if the page control is
94 * @retval SATI_FAILURE_CHECK_RESPONSE_DATA This value is returned if the
95 * page control is not supported.
98 SATI_STATUS sati_mode_sense_is_page_control_supported(
99 SATI_TRANSLATOR_SEQUENCE_T * sequence,
103 U8 * cdb = sati_cb_get_cdb_address(scsi_io);
105 switch (sati_get_cdb_byte(cdb, 2) >> SCSI_MODE_SENSE_PC_SHIFT)
107 case SCSI_MODE_SENSE_PC_CURRENT:
108 case SCSI_MODE_SENSE_PC_DEFAULT:
109 case SCSI_MODE_SENSE_PC_CHANGEABLE:
114 case SCSI_MODE_SENSE_PC_SAVED:
115 sati_scsi_sense_data_construct(
118 SCSI_STATUS_CHECK_CONDITION,
119 SCSI_SENSE_ILLEGAL_REQUEST,
120 SCSI_ASC_SAVING_PARMS_NOT_SUPPORTED,
121 SCSI_ASCQ_SAVING_PARMS_NOT_SUPPORTED
123 return SATI_FAILURE_CHECK_RESPONSE_DATA;
129 * @brief This method indicates if the page code field in the SCSI CDB
130 * is supported by this translation.
131 * For more information on the parameters passed to this method,
132 * please reference sati_translate_command().
134 * @param[in] cdb_length This parameter specifies the length of the SCSI
135 * CDB being translated (e.g. 6-byte, 10-byte, 12-byte, etc.)
137 * @return This method returns an indication as to whether the page code
138 * in the CDB is supported.
139 * @retval SATI_SUCCESS This value is returned if the page code is
141 * @retval SATI_FAILURE_CHECK_RESPONSE_DATA This value is returned if the
142 * page code is not supported.
145 SATI_STATUS sati_mode_sense_is_page_code_supported(
146 SATI_TRANSLATOR_SEQUENCE_T * sequence,
151 U8 * cdb = sati_cb_get_cdb_address(scsi_io);
153 switch (sati_get_cdb_byte(cdb, 2) & SCSI_MODE_SENSE_PAGE_CODE_ENABLE)
155 case SCSI_MODE_PAGE_CACHING:
156 if (sati_get_cdb_byte(cdb, 0) == SCSI_MODE_SENSE_6)
157 sequence->type = SATI_SEQUENCE_MODE_SENSE_6_CACHING;
159 sequence->type = SATI_SEQUENCE_MODE_SENSE_10_CACHING;
162 case SCSI_MODE_PAGE_ALL_PAGES:
163 if (sati_get_cdb_byte(cdb, 0) == SCSI_MODE_SENSE_6)
164 sequence->type = SATI_SEQUENCE_MODE_SENSE_6_ALL_PAGES;
166 sequence->type = SATI_SEQUENCE_MODE_SENSE_10_ALL_PAGES;
169 case SCSI_MODE_PAGE_READ_WRITE_ERROR:
170 if (sati_get_cdb_byte(cdb, 0) == SCSI_MODE_SENSE_6)
171 sequence->type = SATI_SEQUENCE_MODE_SENSE_6_READ_WRITE_ERROR;
173 sequence->type = SATI_SEQUENCE_MODE_SENSE_10_READ_WRITE_ERROR;
176 case SCSI_MODE_PAGE_DISCONNECT_RECONNECT:
177 if (sati_get_cdb_byte(cdb, 0) == SCSI_MODE_SENSE_6)
178 sequence->type = SATI_SEQUENCE_MODE_SENSE_6_DISCONNECT_RECONNECT;
180 sequence->type = SATI_SEQUENCE_MODE_SENSE_10_DISCONNECT_RECONNECT;
183 case SCSI_MODE_PAGE_CONTROL:
184 if (sati_get_cdb_byte(cdb, 0) == SCSI_MODE_SENSE_6)
185 sequence->type = SATI_SEQUENCE_MODE_SENSE_6_CONTROL;
187 sequence->type = SATI_SEQUENCE_MODE_SENSE_10_CONTROL;
190 case SCSI_MODE_PAGE_POWER_CONDITION:
191 if (sati_get_cdb_byte(cdb, 0) == SCSI_MODE_SENSE_6)
192 sequence->type = SATI_SEQUENCE_MODE_SENSE_6_POWER_CONDITION;
194 sequence->type = SATI_SEQUENCE_MODE_SENSE_10_POWER_CONDITION;
197 case SCSI_MODE_PAGE_INFORMATIONAL_EXCP_CONTROL:
198 // The informational exceptions control page is only useful
199 // if SMART is supported.
200 if ((sequence->device->capabilities | SATI_DEVICE_CAP_SMART_SUPPORT)
203 // For a MODE SENSE, utilize INVALID FIELD IN CDB,
204 // For a MODE SELECT, utilize INVALID FIELD IN PARAMETER LIST.
205 if (sati_get_cdb_byte(cdb, 0) == SCSI_MODE_SENSE_6)
207 sati_scsi_sense_data_construct(
210 SCSI_STATUS_CHECK_CONDITION,
211 SCSI_SENSE_ILLEGAL_REQUEST,
212 SCSI_ASC_INVALID_FIELD_IN_CDB,
213 SCSI_ASCQ_INVALID_FIELD_IN_CDB
218 sati_scsi_sense_data_construct(
221 SCSI_STATUS_CHECK_CONDITION,
222 SCSI_SENSE_ILLEGAL_REQUEST,
223 SCSI_ASC_INVALID_FIELD_IN_PARM_LIST,
224 SCSI_ASCQ_INVALID_FIELD_IN_PARM_LIST
228 return SATI_FAILURE_CHECK_RESPONSE_DATA;
231 if (sati_get_cdb_byte(cdb, 0) == SCSI_MODE_SENSE_6)
232 sequence->type = SATI_SEQUENCE_MODE_SENSE_6_INFORMATIONAL_EXCP_CONTROL;
234 sequence->type = SATI_SEQUENCE_MODE_SENSE_10_INFORMATIONAL_EXCP_CONTROL;
238 sati_scsi_sense_data_construct(
241 SCSI_STATUS_CHECK_CONDITION,
242 SCSI_SENSE_ILLEGAL_REQUEST,
243 SCSI_ASC_INVALID_FIELD_IN_CDB,
244 SCSI_ASCQ_INVALID_FIELD_IN_CDB
246 return SATI_FAILURE_CHECK_RESPONSE_DATA;
253 //******************************************************************************
254 //* P R O T E C T E D M E T H O D S
255 //******************************************************************************
258 * @brief This method will calculate the size of the mode sense data header.
259 * This includes the block descriptor if one is requested.
261 * @param[in] scsi_io This parameter specifies the user's SCSI IO object
262 * for which to calculate the mode page header.
263 * @param[in] cdb_size This parameter specifies the number of bytes
264 * associated with the CDB for which to calculate the header.
266 * @return This method returns the size, in bytes, for the mode page header.
268 U16 sati_mode_sense_calculate_page_header(
273 U8 * cdb = sati_cb_get_cdb_address(scsi_io);
276 // The Mode page header length is different for 6-byte vs. 10-byte CDBs.
278 page_length += SCSI_MODE_SENSE_6_HEADER_LENGTH;
280 page_length += SCSI_MODE_SENSE_10_HEADER_LENGTH;
282 // Are block descriptors disabled (DBD)? 0 indicates they are enabled.
283 if ((sati_get_cdb_byte(cdb, 1) & SCSI_MODE_SENSE_DBD_ENABLE) == 0)
285 // The LLBAA bit is not defined for 6-byte mode sense requests.
286 if ( (cdb_size == 10)
287 && (sati_get_cdb_byte(cdb, 1) & SCSI_MODE_SENSE_LLBAA_ENABLE) )
288 page_length += SCSI_MODE_SENSE_LLBA_BLOCK_DESCRIPTOR_LENGTH;
290 page_length += SCSI_MODE_SENSE_STD_BLOCK_DESCRIPTOR_LENGTH;
297 * @brief This method performs command translation common to all mode sense
298 * requests (6 or 10 byte).
299 * For more information on the parameters passed to this method,
300 * please reference sati_translate_command().
302 * @param[in] cdb_length This parameter specifies the number of bytes
303 * in the CDB (6 or 10).
305 * @return This method returns an indication as to whether the translation
307 * @retval SCI_SUCCESS This value is returned if translation succeeded.
308 * @see sati_mode_sense_is_page_control_supported() or
309 * sati_mode_sense_is_page_code_supported() for more information.
311 SATI_STATUS sati_mode_sense_translate_command(
312 SATI_TRANSLATOR_SEQUENCE_T * sequence,
321 * Validate that the supplied page control (PC) field is supported.
323 status = sati_mode_sense_is_page_control_supported(sequence, scsi_io);
324 if (status != SATI_SUCCESS)
328 * Validate that the supplied page code is supported.
330 status = sati_mode_sense_is_page_code_supported(sequence,scsi_io,cdb_length);
331 if (status != SATI_SUCCESS)
334 sati_ata_identify_device_construct(ata_io, sequence);
340 * @brief This method will build the standard block descriptor for a MODE
341 * SENSE 6 or 10 byte request.
342 * For more information on the parameters passed to this method,
343 * please reference sati_translate_command().
345 * @param[in] identify This parameter specifies the IDENTIFY DEVICE data
346 * associated with the SCSI IO.
347 * @param[in] offset This parameter specifies the offset into the data
348 * buffer at which to build the block descriptor.
350 * @return This method returns the size of the block descriptor built.
352 U32 sati_mode_sense_build_std_block_descriptor(
353 SATI_TRANSLATOR_SEQUENCE_T * sequence,
355 ATA_IDENTIFY_DEVICE_DATA_T * identify,
363 // Extract the sector information (sector size, logical blocks) from
364 // the retrieved ATA identify device data.
365 sati_ata_identify_device_get_sector_info(
366 identify, &lba_high, &lba_low, §or_size
369 // Fill in the 4-byte logical block address field.
370 sati_set_data_byte(sequence, scsi_io, offset, (U8)((lba_low>>24) & 0xFF));
371 sati_set_data_byte(sequence, scsi_io, offset+1, (U8)((lba_low>>16) & 0xFF));
372 sati_set_data_byte(sequence, scsi_io, offset+2, (U8)((lba_low>>8) & 0xFF));
373 sati_set_data_byte(sequence, scsi_io, offset+3, (U8)(lba_low & 0xFF));
375 // Clear the reserved field.
376 sati_set_data_byte(sequence, scsi_io, offset+4, 0);
378 // Fill in the three byte Block Length field
379 sati_set_data_byte(sequence,scsi_io, offset+5, (U8)((sector_size>>16) & 0xFF));
380 sati_set_data_byte(sequence,scsi_io, offset+6, (U8)((sector_size>>8) & 0xFF));
381 sati_set_data_byte(sequence,scsi_io, offset+7, (U8)(sector_size & 0xFF));
383 return SCSI_MODE_SENSE_STD_BLOCK_DESCRIPTOR_LENGTH;
387 * @brief This method simply copies the mode sense data into the buffer
388 * at the location specified by page_start. The buffer copied is
389 * determined by page_control (e.g. current, default, or changeable
391 * For more information on the parameters passed to this method,
392 * please reference sati_translate_command().
394 * @param[in] page_start This parameter specifies the starting offset at
395 * which to copy the mode page data.
396 * @param[in] page_control This parameter specifies the page control
397 * indicating the source buffer to be copied.
398 * @param[in] page_code This specifies the mode sense page to copy.
400 * @return This method returns the size of the mode page data being copied.
402 U32 sati_mode_sense_copy_initial_data(
403 SATI_TRANSLATOR_SEQUENCE_T * sequence,
410 U16 page_index = sati_mode_page_get_page_index(page_code);
411 U32 page_length = sat_mode_page_sizes[page_index];
413 // Find out if the current values are requested or if the default
414 // values are being requested.
415 if (page_control == SCSI_MODE_SENSE_PC_CHANGEABLE)
417 // Copy the changeable mode page information.
422 sat_changeable_mode_pages[page_index],
428 // Copy the default static values template to the user data area.
433 sat_default_mode_pages[page_index],
442 * @brief This method performs the read/write error recovery mode page
443 * specific data translation based upon the contents of the remote
444 * device IDENTIFY DEVICE data.
445 * For more information on the parameters passed to this method,
446 * please reference sati_translate_command().
448 * @param[in] identify This parameter specifies the remote device's
449 * IDENTIFY DEVICE data received as part of the IO request.
450 * @param[in] offset This parameter specifies the offset into the data
451 * buffer where the translated data is to be written.
453 * @return This method returns the size of the mode page data that was
456 U32 sati_mode_sense_read_write_error_translate_data(
457 SATI_TRANSLATOR_SEQUENCE_T * sequence,
459 ATA_IDENTIFY_DEVICE_DATA_T * identify,
463 U8 * cdb = sati_cb_get_cdb_address(scsi_io);
464 U8 page_control = sati_get_cdb_byte(cdb, 2) >> SCSI_MODE_SENSE_PC_SHIFT;
467 page_length = sati_mode_sense_copy_initial_data(
472 SCSI_MODE_PAGE_READ_WRITE_ERROR
475 // Currently we do not override any bits in this mode page from the
482 * @brief This method performs the disconnect/reconnect mode page
483 * specific data translation based upon the contents of the remote
484 * device IDENTIFY DEVICE data.
485 * For more information on the parameters passed to this method,
486 * please reference sati_translate_command().
488 * @param[in] identify This parameter specifies the remote device's
489 * IDENTIFY DEVICE data received as part of the IO request.
490 * @param[in] offset This parameter specifies the offset into the data
491 * buffer where the translated data is to be written.
493 * @return This method returns the size of the mode page data that was
496 U32 sati_mode_sense_disconnect_reconnect_translate_data(
497 SATI_TRANSLATOR_SEQUENCE_T * sequence,
499 ATA_IDENTIFY_DEVICE_DATA_T * identify,
503 U8 * cdb = sati_cb_get_cdb_address(scsi_io);
504 U8 page_control = sati_get_cdb_byte(cdb, 2) >> SCSI_MODE_SENSE_PC_SHIFT;
507 page_length = sati_mode_sense_copy_initial_data(
512 SCSI_MODE_PAGE_DISCONNECT_RECONNECT
515 // Currently we do not override any bits in this mode page from the
522 * @brief This method performs the caching mode page specific data
523 * translation based upon the contents of the remote device IDENTIFY
525 * For more information on the parameters passed to this method,
526 * please reference sati_translate_command().
528 * @param[in] identify This parameter specifies the remote device's
529 * IDENTIFY DEVICE data received as part of the IO request.
530 * @param[in] offset This parameter specifies the offset into the data
531 * buffer where the translated data is to be written.
533 * @return This method returns the size of the mode page data that was
536 U32 sati_mode_sense_caching_translate_data(
537 SATI_TRANSLATOR_SEQUENCE_T * sequence,
539 ATA_IDENTIFY_DEVICE_DATA_T * identify,
543 U8 * cdb = sati_cb_get_cdb_address(scsi_io);
544 U8 page_control = sati_get_cdb_byte(cdb, 2) >> SCSI_MODE_SENSE_PC_SHIFT;
547 page_length = sati_mode_sense_copy_initial_data(
552 SCSI_MODE_PAGE_CACHING
555 // If the request queried for the current values, then
556 // we need to translate the data from the IDENTIFY DEVICE request.
557 if (page_control == SCSI_MODE_SENSE_PC_CURRENT)
561 // Update the Write Cache Enabled (WCE) bit in the mode page data
562 // buffer based on the identify response.
563 if ((identify->command_set_enabled0 & ATA_IDENTIFY_DEVICE_WCE_ENABLE) != 0)
565 sati_get_data_byte(sequence, scsi_io, offset+2, &value);
566 value |= SCSI_MODE_PAGE_CACHE_PAGE_WCE_BIT;
567 sati_set_data_byte(sequence, scsi_io, offset+2, value);
568 //This byte has been set twice and needs to be decremented
569 sequence->number_data_bytes_set--;
572 // Update the Disable Read Ahead (DRA) bit in the mode page data
573 // buffer based on the identify response.
574 if ((identify->command_set_enabled0 & ATA_IDENTIFY_DEVICE_RA_ENABLE) == 0)
576 // In SATA the polarity of the bits is inverse.
577 // - SCSI = Disable Read Ahead
578 // - ATA = Read Ahead
579 sati_get_data_byte(sequence, scsi_io, offset+12, &value);
580 value |= SCSI_MODE_PAGE_CACHE_PAGE_DRA_BIT;
581 sati_set_data_byte(sequence, scsi_io, offset+12, value);
583 //This byte has been set twice, the first time in
584 //sati_mode_sense_copy_initial_data. number_data_bytes_set
585 //needs to be decremented
586 sequence->number_data_bytes_set--;
594 * @brief This method performs the control mode page specific data
595 * translation based upon the contents of the remote device
596 * IDENTIFY DEVICE data.
597 * For more information on the parameters passed to this method,
598 * please reference sati_translate_command().
600 * @param[in] identify This parameter specifies the remote device's
601 * IDENTIFY DEVICE data received as part of the IO request.
602 * @param[in] offset This parameter specifies the offset into the data
603 * buffer where the translated data is to be written.
605 * @return This method returns the size of the mode page data that was
608 U32 sati_mode_sense_control_translate_data(
609 SATI_TRANSLATOR_SEQUENCE_T * sequence,
611 ATA_IDENTIFY_DEVICE_DATA_T * identify,
615 U8 * cdb = sati_cb_get_cdb_address(scsi_io);
616 U8 page_control = sati_get_cdb_byte(cdb, 2) >> SCSI_MODE_SENSE_PC_SHIFT;
620 page_length = sati_mode_sense_copy_initial_data(
625 SCSI_MODE_PAGE_CONTROL
628 if (sequence->device->descriptor_sense_enable)
630 sati_get_data_byte(sequence, scsi_io, offset+2,
633 sati_set_data_byte(sequence, scsi_io, offset+2,
634 value | SCSI_MODE_SELECT_MODE_PAGE_D_SENSE);
641 * @brief This method performs the informational exceptions control mode
642 * page specific data translation based upon the contents of the
643 * remote device IDENTIFY DEVICE data.
644 * For more information on the parameters passed to this method,
645 * please reference sati_translate_command().
647 * @param[in] identify This parameter specifies the remote device's
648 * IDENTIFY DEVICE data received as part of the IO request.
649 * @param[in] offset This parameter specifies the offset into the data
650 * buffer where the translated data is to be written.
652 * @return This method returns the size of the mode page data that was
655 U32 sati_mode_sense_informational_excp_control_translate_data(
656 SATI_TRANSLATOR_SEQUENCE_T * sequence,
658 ATA_IDENTIFY_DEVICE_DATA_T * identify,
662 U8 * cdb = sati_cb_get_cdb_address(scsi_io);
663 U8 page_control = sati_get_cdb_byte(cdb, 2) >> SCSI_MODE_SENSE_PC_SHIFT;
666 page_length = sati_mode_sense_copy_initial_data(
671 SCSI_MODE_PAGE_INFORMATIONAL_EXCP_CONTROL
674 // If the request queried for the current values, then
675 // we need to translate the data from the IDENTIFY DEVICE request.
676 if (page_control == SCSI_MODE_SENSE_PC_CURRENT)
680 sati_get_data_byte(sequence, scsi_io, offset+2, &value);
682 // Determine if the SMART feature set is supported and enabled.
683 if ( (identify->command_set_supported0
684 & ATA_IDENTIFY_COMMAND_SET_SUPPORTED0_SMART_ENABLE)
685 && (identify->command_set_enabled0
686 & ATA_IDENTIFY_COMMAND_SET_ENABLED0_SMART_ENABLE) )
688 // Clear the DXCPT field since the SMART feature is supported/enabled.
689 value &= ~SCSI_MODE_PAGE_INFORMATIONAL_EXCP_DXCPT_ENABLE;
693 // Set the Disable Exception Control (DXCPT) field since the SMART
694 // feature is not supported or enabled.
695 value |= SCSI_MODE_PAGE_INFORMATIONAL_EXCP_DXCPT_ENABLE;
698 sati_set_data_byte(sequence, scsi_io, offset+2, value);
700 //This byte has been set twice, the first time in
701 //sati_mode_sense_copy_initial_data. number_data_bytes_set
702 //needs to be decremented
703 sequence->number_data_bytes_set--;
710 * @brief This method performs the Power Condition mode page
711 * specific data translation based upon the contents of the
712 * remote device IDENTIFY DEVICE data.
713 * For more information on the parameters passed to this method,
714 * please reference sati_translate_command().
716 * @param[in] identify This parameter specifies the remote device's
717 * IDENTIFY DEVICE data received as part of the IO request.
718 * @param[in] offset This parameter specifies the offset into the data
719 * buffer where the translated data is to be written.
721 * @return This method returns the size of the mode page data that was
724 U32 sati_mode_sense_power_condition_translate_data(
725 SATI_TRANSLATOR_SEQUENCE_T * sequence,
727 ATA_IDENTIFY_DEVICE_DATA_T * identify,
731 U8 * cdb = sati_cb_get_cdb_address(scsi_io);
732 U8 page_control = sati_get_cdb_byte(cdb, 2) >> SCSI_MODE_SENSE_PC_SHIFT;
736 //Represents tenths of seconds
737 U32 standby_timer = 0x00000000;
739 U8 standby_enabled = STANDBY_TIMER_DISABLED;
741 if ((page_control == SCSI_MODE_SENSE_PC_CURRENT) &&
742 (identify->capabilities1 & STANDBY_TIMER_SUPPORTED))
744 standby_enabled = STANDBY_TIMER_ENABLED;
746 ata_sb_timer = sequence->device->ata_standby_timer;
748 //converting ATA timer values into SCSI timer values
749 if(ata_sb_timer <= 0xF0)
751 standby_timer = ata_sb_timer * 50;
753 else if(ata_sb_timer <= 0xFB)
755 standby_timer = ((ata_sb_timer - 240) * 18000);
757 else if(ata_sb_timer == 0xFC)
759 standby_timer = 12600;
761 else if(ata_sb_timer == 0xFD)
763 standby_timer = 432000;
765 else if(ata_sb_timer == 0xFF)
767 standby_timer = 12750;
771 standby_timer = 0xFFFFFFFF;
775 sati_set_data_byte(sequence, scsi_io, offset, SCSI_MODE_PAGE_POWER_CONDITION);
776 sati_set_data_byte(sequence, scsi_io, offset + 1, (SCSI_MODE_PAGE_1A_LENGTH - 2));
777 sati_set_data_byte(sequence, scsi_io, offset + 2, 0x00);
778 sati_set_data_byte(sequence, scsi_io, offset + 3, standby_enabled);
779 sati_set_data_byte(sequence, scsi_io, offset + 4, 0x00);
780 sati_set_data_byte(sequence, scsi_io, offset + 5, 0x00);
781 sati_set_data_byte(sequence, scsi_io, offset + 6, 0x00);
782 sati_set_data_byte(sequence, scsi_io, offset + 7, 0x00);
783 sati_set_data_byte(sequence, scsi_io, offset + 8, (U8) (standby_timer >> 24));
784 sati_set_data_byte(sequence, scsi_io, offset + 9, (U8) (standby_timer >> 16));
785 sati_set_data_byte(sequence, scsi_io, offset + 10, (U8) (standby_timer >> 8));
786 sati_set_data_byte(sequence, scsi_io, offset + 11, (U8) standby_timer);
788 return SCSI_MODE_PAGE_1A_LENGTH;
792 * @brief This method performs the all pages mode page specific data
793 * translation based upon the contents of the remote device
794 * IDENTIFY DEVICE data. The ALL PAGES mode sense request asks
795 * for all of mode pages and sub-pages in a single page.
796 * The mode pages are added in ascending order.
797 * For more information on the parameters passed to this method,
798 * please reference sati_translate_command().
800 * @param[in] identify This parameter specifies the remote device's
801 * IDENTIFY DEVICE data received as part of the IO request.
802 * @param[in] offset This parameter specifies the offset into the data
803 * buffer where the translated data is to be written.
805 * @return This method returns the size of the mode page data that was
808 U32 sati_mode_sense_all_pages_translate_data(
809 SATI_TRANSLATOR_SEQUENCE_T * sequence,
811 ATA_IDENTIFY_DEVICE_DATA_T * identify,
815 offset += sati_mode_sense_read_write_error_translate_data(
816 sequence, scsi_io, identify, offset
819 offset += sati_mode_sense_disconnect_reconnect_translate_data(
820 sequence, scsi_io, identify, offset
823 offset += sati_mode_sense_caching_translate_data(
824 sequence, scsi_io, identify, offset
827 offset += sati_mode_sense_control_translate_data(
828 sequence, scsi_io, identify, offset
831 offset += sati_mode_sense_informational_excp_control_translate_data(
832 sequence, scsi_io, identify, offset
838 #endif // !defined(DISABLE_SATI_MODE_SENSE)