4 * Home page of code is: http://smartmontools.sourceforge.net
6 * Copyright (C) Joerg Hering <smartmontools-support@lists.sourceforge.net>
7 * Copyright (C) 2003-8 Bruce Allen <smartmontools-support@lists.sourceforge.net>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2, or (at your option)
14 * You should have received a copy of the GNU General Public License
15 * (for example COPYING); if not, write to the Free
16 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 * This code was originally developed as a Senior Thesis by Michael Cornwell
19 * at the Concurrent Systems Laboratory (now part of the Storage Systems
20 * Research Center), Jack Baskin School of Engineering, University of
21 * California, Santa Cruz. http://ssrc.soe.ucsc.edu/
26 #define OS_QNXNTO_H_CVSID "$Id: os_qnxnto.h,v 1.2 2008/03/04 22:09:47 ballen4705 Exp $\n"
28 // Additional material should start here. Note: to keep the '-V' CVS
29 // reporting option working as intended, you should only #include
30 // system include files <something.h>. Local #include files
31 // <"something.h"> should be #included in os_generic.c
34 #ifndef __TYPES_H_INCLUDED
35 #include <sys/types.h>
42 #include <sys/dcmd_cam.h>
43 #include <sys/cam_device.h>
46 //----------------------------------------------------------------------------------------------------------
47 typedef struct _ata_pass_thru ATA_PASS_THRU
;
48 typedef struct _eide_identify EIDE_IDENTIFY
;
49 typedef struct _ata_sense ATA_SENSE
;
53 struct _resmgr_context
;
56 typedef struct _drive_attribute
63 //----------------------------------------------------------------------------------------------------------
64 /* UNIVOS OSD defines and data structures. */
66 #define INQLEN 36 /* Inquiry string length to store. */
68 #define CAM_SUCCESS 0 /* For signaling general success */
69 #define CAM_FAILURE 1 /* For signaling general failure */
71 #define CAM_FALSE 0 /* General purpose flag value */
72 #define CAM_TRUE 1 /* General purpose flag value */
74 //----------------------------------------------------------------------------------------------------------
75 // Group 3 and 4, command codes 60H-9FH are reserved
76 #define SC_ATA_PT16 0x85 // ATA Pass-through
77 //----------------------------------------------------------------------------------------------------------
78 #define ATA_SMART_LBA_MID_SIG 0x4f
79 #define ATA_SMART_LBA_HI_SIG 0xc2
80 #define ATA_SMART_SIG 0xc24f
81 //----------------------------------------------------------------------------------------------------------
82 struct _ata_pass_thru
{
84 #define ATA_PROTO_MSK 0x1e
85 #define ATA_PROTO_RESPONSE (15 << 1)
86 #define ATA_PROTO_FPDMA (12 << 1)
87 #define ATA_PROTO_UDMA_DATA_OUT (11 << 1)
88 #define ATA_PROTO_UDMA_DATA_IN (10 << 1)
89 #define ATA_PROTO_DEVICE_RESET (9 << 1)
90 #define ATA_PROTO_DEVICE_DIAGNOSTIC (8 << 1)
91 #define ATA_PROTO_DMA_QUEUED (7 << 1)
92 #define ATA_PROTO_DMA (6 << 1)
93 #define ATA_PROTO_PIO_DATA_OUT (5 << 1)
94 #define ATA_PROTO_PIO_DATA_IN (4 << 1)
95 #define ATA_PROTO_DATA_NONE (3 << 1)
96 #define ATA_PROTO_SRST (1 << 1)
97 #define ATA_PROTO_HRST (0 << 1)
98 #define ATA_PROTO_EXTEND 0x01
99 uchar_t protocol
; // multiple count, protocol
100 #define ATA_MCOUNT_MSK 0xe0
102 #define ATA_FLG_CK_COND 0x20
103 #define ATA_FLG_T_DIR 0x08 // data from device
104 #define ATA_FLG_BYT_BLOK 0x04
105 #define ATA_FLG_TLEN_STPSIU 0x03
106 #define ATA_FLG_TLEN_SECTOR_COUNT 0x02
107 #define ATA_FLG_TLEN_FEATURE 0x01
112 uchar_t esector_count
;
113 uchar_t sector_count
;
124 //----------------------------------------------------------------------------------------------------------
125 #define SENSE_DATA_FMT_DESCRIPTOR 0x02
127 // Fixed Format Sense Data Structure
128 // Note: The field "error" has the following format:
129 // bit 7 - Address valid bit
130 // bits 6-4 - Error class
131 // bits 3-0 - Error code
133 // Error classes 0-6 are vendor unique and also indicate that the
134 // sense data is in _nonextended_ format. (i.e. not usually used)
135 // struct _scsi_nonextended_sense {
137 // ulong_t sd_block_address;
140 // An error class of 7 and an error code of 0 (70H) indicate SCSI-1
141 // extended sense data format (or SCSI-2 sense data format).
143 // An error class of 7 and an error code of 1 (71H) indicate SCSI-2
146 // Error codes 74H to 7EH are reserved and error code 7FH indicates
147 // a vendor-specific sense data format.
148 typedef struct _scsi_sense
{
149 uchar_t error
; // Error Code
150 uchar_t segment
; // Segment number
151 uchar_t sense
; // Sense key/flags
152 uchar_t info
[4]; // Information (32bit big-endian value)
153 uchar_t asl
; // Additional Sense Length
154 uchar_t csinfo
[4]; // Command-Specific Information
155 uchar_t asc
; // Additional Sense Code
156 uchar_t ascq
; // Additional Sense Code Qualifier
157 uchar_t fruc
; // Field Replaceable Unit Code
158 uchar_t sks
; // Sense Key Specific
159 ushort_t sks_data
; // Sense Key Specific Data (16bit big-endian)
160 ushort_t asb
; // Additional Sense uchar_ts (Max 256-18)
163 // Descriptor Format Sense Data Structure
164 // error code of 72 current, 73 deferred
165 // extended sense data format (or SCSI-2 sense data format).
166 typedef struct _scsi_sense_descriptor
{
167 uchar_t error
; // Error Code
168 uchar_t sense
; // Sense key/flags
169 uchar_t asc
; // Additional Sense Code
170 uchar_t ascq
; // Additional Sense Code Qualifier
172 uchar_t asl
; // Additional Sense Length
173 } SCSI_SENSE_DESCRIPTOR
;
175 typedef struct _scsi_sense_desriptor_header
{
176 uchar_t descriptor_type
;
177 uchar_t descriptor_len
;
178 } SCSI_SENSE_DESCRIPTOR_HEADER
;
180 #define SENSE_DTYPE_INFORMATION 0x00
181 #define SENSE_DTYPE_CSI 0x01 // Command Specific Information
182 #define SENSE_DTYPE_SKS 0x02 // Sense Key Specific
183 #define SENSE_DTYPE_FRU 0x03 // Field Replaceable Unit
184 #define SENSE_DTYPE_STREAM 0x04
185 #define SENSE_DTYPE_BLOCK 0x05
186 #define SENSE_DTYPE_OSD_OBJ_IDENT 0x06 // OSD Object Identification
187 #define SENSE_DTYPE_OSD_INTEGRITY 0x07 // OSD Response Integrity Check Value
188 #define SENSE_DTYPE_OSD_ATR_IDENT 0x08 // OSD Attribute Identification
189 #define SENSE_DTYPE_ATA 0x09
191 typedef struct _ata_status_descriptor
{
192 uchar_t descriptor_type
;
193 #define ATA_SD_DLEN 0x0c
194 uchar_t descriptor_len
; /* 0xc */
195 #define ATA_SD_FLG_EXTEND 0x01
198 uchar_t esector_count
; /* (15:8) */
199 uchar_t sector_count
; /* (7:0) */
200 uchar_t elba_low
; /* (15:8) */
201 uchar_t lba_low
; /* (7:0) */
202 uchar_t elba_mid
; /* (15:8) */
203 uchar_t lba_mid
; /* (7:0) */
204 uchar_t elba_high
; /* (15:8) */
205 uchar_t lba_high
; /* (7:0) */
208 } ATA_STATUS_DESCRIPTOR
;
210 //----------------------------------------------------------------------------------------------------------
212 #define SK_MSK 0x0F // mask to sd_sense field for key
214 #define SK_NO_SENSE 0 // No sense data (no error)
215 #define ASCQ_FILEMARK_DETECTED 0x01
216 #define ASCQ_EOPM_DETECTED 0x02 // End of Partition/Medium Detected
217 #define ASCQ_SETMARK_DETECTED 0x03
218 #define ASCQ_BOPM_DETECTED 0x04 // Beginning of Partition/Medium Detected
220 #define SK_RECOVERED 1 // Recovered error
221 #define ASC_ATA_PASS_THRU 0x00
222 #define ASCQ_ATA_PASS_THRU_INFO_AVAIL 0x1d
224 #define SK_NOT_RDY 2 // Device not ready
225 #define ASC_NO_SEEK_COMPLETE 0x02
226 #define ASC_NOT_READY 0x04
227 #define ASCQ_CAUSE_NOT_REPORTABLE 0x00
228 #define ASCQ_BECOMING_READY 0x01
229 #define ASCQ_INIT_COMMAND_REQUIRED 0x02
230 #define ASCQ_MANUAL_INTERVENTION_REQUIRED 0x03
231 #define ASCQ_FORMAT_IN_PROGRESS 0x04
232 #define ASCQ_UNKNOWN_CHANGED 0xff // NTO extension for fdc's
233 #define ASC_MEDIA_FORMAT 0x30 // bad format
234 #define ASC_MEDIA_NOT_PRESENT 0x3a
235 #define ASC_NOT_CONFIGURED 0x3e
237 #define SK_MEDIUM 3 // Medium error
238 #define ASC_UNRECOVERABLE_READ_ERROR 0x11
239 #define ASC_RECORD_NOT_FOUND 0x14
240 #define ASCQ_RECORD_NOT_FOUND 0x01
241 #define ASC_UNABLE_TO_RECOVER_TOC 0x57
242 #define ASC_INCOMPATIBLE_MEDIUM 0x64
244 #define SK_HARDWARE 4 // Hardware error
245 #define ASC_INTERNAL_TARGET_FAILURE 0x44
246 #define ASC_MEDIA_LOAD_EJECT_FAILURE 0x53
247 #define ASCQ_UNRECOVERABLE_CIRC 0x06
249 #define SK_ILLEGAL 5 // Illegal Request (bad command)
250 #define ASC_INVALID_COMMAND 0x20
251 #define ASC_INVALID_FIELD 0x24
252 #define ASC_INVALID_FIELD_PARAMETER 0x26
253 #define ASC_COMMAND_SEQUENCE_ERROR 0x2c
254 #define ASCQ_READ_SCRAMBLED 0x03
255 #define ASC_ILLEGAL_MODE 0x64
256 #define ASC_COPY_PROTECTION 0x6f
258 #define SK_UNIT_ATN 6 // Unit Attention
259 #define ASC_MEDIUM_CHANGED 0x28
260 #define ASC_BUS_RESET 0x29
261 #define ASC_INSUFFICIENT_TIME_FOR_OPERATION 0x2e
262 #define ASC_OPERATOR_REQUEST 0x5a
263 #define ASCQ_OPERATOR_MEDIUM_REMOVAL 0x01
265 #define SK_DATA_PROT 7 // Data Protect
266 #define ASC_WRITE_PROTECTED 0x27
268 #define SK_BLNK_CHK 8 // Blank Check
269 #define SK_VENDOR 9 // Vendor Specific
270 #define SK_CPY_ABORT 10 // Copy Aborted
271 #define SK_CMD_ABORT 11 // Aborted Command
272 #define SK_EQUAL 12 // Equal
273 #define SK_VOL_OFL 13 // Volume Overflow
274 #define SK_MISCMP 14 // Miscompare
275 #define SK_RESERVED 15 // Reserved
276 //----------------------------------------------------------------------------------------------------------
277 // Command Descriptor Block structure definitions
280 #define CF_LINK 0x01 // Linked-command indication
281 #define CF_FLAG 0x02 // Linked-command with flag bit
282 #define CF_VENDOR0 0x40 // Vendor unique bits
283 #define CF_VENDOR1 0x80
289 // generic 6 byte command descriptor block
294 uchar_t lba_byte0
; // LSB
295 uchar_t transfer_len
;
299 // generic 10 byte command descriptor block
308 uchar_t transfer_len
[2];
312 // generic 12 byte command descriptor block
320 uchar_t transfer_len
[4];
325 struct _format_unit
{
327 #define FU_RSVD0 0xc0 // reserved bits
328 #define FU_FMTDAT 0x10
329 #define FU_CMPLIST 0x08
330 uchar_t defect_list_fmt
;
336 struct _format_unit_old
{
339 uchar_t medium_type_code
;
343 #define FMT_RSVD3 0x80
344 #define FMT_SECT_SIZE_CD 0x70
345 #define FMT_IMMED 0x08
346 #define FMT_HEAD 0x04
348 #define FMT_CERT 0x01
354 #define RW_OPT_RELADR 0x01
355 #define RW_OPT_CORRCT 0x02 // Disable Corrections
356 #define RW_OPT_FUA 0x08 // Force Unit Access
357 #define RW_OPT_DPO 0x10 // Disable Page Out
362 uchar_t transfer_len
;
371 uchar_t transfer_len
[2];
379 uchar_t transfer_len
[4];
384 #define MSEL_OPT_PF 0x10 // Page Format
385 #define MSEL_OPT_SP 0x01 // Save Page
391 uchar_t param_length
;
403 uchar_t param_length
[2];
409 #define LS_OPT_SP 0x01 // Save Parameters
410 #define LS_OPT_PCR 0x02 // Parameter Code Reset
412 #define LS_PC_CUR_THRESHOLD 0x00
413 #define LS_PC_CUR_CUMULATIVE 0x01
414 #define LS_PC_DFLT_THRESHOLD 0x02
415 #define LS_PC_DFLT_CUMULATIVE 0x03
416 uchar_t pc
; // Page Control
421 uchar_t param_length
[2];
427 #define MSNS_OPT_DBD 0x08 // Disable Block Descriptors
429 #define PC_CURRENT 0x00
430 #define PC_CHANGEABLE 0x40
431 #define PC_DEFAULT 0x80
432 #define PC_SAVED 0xC0
436 uchar_t allocation_length
;
440 struct _mode_sense10
{
448 uchar_t allocation_length
[2];
458 uchar_t parameter_pointer
[2];
459 uchar_t allocation_length
[2];
474 #define LD_OPT_IMMED 0x01
478 #define LD_CMD_START 0x01
479 #define LD_CMD_LOEJ 0x02
480 #define LD_CMD_STOP 0x00
481 #define LD_CMD_EJECT 0x02
482 #define LD_CMD_LOAD 0x03
485 #define LD_CMD_SA_HOLD 0x08
486 #define LD_CMD_SA_EOT 0x04
487 #define LD_CMD_SA_RT 0x02 // re-tension
488 #define LD_CMD_SA_LOEJ 0x01
491 #define LD_CMD_PC_MSK 0xf0
492 #define LD_CMD_PC_NC 0
493 #define LD_CMD_PC_ACTIVE 1
494 #define LD_CMD_PC_IDLE 2
495 #define LD_CMD_PC_STANDBY 3
496 #define LD_CMD_PC_SLEEP 5
505 #define SC_OPT_RELADR 0x01
506 #define SC_OPT_IMMED 0x02
508 uchar_t num_blocks
[2];
521 uchar_t allocation_length
[2];
523 } read_disc_information
;
542 uchar_t start_minute
;
543 uchar_t start_second
;
566 #define CD_SCAN_DIR_FORWARD 0x00
567 #define CD_SCAN_DIR_REVERSE 0x10
569 uchar_t start_address
[4];
570 #define CD_SCAN_TYPE_LBA 0x00
571 #define CD_SCAN_TYPE_MSF 0x40
572 #define CD_SCAN_TYPE_TRK 0x80
573 #define CD_SCAN_TYPE_MSK 0xc0
584 #define RTOC_OPT_MSF 0x02
586 #define RTOC_FMT_TOC 0x0
587 #define RTOC_FMT_SESSION 0x1
588 #define RTOC_FMT_QSUBCODE 0x2
589 #define RTOC_FMT_QSUBCHNL 0x3
590 #define RTOC_FMT_ATIP 0x4
591 #define RTOC_FMT_CDTEXT 0x5
597 uchar_t allocation_length
[2];
598 #define RTOC_CNTL_FMT_SESSION 0x40
599 uchar_t control_format
;
606 uchar_t allocation_length
[2];
612 #define EXCHANGE_OPT_IMMED 0x01
616 #define EXCHANGE_CMD_START 0x01
617 #define EXCHANGE_CMD_LOEJ 0x02
631 uchar_t feature_number
[2];
635 uchar_t allocation_length
[2];
641 #define GE_OPT_POLLED 0x01
645 #define NCR_OPERATIONAL_CHANGE 0x02
646 #define NCR_POWER_MANAGEMENT 0x04
647 #define NCR_EXTERNAL_REQUEST 0x08
648 #define NCR_MEDIA 0x10
649 #define NCR_MULTI_INITIATOR 0x20
650 #define NCR_DEVICE_BUSY 0x40
651 uchar_t ncr
; // notification class request
654 uchar_t allocation_length
[2];
666 uchar_t allocation_length
[2];
668 } read_formated_capacities
;
673 uchar_t read_speed
[2];
674 uchar_t write_speed
[2];
680 #define RSCHNL_OPT_MSF 0x02
682 #define RSCHNL_DATA_SUBQ 0x40
688 uchar_t allocation_length
[2];
692 #define CD_FRAME_SYNC_SIZE 12
693 #define CD_FRAME_HDR_SIZE 4
694 #define CD_FRAME_SUB_HDR_SIZE 8
695 #define CD_FRAME_EDC_SIZE 4
696 #define CD_FRAME_ECC_SIZE 276
697 #define CD_FRAME_AUX_SIZE 8
698 #define CD_FRAME_ZERO_SIZE 8
699 #define CD_FRAME_SPARE_SIZE 4
700 #define CD_FRAME_C2_ERR_SIZE 294
701 #define CD_FRAME_BLOCK_ERR_SIZE 2
706 // expected sector type
707 #define RDCD_EST_ANY_SECTOR (0 << 2)
708 #define RDCD_EST_CDDA_SECTOR (1 << 2)
709 #define RDCD_EST_YELLOW_MODE1_SECTOR (2 << 2)
710 #define RDCD_EST_YELLOW_MODE2_SECTOR (3 << 2)
711 #define RDCD_EST_XA_SECTOR (4 << 2)
712 #define RDCD_EST_XA_FORM2_SECTOR (5 << 2)
713 #define RDCD_EST_MSK (7 << 2)
715 uchar_t transfer_len
[3];
717 #define RDCD_FLG_SYNC 0x80
718 #define RDCD_FLG_UDATA 0x10
719 #define RDCD_FLG_ECC 0x08
720 #define RDCD_FLG_CD_ERR 0x02
721 #define RDCD_FLG_CD_BLOCK_ERR 0x04
722 #define RDCD_FLG_HC_NONE ( 0x00 << 5 )
723 #define RDCD_FLG_HC_HDR ( 0x01 << 5 )
724 #define RDCD_FLG_HC_SUBHEADER ( 0x02 << 5 )
725 #define RDCD_FLG_HC_ALL_HEADERS ( 0x03 << 5 )
726 uchar_t subch_selection
;
734 uchar_t start_minute
;
735 uchar_t start_second
;
741 uchar_t subch_selection
;
745 struct _ata_pass_thru
{
747 #define ATA_PROTO_MSK 0x1e
748 #define ATA_PROTO_RESPONSE (15 << 1)
749 #define ATA_PROTO_FPDMA (12 << 1)
750 #define ATA_PROTO_UDMA_DATA_OUT (11 << 1)
751 #define ATA_PROTO_UDMA_DATA_IN (10 << 1)
752 #define ATA_PROTO_DEVICE_RESET (9 << 1)
753 #define ATA_PROTO_DEVICE_DIAGNOSTIC (8 << 1)
754 #define ATA_PROTO_DMA_QUEUED (7 << 1)
755 #define ATA_PROTO_DMA (6 << 1)
756 #define ATA_PROTO_PIO_DATA_OUT (5 << 1)
757 #define ATA_PROTO_PIO_DATA_IN (4 << 1)
758 #define ATA_PROTO_DATA_NONE (3 << 1)
759 #define ATA_PROTO_SRST (1 << 1)
760 #define ATA_PROTO_HRST (0 << 1)
761 #define ATA_PROTO_EXTEND 0x01
762 uchar_t protocol
; // multiple count, protocol
763 #define ATA_MCOUNT_MSK 0xe0
765 #define ATA_FLG_CK_COND 0x20
766 #define ATA_FLG_T_DIR 0x08 // data from device
767 #define ATA_FLG_BYT_BLOK 0x04
768 #define ATA_FLG_TLEN_STPSIU 0x03
769 #define ATA_FLG_TLEN_SECTOR_COUNT 0x02
770 #define ATA_FLG_TLEN_FEATURE 0x01
775 uchar_t esector_count
;
776 uchar_t sector_count
;
788 // sequential access commands
791 #define ERASE_OPT_LONG 0x01
799 #define LOCATE_OPT_CP 0x2
800 #define LOCATE_OPT_BT 0x4
803 uchar_t ba
[4]; // block address
816 #define RP_OPT_BT 0x01 // block address type
817 #define RP_OPT_LNG 0x02 // long format
818 #define RP_OPT_TCLP 0x04 // total current logical position
826 #define SRW_OPT_FIXED 0x01
827 #define SRW_OPT_SILI 0x02
831 uchar_t transfer_len
[3];
844 #define SPACE_CODE_BLOCKS 0x00
845 #define SPACE_CODE_FMRKS 0x01
846 #define SPACE_CODE_SEQ_FMRKS 0x02
847 #define SPACE_CODE_EOD 0x03
848 #define SPACE_CODE_SMRKS 0x04
849 #define SPACE_CODE_SEQ_SMRKS 0x05
857 #define WF_OPT_IMMED 0x01
858 #define WF_OPT_WSMK 0x02
860 uchar_t transfer_length
[3];
866 #define RD_OPT_MEDIA 0x01
869 uchar_t allocation_length
[2];
875 #define FM_OPT_IMMED 0x01
876 #define FM_OPT_VERIFY 0x02
878 #define FM_FMT_DFLT 0x00
879 #define FM_FMT_PARTITION 0x01
880 #define FM_FMT_FORMAT_PARTITION 0x02
882 uchar_t transfer_length
[2];
886 //----------------------------------------------------------------------------------------------------------
890 SCSI_SENSE_DESCRIPTOR sense
;
891 ATA_STATUS_DESCRIPTOR desc
;
893 //----------------------------------------------------------------------------------------------------------
896 #endif /* OS_QNXNTO_H_ */