diff --git a/sm5/AUTHORS b/sm5/AUTHORS index f781bf174bcba2b3487ed01373f76afe5ff6a32c..7b736453f1b6d662c3992da527d93fb275593c91 100644 --- a/sm5/AUTHORS +++ b/sm5/AUTHORS @@ -1,4 +1,4 @@ -$Id: AUTHORS,v 1.17 2006/12/20 12:24:34 guidog Exp $ +$Id: AUTHORS,v 1.18 2007/11/13 14:53:27 jhering Exp $ This code was originally developed as a Senior Thesis by Michael Cornwell at the Concurrent Systems Laboratory (now part of the Storage @@ -11,19 +11,19 @@ ucsc-smartsuite and smartsuite packages, and is derived from that code. Maintainers / Developers: Bruce Allen <smartmontools-support@lists.sourceforge.net> -Erik Inge Bols� <knan@mo.himolde.no> +Erik Inge Bols� <knan@mo.himolde.no> Stanislav Brabec <sbrabec@suse.cz> Peter Cassidy <pcassidy@mac.com> Casper Dik <casper@holland.sun.com> Christian Franke <franke@computer.org> -Guilhem Fr�zou <guilhem.frezou@catii.fr> +Guilhem Fr�zou <guilhem.frezou@catii.fr> Douglas Gilbert <dougg@torque.net> Guido Guenther <agx@sigxcpu.org> Geoff Keating <geoffk@geoffk.org> Dr. David Kirkby <drkirkby@ntlworld.com> -Kai M�kisara <kai.makisara@kolumbus.fi> +Kai M�kisara <kai.makisara@kolumbus.fi> Eduard Martinescu <martines@rochester.rr.com> -Fr�d�ric L. W. Meunier <http://www.pervalidus.net/contact.html> +Fr�d�ric L. W. Meunier <http://www.pervalidus.net/contact.html> Keiji Sawada <card_captor@users.sourceforge.net> David Snyder <dasnyderx@yahoo.com> Sergey Svishchev <svs@ropnet.ru> @@ -32,3 +32,4 @@ Richard Zybert <richard.zybert@zybert.co.uk> Yuri Dario <mc6530@mclink.it> Shengfeng Zhou <linux@highpoint-tech.com> Praveen Chidambaram <bunchofmails@gmail.com> +Joerg Hering <hering.ruegen@gmx.de> diff --git a/sm5/CHANGELOG b/sm5/CHANGELOG index b918b5d5715955900ae75bbdbff098ea6b792d7f..c9fe613596a2ca6de10a81189aeb42b8847c8361 100644 --- a/sm5/CHANGELOG +++ b/sm5/CHANGELOG @@ -1,26 +1,27 @@ CHANGELOG for smartmontools -$Id: CHANGELOG,v 1.636 2007/11/01 20:53:29 chrfranke Exp $ +$Id: CHANGELOG,v 1.637 2007/11/13 14:53:27 jhering Exp $ The most recent version of this file is: http://smartmontools.cvs.sourceforge.net/smartmontools/sm5/CHANGELOG?view=markup Maintainers / Developers Key: [BA] Bruce Allen -[EB] Erik Inge Bols� +[EB] Erik Inge Bols� [SB] Stanislav Brabec [PC] Peter Cassidy [YD] Yuri Dario [CD] Casper Dik [CF] Christian Franke -[GF] Guilhem Fr�zou +[GF] Guilhem Fr�zou [DG] Douglas Gilbert [GG] Guido Guenther [GK] Geoff Keating [DK] Dr. David Kirkby -[KM] Kai M�kisara +[JH] Joerg Hering +[KM] Kai M�kisara [EM] Eduard Martinescu -[FM] Fr�d�ric L. W. Meunier +[FM] Fr�d�ric L. W. Meunier [KS] Keiji Sawada [DS] David Snyder [SS] Sergey Svishchev @@ -32,6 +33,11 @@ Maintainers / Developers Key: NOTES FOR FUTURE RELEASES: see TODO file. <DEVELOPERS: ADDITIONS TO THE CHANGE LOG GO JUST BELOW HERE, PLEASE> + [JH] initial porting to QNX Neutrino 6.3.2 + need at this time a prerelease devb-eide driver and libcam.so.2 + only tested for X86 Target, but devb-eide and lobcam.so.2 available for X86/ARM + the officional driver coming soon with the next QNX release + create two new source files os_qnxnto.[c..h] [CF] smartd: Added option '-n, --no-fork' so that smartd works better with modern init methods. Thanks to Enrico Scholz @@ -266,7 +272,7 @@ smartmontools 5.37 Experimental Release and T series. [GG] Add CCISS (Compaq Smart Array Controller) support with contributions - from Praveen Chidambaram, Douglas Gilbert, Guido Guenther and Fr�d�ric + from Praveen Chidambaram, Douglas Gilbert, Guido Guenther and Fr�d�ric BOITEUX [PW] Drive database: added Hitachi Deskstar T7K250 and Hitachi diff --git a/sm5/configure.in b/sm5/configure.in index 74c9de17003f9e3662589e4df2702a7320a2bcd7..89d8800ed237ac27568312564db452a5d9cb0c4a 100644 --- a/sm5/configure.in +++ b/sm5/configure.in @@ -1,5 +1,5 @@ # -# $Id: configure.in,v 1.126 2007/04/03 18:20:46 shattered Exp $ +# $Id: configure.in,v 1.127 2007/11/13 14:53:27 jhering Exp $ # dnl Process this file with autoconf to produce a configure script. AC_PREREQ(2.50) @@ -7,7 +7,7 @@ AC_INIT(smartmontools, 5.38, smartmontools-support@lists.sourceforge.net) AC_CONFIG_SRCDIR(smartctl.cpp) smartmontools_configure_date=`date -u +"%Y/%m/%d %T %Z"` -smartmontools_cvs_tag=`echo '$Id: configure.in,v 1.126 2007/04/03 18:20:46 shattered Exp $'` +smartmontools_cvs_tag=`echo '$Id: configure.in,v 1.127 2007/11/13 14:53:27 jhering Exp $'` smartmontools_release_date=2006/12/20 smartmontools_release_time="20:37:59 UTC" @@ -167,6 +167,10 @@ case "${host}" in *-*-darwin*) AC_SUBST([os_deps], ['os_darwin.o']) AC_SUBST([os_libs], ['-framework CoreFoundation -framework IOKit']) ;; + *-*-nto-qnx*) + AC_SUBST([os_deps], ['os_qnxnto.o']) + AC_SUBST([os_libs], ['']) ;; + *) AC_SUBST([os_deps], ['os_generic.o']) AC_SUBST([os_libs], ['']) ;; diff --git a/sm5/os_qnxnto.cpp b/sm5/os_qnxnto.cpp new file mode 100644 index 0000000000000000000000000000000000000000..13094a9cb4dff79838d2b3bbf28475cb23861207 --- /dev/null +++ b/sm5/os_qnxnto.cpp @@ -0,0 +1,627 @@ + + +// This is needed for the various HAVE_* macros and PROJECT_* macros. +#include "config.h" + +// These are needed to define prototypes and structures for the +// functions defined below +#include "int64.h" +#include "atacmds.h" +#include "scsicmds.h" +#include "utility.h" + +// This is to include whatever structures and prototypes you define in +// os_generic.h +#include "os_qnxnto.h" + +// Needed by '-V' option (CVS versioning) of smartd/smartctl. You +// should have one *_H_CVSID macro appearing below for each file +// appearing with #include "*.h" above. Please list these (below) in +// alphabetic/dictionary order. +const char *os_XXXX_c_cvsid="$Id: os_qnxnto.cpp,v 1.1 2007/11/13 14:53:27 jhering Exp $" \ +ATACMDS_H_CVSID CONFIG_H_CVSID INT64_H_CVSID OS_QNXNTO_H_CVSID SCSICMDS_H_CVSID UTILITY_H_CVSID; + + +// This is here to prevent compiler warnings for unused arguments of +// functions. +#define ARGUSED(x) ((void)(x)) + +// Please eliminate the following block: both the #include and +// the 'unsupported()' function. They are only here to warn +// unsuspecting users that their Operating System is not supported! If +// you wish, you can use a similar warning mechanism for any of the +// functions in this file that you can not (or choose not to) +// implement. + + +#ifdef HAVE_UNAME +#include <sys/utsname.h> +#endif +//---------------------------------------------------------------------------------------------- +// private Functions +static int ata_sense_data(void *sdata,int *error,int *key,int *asc,int *ascq); +static int ata_interpret_sense(struct cam_pass_thru *cpt,void *sense,int *status,int rcount); +static int ata_pass_thru(int fd,struct cam_pass_thru *pcpt); +//---------------------------------------------------------------------------------------------- +static void unsupported(){ + static int warninggiven; + + if (!warninggiven) { + char *osname; + extern unsigned char debugmode; + unsigned char savedebugmode=debugmode; + +#ifdef HAVE_UNAME + struct utsname ostype; + uname(&ostype); + osname=ostype.sysname; +#else + osname="host's"; +#endif + + debugmode=1; + pout("\n" + "############################################################################\n" + "WARNING: smartmontools has not been ported to the %s Operating System.\n" + "Please see the files os_generic.cpp and os_generic.h for porting instructions.\n" + "############################################################################\n\n", + osname); + debugmode=savedebugmode; + warninggiven=1; + } + + return; +} +// End of the 'unsupported()' block that you should eliminate. + + +// print examples for smartctl. You should modify this function so +// that the device paths are sensible for your OS, and to eliminate +// unsupported commands (eg, 3ware controllers). +void print_smartctl_examples(){ + printf("=================================================== SMARTCTL EXAMPLES =====\n\n"); +#ifdef HAVE_GETOPT_LONG + printf( + " smartctl -a /dev/hd0 (Prints all SMART information)\n\n" + " smartctl --smart=on --offlineauto=on --saveauto=on /dev/hd0\n" + " (Enables SMART on first disk)\n\n" + " smartctl -t long /dev/hd0 (Executes extended disk self-test)\n\n" + " smartctl --attributes --log=selftest --quietmode=errorsonly /dev/hd0\n" + " (Prints Self-Test & Attribute errors)\n" + " smartctl -a --device=3ware,2 /dev/sda\n" + " (Prints all SMART info for 3rd ATA disk on 3ware RAID controller)\n" + ); +#else + printf( + " smartctl -a /dev/hd0 (Prints all SMART information)\n" + " smartctl -s on -o on -S on /dev/hd0 (Enables SMART on first disk)\n" + " smartctl -t long /dev/hd0 (Executes extended disk self-test)\n" + " smartctl -A -l selftest -q errorsonly /dev/hd0\n" + " (Prints Self-Test & Attribute errors)\n" + " smartctl -a -d 3ware,2 /dev/sda\n" + " (Prints all SMART info for 3rd ATA disk on 3ware RAID controller)\n" + ); +#endif + return; +} + +// tries to guess device type given the name (a path). See utility.h +// for return values. +static const char *net_dev_prefix = "/dev/"; +static const char *net_dev_ata_disk = "hd"; + +int guess_device_type (const char* dev_name) +{ +int len,dev_prefix_len; + dev_prefix_len=strlen(net_dev_prefix); + if(!dev_name||!(len=strlen(dev_name))) + return(CONTROLLER_UNKNOWN); + if (!strncmp(net_dev_prefix,dev_name,dev_prefix_len)) + { + if(len<=dev_prefix_len) + return(CONTROLLER_UNKNOWN); + else + dev_name += dev_prefix_len; + } + if(!strncmp(net_dev_ata_disk,dev_name,strlen(net_dev_ata_disk))) + return(CONTROLLER_ATA); + return(CONTROLLER_UNKNOWN); +} + +// makes a list of ATA or SCSI devices for the DEVICESCAN directive of +// smartd. Returns number N of devices, or -1 if out of +// memory. Allocates N+1 arrays: one of N pointers (devlist); the +// other N arrays each contain null-terminated character strings. In +// the case N==0, no arrays are allocated because the array of 0 +// pointers has zero length, equivalent to calling malloc(0). +int make_device_names (char*** devlist, const char* name) { + ARGUSED(devlist); + ARGUSED(name); + unsupported(); + return 0; +} + +// Like open(). Return non-negative integer handle, only used by the +// functions below. type=="ATA" or "SCSI". If you need to store +// extra information about your devices, create a private internal +// array within this file (see os_freebsd.cpp for an example). If you +// can not open the device (permission denied, does not exist, etc) +// set errno as open() does and return <0. +int deviceopen(const char *pathname, char *type) +{ + if(!strcmp(type, "ATA")) + return(open(pathname,O_RDWR|O_NONBLOCK)); + else + return(-1); +} + +// Like close(). Acts only on integer handles returned by +// deviceopen() above. +int deviceclose(int fd) +{ + return(close(fd)); +} +//---------------------------------------------------------------------------------------------- +// Interface to ATA devices. See os_linux.cpp for the cannonical example. +// DETAILED DESCRIPTION OF ARGUMENTS +// device: is the integer handle provided by deviceopen() +// command: defines the different operations, see atacmds.h +// select: additional input data IF NEEDED (which log, which type of +// self-test). +// data: location to write output data, IF NEEDED (1 or 512 bytes). +// Note: not all commands use all arguments. +// RETURN VALUES (for all commands BUT command==STATUS_CHECK) +// -1 if the command failed +// 0 if the command succeeded, +// RETURN VALUES if command==STATUS_CHECK +// -1 if the command failed OR the disk SMART status can't be determined +// 0 if the command succeeded and disk SMART status is "OK" +// 1 if the command succeeded and disk SMART status is "FAILING" +int ata_command_interface(int fd,smart_command_set command,int select,char *data) +{ +struct cam_pass_thru cpt; +ATA_SENSE sense; +CDB *cdb; +int status,rc; + memset(&cpt,0x00,sizeof(struct cam_pass_thru)); + cdb=(CDB *)cpt.cam_cdb; + rc=-1; + switch(command) + { + case READ_VALUES: + cpt.cam_flags = CAM_DIR_IN; + cpt.cam_cdb_len = 16; + cpt.cam_dxfer_len = 512; + cpt.cam_data_ptr = (uint32_t)data; + cpt.cam_sense_len = sizeof(sense); + cpt.cam_sense_ptr = (uint32_t)&sense; + cdb->ata_pass_thru.opcode = SC_ATA_PT16; + cdb->ata_pass_thru.protocol = ATA_PROTO_PIO_DATA_IN; + cdb->ata_pass_thru.flags = ATA_FLG_T_DIR|ATA_FLG_TLEN_STPSIU; + cdb->ata_pass_thru.command = ATA_SMART_CMD; + cdb->ata_pass_thru.features = ATA_SMART_READ_VALUES; + cdb->ata_pass_thru.lba_mid = ATA_SMART_LBA_MID_SIG; + cdb->ata_pass_thru.lba_high = ATA_SMART_LBA_HI_SIG; + break; + case READ_THRESHOLDS: + cpt.cam_flags = CAM_DIR_IN; + cpt.cam_cdb_len = 16; + cpt.cam_dxfer_len = 512; + cpt.cam_data_ptr = (uint32_t)data; + cpt.cam_sense_len = sizeof(sense); + cpt.cam_sense_ptr = (uint32_t)&sense; + cdb->ata_pass_thru.opcode = SC_ATA_PT16; + cdb->ata_pass_thru.protocol = ATA_PROTO_PIO_DATA_IN; + cdb->ata_pass_thru.flags = ATA_FLG_T_DIR|ATA_FLG_TLEN_STPSIU; + cdb->ata_pass_thru.command = ATA_SMART_CMD; + cdb->ata_pass_thru.features = ATA_SMART_READ_THRESHOLDS; + cdb->ata_pass_thru.lba_mid = ATA_SMART_LBA_MID_SIG; + cdb->ata_pass_thru.lba_high = ATA_SMART_LBA_HI_SIG; + break; + case READ_LOG: + cpt.cam_flags = CAM_DIR_IN; + cpt.cam_cdb_len = 16; + cpt.cam_dxfer_len = 512; + cpt.cam_data_ptr = (uint32_t)data; + cpt.cam_sense_len = sizeof(sense); + cpt.cam_sense_ptr = (uint32_t)&sense; + cdb->ata_pass_thru.opcode = SC_ATA_PT16; + cdb->ata_pass_thru.protocol = ATA_PROTO_PIO_DATA_IN; + cdb->ata_pass_thru.flags = ATA_FLG_T_DIR | ATA_FLG_TLEN_STPSIU; + cdb->ata_pass_thru.command = ATA_SMART_CMD; + cdb->ata_pass_thru.features = ATA_SMART_READ_LOG_SECTOR; + cdb->ata_pass_thru.sector_count= 1; + cdb->ata_pass_thru.lba_low = select; + cdb->ata_pass_thru.lba_mid = ATA_SMART_LBA_MID_SIG; + cdb->ata_pass_thru.lba_high = ATA_SMART_LBA_HI_SIG; + break; + case WRITE_LOG: + return(-1); + break; + case IDENTIFY: + cpt.cam_flags = CAM_DIR_IN; + cpt.cam_cdb_len = 16; + cpt.cam_dxfer_len = 512; + cpt.cam_data_ptr = (uint32_t)data; + cpt.cam_sense_len = sizeof(sense); + cpt.cam_sense_ptr = (uint32_t)&sense; + cdb->ata_pass_thru.opcode = SC_ATA_PT16; + cdb->ata_pass_thru.protocol = ATA_PROTO_PIO_DATA_IN; + cdb->ata_pass_thru.flags = ATA_FLG_T_DIR|ATA_FLG_TLEN_STPSIU; + cdb->ata_pass_thru.command = ATA_IDENTIFY_DEVICE; + break; + case PIDENTIFY: + cpt.cam_flags = CAM_DIR_IN; + cpt.cam_cdb_len = 16; + cpt.cam_dxfer_len = 512; + cpt.cam_data_ptr = (uint32_t)data; + cpt.cam_sense_len = sizeof(sense); + cpt.cam_sense_ptr = (uint32_t)&sense; + cdb->ata_pass_thru.opcode = SC_ATA_PT16; + cdb->ata_pass_thru.protocol = ATA_PROTO_PIO_DATA_IN; + cdb->ata_pass_thru.flags = ATA_FLG_T_DIR|ATA_FLG_TLEN_STPSIU; + cdb->ata_pass_thru.command = ATA_IDENTIFY_PACKET_DEVICE; + break; + case ENABLE: + cpt.cam_flags = CAM_DIR_NONE; + cpt.cam_cdb_len = 16; + cpt.cam_sense_len = sizeof(sense); + cpt.cam_sense_ptr = (uint32_t)&sense; + cdb->ata_pass_thru.opcode = SC_ATA_PT16; + cdb->ata_pass_thru.protocol = ATA_PROTO_DATA_NONE; + cdb->ata_pass_thru.command = ATA_SMART_CMD; + cdb->ata_pass_thru.features = ATA_SMART_ENABLE; + cdb->ata_pass_thru.lba_mid = ATA_SMART_LBA_MID_SIG; + cdb->ata_pass_thru.lba_high = ATA_SMART_LBA_HI_SIG; + break; + case DISABLE: + cpt.cam_flags = CAM_DIR_NONE; + cpt.cam_cdb_len = 16; + cpt.cam_sense_len = sizeof(sense); + cpt.cam_sense_ptr = (uint32_t)&sense; + cdb->ata_pass_thru.opcode = SC_ATA_PT16; + cdb->ata_pass_thru.protocol = ATA_PROTO_DATA_NONE; + cdb->ata_pass_thru.command = ATA_SMART_CMD; + cdb->ata_pass_thru.features = ATA_SMART_DISABLE; + cdb->ata_pass_thru.lba_mid = ATA_SMART_LBA_MID_SIG; + cdb->ata_pass_thru.lba_high = ATA_SMART_LBA_HI_SIG; + break; + case AUTO_OFFLINE: + // NOTE: According to ATAPI 4 and UP, this command is obsolete + cpt.cam_flags = CAM_DIR_NONE; + cpt.cam_cdb_len = 16; + cpt.cam_sense_len = sizeof(sense); + cpt.cam_sense_ptr = (uint32_t)&sense; + cdb->ata_pass_thru.opcode = SC_ATA_PT16; + cdb->ata_pass_thru.protocol = ATA_PROTO_DATA_NONE; + cdb->ata_pass_thru.command = ATA_SMART_CMD; + cdb->ata_pass_thru.features = ATA_SMART_AUTO_OFFLINE; + cdb->ata_pass_thru.lba_low = select; + cdb->ata_pass_thru.lba_mid = ATA_SMART_LBA_MID_SIG; + cdb->ata_pass_thru.lba_high = ATA_SMART_LBA_HI_SIG; + break; + case AUTOSAVE: + cpt.cam_flags = CAM_DIR_NONE; + cpt.cam_cdb_len = 16; + cpt.cam_sense_len = sizeof(sense); + cpt.cam_sense_ptr = (uint32_t)&sense; + cdb->ata_pass_thru.opcode = SC_ATA_PT16; + cdb->ata_pass_thru.protocol = ATA_PROTO_DATA_NONE; + cdb->ata_pass_thru.command = ATA_SMART_CMD; + cdb->ata_pass_thru.features = ATA_SMART_AUTOSAVE; + cdb->ata_pass_thru.sector_count= select; + cdb->ata_pass_thru.lba_mid = ATA_SMART_LBA_MID_SIG; + cdb->ata_pass_thru.lba_high = ATA_SMART_LBA_HI_SIG; + break; + case IMMEDIATE_OFFLINE: + // NOTE: According to ATAPI 4 and UP, this command is obsolete + cpt.cam_flags = CAM_DIR_NONE; + cpt.cam_cdb_len = 16; + cpt.cam_sense_len = sizeof(sense); + cpt.cam_sense_ptr = (uint32_t)&sense; + cdb->ata_pass_thru.opcode = SC_ATA_PT16; + cdb->ata_pass_thru.protocol = ATA_PROTO_DATA_NONE; + cdb->ata_pass_thru.command = ATA_SMART_CMD; + cdb->ata_pass_thru.features = ATA_SMART_IMMEDIATE_OFFLINE; + cdb->ata_pass_thru.lba_low = select; + cdb->ata_pass_thru.lba_mid = ATA_SMART_LBA_MID_SIG; + cdb->ata_pass_thru.lba_high = ATA_SMART_LBA_HI_SIG; + break; + case STATUS_CHECK: + // same command, no HDIO in NetBSD + case STATUS: + cpt.cam_flags = CAM_DIR_NONE; + cpt.cam_cdb_len = 16; + cpt.cam_sense_len = sizeof(sense); + cpt.cam_sense_ptr = (uint32_t)&sense; + cdb->ata_pass_thru.opcode = SC_ATA_PT16; + cdb->ata_pass_thru.protocol = ATA_PROTO_DATA_NONE; + cdb->ata_pass_thru.flags = ATA_FLG_CK_COND; + cdb->ata_pass_thru.command = ATA_SMART_CMD; + cdb->ata_pass_thru.features = ATA_SMART_STATUS; + cdb->ata_pass_thru.lba_mid = ATA_SMART_LBA_MID_SIG; + cdb->ata_pass_thru.lba_high = ATA_SMART_LBA_HI_SIG; + break; + case CHECK_POWER_MODE: + cpt.cam_flags = CAM_DIR_NONE; + cpt.cam_cdb_len = 16; + cpt.cam_sense_len = sizeof(sense); + cpt.cam_sense_ptr = (uint32_t)&sense; + cdb->ata_pass_thru.opcode = SC_ATA_PT16; + cdb->ata_pass_thru.protocol = ATA_PROTO_DATA_NONE; + cdb->ata_pass_thru.flags = ATA_FLG_CK_COND; + cdb->ata_pass_thru.command = ATA_CHECK_POWER_MODE; + break; + default: + pout("Unrecognized command %d in ata_command_interface()\n", command); + errno=ENOSYS; + return(-1); + } +// execute now + if((status=ata_pass_thru(fd,&cpt))==EOK) + if(cpt.cam_status!=CAM_REQ_CMP) + ata_interpret_sense(&cpt,&sense,&status,0); + rc=status==EOK?0:1; + if((command==STATUS||command==STATUS_CHECK)&&status==EOK) + rc=((sense.desc.lba_high<<8)|sense.desc.lba_mid)==ATA_SMART_SIG?0:1; + if(command==CHECK_POWER_MODE) + data[0]=cdb->ata_pass_thru.sector_count; +// finish + return(rc); +} +//---------------------------------------------------------------------------------------------- +int marvell_command_interface(int fd, smart_command_set command, int select, char *data) +{ + ARGUSED(fd); + ARGUSED(command); + ARGUSED(select); + ARGUSED(data); + unsupported(); + return -1; +} +//---------------------------------------------------------------------------------------------- +int highpoint_command_interface(int fd, smart_command_set command, int select, char *data) +{ + ARGUSED(fd); + ARGUSED(command); + ARGUSED(select); + ARGUSED(data); + unsupported(); + return -1; +} +//---------------------------------------------------------------------------------------------- +// Interface to ATA devices behind 3ware escalade/apache RAID +// controller cards. Same description as ata_command_interface() +// above except that 0 <= disknum <= 15 specifies the ATA disk +// attached to the controller, and controller_type specifies the +// precise type of 3ware controller. See os_linux.c +int escalade_command_interface(int fd,int disknum,int controller_type,smart_command_set command,int select,char *data) +{ + ARGUSED(fd); + ARGUSED(disknum); + ARGUSED(controller_type); + ARGUSED(command); + ARGUSED(select); + ARGUSED(data); + + unsupported(); + return -1; +} +//---------------------------------------------------------------------------------------------- +#include <errno.h> +// Interface to SCSI devices. See os_linux.c +int do_scsi_cmnd_io(int fd,struct scsi_cmnd_io * iop,int report) +{ + ARGUSED(fd); + ARGUSED(iop); + ARGUSED(report); + unsupported(); + return -ENOSYS; +} +//---------------------------------------------------------------------------------------------- +//---------------------------------------------------------------------------------------------- +static int ata_sense_data(void *sdata,int *error,int *key,int *asc,int *ascq) +{ +SCSI_SENSE *sf; +SCSI_SENSE_DESCRIPTOR *sd; + sf=(SCSI_SENSE *)sdata; + sd=(SCSI_SENSE_DESCRIPTOR *)sdata; + *error=sf->error; + if(*error & SENSE_DATA_FMT_DESCRIPTOR) + { + *key=sd->sense & SK_MSK; + *asc=sd->asc; + *ascq=sd->ascq; + } + else + { + *key=sf->sense & SK_MSK; + *asc=sf->asc; + *ascq=sf->ascq; + } + return(CAM_SUCCESS); +} +//---------------------------------------------------------------------------------------------- +static int ata_interpret_sense(struct cam_pass_thru *cpt,void *sense,int *status,int rcount) +{ +int retry; +int key; +int asc; +int ascq; +int error; + *status=EIO; + retry=CAM_TRUE; + if(cpt->cam_status&CAM_AUTOSNS_VALID) + { + ata_sense_data(sense,&error,&key,&asc,&ascq); + switch(key) + { + case SK_NO_SENSE: // No sense data (no error) + retry=CAM_FALSE; + *status=EOK; + break; + case SK_RECOVERED: // Recovered error + switch(asc) + { + case ASC_ATA_PASS_THRU: + switch(ascq) + { + case ASCQ_ATA_PASS_THRU_INFO_AVAIL: + break; + default: + break; + } + break; + default: + break; + } + retry=CAM_FALSE; + *status=EOK; + break; + case SK_NOT_RDY: // Device not ready + *status=EAGAIN; + switch(asc) + { + case ASC_NOT_READY: + switch(ascq) + { + case ASCQ_BECOMING_READY: + case ASCQ_CAUSE_NOT_REPORTABLE: + default: + retry=CAM_FALSE; + break; + } + break; + case ASC_MEDIA_NOT_PRESENT: + *status=ENXIO; + retry=CAM_FALSE; + break; + } + break; + case SK_MEDIUM: // Medium error + case SK_HARDWARE: // Hardware error + retry=CAM_FALSE; + *status=EIO; + break; + case SK_ILLEGAL: // Illegal Request (bad command) + retry=CAM_FALSE; + *status=EINVAL; + break; + case SK_UNIT_ATN: // Unit Attention + switch(asc) + { + case ASC_MEDIUM_CHANGED: + *status=ESTALE; + retry=CAM_FALSE; + break; + case ASC_BUS_RESET: + break; + } + break; + case SK_DATA_PROT: // Data Protect + retry=CAM_FALSE; + *status=EROFS; + break; + case SK_VENDOR: // Vendor Specific + case SK_CPY_ABORT: // Copy Aborted + retry=CAM_FALSE; + *status=EIO; + break; + case SK_CMD_ABORT: // Aborted Command + retry=CAM_FALSE; + *status=ECANCELED; + break; + case SK_EQUAL: // Equal + case SK_VOL_OFL: // Volume Overflow + case SK_MISCMP: // Miscompare + case SK_RESERVED: // Reserved + break; + } + if(*status==EOK) + { + switch(cpt->cam_status&CAM_STATUS_MASK) + { + case CAM_REQ_CMP_ERR: // CCB request completed with an err + retry=CAM_FALSE; + *status=EIO; + break; + case CAM_BUSY: // CAM subsystem is busy + *status=EAGAIN; + break; + case CAM_REQ_INVALID: // CCB request is invalid + case CAM_PATH_INVALID: // Path ID supplied is invalid + case CAM_DEV_NOT_THERE: // SCSI device not installed/there + case CAM_SEL_TIMEOUT: // Target selection timeout + case CAM_LUN_INVALID: // LUN supplied is invalid + case CAM_TID_INVALID: // Target ID supplied is invalid + retry=CAM_FALSE; + *status=ENXIO; + break; + case CAM_CMD_TIMEOUT: // Command timeout + *status=rcount?EAGAIN:EIO; + break; + case CAM_MSG_REJECT_REC: // Message reject received + case CAM_SCSI_BUS_RESET: // SCSI bus reset sent/received + case CAM_UNCOR_PARITY: // Uncorrectable parity err occurred + case CAM_AUTOSENSE_FAIL: // Autosense: Request sense cmd fail + case CAM_NO_HBA: // No HBA detected Error + case CAM_DATA_RUN_ERR: // Data overrun/underrun error + retry=CAM_FALSE; + *status=EIO; + break; + case CAM_UNEXP_BUSFREE: // Unexpected BUS free + case CAM_SEQUENCE_FAIL: // Target bus phase sequence failure + *status=EIO; + break; + case CAM_PROVIDE_FAIL: // Unable to provide requ. capability + retry=CAM_FALSE; + *status=ENOTTY; + break; + case CAM_CCB_LEN_ERR: // CCB length supplied is inadequate + case CAM_BDR_SENT: // A SCSI BDR msg was sent to target + case CAM_REQ_TERMIO: // CCB request terminated by the host + case CAM_FUNC_NOTAVAIL: // The requ. func is not available + case CAM_NO_NEXUS: // Nexus is not established + case CAM_IID_INVALID: // The initiator ID is invalid + case CAM_CDB_RECVD: // The SCSI CDB has been received + retry=CAM_FALSE; + *status=EIO; + break; + case CAM_SCSI_BUSY: // SCSI bus busy + *status=EAGAIN; + break; + } + } + } + return(retry); +} +//---------------------------------------------------------------------------------------------- +static int ata_pass_thru(int fd,struct cam_pass_thru *pcpt) +{ +int icnt; +int status; +iov_t iov[3]; +struct cam_pass_thru cpt; + cpt=*pcpt; + icnt=1; + SETIOV(&iov[0],&cpt,sizeof(cpt)); + cpt.cam_timeout=cpt.cam_timeout?cpt.cam_timeout:CAM_TIME_DEFAULT; + if(cpt.cam_sense_len) + { + SETIOV(&iov[1],cpt.cam_sense_ptr,cpt.cam_sense_len); + cpt.cam_sense_ptr=sizeof(cpt); + icnt++; + } + if(cpt.cam_dxfer_len) + { + SETIOV(&iov[2],(void *)cpt.cam_data_ptr,cpt.cam_dxfer_len); + cpt.cam_data_ptr=(paddr_t)sizeof(cpt)+cpt.cam_sense_len; + icnt++; + } + if((status=devctlv(fd,DCMD_CAM_PASS_THRU,icnt,icnt,iov,iov,NULL))) + pout("ata_pass_thru devctl: %s\n",strerror(status)); + pcpt->cam_status=cpt.cam_status; + pcpt->cam_scsi_status=cpt.cam_scsi_status; + return(status); +} +//---------------------------------------------------------------------------------------------- diff --git a/sm5/os_qnxnto.h b/sm5/os_qnxnto.h new file mode 100644 index 0000000000000000000000000000000000000000..8d724b7773913a8d822f9fcd476e0e10536c20d7 --- /dev/null +++ b/sm5/os_qnxnto.h @@ -0,0 +1,896 @@ +/* + * os_generic.h + * + * Home page of code is: http://smartmontools.sourceforge.net + * + * Copyright (C) Joerg Hering <smartmontools-support@lists.sourceforge.net> + * Copyright (C) 2003-6 Bruce Allen <smartmontools-support@lists.sourceforge.net> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * You should have received a copy of the GNU General Public License + * (for example COPYING); if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * This code was originally developed as a Senior Thesis by Michael Cornwell + * at the Concurrent Systems Laboratory (now part of the Storage Systems + * Research Center), Jack Baskin School of Engineering, University of + * California, Santa Cruz. http://ssrc.soe.ucsc.edu/ + * + */ +#ifndef OS_QNXNTO_H_ +#define OS_QNXNTO_H_ +#define OS_QNXNTO_H_CVSID "$Id: os_qnxnto.h,v 1.1 2007/11/13 14:53:27 jhering Exp $\n" + +// Additional material should start here. Note: to keep the '-V' CVS +// reporting option working as intended, you should only #include +// system include files <something.h>. Local #include files +// <"something.h"> should be #included in os_generic.c +#include <sys/cpt.h> + +#ifndef __TYPES_H_INCLUDED +#include <sys/types.h> +#endif + +#include <stdio.h> +#include <fcntl.h> +#include <gulliver.h> +#include <sys/cpt.h> +#include <sys/dcmd_cam.h> +#include <sys/cam_device.h> +#include "atacmds.h" + +//---------------------------------------------------------------------------------------------------------- +typedef struct _ata_pass_thru ATA_PASS_THRU; +typedef struct _eide_identify EIDE_IDENTIFY; +typedef struct _ata_sense ATA_SENSE; + +typedef void CCB; +struct _sim_hba; +struct _resmgr_context; + + +typedef struct _drive_attribute + { + int id; + int threshold; + char *name; + }DRIVE_ATTRIBUTE; + +//---------------------------------------------------------------------------------------------------------- +/* UNIVOS OSD defines and data structures. */ + +#define INQLEN 36 /* Inquiry string length to store. */ + +#define CAM_SUCCESS 0 /* For signaling general success */ +#define CAM_FAILURE 1 /* For signaling general failure */ + +#define CAM_FALSE 0 /* General purpose flag value */ +#define CAM_TRUE 1 /* General purpose flag value */ + +//---------------------------------------------------------------------------------------------------------- +// Group 3 and 4, command codes 60H-9FH are reserved +#define SC_ATA_PT16 0x85 // ATA Pass-through +//---------------------------------------------------------------------------------------------------------- +#define ATA_SMART_LBA_MID_SIG 0x4f +#define ATA_SMART_LBA_HI_SIG 0xc2 +#define ATA_SMART_SIG 0xc24f +//---------------------------------------------------------------------------------------------------------- + struct _ata_pass_thru { + uchar_t opcode; +#define ATA_PROTO_MSK 0x1e +#define ATA_PROTO_RESPONSE (15 << 1) +#define ATA_PROTO_FPDMA (12 << 1) +#define ATA_PROTO_UDMA_DATA_OUT (11 << 1) +#define ATA_PROTO_UDMA_DATA_IN (10 << 1) +#define ATA_PROTO_DEVICE_RESET (9 << 1) +#define ATA_PROTO_DEVICE_DIAGNOSTIC (8 << 1) +#define ATA_PROTO_DMA_QUEUED (7 << 1) +#define ATA_PROTO_DMA (6 << 1) +#define ATA_PROTO_PIO_DATA_OUT (5 << 1) +#define ATA_PROTO_PIO_DATA_IN (4 << 1) +#define ATA_PROTO_DATA_NONE (3 << 1) +#define ATA_PROTO_SRST (1 << 1) +#define ATA_PROTO_HRST (0 << 1) +#define ATA_PROTO_EXTEND 0x01 + uchar_t protocol; // multiple count, protocol +#define ATA_MCOUNT_MSK 0xe0 + +#define ATA_FLG_CK_COND 0x20 +#define ATA_FLG_T_DIR 0x08 // data from device +#define ATA_FLG_BYT_BLOK 0x04 +#define ATA_FLG_TLEN_STPSIU 0x03 +#define ATA_FLG_TLEN_SECTOR_COUNT 0x02 +#define ATA_FLG_TLEN_FEATURE 0x01 + uchar_t flags; + + uchar_t efeatures; + uchar_t features; + uchar_t esector_count; + uchar_t sector_count; + uchar_t elba_low; + uchar_t lba_low; + uchar_t elba_mid; + uchar_t lba_mid; + uchar_t elba_high; + uchar_t lba_high; + uchar_t device; + uchar_t command; + uchar_t control; + } ata_pass_thru_; +//---------------------------------------------------------------------------------------------------------- +#define SENSE_DATA_FMT_DESCRIPTOR 0x02 + +// Fixed Format Sense Data Structure +// Note: The field "error" has the following format: +// bit 7 - Address valid bit +// bits 6-4 - Error class +// bits 3-0 - Error code +// +// Error classes 0-6 are vendor unique and also indicate that the +// sense data is in _nonextended_ format. (i.e. not usually used) +// struct _scsi_nonextended_sense { +// uchar_t sd_err; +// ulong_t sd_block_address; +// }; +// +// An error class of 7 and an error code of 0 (70H) indicate SCSI-1 +// extended sense data format (or SCSI-2 sense data format). +// +// An error class of 7 and an error code of 1 (71H) indicate SCSI-2 +// deferred errors. +// +// Error codes 74H to 7EH are reserved and error code 7FH indicates +// a vendor-specific sense data format. +typedef struct _scsi_sense { + uchar_t error; // Error Code + uchar_t segment; // Segment number + uchar_t sense; // Sense key/flags + uchar_t info[4]; // Information (32bit big-endian value) + uchar_t asl; // Additional Sense Length + uchar_t csinfo[4]; // Command-Specific Information + uchar_t asc; // Additional Sense Code + uchar_t ascq; // Additional Sense Code Qualifier + uchar_t fruc; // Field Replaceable Unit Code + uchar_t sks; // Sense Key Specific + ushort_t sks_data; // Sense Key Specific Data (16bit big-endian) + ushort_t asb; // Additional Sense uchar_ts (Max 256-18) +} SCSI_SENSE; + +// Descriptor Format Sense Data Structure +// error code of 72 current, 73 deferred +// extended sense data format (or SCSI-2 sense data format). +typedef struct _scsi_sense_descriptor { + uchar_t error; // Error Code + uchar_t sense; // Sense key/flags + uchar_t asc; // Additional Sense Code + uchar_t ascq; // Additional Sense Code Qualifier + uchar_t rsvd[3]; + uchar_t asl; // Additional Sense Length +} SCSI_SENSE_DESCRIPTOR; + +typedef struct _scsi_sense_desriptor_header { + uchar_t descriptor_type; + uchar_t descriptor_len; +} SCSI_SENSE_DESCRIPTOR_HEADER; + +#define SENSE_DTYPE_INFORMATION 0x00 +#define SENSE_DTYPE_CSI 0x01 // Command Specific Information +#define SENSE_DTYPE_SKS 0x02 // Sense Key Specific +#define SENSE_DTYPE_FRU 0x03 // Field Replaceable Unit +#define SENSE_DTYPE_STREAM 0x04 +#define SENSE_DTYPE_BLOCK 0x05 +#define SENSE_DTYPE_OSD_OBJ_IDENT 0x06 // OSD Object Identification +#define SENSE_DTYPE_OSD_INTEGRITY 0x07 // OSD Response Integrity Check Value +#define SENSE_DTYPE_OSD_ATR_IDENT 0x08 // OSD Attribute Identification +#define SENSE_DTYPE_ATA 0x09 + +typedef struct _ata_status_descriptor { + uchar_t descriptor_type; +#define ATA_SD_DLEN 0x0c + uchar_t descriptor_len; /* 0xc */ +#define ATA_SD_FLG_EXTEND 0x01 + uchar_t flags; + uchar_t error; + uchar_t esector_count; /* (15:8) */ + uchar_t sector_count; /* (7:0) */ + uchar_t elba_low; /* (15:8) */ + uchar_t lba_low; /* (7:0) */ + uchar_t elba_mid; /* (15:8) */ + uchar_t lba_mid; /* (7:0) */ + uchar_t elba_high; /* (15:8) */ + uchar_t lba_high; /* (7:0) */ + uchar_t device; + uchar_t status; +} ATA_STATUS_DESCRIPTOR; + +//---------------------------------------------------------------------------------------------------------- +// Sense Keys +#define SK_MSK 0x0F // mask to sd_sense field for key + +#define SK_NO_SENSE 0 // No sense data (no error) + #define ASCQ_FILEMARK_DETECTED 0x01 + #define ASCQ_EOPM_DETECTED 0x02 // End of Partition/Medium Detected + #define ASCQ_SETMARK_DETECTED 0x03 + #define ASCQ_BOPM_DETECTED 0x04 // Beginning of Partition/Medium Detected + +#define SK_RECOVERED 1 // Recovered error + #define ASC_ATA_PASS_THRU 0x00 + #define ASCQ_ATA_PASS_THRU_INFO_AVAIL 0x1d + +#define SK_NOT_RDY 2 // Device not ready + #define ASC_NO_SEEK_COMPLETE 0x02 + #define ASC_NOT_READY 0x04 + #define ASCQ_CAUSE_NOT_REPORTABLE 0x00 + #define ASCQ_BECOMING_READY 0x01 + #define ASCQ_INIT_COMMAND_REQUIRED 0x02 + #define ASCQ_MANUAL_INTERVENTION_REQUIRED 0x03 + #define ASCQ_FORMAT_IN_PROGRESS 0x04 + #define ASCQ_UNKNOWN_CHANGED 0xff // NTO extension for fdc's + #define ASC_MEDIA_FORMAT 0x30 // bad format + #define ASC_MEDIA_NOT_PRESENT 0x3a + #define ASC_NOT_CONFIGURED 0x3e + +#define SK_MEDIUM 3 // Medium error + #define ASC_UNRECOVERABLE_READ_ERROR 0x11 + #define ASC_RECORD_NOT_FOUND 0x14 + #define ASCQ_RECORD_NOT_FOUND 0x01 + #define ASC_UNABLE_TO_RECOVER_TOC 0x57 + #define ASC_INCOMPATIBLE_MEDIUM 0x64 + +#define SK_HARDWARE 4 // Hardware error + #define ASC_INTERNAL_TARGET_FAILURE 0x44 + #define ASC_MEDIA_LOAD_EJECT_FAILURE 0x53 + #define ASCQ_UNRECOVERABLE_CIRC 0x06 + +#define SK_ILLEGAL 5 // Illegal Request (bad command) + #define ASC_INVALID_COMMAND 0x20 + #define ASC_INVALID_FIELD 0x24 + #define ASC_INVALID_FIELD_PARAMETER 0x26 + #define ASC_COMMAND_SEQUENCE_ERROR 0x2c + #define ASCQ_READ_SCRAMBLED 0x03 + #define ASC_ILLEGAL_MODE 0x64 + #define ASC_COPY_PROTECTION 0x6f + +#define SK_UNIT_ATN 6 // Unit Attention + #define ASC_MEDIUM_CHANGED 0x28 + #define ASC_BUS_RESET 0x29 + #define ASC_INSUFFICIENT_TIME_FOR_OPERATION 0x2e + #define ASC_OPERATOR_REQUEST 0x5a + #define ASCQ_OPERATOR_MEDIUM_REMOVAL 0x01 + +#define SK_DATA_PROT 7 // Data Protect + #define ASC_WRITE_PROTECTED 0x27 + +#define SK_BLNK_CHK 8 // Blank Check +#define SK_VENDOR 9 // Vendor Specific +#define SK_CPY_ABORT 10 // Copy Aborted +#define SK_CMD_ABORT 11 // Aborted Command +#define SK_EQUAL 12 // Equal +#define SK_VOL_OFL 13 // Volume Overflow +#define SK_MISCMP 14 // Miscompare +#define SK_RESERVED 15 // Reserved +//---------------------------------------------------------------------------------------------------------- +// Command Descriptor Block structure definitions + +// CDB Flags +#define CF_LINK 0x01 // Linked-command indication +#define CF_FLAG 0x02 // Linked-command with flag bit +#define CF_VENDOR0 0x40 // Vendor unique bits +#define CF_VENDOR1 0x80 + +#define CF_FUA 0x08 +#define CF_DPO 0x10 + +typedef union _cdb { + // generic 6 byte command descriptor block + struct { + uchar_t opcode; + uchar_t lun_opt; + uchar_t lba_byte1; + uchar_t lba_byte0; // LSB + uchar_t transfer_len; + uchar_t control; + } gen6; + + // generic 10 byte command descriptor block + struct { + uchar_t opcode; + uchar_t lun_opt; + uchar_t lba_byte3; + uchar_t lba_byte4; + uchar_t lba_byte1; + uchar_t lba_byte0; + uchar_t rsvd; + uchar_t transfer_len[2]; + uchar_t control; + } gen10; + + // generic 12 byte command descriptor block + struct { + uchar_t opcode; + uchar_t lun_opt; + uchar_t lba_byte3; + uchar_t lba_byte4; + uchar_t lba_byte1; + uchar_t lba_byte0; + uchar_t transfer_len[4]; + uchar_t rsvd10; + uchar_t control; + } gen12; + + struct _format_unit { + uchar_t op_code; +#define FU_RSVD0 0xc0 // reserved bits +#define FU_FMTDAT 0x10 +#define FU_CMPLIST 0x08 + uchar_t defect_list_fmt; + uchar_t track_num; + ushort_t interleave; + uchar_t rsvd1[7]; + } format_unit; + + struct _format_unit_old { + uchar_t op_code; + uchar_t rsvd0; + uchar_t medium_type_code; + uchar_t rsvd1; + uchar_t interleave; + uchar_t rsvd2; +#define FMT_RSVD3 0x80 +#define FMT_SECT_SIZE_CD 0x70 +#define FMT_IMMED 0x08 +#define FMT_HEAD 0x04 +#define FMT_ST 0x02 +#define FMT_CERT 0x01 + uchar_t cert; + uchar_t track_addr; + uchar_t rsvd4[4]; + } format_unit_old; + +#define RW_OPT_RELADR 0x01 +#define RW_OPT_CORRCT 0x02 // Disable Corrections +#define RW_OPT_FUA 0x08 // Force Unit Access +#define RW_OPT_DPO 0x10 // Disable Page Out + struct { + uchar_t opcode; + uchar_t lun_lba; + uchar_t lba[2]; + uchar_t transfer_len; + uchar_t control; + } read_write6; + + struct { + uchar_t opcode; + uchar_t lun_opt; + uchar_t lba[4]; + uchar_t rsvd2; + uchar_t transfer_len[2]; + uchar_t control; + } read_write10; + + struct { + uchar_t opcode; + uchar_t lun_opt; + uchar_t lba[4]; + uchar_t transfer_len[4]; + uchar_t rsvd2; + uchar_t control; + } read_write12; + +#define MSEL_OPT_PF 0x10 // Page Format +#define MSEL_OPT_SP 0x01 // Save Page + struct { + uchar_t opcode; + uchar_t lun_opt; + uchar_t rsvd2; + uchar_t rsvd3; + uchar_t param_length; + uchar_t control; + } mode_select; + + struct { + uchar_t opcode; + uchar_t lun_opt; + uchar_t rsvd2; + uchar_t rsvd3; + uchar_t rsvd4; + uchar_t rsvd5; + uchar_t rsvd6; + uchar_t param_length[2]; + uchar_t control; + } mode_select10; + + struct { + uchar_t opcode; +#define LS_OPT_SP 0x01 // Save Parameters +#define LS_OPT_PCR 0x02 // Parameter Code Reset + uchar_t lun_opt; +#define LS_PC_CUR_THRESHOLD 0x00 +#define LS_PC_CUR_CUMULATIVE 0x01 +#define LS_PC_DFLT_THRESHOLD 0x02 +#define LS_PC_DFLT_CUMULATIVE 0x03 + uchar_t pc; // Page Control + uchar_t rsvd3; + uchar_t rsvd4; + uchar_t rsvd5; + uchar_t rsvd6; + uchar_t param_length[2]; + uchar_t control; + } log_select; + + struct { + uchar_t opcode; +#define MSNS_OPT_DBD 0x08 // Disable Block Descriptors + uchar_t lun_opt; +#define PC_CURRENT 0x00 +#define PC_CHANGEABLE 0x40 +#define PC_DEFAULT 0x80 +#define PC_SAVED 0xC0 +#define PC_MSK 0xC0 + uchar_t pc_page; + uchar_t subpage; + uchar_t allocation_length; + uchar_t control; + } mode_sense; + + struct _mode_sense10 { + uchar_t opcode; + uchar_t lun_opt; + uchar_t pc_page; + uchar_t subpage; + uchar_t rsvd4; + uchar_t rsvd5; + uchar_t rsvd6; + uchar_t allocation_length[2]; + uchar_t control; + } mode_sense10; + + struct { + uchar_t opcode; + uchar_t lun_opt; + uchar_t pc_page; + uchar_t rsvd3; + uchar_t rsvd4; + uchar_t parameter_pointer[2]; + uchar_t allocation_length[2]; + uchar_t control; + } log_sense; + + struct { + uchar_t opcode; + uchar_t lun_opt; + uchar_t rsvd2; + uchar_t rsvd3; + uchar_t prevent; + uchar_t control; + } removal; + + struct { + uchar_t opcode; +#define LD_OPT_IMMED 0x01 + uchar_t lun_opt; + uchar_t rsvd2; + uchar_t rsvd3; +#define LD_CMD_START 0x01 +#define LD_CMD_LOEJ 0x02 +#define LD_CMD_STOP 0x00 +#define LD_CMD_EJECT 0x02 +#define LD_CMD_LOAD 0x03 + +// Sequential-Access +#define LD_CMD_SA_HOLD 0x08 +#define LD_CMD_SA_EOT 0x04 +#define LD_CMD_SA_RT 0x02 // re-tension +#define LD_CMD_SA_LOEJ 0x01 + +// Block +#define LD_CMD_PC_MSK 0xf0 +#define LD_CMD_PC_NC 0 +#define LD_CMD_PC_ACTIVE 1 +#define LD_CMD_PC_IDLE 2 +#define LD_CMD_PC_STANDBY 3 +#define LD_CMD_PC_SLEEP 5 + + uchar_t cmd; + uchar_t control; + } load; + + struct { + uchar_t opcode; + uchar_t lun_opt; +#define SC_OPT_RELADR 0x01 +#define SC_OPT_IMMED 0x02 + uchar_t lba[4]; + uchar_t num_blocks[2]; + uchar_t control; + } synchronize_cache; + +// cdrom commands + struct { + uchar_t opcode; + uchar_t rsvd1; + uchar_t rsvd2; + uchar_t rsvd3; + uchar_t rsvd4; + uchar_t rsvd5; + uchar_t rsvd6; + uchar_t allocation_length[2]; + uchar_t control; + } read_disc_information; + + struct { + uchar_t opcode; + uchar_t lun_opt; + uchar_t rsvd2; + uchar_t rsvd3; + uchar_t rsvd4; + uchar_t rsvd5; + uchar_t rsvd6; + uchar_t rsvd7; + uchar_t resume; + uchar_t control; + } pause_resume; + + struct { + uchar_t opcode; + uchar_t lun_opt; + uchar_t rsvd2; + uchar_t start_minute; + uchar_t start_second; + uchar_t start_frame; + uchar_t end_minute; + uchar_t end_second; + uchar_t end_frame; + uchar_t control; + } play_audio_msf; + + struct { + uchar_t opcode; + uchar_t lun_opt; + uchar_t rsvd2; + uchar_t rsvd3; + uchar_t start_track; + uchar_t start_index; + uchar_t rsvd6; + uchar_t end_track; + uchar_t end_index; + uchar_t control; + } play_audio_ti; + + struct { + uchar_t opcode; +#define CD_SCAN_DIR_FORWARD 0x00 +#define CD_SCAN_DIR_REVERSE 0x10 + uchar_t opt; + uchar_t start_address[4]; +#define CD_SCAN_TYPE_LBA 0x00 +#define CD_SCAN_TYPE_MSF 0x40 +#define CD_SCAN_TYPE_TRK 0x80 +#define CD_SCAN_TYPE_MSK 0xc0 + uchar_t rsvd6; + uchar_t rsvd7; + uchar_t rsvd8; + uchar_t type; + uchar_t rsvd10; + uchar_t rsvd11; + } cd_scan; + + struct { + uchar_t opcode; +#define RTOC_OPT_MSF 0x02 + uchar_t lun_opt; +#define RTOC_FMT_TOC 0x0 +#define RTOC_FMT_SESSION 0x1 +#define RTOC_FMT_QSUBCODE 0x2 +#define RTOC_FMT_QSUBCHNL 0x3 +#define RTOC_FMT_ATIP 0x4 +#define RTOC_FMT_CDTEXT 0x5 + uchar_t format; + uchar_t rsvd3; + uchar_t rsvd4; + uchar_t rsvd5; + uchar_t start_track; + uchar_t allocation_length[2]; +#define RTOC_CNTL_FMT_SESSION 0x40 + uchar_t control_format; + } read_toc; + + struct { + uchar_t opcode; + uchar_t lun_opt; + uchar_t rsvd2[6]; + uchar_t allocation_length[2]; + uchar_t rsvd3[2]; + } mechanism_status; + + struct { + uchar_t opcode; +#define EXCHANGE_OPT_IMMED 0x01 + uchar_t lun_opt; + uchar_t rsvd2; + uchar_t rsvd3; +#define EXCHANGE_CMD_START 0x01 +#define EXCHANGE_CMD_LOEJ 0x02 + uchar_t cmd; + uchar_t rsvd5; + uchar_t rsvd6; + uchar_t rsvd7; + uchar_t slot; + uchar_t rsvd9; + uchar_t rsvd10; + uchar_t rsvd11; + } exchange; + + struct { + uchar_t opcode; + uchar_t rt; + uchar_t feature_number[2]; + uchar_t rsvd4; + uchar_t rsvd5; + uchar_t rsvd6; + uchar_t allocation_length[2]; + uchar_t control; + } get_configuration; + + struct { + uchar_t opcode; +#define GE_OPT_POLLED 0x01 + uchar_t opt; + uchar_t rsvd2; + uchar_t rsvd3; +#define NCR_OPERATIONAL_CHANGE 0x02 +#define NCR_POWER_MANAGEMENT 0x04 +#define NCR_EXTERNAL_REQUEST 0x08 +#define NCR_MEDIA 0x10 +#define NCR_MULTI_INITIATOR 0x20 +#define NCR_DEVICE_BUSY 0x40 + uchar_t ncr; // notification class request + uchar_t rsvd5; + uchar_t rsvd6; + uchar_t allocation_length[2]; + uchar_t control; + } get_event; + + struct { + uchar_t opcode; + uchar_t lun_opt; + uchar_t rsvd2; + uchar_t rsvd3; + uchar_t rsvd4; + uchar_t rsvd5; + uchar_t rsvd6; + uchar_t allocation_length[2]; + uchar_t control; + } read_formated_capacities; + + struct { + uchar_t opcode; + uchar_t lun_opt; + uchar_t read_speed[2]; + uchar_t write_speed[2]; + uchar_t rsvd2[6]; + } cd_speed; + + struct { + uchar_t opcode; +#define RSCHNL_OPT_MSF 0x02 + uchar_t lun_opt; +#define RSCHNL_DATA_SUBQ 0x40 + uchar_t data; + uchar_t data_format; + uchar_t rsvd4; + uchar_t rsvd5; + uchar_t track; + uchar_t allocation_length[2]; + uchar_t control; + } read_subchannel; + +#define CD_FRAME_SYNC_SIZE 12 +#define CD_FRAME_HDR_SIZE 4 +#define CD_FRAME_SUB_HDR_SIZE 8 +#define CD_FRAME_EDC_SIZE 4 +#define CD_FRAME_ECC_SIZE 276 +#define CD_FRAME_AUX_SIZE 8 +#define CD_FRAME_ZERO_SIZE 8 +#define CD_FRAME_SPARE_SIZE 4 +#define CD_FRAME_C2_ERR_SIZE 294 +#define CD_FRAME_BLOCK_ERR_SIZE 2 + + struct { + uchar_t opcode; + uchar_t lun_stype; +// expected sector type +#define RDCD_EST_ANY_SECTOR (0 << 2) +#define RDCD_EST_CDDA_SECTOR (1 << 2) +#define RDCD_EST_YELLOW_MODE1_SECTOR (2 << 2) +#define RDCD_EST_YELLOW_MODE2_SECTOR (3 << 2) +#define RDCD_EST_XA_SECTOR (4 << 2) +#define RDCD_EST_XA_FORM2_SECTOR (5 << 2) +#define RDCD_EST_MSK (7 << 2) + uchar_t lba[4]; + uchar_t transfer_len[3]; + uchar_t flags; +#define RDCD_FLG_SYNC 0x80 +#define RDCD_FLG_UDATA 0x10 +#define RDCD_FLG_ECC 0x08 +#define RDCD_FLG_CD_ERR 0x02 +#define RDCD_FLG_CD_BLOCK_ERR 0x04 +#define RDCD_FLG_HC_NONE ( 0x00 << 5 ) +#define RDCD_FLG_HC_HDR ( 0x01 << 5 ) +#define RDCD_FLG_HC_SUBHEADER ( 0x02 << 5 ) +#define RDCD_FLG_HC_ALL_HEADERS ( 0x03 << 5 ) + uchar_t subch_selection; + uchar_t rsvd3; + } read_cd; + + struct { + uchar_t opcode; + uchar_t lun_stype; + uchar_t rsvd2; + uchar_t start_minute; + uchar_t start_second; + uchar_t start_frame; + uchar_t end_minute; + uchar_t end_second; + uchar_t end_frame; + uchar_t flags; + uchar_t subch_selection; + uchar_t rsvd11; + } read_cd_msf; + + struct _ata_pass_thru { + uchar_t opcode; +#define ATA_PROTO_MSK 0x1e +#define ATA_PROTO_RESPONSE (15 << 1) +#define ATA_PROTO_FPDMA (12 << 1) +#define ATA_PROTO_UDMA_DATA_OUT (11 << 1) +#define ATA_PROTO_UDMA_DATA_IN (10 << 1) +#define ATA_PROTO_DEVICE_RESET (9 << 1) +#define ATA_PROTO_DEVICE_DIAGNOSTIC (8 << 1) +#define ATA_PROTO_DMA_QUEUED (7 << 1) +#define ATA_PROTO_DMA (6 << 1) +#define ATA_PROTO_PIO_DATA_OUT (5 << 1) +#define ATA_PROTO_PIO_DATA_IN (4 << 1) +#define ATA_PROTO_DATA_NONE (3 << 1) +#define ATA_PROTO_SRST (1 << 1) +#define ATA_PROTO_HRST (0 << 1) +#define ATA_PROTO_EXTEND 0x01 + uchar_t protocol; // multiple count, protocol +#define ATA_MCOUNT_MSK 0xe0 + +#define ATA_FLG_CK_COND 0x20 +#define ATA_FLG_T_DIR 0x08 // data from device +#define ATA_FLG_BYT_BLOK 0x04 +#define ATA_FLG_TLEN_STPSIU 0x03 +#define ATA_FLG_TLEN_SECTOR_COUNT 0x02 +#define ATA_FLG_TLEN_FEATURE 0x01 + uchar_t flags; + + uchar_t efeatures; + uchar_t features; + uchar_t esector_count; + uchar_t sector_count; + uchar_t elba_low; + uchar_t lba_low; + uchar_t elba_mid; + uchar_t lba_mid; + uchar_t elba_high; + uchar_t lba_high; + uchar_t device; + uchar_t command; + uchar_t control; + } ata_pass_thru; + +// sequential access commands + struct { + uchar_t opcode; +#define ERASE_OPT_LONG 0x01 + uchar_t opt; + uchar_t rsvd[3]; + uchar_t control; + } erase; + + struct { + uchar_t opcode; +#define LOCATE_OPT_CP 0x2 +#define LOCATE_OPT_BT 0x4 + uchar_t opt; + uchar_t rsvd2; + uchar_t ba[4]; // block address + uchar_t rsvd7; + uchar_t partition; + uchar_t control; + } locate; + + struct { + uchar_t opcode; + uchar_t opt; + uchar_t rsvd2[3]; + uchar_t control; + } read_block_limits; + +#define RP_OPT_BT 0x01 // block address type +#define RP_OPT_LNG 0x02 // long format +#define RP_OPT_TCLP 0x04 // total current logical position + struct { + uchar_t opcode; + uchar_t lun_opt; + uchar_t rsvd2[7]; + uchar_t control; + } read_position; + +#define SRW_OPT_FIXED 0x01 +#define SRW_OPT_SILI 0x02 + struct { + uchar_t opcode; + uchar_t opt; + uchar_t transfer_len[3]; + uchar_t control; + } sa_read_write; + + struct { + uchar_t opcode; + uchar_t opt; + uchar_t rsvd[3]; + uchar_t control; + } rewind; + + struct { + uchar_t opcode; +#define SPACE_CODE_BLOCKS 0x00 +#define SPACE_CODE_FMRKS 0x01 +#define SPACE_CODE_SEQ_FMRKS 0x02 +#define SPACE_CODE_EOD 0x03 +#define SPACE_CODE_SMRKS 0x04 +#define SPACE_CODE_SEQ_SMRKS 0x05 + uchar_t lun_code; + uchar_t count[3]; + uchar_t control; + } space; + + struct { + uchar_t opcode; +#define WF_OPT_IMMED 0x01 +#define WF_OPT_WSMK 0x02 + uchar_t opt; + uchar_t transfer_length[3]; + uchar_t control; + } write_filemarks; + + struct { + uchar_t opcode; +#define RD_OPT_MEDIA 0x01 + uchar_t opt; + uchar_t rsvd[5]; + uchar_t allocation_length[2]; + uchar_t control; + } report_density; + + struct { + uchar_t opcode; +#define FM_OPT_IMMED 0x01 +#define FM_OPT_VERIFY 0x02 + uchar_t opt; +#define FM_FMT_DFLT 0x00 +#define FM_FMT_PARTITION 0x01 +#define FM_FMT_FORMAT_PARTITION 0x02 + uchar_t format; + uchar_t transfer_length[2]; + uchar_t control; + } format_media; +} CDB; +//---------------------------------------------------------------------------------------------------------- + +struct _ata_sense + { + SCSI_SENSE_DESCRIPTOR sense; + ATA_STATUS_DESCRIPTOR desc; + }; +//---------------------------------------------------------------------------------------------------------- + + +#endif /* OS_QNXNTO_H_ */ diff --git a/sm5/smartctl.cpp b/sm5/smartctl.cpp index 687cdd281775857e98566720cf1d89a8846c6644..cb0d3dbf85d6169fe418c4bf3f8877b0aaf01998 100644 --- a/sm5/smartctl.cpp +++ b/sm5/smartctl.cpp @@ -36,6 +36,11 @@ #include <unistd.h> #endif +#if defined(__QNXNTO__) +#include <unistd.h> +#endif + + #include "int64.h" #include "atacmds.h" #include "ataprint.h" @@ -50,7 +55,7 @@ extern const char *os_solaris_ata_s_cvsid; #endif extern const char *atacmdnames_c_cvsid, *atacmds_c_cvsid, *ataprint_c_cvsid, *knowndrives_c_cvsid, *os_XXXX_c_cvsid, *scsicmds_c_cvsid, *scsiprint_c_cvsid, *utility_c_cvsid; -const char* smartctl_c_cvsid="$Id: smartctl.cpp,v 1.167 2007/09/06 08:48:55 ballen4705 Exp $" +const char* smartctl_c_cvsid="$Id: smartctl.cpp,v 1.168 2007/11/13 14:53:27 jhering Exp $" ATACMDS_H_CVSID ATAPRINT_H_CVSID CONFIG_H_CVSID EXTERN_H_CVSID INT64_H_CVSID KNOWNDRIVES_H_CVSID SCSICMDS_H_CVSID SCSIPRINT_H_CVSID SMARTCTL_H_CVSID UTILITY_H_CVSID; // This is a block containing all the "control variables". We declare