4 * Home page of code is: http://www.smartmontools.org
6 * Copyright (C) 2007 Joerg Hering
7 * Copyright (C) 2003-8 Bruce Allen
9 * SPDX-License-Identifier: GPL-2.0-or-later
13 #define OS_QNXNTO_H_CVSID "$Id: os_qnxnto.h 4761 2018-08-20 19:33:04Z chrfranke $\n"
15 // Additional material should start here. Note: to keep the '-V' CVS
16 // reporting option working as intended, you should only #include
17 // system include files <something.h>. Local #include files
18 // <"something.h"> should be #included in os_generic.c
21 #ifndef __TYPES_H_INCLUDED
22 #include <sys/types.h>
29 #include <sys/dcmd_cam.h>
30 #include <sys/cam_device.h>
33 //----------------------------------------------------------------------------------------------------------
34 typedef struct _ata_pass_thru ATA_PASS_THRU
;
35 typedef struct _eide_identify EIDE_IDENTIFY
;
36 typedef struct _ata_sense ATA_SENSE
;
40 struct _resmgr_context
;
43 typedef struct _drive_attribute
50 //----------------------------------------------------------------------------------------------------------
51 /* UNIVOS OSD defines and data structures. */
53 #define INQLEN 36 /* Inquiry string length to store. */
55 #define CAM_SUCCESS 0 /* For signaling general success */
56 #define CAM_FAILURE 1 /* For signaling general failure */
58 #define CAM_FALSE 0 /* General purpose flag value */
59 #define CAM_TRUE 1 /* General purpose flag value */
61 //----------------------------------------------------------------------------------------------------------
62 // Group 3 and 4, command codes 60H-9FH are reserved
63 #define SC_ATA_PT16 0x85 // ATA Pass-through
64 //----------------------------------------------------------------------------------------------------------
65 #define ATA_SMART_LBA_MID_SIG 0x4f
66 #define ATA_SMART_LBA_HI_SIG 0xc2
67 #define ATA_SMART_SIG 0xc24f
68 //----------------------------------------------------------------------------------------------------------
69 struct _ata_pass_thru
{
71 #define ATA_PROTO_MSK 0x1e
72 #define ATA_PROTO_RESPONSE (15 << 1)
73 #define ATA_PROTO_FPDMA (12 << 1)
74 #define ATA_PROTO_UDMA_DATA_OUT (11 << 1)
75 #define ATA_PROTO_UDMA_DATA_IN (10 << 1)
76 #define ATA_PROTO_DEVICE_RESET (9 << 1)
77 #define ATA_PROTO_DEVICE_DIAGNOSTIC (8 << 1)
78 #define ATA_PROTO_DMA_QUEUED (7 << 1)
79 #define ATA_PROTO_DMA (6 << 1)
80 #define ATA_PROTO_PIO_DATA_OUT (5 << 1)
81 #define ATA_PROTO_PIO_DATA_IN (4 << 1)
82 #define ATA_PROTO_DATA_NONE (3 << 1)
83 #define ATA_PROTO_SRST (1 << 1)
84 #define ATA_PROTO_HRST (0 << 1)
85 #define ATA_PROTO_EXTEND 0x01
86 uchar_t protocol
; // multiple count, protocol
87 #define ATA_MCOUNT_MSK 0xe0
89 #define ATA_FLG_CK_COND 0x20
90 #define ATA_FLG_T_DIR 0x08 // data from device
91 #define ATA_FLG_BYT_BLOK 0x04
92 #define ATA_FLG_TLEN_STPSIU 0x03
93 #define ATA_FLG_TLEN_SECTOR_COUNT 0x02
94 #define ATA_FLG_TLEN_FEATURE 0x01
99 uchar_t esector_count
;
100 uchar_t sector_count
;
111 //----------------------------------------------------------------------------------------------------------
112 #define SENSE_DATA_FMT_DESCRIPTOR 0x02
114 // Fixed Format Sense Data Structure
115 // Note: The field "error" has the following format:
116 // bit 7 - Address valid bit
117 // bits 6-4 - Error class
118 // bits 3-0 - Error code
120 // Error classes 0-6 are vendor unique and also indicate that the
121 // sense data is in _nonextended_ format. (i.e. not usually used)
122 // struct _scsi_nonextended_sense {
124 // ulong_t sd_block_address;
127 // An error class of 7 and an error code of 0 (70H) indicate SCSI-1
128 // extended sense data format (or SCSI-2 sense data format).
130 // An error class of 7 and an error code of 1 (71H) indicate SCSI-2
133 // Error codes 74H to 7EH are reserved and error code 7FH indicates
134 // a vendor-specific sense data format.
135 typedef struct _scsi_sense
{
136 uchar_t error
; // Error Code
137 uchar_t segment
; // Segment number
138 uchar_t sense
; // Sense key/flags
139 uchar_t info
[4]; // Information (32bit big-endian value)
140 uchar_t asl
; // Additional Sense Length
141 uchar_t csinfo
[4]; // Command-Specific Information
142 uchar_t asc
; // Additional Sense Code
143 uchar_t ascq
; // Additional Sense Code Qualifier
144 uchar_t fruc
; // Field Replaceable Unit Code
145 uchar_t sks
; // Sense Key Specific
146 ushort_t sks_data
; // Sense Key Specific Data (16bit big-endian)
147 ushort_t asb
; // Additional Sense uchar_ts (Max 256-18)
150 // Descriptor Format Sense Data Structure
151 // error code of 72 current, 73 deferred
152 // extended sense data format (or SCSI-2 sense data format).
153 typedef struct _scsi_sense_descriptor
{
154 uchar_t error
; // Error Code
155 uchar_t sense
; // Sense key/flags
156 uchar_t asc
; // Additional Sense Code
157 uchar_t ascq
; // Additional Sense Code Qualifier
159 uchar_t asl
; // Additional Sense Length
160 } SCSI_SENSE_DESCRIPTOR
;
162 typedef struct _scsi_sense_desriptor_header
{
163 uchar_t descriptor_type
;
164 uchar_t descriptor_len
;
165 } SCSI_SENSE_DESCRIPTOR_HEADER
;
167 #define SENSE_DTYPE_INFORMATION 0x00
168 #define SENSE_DTYPE_CSI 0x01 // Command Specific Information
169 #define SENSE_DTYPE_SKS 0x02 // Sense Key Specific
170 #define SENSE_DTYPE_FRU 0x03 // Field Replaceable Unit
171 #define SENSE_DTYPE_STREAM 0x04
172 #define SENSE_DTYPE_BLOCK 0x05
173 #define SENSE_DTYPE_OSD_OBJ_IDENT 0x06 // OSD Object Identification
174 #define SENSE_DTYPE_OSD_INTEGRITY 0x07 // OSD Response Integrity Check Value
175 #define SENSE_DTYPE_OSD_ATR_IDENT 0x08 // OSD Attribute Identification
176 #define SENSE_DTYPE_ATA 0x09
178 typedef struct _ata_status_descriptor
{
179 uchar_t descriptor_type
;
180 #define ATA_SD_DLEN 0x0c
181 uchar_t descriptor_len
; /* 0xc */
182 #define ATA_SD_FLG_EXTEND 0x01
185 uchar_t esector_count
; /* (15:8) */
186 uchar_t sector_count
; /* (7:0) */
187 uchar_t elba_low
; /* (15:8) */
188 uchar_t lba_low
; /* (7:0) */
189 uchar_t elba_mid
; /* (15:8) */
190 uchar_t lba_mid
; /* (7:0) */
191 uchar_t elba_high
; /* (15:8) */
192 uchar_t lba_high
; /* (7:0) */
195 } ATA_STATUS_DESCRIPTOR
;
197 //----------------------------------------------------------------------------------------------------------
199 #define SK_MSK 0x0F // mask to sd_sense field for key
201 #define SK_NO_SENSE 0 // No sense data (no error)
202 #define ASCQ_FILEMARK_DETECTED 0x01
203 #define ASCQ_EOPM_DETECTED 0x02 // End of Partition/Medium Detected
204 #define ASCQ_SETMARK_DETECTED 0x03
205 #define ASCQ_BOPM_DETECTED 0x04 // Beginning of Partition/Medium Detected
207 #define SK_RECOVERED 1 // Recovered error
208 #define ASC_ATA_PASS_THRU 0x00
209 #define ASCQ_ATA_PASS_THRU_INFO_AVAIL 0x1d
211 #define SK_NOT_RDY 2 // Device not ready
212 #define ASC_NO_SEEK_COMPLETE 0x02
213 #define ASC_NOT_READY 0x04
214 #define ASCQ_CAUSE_NOT_REPORTABLE 0x00
215 #define ASCQ_BECOMING_READY 0x01
216 #define ASCQ_INIT_COMMAND_REQUIRED 0x02
217 #define ASCQ_MANUAL_INTERVENTION_REQUIRED 0x03
218 #define ASCQ_FORMAT_IN_PROGRESS 0x04
219 #define ASCQ_UNKNOWN_CHANGED 0xff // NTO extension for fdc's
220 #define ASC_MEDIA_FORMAT 0x30 // bad format
221 #define ASC_MEDIA_NOT_PRESENT 0x3a
222 #define ASC_NOT_CONFIGURED 0x3e
224 #define SK_MEDIUM 3 // Medium error
225 #define ASC_UNRECOVERABLE_READ_ERROR 0x11
226 #define ASC_RECORD_NOT_FOUND 0x14
227 #define ASCQ_RECORD_NOT_FOUND 0x01
228 #define ASC_UNABLE_TO_RECOVER_TOC 0x57
229 #define ASC_INCOMPATIBLE_MEDIUM 0x64
231 #define SK_HARDWARE 4 // Hardware error
232 #define ASC_INTERNAL_TARGET_FAILURE 0x44
233 #define ASC_MEDIA_LOAD_EJECT_FAILURE 0x53
234 #define ASCQ_UNRECOVERABLE_CIRC 0x06
236 #define SK_ILLEGAL 5 // Illegal Request (bad command)
237 #define ASC_INVALID_COMMAND 0x20
238 #define ASC_INVALID_FIELD 0x24
239 #define ASC_INVALID_FIELD_PARAMETER 0x26
240 #define ASC_COMMAND_SEQUENCE_ERROR 0x2c
241 #define ASCQ_READ_SCRAMBLED 0x03
242 #define ASC_ILLEGAL_MODE 0x64
243 #define ASC_COPY_PROTECTION 0x6f
245 #define SK_UNIT_ATN 6 // Unit Attention
246 #define ASC_MEDIUM_CHANGED 0x28
247 #define ASC_BUS_RESET 0x29
248 #define ASC_INSUFFICIENT_TIME_FOR_OPERATION 0x2e
249 #define ASC_OPERATOR_REQUEST 0x5a
250 #define ASCQ_OPERATOR_MEDIUM_REMOVAL 0x01
252 #define SK_DATA_PROT 7 // Data Protect
253 #define ASC_WRITE_PROTECTED 0x27
255 #define SK_BLNK_CHK 8 // Blank Check
256 #define SK_VENDOR 9 // Vendor Specific
257 #define SK_CPY_ABORT 10 // Copy Aborted
258 #define SK_CMD_ABORT 11 // Aborted Command
259 #define SK_EQUAL 12 // Equal
260 #define SK_VOL_OFL 13 // Volume Overflow
261 #define SK_MISCMP 14 // Miscompare
262 #define SK_RESERVED 15 // Reserved
263 //----------------------------------------------------------------------------------------------------------
264 // Command Descriptor Block structure definitions
267 #define CF_LINK 0x01 // Linked-command indication
268 #define CF_FLAG 0x02 // Linked-command with flag bit
269 #define CF_VENDOR0 0x40 // Vendor unique bits
270 #define CF_VENDOR1 0x80
276 // generic 6 byte command descriptor block
281 uchar_t lba_byte0
; // LSB
282 uchar_t transfer_len
;
286 // generic 10 byte command descriptor block
295 uchar_t transfer_len
[2];
299 // generic 12 byte command descriptor block
307 uchar_t transfer_len
[4];
312 struct _format_unit
{
314 #define FU_RSVD0 0xc0 // reserved bits
315 #define FU_FMTDAT 0x10
316 #define FU_CMPLIST 0x08
317 uchar_t defect_list_fmt
;
323 struct _format_unit_old
{
326 uchar_t medium_type_code
;
330 #define FMT_RSVD3 0x80
331 #define FMT_SECT_SIZE_CD 0x70
332 #define FMT_IMMED 0x08
333 #define FMT_HEAD 0x04
335 #define FMT_CERT 0x01
341 #define RW_OPT_RELADR 0x01
342 #define RW_OPT_CORRCT 0x02 // Disable Corrections
343 #define RW_OPT_FUA 0x08 // Force Unit Access
344 #define RW_OPT_DPO 0x10 // Disable Page Out
349 uchar_t transfer_len
;
358 uchar_t transfer_len
[2];
366 uchar_t transfer_len
[4];
371 #define MSEL_OPT_PF 0x10 // Page Format
372 #define MSEL_OPT_SP 0x01 // Save Page
378 uchar_t param_length
;
390 uchar_t param_length
[2];
396 #define LS_OPT_SP 0x01 // Save Parameters
397 #define LS_OPT_PCR 0x02 // Parameter Code Reset
399 #define LS_PC_CUR_THRESHOLD 0x00
400 #define LS_PC_CUR_CUMULATIVE 0x01
401 #define LS_PC_DFLT_THRESHOLD 0x02
402 #define LS_PC_DFLT_CUMULATIVE 0x03
403 uchar_t pc
; // Page Control
408 uchar_t param_length
[2];
414 #define MSNS_OPT_DBD 0x08 // Disable Block Descriptors
416 #define PC_CURRENT 0x00
417 #define PC_CHANGEABLE 0x40
418 #define PC_DEFAULT 0x80
419 #define PC_SAVED 0xC0
423 uchar_t allocation_length
;
427 struct _mode_sense10
{
435 uchar_t allocation_length
[2];
445 uchar_t parameter_pointer
[2];
446 uchar_t allocation_length
[2];
461 #define LD_OPT_IMMED 0x01
465 #define LD_CMD_START 0x01
466 #define LD_CMD_LOEJ 0x02
467 #define LD_CMD_STOP 0x00
468 #define LD_CMD_EJECT 0x02
469 #define LD_CMD_LOAD 0x03
472 #define LD_CMD_SA_HOLD 0x08
473 #define LD_CMD_SA_EOT 0x04
474 #define LD_CMD_SA_RT 0x02 // re-tension
475 #define LD_CMD_SA_LOEJ 0x01
478 #define LD_CMD_PC_MSK 0xf0
479 #define LD_CMD_PC_NC 0
480 #define LD_CMD_PC_ACTIVE 1
481 #define LD_CMD_PC_IDLE 2
482 #define LD_CMD_PC_STANDBY 3
483 #define LD_CMD_PC_SLEEP 5
492 #define SC_OPT_RELADR 0x01
493 #define SC_OPT_IMMED 0x02
495 uchar_t num_blocks
[2];
508 uchar_t allocation_length
[2];
510 } read_disc_information
;
529 uchar_t start_minute
;
530 uchar_t start_second
;
553 #define CD_SCAN_DIR_FORWARD 0x00
554 #define CD_SCAN_DIR_REVERSE 0x10
556 uchar_t start_address
[4];
557 #define CD_SCAN_TYPE_LBA 0x00
558 #define CD_SCAN_TYPE_MSF 0x40
559 #define CD_SCAN_TYPE_TRK 0x80
560 #define CD_SCAN_TYPE_MSK 0xc0
571 #define RTOC_OPT_MSF 0x02
573 #define RTOC_FMT_TOC 0x0
574 #define RTOC_FMT_SESSION 0x1
575 #define RTOC_FMT_QSUBCODE 0x2
576 #define RTOC_FMT_QSUBCHNL 0x3
577 #define RTOC_FMT_ATIP 0x4
578 #define RTOC_FMT_CDTEXT 0x5
584 uchar_t allocation_length
[2];
585 #define RTOC_CNTL_FMT_SESSION 0x40
586 uchar_t control_format
;
593 uchar_t allocation_length
[2];
599 #define EXCHANGE_OPT_IMMED 0x01
603 #define EXCHANGE_CMD_START 0x01
604 #define EXCHANGE_CMD_LOEJ 0x02
618 uchar_t feature_number
[2];
622 uchar_t allocation_length
[2];
628 #define GE_OPT_POLLED 0x01
632 #define NCR_OPERATIONAL_CHANGE 0x02
633 #define NCR_POWER_MANAGEMENT 0x04
634 #define NCR_EXTERNAL_REQUEST 0x08
635 #define NCR_MEDIA 0x10
636 #define NCR_MULTI_INITIATOR 0x20
637 #define NCR_DEVICE_BUSY 0x40
638 uchar_t ncr
; // notification class request
641 uchar_t allocation_length
[2];
653 uchar_t allocation_length
[2];
655 } read_formated_capacities
;
660 uchar_t read_speed
[2];
661 uchar_t write_speed
[2];
667 #define RSCHNL_OPT_MSF 0x02
669 #define RSCHNL_DATA_SUBQ 0x40
675 uchar_t allocation_length
[2];
679 #define CD_FRAME_SYNC_SIZE 12
680 #define CD_FRAME_HDR_SIZE 4
681 #define CD_FRAME_SUB_HDR_SIZE 8
682 #define CD_FRAME_EDC_SIZE 4
683 #define CD_FRAME_ECC_SIZE 276
684 #define CD_FRAME_AUX_SIZE 8
685 #define CD_FRAME_ZERO_SIZE 8
686 #define CD_FRAME_SPARE_SIZE 4
687 #define CD_FRAME_C2_ERR_SIZE 294
688 #define CD_FRAME_BLOCK_ERR_SIZE 2
693 // expected sector type
694 #define RDCD_EST_ANY_SECTOR (0 << 2)
695 #define RDCD_EST_CDDA_SECTOR (1 << 2)
696 #define RDCD_EST_YELLOW_MODE1_SECTOR (2 << 2)
697 #define RDCD_EST_YELLOW_MODE2_SECTOR (3 << 2)
698 #define RDCD_EST_XA_SECTOR (4 << 2)
699 #define RDCD_EST_XA_FORM2_SECTOR (5 << 2)
700 #define RDCD_EST_MSK (7 << 2)
702 uchar_t transfer_len
[3];
704 #define RDCD_FLG_SYNC 0x80
705 #define RDCD_FLG_UDATA 0x10
706 #define RDCD_FLG_ECC 0x08
707 #define RDCD_FLG_CD_ERR 0x02
708 #define RDCD_FLG_CD_BLOCK_ERR 0x04
709 #define RDCD_FLG_HC_NONE ( 0x00 << 5 )
710 #define RDCD_FLG_HC_HDR ( 0x01 << 5 )
711 #define RDCD_FLG_HC_SUBHEADER ( 0x02 << 5 )
712 #define RDCD_FLG_HC_ALL_HEADERS ( 0x03 << 5 )
713 uchar_t subch_selection
;
721 uchar_t start_minute
;
722 uchar_t start_second
;
728 uchar_t subch_selection
;
732 struct _ata_pass_thru
{
734 #define ATA_PROTO_MSK 0x1e
735 #define ATA_PROTO_RESPONSE (15 << 1)
736 #define ATA_PROTO_FPDMA (12 << 1)
737 #define ATA_PROTO_UDMA_DATA_OUT (11 << 1)
738 #define ATA_PROTO_UDMA_DATA_IN (10 << 1)
739 #define ATA_PROTO_DEVICE_RESET (9 << 1)
740 #define ATA_PROTO_DEVICE_DIAGNOSTIC (8 << 1)
741 #define ATA_PROTO_DMA_QUEUED (7 << 1)
742 #define ATA_PROTO_DMA (6 << 1)
743 #define ATA_PROTO_PIO_DATA_OUT (5 << 1)
744 #define ATA_PROTO_PIO_DATA_IN (4 << 1)
745 #define ATA_PROTO_DATA_NONE (3 << 1)
746 #define ATA_PROTO_SRST (1 << 1)
747 #define ATA_PROTO_HRST (0 << 1)
748 #define ATA_PROTO_EXTEND 0x01
749 uchar_t protocol
; // multiple count, protocol
750 #define ATA_MCOUNT_MSK 0xe0
752 #define ATA_FLG_CK_COND 0x20
753 #define ATA_FLG_T_DIR 0x08 // data from device
754 #define ATA_FLG_BYT_BLOK 0x04
755 #define ATA_FLG_TLEN_STPSIU 0x03
756 #define ATA_FLG_TLEN_SECTOR_COUNT 0x02
757 #define ATA_FLG_TLEN_FEATURE 0x01
762 uchar_t esector_count
;
763 uchar_t sector_count
;
775 // sequential access commands
778 #define ERASE_OPT_LONG 0x01
786 #define LOCATE_OPT_CP 0x2
787 #define LOCATE_OPT_BT 0x4
790 uchar_t ba
[4]; // block address
803 #define RP_OPT_BT 0x01 // block address type
804 #define RP_OPT_LNG 0x02 // long format
805 #define RP_OPT_TCLP 0x04 // total current logical position
813 #define SRW_OPT_FIXED 0x01
814 #define SRW_OPT_SILI 0x02
818 uchar_t transfer_len
[3];
831 #define SPACE_CODE_BLOCKS 0x00
832 #define SPACE_CODE_FMRKS 0x01
833 #define SPACE_CODE_SEQ_FMRKS 0x02
834 #define SPACE_CODE_EOD 0x03
835 #define SPACE_CODE_SMRKS 0x04
836 #define SPACE_CODE_SEQ_SMRKS 0x05
844 #define WF_OPT_IMMED 0x01
845 #define WF_OPT_WSMK 0x02
847 uchar_t transfer_length
[3];
853 #define RD_OPT_MEDIA 0x01
856 uchar_t allocation_length
[2];
862 #define FM_OPT_IMMED 0x01
863 #define FM_OPT_VERIFY 0x02
865 #define FM_FMT_DFLT 0x00
866 #define FM_FMT_PARTITION 0x01
867 #define FM_FMT_FORMAT_PARTITION 0x02
869 uchar_t transfer_length
[2];
873 //----------------------------------------------------------------------------------------------------------
877 SCSI_SENSE_DESCRIPTOR sense
;
878 ATA_STATUS_DESCRIPTOR desc
;
880 //----------------------------------------------------------------------------------------------------------
883 #endif /* OS_QNXNTO_H_ */