2 * This file is provided under a dual BSD/GPLv2 license. When using or
3 * redistributing this file, you may do so under either license.
7 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of version 2 of the GNU General Public License as
11 * published by the Free Software Foundation.
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
21 * The full GNU General Public License is included in this distribution
22 * in the file called LICENSE.GPL.
26 * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved.
27 * All rights reserved.
29 * Redistribution and use in source and binary forms, with or without
30 * modification, are permitted provided that the following conditions
33 * * Redistributions of source code must retain the above copyright
34 * notice, this list of conditions and the following disclaimer.
35 * * Redistributions in binary form must reproduce the above copyright
36 * notice, this list of conditions and the following disclaimer in
37 * the documentation and/or other materials provided with the
40 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
41 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
42 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
43 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
44 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
46 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
47 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
48 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
49 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
50 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
53 #include <sys/cdefs.h>
54 __FBSDID("$FreeBSD$");
58 * @brief This file contains the method implementations required to
59 * translate the SCSI mode sense (6 and 10-byte) commands.
62 #if !defined(DISABLE_SATI_MODE_SENSE)
64 #include <dev/isci/scil/sati_mode_sense.h>
65 #include <dev/isci/scil/sati_mode_pages.h>
66 #include <dev/isci/scil/sati_callbacks.h>
67 #include <dev/isci/scil/sati_util.h>
68 #include <dev/isci/scil/intel_scsi.h>
69 #include <dev/isci/scil/intel_ata.h>
71 //******************************************************************************
72 //* P R I V A T E M E T H O D S
73 //******************************************************************************
75 #define STANDBY_TIMER_DISABLED 0x00
76 #define STANDBY_TIMER_ENABLED 0x01
77 #define STANDBY_TIMER_SUPPORTED 0x2000
82 * @brief This method indicates if the supplied page control is supported
83 * by this translation implementation. Currently savable parameters
84 * (i.e. non-volatile) are not supported.
85 * For more information on the parameters passed to this method,
86 * please reference sati_translate_command().
88 * @return This method returns an indication of whether the page control
89 * specified in the SCSI CDB is supported.
90 * @retval SATI_SUCCESS This value is returned if the page control is
92 * @retval SATI_FAILURE_CHECK_RESPONSE_DATA This value is returned if the
93 * page control is not supported.
96 SATI_STATUS sati_mode_sense_is_page_control_supported(
97 SATI_TRANSLATOR_SEQUENCE_T * sequence,
101 U8 * cdb = sati_cb_get_cdb_address(scsi_io);
103 switch (sati_get_cdb_byte(cdb, 2) >> SCSI_MODE_SENSE_PC_SHIFT)
105 case SCSI_MODE_SENSE_PC_CURRENT:
106 case SCSI_MODE_SENSE_PC_DEFAULT:
107 case SCSI_MODE_SENSE_PC_CHANGEABLE:
112 case SCSI_MODE_SENSE_PC_SAVED:
113 sati_scsi_sense_data_construct(
116 SCSI_STATUS_CHECK_CONDITION,
117 SCSI_SENSE_ILLEGAL_REQUEST,
118 SCSI_ASC_SAVING_PARMS_NOT_SUPPORTED,
119 SCSI_ASCQ_SAVING_PARMS_NOT_SUPPORTED
121 return SATI_FAILURE_CHECK_RESPONSE_DATA;
127 * @brief This method indicates if the page code field in the SCSI CDB
128 * is supported by this translation.
129 * For more information on the parameters passed to this method,
130 * please reference sati_translate_command().
132 * @param[in] cdb_length This parameter specifies the length of the SCSI
133 * CDB being translated (e.g. 6-byte, 10-byte, 12-byte, etc.)
135 * @return This method returns an indication as to whether the page code
136 * in the CDB is supported.
137 * @retval SATI_SUCCESS This value is returned if the page code is
139 * @retval SATI_FAILURE_CHECK_RESPONSE_DATA This value is returned if the
140 * page code is not supported.
143 SATI_STATUS sati_mode_sense_is_page_code_supported(
144 SATI_TRANSLATOR_SEQUENCE_T * sequence,
149 U8 * cdb = sati_cb_get_cdb_address(scsi_io);
151 switch (sati_get_cdb_byte(cdb, 2) & SCSI_MODE_SENSE_PAGE_CODE_ENABLE)
153 case SCSI_MODE_PAGE_CACHING:
154 if (sati_get_cdb_byte(cdb, 0) == SCSI_MODE_SENSE_6)
155 sequence->type = SATI_SEQUENCE_MODE_SENSE_6_CACHING;
157 sequence->type = SATI_SEQUENCE_MODE_SENSE_10_CACHING;
160 case SCSI_MODE_PAGE_ALL_PAGES:
161 if (sati_get_cdb_byte(cdb, 0) == SCSI_MODE_SENSE_6)
162 sequence->type = SATI_SEQUENCE_MODE_SENSE_6_ALL_PAGES;
164 sequence->type = SATI_SEQUENCE_MODE_SENSE_10_ALL_PAGES;
167 case SCSI_MODE_PAGE_READ_WRITE_ERROR:
168 if (sati_get_cdb_byte(cdb, 0) == SCSI_MODE_SENSE_6)
169 sequence->type = SATI_SEQUENCE_MODE_SENSE_6_READ_WRITE_ERROR;
171 sequence->type = SATI_SEQUENCE_MODE_SENSE_10_READ_WRITE_ERROR;
174 case SCSI_MODE_PAGE_DISCONNECT_RECONNECT:
175 if (sati_get_cdb_byte(cdb, 0) == SCSI_MODE_SENSE_6)
176 sequence->type = SATI_SEQUENCE_MODE_SENSE_6_DISCONNECT_RECONNECT;
178 sequence->type = SATI_SEQUENCE_MODE_SENSE_10_DISCONNECT_RECONNECT;
181 case SCSI_MODE_PAGE_CONTROL:
182 if (sati_get_cdb_byte(cdb, 0) == SCSI_MODE_SENSE_6)
183 sequence->type = SATI_SEQUENCE_MODE_SENSE_6_CONTROL;
185 sequence->type = SATI_SEQUENCE_MODE_SENSE_10_CONTROL;
188 case SCSI_MODE_PAGE_POWER_CONDITION:
189 if (sati_get_cdb_byte(cdb, 0) == SCSI_MODE_SENSE_6)
190 sequence->type = SATI_SEQUENCE_MODE_SENSE_6_POWER_CONDITION;
192 sequence->type = SATI_SEQUENCE_MODE_SENSE_10_POWER_CONDITION;
195 case SCSI_MODE_PAGE_INFORMATIONAL_EXCP_CONTROL:
196 // The informational exceptions control page is only useful
197 // if SMART is supported.
198 if ((sequence->device->capabilities | SATI_DEVICE_CAP_SMART_SUPPORT)
201 // For a MODE SENSE, utilize INVALID FIELD IN CDB,
202 // For a MODE SELECT, utilize INVALID FIELD IN PARAMETER LIST.
203 if (sati_get_cdb_byte(cdb, 0) == SCSI_MODE_SENSE_6)
205 sati_scsi_sense_data_construct(
208 SCSI_STATUS_CHECK_CONDITION,
209 SCSI_SENSE_ILLEGAL_REQUEST,
210 SCSI_ASC_INVALID_FIELD_IN_CDB,
211 SCSI_ASCQ_INVALID_FIELD_IN_CDB
216 sati_scsi_sense_data_construct(
219 SCSI_STATUS_CHECK_CONDITION,
220 SCSI_SENSE_ILLEGAL_REQUEST,
221 SCSI_ASC_INVALID_FIELD_IN_PARM_LIST,
222 SCSI_ASCQ_INVALID_FIELD_IN_PARM_LIST
226 return SATI_FAILURE_CHECK_RESPONSE_DATA;
229 if (sati_get_cdb_byte(cdb, 0) == SCSI_MODE_SENSE_6)
230 sequence->type = SATI_SEQUENCE_MODE_SENSE_6_INFORMATIONAL_EXCP_CONTROL;
232 sequence->type = SATI_SEQUENCE_MODE_SENSE_10_INFORMATIONAL_EXCP_CONTROL;
236 sati_scsi_sense_data_construct(
239 SCSI_STATUS_CHECK_CONDITION,
240 SCSI_SENSE_ILLEGAL_REQUEST,
241 SCSI_ASC_INVALID_FIELD_IN_CDB,
242 SCSI_ASCQ_INVALID_FIELD_IN_CDB
244 return SATI_FAILURE_CHECK_RESPONSE_DATA;
251 //******************************************************************************
252 //* P R O T E C T E D M E T H O D S
253 //******************************************************************************
256 * @brief This method will calculate the size of the mode sense data header.
257 * This includes the block descriptor if one is requested.
259 * @param[in] scsi_io This parameter specifies the user's SCSI IO object
260 * for which to calculate the mode page header.
261 * @param[in] cdb_size This parameter specifies the number of bytes
262 * associated with the CDB for which to calculate the header.
264 * @return This method returns the size, in bytes, for the mode page header.
266 U16 sati_mode_sense_calculate_page_header(
271 U8 * cdb = sati_cb_get_cdb_address(scsi_io);
274 // The Mode page header length is different for 6-byte vs. 10-byte CDBs.
276 page_length += SCSI_MODE_SENSE_6_HEADER_LENGTH;
278 page_length += SCSI_MODE_SENSE_10_HEADER_LENGTH;
280 // Are block descriptors disabled (DBD)? 0 indicates they are enabled.
281 if ((sati_get_cdb_byte(cdb, 1) & SCSI_MODE_SENSE_DBD_ENABLE) == 0)
283 // The LLBAA bit is not defined for 6-byte mode sense requests.
284 if ( (cdb_size == 10)
285 && (sati_get_cdb_byte(cdb, 1) & SCSI_MODE_SENSE_LLBAA_ENABLE) )
286 page_length += SCSI_MODE_SENSE_LLBA_BLOCK_DESCRIPTOR_LENGTH;
288 page_length += SCSI_MODE_SENSE_STD_BLOCK_DESCRIPTOR_LENGTH;
295 * @brief This method performs command translation common to all mode sense
296 * requests (6 or 10 byte).
297 * For more information on the parameters passed to this method,
298 * please reference sati_translate_command().
300 * @param[in] cdb_length This parameter specifies the number of bytes
301 * in the CDB (6 or 10).
303 * @return This method returns an indication as to whether the translation
305 * @retval SCI_SUCCESS This value is returned if translation succeeded.
306 * @see sati_mode_sense_is_page_control_supported() or
307 * sati_mode_sense_is_page_code_supported() for more information.
309 SATI_STATUS sati_mode_sense_translate_command(
310 SATI_TRANSLATOR_SEQUENCE_T * sequence,
319 * Validate that the supplied page control (PC) field is supported.
321 status = sati_mode_sense_is_page_control_supported(sequence, scsi_io);
322 if (status != SATI_SUCCESS)
326 * Validate that the supplied page code is supported.
328 status = sati_mode_sense_is_page_code_supported(sequence,scsi_io,cdb_length);
329 if (status != SATI_SUCCESS)
332 sati_ata_identify_device_construct(ata_io, sequence);
338 * @brief This method will build the standard block descriptor for a MODE
339 * SENSE 6 or 10 byte request.
340 * For more information on the parameters passed to this method,
341 * please reference sati_translate_command().
343 * @param[in] identify This parameter specifies the IDENTIFY DEVICE data
344 * associated with the SCSI IO.
345 * @param[in] offset This parameter specifies the offset into the data
346 * buffer at which to build the block descriptor.
348 * @return This method returns the size of the block descriptor built.
350 U32 sati_mode_sense_build_std_block_descriptor(
351 SATI_TRANSLATOR_SEQUENCE_T * sequence,
353 ATA_IDENTIFY_DEVICE_DATA_T * identify,
361 // Extract the sector information (sector size, logical blocks) from
362 // the retrieved ATA identify device data.
363 sati_ata_identify_device_get_sector_info(
364 identify, &lba_high, &lba_low, §or_size
367 // Fill in the 4-byte logical block address field.
368 sati_set_data_byte(sequence, scsi_io, offset, (U8)((lba_low>>24) & 0xFF));
369 sati_set_data_byte(sequence, scsi_io, offset+1, (U8)((lba_low>>16) & 0xFF));
370 sati_set_data_byte(sequence, scsi_io, offset+2, (U8)((lba_low>>8) & 0xFF));
371 sati_set_data_byte(sequence, scsi_io, offset+3, (U8)(lba_low & 0xFF));
373 // Clear the reserved field.
374 sati_set_data_byte(sequence, scsi_io, offset+4, 0);
376 // Fill in the three byte Block Length field
377 sati_set_data_byte(sequence,scsi_io, offset+5, (U8)((sector_size>>16) & 0xFF));
378 sati_set_data_byte(sequence,scsi_io, offset+6, (U8)((sector_size>>8) & 0xFF));
379 sati_set_data_byte(sequence,scsi_io, offset+7, (U8)(sector_size & 0xFF));
381 return SCSI_MODE_SENSE_STD_BLOCK_DESCRIPTOR_LENGTH;
385 * @brief This method simply copies the mode sense data into the buffer
386 * at the location specified by page_start. The buffer copied is
387 * determined by page_control (e.g. current, default, or changeable
389 * For more information on the parameters passed to this method,
390 * please reference sati_translate_command().
392 * @param[in] page_start This parameter specifies the starting offset at
393 * which to copy the mode page data.
394 * @param[in] page_control This parameter specifies the page control
395 * indicating the source buffer to be copied.
396 * @param[in] page_code This specifies the mode sense page to copy.
398 * @return This method returns the size of the mode page data being copied.
400 U32 sati_mode_sense_copy_initial_data(
401 SATI_TRANSLATOR_SEQUENCE_T * sequence,
408 U16 page_index = sati_mode_page_get_page_index(page_code);
409 U32 page_length = sat_mode_page_sizes[page_index];
411 // Find out if the current values are requested or if the default
412 // values are being requested.
413 if (page_control == SCSI_MODE_SENSE_PC_CHANGEABLE)
415 // Copy the changeable mode page information.
420 sat_changeable_mode_pages[page_index],
426 // Copy the default static values template to the user data area.
431 sat_default_mode_pages[page_index],
440 * @brief This method performs the read/write error recovery mode page
441 * specific data translation based upon the contents of the remote
442 * device IDENTIFY DEVICE data.
443 * For more information on the parameters passed to this method,
444 * please reference sati_translate_command().
446 * @param[in] identify This parameter specifies the remote device's
447 * IDENTIFY DEVICE data received as part of the IO request.
448 * @param[in] offset This parameter specifies the offset into the data
449 * buffer where the translated data is to be written.
451 * @return This method returns the size of the mode page data that was
454 U32 sati_mode_sense_read_write_error_translate_data(
455 SATI_TRANSLATOR_SEQUENCE_T * sequence,
457 ATA_IDENTIFY_DEVICE_DATA_T * identify,
461 U8 * cdb = sati_cb_get_cdb_address(scsi_io);
462 U8 page_control = sati_get_cdb_byte(cdb, 2) >> SCSI_MODE_SENSE_PC_SHIFT;
465 page_length = sati_mode_sense_copy_initial_data(
470 SCSI_MODE_PAGE_READ_WRITE_ERROR
473 // Currently we do not override any bits in this mode page from the
480 * @brief This method performs the disconnect/reconnect mode page
481 * specific data translation based upon the contents of the remote
482 * device IDENTIFY DEVICE data.
483 * For more information on the parameters passed to this method,
484 * please reference sati_translate_command().
486 * @param[in] identify This parameter specifies the remote device's
487 * IDENTIFY DEVICE data received as part of the IO request.
488 * @param[in] offset This parameter specifies the offset into the data
489 * buffer where the translated data is to be written.
491 * @return This method returns the size of the mode page data that was
494 U32 sati_mode_sense_disconnect_reconnect_translate_data(
495 SATI_TRANSLATOR_SEQUENCE_T * sequence,
497 ATA_IDENTIFY_DEVICE_DATA_T * identify,
501 U8 * cdb = sati_cb_get_cdb_address(scsi_io);
502 U8 page_control = sati_get_cdb_byte(cdb, 2) >> SCSI_MODE_SENSE_PC_SHIFT;
505 page_length = sati_mode_sense_copy_initial_data(
510 SCSI_MODE_PAGE_DISCONNECT_RECONNECT
513 // Currently we do not override any bits in this mode page from the
520 * @brief This method performs the caching mode page specific data
521 * translation based upon the contents of the remote device IDENTIFY
523 * For more information on the parameters passed to this method,
524 * please reference sati_translate_command().
526 * @param[in] identify This parameter specifies the remote device's
527 * IDENTIFY DEVICE data received as part of the IO request.
528 * @param[in] offset This parameter specifies the offset into the data
529 * buffer where the translated data is to be written.
531 * @return This method returns the size of the mode page data that was
534 U32 sati_mode_sense_caching_translate_data(
535 SATI_TRANSLATOR_SEQUENCE_T * sequence,
537 ATA_IDENTIFY_DEVICE_DATA_T * identify,
541 U8 * cdb = sati_cb_get_cdb_address(scsi_io);
542 U8 page_control = sati_get_cdb_byte(cdb, 2) >> SCSI_MODE_SENSE_PC_SHIFT;
545 page_length = sati_mode_sense_copy_initial_data(
550 SCSI_MODE_PAGE_CACHING
553 // If the request queried for the current values, then
554 // we need to translate the data from the IDENTIFY DEVICE request.
555 if (page_control == SCSI_MODE_SENSE_PC_CURRENT)
559 // Update the Write Cache Enabled (WCE) bit in the mode page data
560 // buffer based on the identify response.
561 if ((identify->command_set_enabled0 & ATA_IDENTIFY_DEVICE_WCE_ENABLE) != 0)
563 sati_get_data_byte(sequence, scsi_io, offset+2, &value);
564 value |= SCSI_MODE_PAGE_CACHE_PAGE_WCE_BIT;
565 sati_set_data_byte(sequence, scsi_io, offset+2, value);
566 //This byte has been set twice and needs to be decremented
567 sequence->number_data_bytes_set--;
570 // Update the Disable Read Ahead (DRA) bit in the mode page data
571 // buffer based on the identify response.
572 if ((identify->command_set_enabled0 & ATA_IDENTIFY_DEVICE_RA_ENABLE) == 0)
574 // In SATA the polarity of the bits is inverse.
575 // - SCSI = Disable Read Ahead
576 // - ATA = Read Ahead
577 sati_get_data_byte(sequence, scsi_io, offset+12, &value);
578 value |= SCSI_MODE_PAGE_CACHE_PAGE_DRA_BIT;
579 sati_set_data_byte(sequence, scsi_io, offset+12, value);
581 //This byte has been set twice, the first time in
582 //sati_mode_sense_copy_initial_data. number_data_bytes_set
583 //needs to be decremented
584 sequence->number_data_bytes_set--;
592 * @brief This method performs the control mode page specific data
593 * translation based upon the contents of the remote device
594 * IDENTIFY DEVICE data.
595 * For more information on the parameters passed to this method,
596 * please reference sati_translate_command().
598 * @param[in] identify This parameter specifies the remote device's
599 * IDENTIFY DEVICE data received as part of the IO request.
600 * @param[in] offset This parameter specifies the offset into the data
601 * buffer where the translated data is to be written.
603 * @return This method returns the size of the mode page data that was
606 U32 sati_mode_sense_control_translate_data(
607 SATI_TRANSLATOR_SEQUENCE_T * sequence,
609 ATA_IDENTIFY_DEVICE_DATA_T * identify,
613 U8 * cdb = sati_cb_get_cdb_address(scsi_io);
614 U8 page_control = sati_get_cdb_byte(cdb, 2) >> SCSI_MODE_SENSE_PC_SHIFT;
618 page_length = sati_mode_sense_copy_initial_data(
623 SCSI_MODE_PAGE_CONTROL
626 if (sequence->device->descriptor_sense_enable)
628 sati_get_data_byte(sequence, scsi_io, offset+2,
631 sati_set_data_byte(sequence, scsi_io, offset+2,
632 value | SCSI_MODE_SELECT_MODE_PAGE_D_SENSE);
639 * @brief This method performs the informational exceptions control mode
640 * page specific data translation based upon the contents of the
641 * remote device IDENTIFY DEVICE data.
642 * For more information on the parameters passed to this method,
643 * please reference sati_translate_command().
645 * @param[in] identify This parameter specifies the remote device's
646 * IDENTIFY DEVICE data received as part of the IO request.
647 * @param[in] offset This parameter specifies the offset into the data
648 * buffer where the translated data is to be written.
650 * @return This method returns the size of the mode page data that was
653 U32 sati_mode_sense_informational_excp_control_translate_data(
654 SATI_TRANSLATOR_SEQUENCE_T * sequence,
656 ATA_IDENTIFY_DEVICE_DATA_T * identify,
660 U8 * cdb = sati_cb_get_cdb_address(scsi_io);
661 U8 page_control = sati_get_cdb_byte(cdb, 2) >> SCSI_MODE_SENSE_PC_SHIFT;
664 page_length = sati_mode_sense_copy_initial_data(
669 SCSI_MODE_PAGE_INFORMATIONAL_EXCP_CONTROL
672 // If the request queried for the current values, then
673 // we need to translate the data from the IDENTIFY DEVICE request.
674 if (page_control == SCSI_MODE_SENSE_PC_CURRENT)
678 sati_get_data_byte(sequence, scsi_io, offset+2, &value);
680 // Determine if the SMART feature set is supported and enabled.
681 if ( (identify->command_set_supported0
682 & ATA_IDENTIFY_COMMAND_SET_SUPPORTED0_SMART_ENABLE)
683 && (identify->command_set_enabled0
684 & ATA_IDENTIFY_COMMAND_SET_ENABLED0_SMART_ENABLE) )
686 // Clear the DXCPT field since the SMART feature is supported/enabled.
687 value &= ~SCSI_MODE_PAGE_INFORMATIONAL_EXCP_DXCPT_ENABLE;
691 // Set the Disable Exception Control (DXCPT) field since the SMART
692 // feature is not supported or enabled.
693 value |= SCSI_MODE_PAGE_INFORMATIONAL_EXCP_DXCPT_ENABLE;
696 sati_set_data_byte(sequence, scsi_io, offset+2, value);
698 //This byte has been set twice, the first time in
699 //sati_mode_sense_copy_initial_data. number_data_bytes_set
700 //needs to be decremented
701 sequence->number_data_bytes_set--;
708 * @brief This method performs the Power Condition mode page
709 * specific data translation based upon the contents of the
710 * remote device IDENTIFY DEVICE data.
711 * For more information on the parameters passed to this method,
712 * please reference sati_translate_command().
714 * @param[in] identify This parameter specifies the remote device's
715 * IDENTIFY DEVICE data received as part of the IO request.
716 * @param[in] offset This parameter specifies the offset into the data
717 * buffer where the translated data is to be written.
719 * @return This method returns the size of the mode page data that was
722 U32 sati_mode_sense_power_condition_translate_data(
723 SATI_TRANSLATOR_SEQUENCE_T * sequence,
725 ATA_IDENTIFY_DEVICE_DATA_T * identify,
729 U8 * cdb = sati_cb_get_cdb_address(scsi_io);
730 U8 page_control = sati_get_cdb_byte(cdb, 2) >> SCSI_MODE_SENSE_PC_SHIFT;
734 //Represents tenths of seconds
735 U32 standby_timer = 0x00000000;
737 U8 standby_enabled = STANDBY_TIMER_DISABLED;
739 if ((page_control == SCSI_MODE_SENSE_PC_CURRENT) &&
740 (identify->capabilities1 & STANDBY_TIMER_SUPPORTED))
742 standby_enabled = STANDBY_TIMER_ENABLED;
744 ata_sb_timer = sequence->device->ata_standby_timer;
746 //converting ATA timer values into SCSI timer values
747 if(ata_sb_timer <= 0xF0)
749 standby_timer = ata_sb_timer * 50;
751 else if(ata_sb_timer <= 0xFB)
753 standby_timer = ((ata_sb_timer - 240) * 18000);
755 else if(ata_sb_timer == 0xFC)
757 standby_timer = 12600;
759 else if(ata_sb_timer == 0xFD)
761 standby_timer = 432000;
763 else if(ata_sb_timer == 0xFF)
765 standby_timer = 12750;
769 standby_timer = 0xFFFFFFFF;
773 sati_set_data_byte(sequence, scsi_io, offset, SCSI_MODE_PAGE_POWER_CONDITION);
774 sati_set_data_byte(sequence, scsi_io, offset + 1, (SCSI_MODE_PAGE_1A_LENGTH - 2));
775 sati_set_data_byte(sequence, scsi_io, offset + 2, 0x00);
776 sati_set_data_byte(sequence, scsi_io, offset + 3, standby_enabled);
777 sati_set_data_byte(sequence, scsi_io, offset + 4, 0x00);
778 sati_set_data_byte(sequence, scsi_io, offset + 5, 0x00);
779 sati_set_data_byte(sequence, scsi_io, offset + 6, 0x00);
780 sati_set_data_byte(sequence, scsi_io, offset + 7, 0x00);
781 sati_set_data_byte(sequence, scsi_io, offset + 8, (U8) (standby_timer >> 24));
782 sati_set_data_byte(sequence, scsi_io, offset + 9, (U8) (standby_timer >> 16));
783 sati_set_data_byte(sequence, scsi_io, offset + 10, (U8) (standby_timer >> 8));
784 sati_set_data_byte(sequence, scsi_io, offset + 11, (U8) standby_timer);
786 return SCSI_MODE_PAGE_1A_LENGTH;
790 * @brief This method performs the all pages mode page specific data
791 * translation based upon the contents of the remote device
792 * IDENTIFY DEVICE data. The ALL PAGES mode sense request asks
793 * for all of mode pages and sub-pages in a single page.
794 * The mode pages are added in ascending order.
795 * For more information on the parameters passed to this method,
796 * please reference sati_translate_command().
798 * @param[in] identify This parameter specifies the remote device's
799 * IDENTIFY DEVICE data received as part of the IO request.
800 * @param[in] offset This parameter specifies the offset into the data
801 * buffer where the translated data is to be written.
803 * @return This method returns the size of the mode page data that was
806 U32 sati_mode_sense_all_pages_translate_data(
807 SATI_TRANSLATOR_SEQUENCE_T * sequence,
809 ATA_IDENTIFY_DEVICE_DATA_T * identify,
813 offset += sati_mode_sense_read_write_error_translate_data(
814 sequence, scsi_io, identify, offset
817 offset += sati_mode_sense_disconnect_reconnect_translate_data(
818 sequence, scsi_io, identify, offset
821 offset += sati_mode_sense_caching_translate_data(
822 sequence, scsi_io, identify, offset
825 offset += sati_mode_sense_control_translate_data(
826 sequence, scsi_io, identify, offset
829 offset += sati_mode_sense_informational_excp_control_translate_data(
830 sequence, scsi_io, identify, offset
836 #endif // !defined(DISABLE_SATI_MODE_SENSE)