2003-07-22 13:00:36 +05:30
|
|
|
/* vi: set sw=4 ts=4: */
|
|
|
|
/*
|
|
|
|
* hdparm implementation for busybox
|
|
|
|
*
|
2003-11-29 04:25:03 +05:30
|
|
|
* Copyright (C) [2003] by [Matteo Croce] <3297627799@wind.it>
|
2003-10-09 12:58:22 +05:30
|
|
|
* Hacked by Tito <farmatito@tiscali.it> for size optimization.
|
2003-07-22 13:00:36 +05:30
|
|
|
*
|
2006-04-17 02:08:26 +05:30
|
|
|
* Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
|
2003-07-22 13:00:36 +05:30
|
|
|
*
|
|
|
|
* This program is based on the source code of hdparm: see below...
|
|
|
|
* hdparm.c - Command line interface to get/set hard disk parameters
|
|
|
|
* - by Mark Lord (C) 1994-2002 -- freely distributable
|
|
|
|
*/
|
2007-05-27 00:30:18 +05:30
|
|
|
#include "libbb.h"
|
2003-07-22 13:00:36 +05:30
|
|
|
#include <linux/hdreg.h>
|
|
|
|
|
|
|
|
/* device types */
|
|
|
|
/* ------------ */
|
|
|
|
#define NO_DEV 0xffff
|
|
|
|
#define ATA_DEV 0x0000
|
|
|
|
#define ATAPI_DEV 0x0001
|
|
|
|
|
|
|
|
/* word definitions */
|
|
|
|
/* ---------------- */
|
|
|
|
#define GEN_CONFIG 0 /* general configuration */
|
|
|
|
#define LCYLS 1 /* number of logical cylinders */
|
|
|
|
#define CONFIG 2 /* specific configuration */
|
|
|
|
#define LHEADS 3 /* number of logical heads */
|
|
|
|
#define TRACK_BYTES 4 /* number of bytes/track (ATA-1) */
|
|
|
|
#define SECT_BYTES 5 /* number of bytes/sector (ATA-1) */
|
|
|
|
#define LSECTS 6 /* number of logical sectors/track */
|
|
|
|
#define START_SERIAL 10 /* ASCII serial number */
|
|
|
|
#define LENGTH_SERIAL 10 /* 10 words (20 bytes or characters) */
|
|
|
|
#define BUF_TYPE 20 /* buffer type (ATA-1) */
|
|
|
|
#define BUFFER__SIZE 21 /* buffer size (ATA-1) */
|
|
|
|
#define RW_LONG 22 /* extra bytes in R/W LONG cmd ( < ATA-4)*/
|
|
|
|
#define START_FW_REV 23 /* ASCII firmware revision */
|
|
|
|
#define LENGTH_FW_REV 4 /* 4 words (8 bytes or characters) */
|
2006-01-25 05:38:53 +05:30
|
|
|
#define START_MODEL 27 /* ASCII model number */
|
|
|
|
#define LENGTH_MODEL 20 /* 20 words (40 bytes or characters) */
|
2007-05-30 05:59:55 +05:30
|
|
|
#define SECTOR_XFER_MAX 47 /* r/w multiple: max sectors xfered */
|
2003-07-22 13:00:36 +05:30
|
|
|
#define DWORD_IO 48 /* can do double-word IO (ATA-1 only) */
|
|
|
|
#define CAPAB_0 49 /* capabilities */
|
|
|
|
#define CAPAB_1 50
|
|
|
|
#define PIO_MODE 51 /* max PIO mode supported (obsolete)*/
|
|
|
|
#define DMA_MODE 52 /* max Singleword DMA mode supported (obs)*/
|
|
|
|
#define WHATS_VALID 53 /* what fields are valid */
|
|
|
|
#define LCYLS_CUR 54 /* current logical cylinders */
|
|
|
|
#define LHEADS_CUR 55 /* current logical heads */
|
2007-05-30 05:59:55 +05:30
|
|
|
#define LSECTS_CUR 56 /* current logical sectors/track */
|
2003-07-22 13:00:36 +05:30
|
|
|
#define CAPACITY_LSB 57 /* current capacity in sectors */
|
|
|
|
#define CAPACITY_MSB 58
|
|
|
|
#define SECTOR_XFER_CUR 59 /* r/w multiple: current sectors xfered */
|
|
|
|
#define LBA_SECTS_LSB 60 /* LBA: total number of user */
|
|
|
|
#define LBA_SECTS_MSB 61 /* addressable sectors */
|
|
|
|
#define SINGLE_DMA 62 /* singleword DMA modes */
|
|
|
|
#define MULTI_DMA 63 /* multiword DMA modes */
|
|
|
|
#define ADV_PIO_MODES 64 /* advanced PIO modes supported */
|
|
|
|
/* multiword DMA xfer cycle time: */
|
|
|
|
#define DMA_TIME_MIN 65 /* - minimum */
|
2009-04-02 01:18:05 +05:30
|
|
|
#define DMA_TIME_NORM 66 /* - manufacturer's recommended */
|
2003-07-22 13:00:36 +05:30
|
|
|
/* minimum PIO xfer cycle time: */
|
|
|
|
#define PIO_NO_FLOW 67 /* - without flow control */
|
|
|
|
#define PIO_FLOW 68 /* - with IORDY flow control */
|
|
|
|
#define PKT_REL 71 /* typical #ns from PKT cmd to bus rel */
|
|
|
|
#define SVC_NBSY 72 /* typical #ns from SERVICE cmd to !BSY */
|
|
|
|
#define CDR_MAJOR 73 /* CD ROM: major version number */
|
|
|
|
#define CDR_MINOR 74 /* CD ROM: minor version number */
|
|
|
|
#define QUEUE_DEPTH 75 /* queue depth */
|
|
|
|
#define MAJOR 80 /* major version number */
|
|
|
|
#define MINOR 81 /* minor version number */
|
|
|
|
#define CMDS_SUPP_0 82 /* command/feature set(s) supported */
|
|
|
|
#define CMDS_SUPP_1 83
|
|
|
|
#define CMDS_SUPP_2 84
|
|
|
|
#define CMDS_EN_0 85 /* command/feature set(s) enabled */
|
|
|
|
#define CMDS_EN_1 86
|
|
|
|
#define CMDS_EN_2 87
|
|
|
|
#define ULTRA_DMA 88 /* ultra DMA modes */
|
|
|
|
/* time to complete security erase */
|
|
|
|
#define ERASE_TIME 89 /* - ordinary */
|
|
|
|
#define ENH_ERASE_TIME 90 /* - enhanced */
|
|
|
|
#define ADV_PWR 91 /* current advanced power management level
|
2003-10-09 12:58:22 +05:30
|
|
|
in low byte, 0x40 in high byte. */
|
2009-04-02 01:18:05 +05:30
|
|
|
#define PSWD_CODE 92 /* master password revision code */
|
2003-07-22 13:00:36 +05:30
|
|
|
#define HWRST_RSLT 93 /* hardware reset result */
|
2006-01-25 05:38:53 +05:30
|
|
|
#define ACOUSTIC 94 /* acoustic mgmt values ( >= ATA-6) */
|
2003-07-22 13:00:36 +05:30
|
|
|
#define LBA_LSB 100 /* LBA: maximum. Currently only 48 */
|
|
|
|
#define LBA_MID 101 /* bits are used, but addr 103 */
|
|
|
|
#define LBA_48_MSB 102 /* has been reserved for LBA in */
|
|
|
|
#define LBA_64_MSB 103 /* the future. */
|
2006-01-25 05:38:53 +05:30
|
|
|
#define RM_STAT 127 /* removable media status notification feature set support */
|
2003-07-22 13:00:36 +05:30
|
|
|
#define SECU_STATUS 128 /* security status */
|
|
|
|
#define CFA_PWR_MODE 160 /* CFA power mode 1 */
|
|
|
|
#define START_MEDIA 176 /* media serial number */
|
|
|
|
#define LENGTH_MEDIA 20 /* 20 words (40 bytes or characters)*/
|
|
|
|
#define START_MANUF 196 /* media manufacturer I.D. */
|
|
|
|
#define LENGTH_MANUF 10 /* 10 words (20 bytes or characters) */
|
|
|
|
#define INTEGRITY 255 /* integrity word */
|
|
|
|
|
|
|
|
/* bit definitions within the words */
|
|
|
|
/* -------------------------------- */
|
|
|
|
|
|
|
|
/* many words are considered valid if bit 15 is 0 and bit 14 is 1 */
|
|
|
|
#define VALID 0xc000
|
|
|
|
#define VALID_VAL 0x4000
|
|
|
|
/* many words are considered invalid if they are either all-0 or all-1 */
|
|
|
|
#define NOVAL_0 0x0000
|
|
|
|
#define NOVAL_1 0xffff
|
|
|
|
|
|
|
|
/* word 0: gen_config */
|
2003-10-09 12:58:22 +05:30
|
|
|
#define NOT_ATA 0x8000
|
2003-07-22 13:00:36 +05:30
|
|
|
#define NOT_ATAPI 0x4000 /* (check only if bit 15 == 1) */
|
|
|
|
#define MEDIA_REMOVABLE 0x0080
|
|
|
|
#define DRIVE_NOT_REMOVABLE 0x0040 /* bit obsoleted in ATA 6 */
|
|
|
|
#define INCOMPLETE 0x0004
|
|
|
|
#define CFA_SUPPORT_VAL 0x848a /* 848a=CFA feature set support */
|
|
|
|
#define DRQ_RESPONSE_TIME 0x0060
|
|
|
|
#define DRQ_3MS_VAL 0x0000
|
|
|
|
#define DRQ_INTR_VAL 0x0020
|
|
|
|
#define DRQ_50US_VAL 0x0040
|
|
|
|
#define PKT_SIZE_SUPPORTED 0x0003
|
|
|
|
#define PKT_SIZE_12_VAL 0x0000
|
|
|
|
#define PKT_SIZE_16_VAL 0x0001
|
|
|
|
#define EQPT_TYPE 0x1f00
|
|
|
|
#define SHIFT_EQPT 8
|
|
|
|
|
|
|
|
#define CDROM 0x0005
|
|
|
|
|
|
|
|
/* word 1: number of logical cylinders */
|
|
|
|
#define LCYLS_MAX 0x3fff /* maximum allowable value */
|
|
|
|
|
2004-04-14 23:21:38 +05:30
|
|
|
/* word 2: specific configuration
|
2003-07-22 13:00:36 +05:30
|
|
|
* (a) require SET FEATURES to spin-up
|
|
|
|
* (b) require spin-up to fully reply to IDENTIFY DEVICE
|
|
|
|
*/
|
|
|
|
#define STBY_NID_VAL 0x37c8 /* (a) and (b) */
|
|
|
|
#define STBY_ID_VAL 0x738c /* (a) and not (b) */
|
2006-01-25 05:38:53 +05:30
|
|
|
#define PWRD_NID_VAL 0x8c73 /* not (a) and (b) */
|
2003-07-22 13:00:36 +05:30
|
|
|
#define PWRD_ID_VAL 0xc837 /* not (a) and not (b) */
|
|
|
|
|
|
|
|
/* words 47 & 59: sector_xfer_max & sector_xfer_cur */
|
|
|
|
#define SECTOR_XFER 0x00ff /* sectors xfered on r/w multiple cmds*/
|
|
|
|
#define MULTIPLE_SETTING_VALID 0x0100 /* 1=multiple sector setting is valid */
|
|
|
|
|
|
|
|
/* word 49: capabilities 0 */
|
2007-07-15 03:37:14 +05:30
|
|
|
#define STD_STBY 0x2000 /* 1=standard values supported (ATA); 0=vendor specific values */
|
2003-07-22 13:00:36 +05:30
|
|
|
#define IORDY_SUP 0x0800 /* 1=support; 0=may be supported */
|
|
|
|
#define IORDY_OFF 0x0400 /* 1=may be disabled */
|
|
|
|
#define LBA_SUP 0x0200 /* 1=Logical Block Address support */
|
|
|
|
#define DMA_SUP 0x0100 /* 1=Direct Memory Access support */
|
|
|
|
#define DMA_IL_SUP 0x8000 /* 1=interleaved DMA support (ATAPI) */
|
|
|
|
#define CMD_Q_SUP 0x4000 /* 1=command queuing support (ATAPI) */
|
|
|
|
#define OVLP_SUP 0x2000 /* 1=overlap operation support (ATAPI) */
|
|
|
|
#define SWRST_REQ 0x1000 /* 1=ATA SW reset required (ATAPI, obsolete */
|
|
|
|
|
|
|
|
/* word 50: capabilities 1 */
|
|
|
|
#define MIN_STANDBY_TIMER 0x0001 /* 1=device specific standby timer value minimum */
|
|
|
|
|
|
|
|
/* words 51 & 52: PIO & DMA cycle times */
|
|
|
|
#define MODE 0xff00 /* the mode is in the MSBs */
|
|
|
|
|
|
|
|
/* word 53: whats_valid */
|
2006-01-25 05:38:53 +05:30
|
|
|
#define OK_W88 0x0004 /* the ultra_dma info is valid */
|
2003-07-22 13:00:36 +05:30
|
|
|
#define OK_W64_70 0x0002 /* see above for word descriptions */
|
|
|
|
#define OK_W54_58 0x0001 /* current cyl, head, sector, cap. info valid */
|
|
|
|
|
|
|
|
/*word 63,88: dma_mode, ultra_dma_mode*/
|
|
|
|
#define MODE_MAX 7 /* bit definitions force udma <=7 (when
|
|
|
|
* udma >=8 comes out it'll have to be
|
|
|
|
* defined in a new dma_mode word!) */
|
|
|
|
|
|
|
|
/* word 64: PIO transfer modes */
|
|
|
|
#define PIO_SUP 0x00ff /* only bits 0 & 1 are used so far, */
|
|
|
|
#define PIO_MODE_MAX 8 /* but all 8 bits are defined */
|
|
|
|
|
|
|
|
/* word 75: queue_depth */
|
|
|
|
#define DEPTH_BITS 0x001f /* bits used for queue depth */
|
|
|
|
|
|
|
|
/* words 80-81: version numbers */
|
|
|
|
/* NOVAL_0 or NOVAL_1 means device does not report version */
|
|
|
|
|
|
|
|
/* word 81: minor version number */
|
2006-04-28 07:03:30 +05:30
|
|
|
#define MINOR_MAX 0x22
|
2003-07-22 13:00:36 +05:30
|
|
|
/* words 82-84: cmds/feats supported */
|
|
|
|
#define CMDS_W82 0x77ff /* word 82: defined command locations*/
|
|
|
|
#define CMDS_W83 0x3fff /* word 83: defined command locations*/
|
|
|
|
#define CMDS_W84 0x002f /* word 83: defined command locations*/
|
2003-10-09 12:58:22 +05:30
|
|
|
#define SUPPORT_48_BIT 0x0400
|
2003-07-22 13:00:36 +05:30
|
|
|
#define NUM_CMD_FEAT_STR 48
|
|
|
|
|
|
|
|
/* words 85-87: cmds/feats enabled */
|
|
|
|
/* use cmd_feat_str[] to display what commands and features have
|
2003-10-09 12:58:22 +05:30
|
|
|
* been enabled with words 85-87
|
2003-07-22 13:00:36 +05:30
|
|
|
*/
|
|
|
|
|
|
|
|
/* words 89, 90, SECU ERASE TIME */
|
2007-05-23 03:16:11 +05:30
|
|
|
#define ERASE_BITS 0x00ff
|
2003-07-22 13:00:36 +05:30
|
|
|
|
|
|
|
/* word 92: master password revision */
|
|
|
|
/* NOVAL_0 or NOVAL_1 means no support for master password revision */
|
|
|
|
|
|
|
|
/* word 93: hw reset result */
|
2007-05-23 03:16:11 +05:30
|
|
|
#define CBLID 0x2000 /* CBLID status */
|
|
|
|
#define RST0 0x0001 /* 1=reset to device #0 */
|
|
|
|
#define DEV_DET 0x0006 /* how device num determined */
|
|
|
|
#define JUMPER_VAL 0x0002 /* device num determined by jumper */
|
|
|
|
#define CSEL_VAL 0x0004 /* device num determined by CSEL_VAL */
|
2003-07-22 13:00:36 +05:30
|
|
|
|
|
|
|
/* word 127: removable media status notification feature set support */
|
2007-05-23 03:16:11 +05:30
|
|
|
#define RM_STAT_BITS 0x0003
|
|
|
|
#define RM_STAT_SUP 0x0001
|
2003-10-09 12:58:22 +05:30
|
|
|
|
2003-07-22 13:00:36 +05:30
|
|
|
/* word 128: security */
|
2007-05-23 03:16:11 +05:30
|
|
|
#define SECU_ENABLED 0x0002
|
|
|
|
#define SECU_LEVEL 0x0010
|
|
|
|
#define NUM_SECU_STR 6
|
2003-07-22 13:00:36 +05:30
|
|
|
|
|
|
|
/* word 160: CFA power mode */
|
2007-05-23 03:16:11 +05:30
|
|
|
#define VALID_W160 0x8000 /* 1=word valid */
|
|
|
|
#define PWR_MODE_REQ 0x2000 /* 1=CFA power mode req'd by some cmds*/
|
|
|
|
#define PWR_MODE_OFF 0x1000 /* 1=CFA power moded disabled */
|
|
|
|
#define MAX_AMPS 0x0fff /* value = max current in ma */
|
2003-07-22 13:00:36 +05:30
|
|
|
|
|
|
|
/* word 255: integrity */
|
2007-05-23 03:16:11 +05:30
|
|
|
#define SIG 0x00ff /* signature location */
|
|
|
|
#define SIG_VAL 0x00a5 /* signature value */
|
2003-07-22 13:00:36 +05:30
|
|
|
|
2007-05-23 03:16:11 +05:30
|
|
|
#define TIMING_BUF_MB 1
|
|
|
|
#define TIMING_BUF_BYTES (TIMING_BUF_MB * 1024 * 1024)
|
2003-10-09 12:58:22 +05:30
|
|
|
|
2007-05-23 03:16:11 +05:30
|
|
|
#undef DO_FLUSHCACHE /* under construction: force cache flush on -W0 */
|
2003-10-09 12:58:22 +05:30
|
|
|
|
2007-09-27 15:53:34 +05:30
|
|
|
|
2009-05-20 19:41:41 +05:30
|
|
|
#define IS_GET 1
|
|
|
|
#define IS_SET 2
|
|
|
|
|
|
|
|
|
2007-09-27 15:53:34 +05:30
|
|
|
enum { fd = 3 };
|
|
|
|
|
2007-09-28 15:55:32 +05:30
|
|
|
|
|
|
|
struct globals {
|
|
|
|
smallint get_identity, get_geom;
|
|
|
|
smallint do_flush;
|
|
|
|
smallint do_ctimings, do_timings;
|
|
|
|
smallint reread_partn;
|
|
|
|
smallint set_piomode, noisy_piomode;
|
2009-05-20 19:41:41 +05:30
|
|
|
smallint getset_readahead;
|
|
|
|
smallint getset_readonly;
|
|
|
|
smallint getset_unmask;
|
|
|
|
smallint getset_mult;
|
2008-03-20 19:14:50 +05:30
|
|
|
#ifdef HDIO_GET_QDMA
|
2009-05-20 19:41:41 +05:30
|
|
|
smallint getset_dma_q;
|
2008-03-20 19:14:50 +05:30
|
|
|
#endif
|
2009-05-20 19:41:41 +05:30
|
|
|
smallint getset_nowerr;
|
|
|
|
smallint getset_keep;
|
|
|
|
smallint getset_io32bit;
|
2007-09-28 15:55:32 +05:30
|
|
|
int piomode;
|
|
|
|
unsigned long Xreadahead;
|
|
|
|
unsigned long readonly;
|
|
|
|
unsigned long unmask;
|
|
|
|
unsigned long mult;
|
2008-03-20 19:14:50 +05:30
|
|
|
#ifdef HDIO_SET_QDMA
|
2007-09-28 15:55:32 +05:30
|
|
|
unsigned long dma_q;
|
2008-03-20 19:14:50 +05:30
|
|
|
#endif
|
2007-09-28 15:55:32 +05:30
|
|
|
unsigned long nowerr;
|
|
|
|
unsigned long keep;
|
|
|
|
unsigned long io32bit;
|
|
|
|
#if ENABLE_FEATURE_HDPARM_HDIO_GETSET_DMA
|
|
|
|
unsigned long dma;
|
2009-05-20 19:41:41 +05:30
|
|
|
smallint getset_dma;
|
2007-09-28 15:55:32 +05:30
|
|
|
#endif
|
|
|
|
#ifdef HDIO_DRIVE_CMD
|
|
|
|
smallint set_xfermode, get_xfermode;
|
2009-05-20 19:41:41 +05:30
|
|
|
smallint getset_dkeep;
|
|
|
|
smallint getset_standby;
|
|
|
|
smallint getset_lookahead;
|
|
|
|
smallint getset_prefetch;
|
|
|
|
smallint getset_defects;
|
|
|
|
smallint getset_wcache;
|
|
|
|
smallint getset_doorlock;
|
|
|
|
smallint set_seagate;
|
|
|
|
smallint set_standbynow;
|
|
|
|
smallint set_sleepnow;
|
2007-09-28 15:55:32 +05:30
|
|
|
smallint get_powermode;
|
2009-05-20 19:41:41 +05:30
|
|
|
smallint getset_apmmode;
|
2007-09-28 15:55:32 +05:30
|
|
|
int xfermode_requested;
|
|
|
|
unsigned long dkeep;
|
2008-03-20 19:14:50 +05:30
|
|
|
unsigned long standby_requested; /* 0..255 */
|
2007-09-28 15:55:32 +05:30
|
|
|
unsigned long lookahead;
|
|
|
|
unsigned long prefetch;
|
|
|
|
unsigned long defects;
|
|
|
|
unsigned long wcache;
|
|
|
|
unsigned long doorlock;
|
|
|
|
unsigned long apmmode;
|
|
|
|
#endif
|
2009-04-21 16:39:40 +05:30
|
|
|
IF_FEATURE_HDPARM_GET_IDENTITY( smallint get_IDentity;)
|
2009-05-20 19:41:41 +05:30
|
|
|
IF_FEATURE_HDPARM_HDIO_TRISTATE_HWIF( smallint getset_busstate;)
|
2009-04-21 16:39:40 +05:30
|
|
|
IF_FEATURE_HDPARM_HDIO_DRIVE_RESET( smallint perform_reset;)
|
|
|
|
IF_FEATURE_HDPARM_HDIO_TRISTATE_HWIF( smallint perform_tristate;)
|
|
|
|
IF_FEATURE_HDPARM_HDIO_UNREGISTER_HWIF(smallint unregister_hwif;)
|
|
|
|
IF_FEATURE_HDPARM_HDIO_SCAN_HWIF( smallint scan_hwif;)
|
|
|
|
IF_FEATURE_HDPARM_HDIO_TRISTATE_HWIF( unsigned long busstate;)
|
|
|
|
IF_FEATURE_HDPARM_HDIO_TRISTATE_HWIF( unsigned long tristate;)
|
|
|
|
IF_FEATURE_HDPARM_HDIO_UNREGISTER_HWIF(unsigned long hwif;)
|
2007-09-28 15:55:32 +05:30
|
|
|
#if ENABLE_FEATURE_HDPARM_HDIO_SCAN_HWIF
|
|
|
|
unsigned long hwif_data;
|
|
|
|
unsigned long hwif_ctrl;
|
|
|
|
unsigned long hwif_irq;
|
|
|
|
#endif
|
2007-09-28 15:58:03 +05:30
|
|
|
#ifdef DO_FLUSHCACHE
|
|
|
|
unsigned char flushcache[4] = { WIN_FLUSHCACHE, 0, 0, 0 };
|
|
|
|
#endif
|
2007-09-28 15:55:32 +05:30
|
|
|
};
|
|
|
|
#define G (*(struct globals*)&bb_common_bufsiz1)
|
|
|
|
struct BUG_G_too_big {
|
|
|
|
char BUG_G_too_big[sizeof(G) <= COMMON_BUFSIZE ? 1 : -1];
|
|
|
|
};
|
|
|
|
#define get_identity (G.get_identity )
|
|
|
|
#define get_geom (G.get_geom )
|
|
|
|
#define do_flush (G.do_flush )
|
|
|
|
#define do_ctimings (G.do_ctimings )
|
|
|
|
#define do_timings (G.do_timings )
|
|
|
|
#define reread_partn (G.reread_partn )
|
|
|
|
#define set_piomode (G.set_piomode )
|
|
|
|
#define noisy_piomode (G.noisy_piomode )
|
2009-05-20 19:41:41 +05:30
|
|
|
#define getset_readahead (G.getset_readahead )
|
|
|
|
#define getset_readonly (G.getset_readonly )
|
|
|
|
#define getset_unmask (G.getset_unmask )
|
|
|
|
#define getset_mult (G.getset_mult )
|
|
|
|
#define getset_dma_q (G.getset_dma_q )
|
|
|
|
#define getset_nowerr (G.getset_nowerr )
|
|
|
|
#define getset_keep (G.getset_keep )
|
|
|
|
#define getset_io32bit (G.getset_io32bit )
|
2007-09-28 15:55:32 +05:30
|
|
|
#define piomode (G.piomode )
|
|
|
|
#define Xreadahead (G.Xreadahead )
|
|
|
|
#define readonly (G.readonly )
|
|
|
|
#define unmask (G.unmask )
|
|
|
|
#define mult (G.mult )
|
|
|
|
#define dma_q (G.dma_q )
|
|
|
|
#define nowerr (G.nowerr )
|
|
|
|
#define keep (G.keep )
|
|
|
|
#define io32bit (G.io32bit )
|
|
|
|
#define dma (G.dma )
|
2009-05-20 19:41:41 +05:30
|
|
|
#define getset_dma (G.getset_dma )
|
2007-09-28 15:55:32 +05:30
|
|
|
#define set_xfermode (G.set_xfermode )
|
|
|
|
#define get_xfermode (G.get_xfermode )
|
2009-05-20 19:41:41 +05:30
|
|
|
#define getset_dkeep (G.getset_dkeep )
|
|
|
|
#define getset_standby (G.getset_standby )
|
|
|
|
#define getset_lookahead (G.getset_lookahead )
|
|
|
|
#define getset_prefetch (G.getset_prefetch )
|
|
|
|
#define getset_defects (G.getset_defects )
|
|
|
|
#define getset_wcache (G.getset_wcache )
|
|
|
|
#define getset_doorlock (G.getset_doorlock )
|
2007-09-28 15:55:32 +05:30
|
|
|
#define set_seagate (G.set_seagate )
|
|
|
|
#define set_standbynow (G.set_standbynow )
|
|
|
|
#define set_sleepnow (G.set_sleepnow )
|
|
|
|
#define get_powermode (G.get_powermode )
|
2009-05-20 19:41:41 +05:30
|
|
|
#define getset_apmmode (G.getset_apmmode )
|
2007-09-28 15:55:32 +05:30
|
|
|
#define xfermode_requested (G.xfermode_requested )
|
|
|
|
#define dkeep (G.dkeep )
|
|
|
|
#define standby_requested (G.standby_requested )
|
|
|
|
#define lookahead (G.lookahead )
|
|
|
|
#define prefetch (G.prefetch )
|
|
|
|
#define defects (G.defects )
|
|
|
|
#define wcache (G.wcache )
|
|
|
|
#define doorlock (G.doorlock )
|
|
|
|
#define apmmode (G.apmmode )
|
|
|
|
#define get_IDentity (G.get_IDentity )
|
2009-05-20 19:41:41 +05:30
|
|
|
#define getset_busstate (G.getset_busstate )
|
2007-09-28 15:55:32 +05:30
|
|
|
#define perform_reset (G.perform_reset )
|
|
|
|
#define perform_tristate (G.perform_tristate )
|
|
|
|
#define unregister_hwif (G.unregister_hwif )
|
|
|
|
#define scan_hwif (G.scan_hwif )
|
|
|
|
#define busstate (G.busstate )
|
|
|
|
#define tristate (G.tristate )
|
|
|
|
#define hwif (G.hwif )
|
|
|
|
#define hwif_data (G.hwif_data )
|
|
|
|
#define hwif_ctrl (G.hwif_ctrl )
|
|
|
|
#define hwif_irq (G.hwif_irq )
|
|
|
|
|
|
|
|
|
2003-10-09 12:58:22 +05:30
|
|
|
/* Busybox messages and functions */
|
2007-07-15 03:37:14 +05:30
|
|
|
#if ENABLE_IOCTL_HEX2STR_ERROR
|
2007-09-27 15:53:34 +05:30
|
|
|
static int ioctl_alt_func(/*int fd,*/ int cmd, unsigned char *args, int alt, const char *string)
|
2003-10-09 12:58:22 +05:30
|
|
|
{
|
2007-07-15 03:37:14 +05:30
|
|
|
if (!ioctl(fd, cmd, args))
|
|
|
|
return 0;
|
|
|
|
args[0] = alt;
|
|
|
|
return bb_ioctl_or_warn(fd, cmd, args, string);
|
2003-10-09 12:58:22 +05:30
|
|
|
}
|
2007-09-27 15:53:34 +05:30
|
|
|
#define ioctl_alt_or_warn(cmd,args,alt) ioctl_alt_func(cmd,args,alt,#cmd)
|
2007-07-15 03:37:14 +05:30
|
|
|
#else
|
2007-09-27 15:53:34 +05:30
|
|
|
static int ioctl_alt_func(/*int fd,*/ int cmd, unsigned char *args, int alt)
|
2006-04-29 21:33:40 +05:30
|
|
|
{
|
|
|
|
if (!ioctl(fd, cmd, args))
|
|
|
|
return 0;
|
|
|
|
args[0] = alt;
|
2007-07-15 03:37:14 +05:30
|
|
|
return bb_ioctl_or_warn(fd, cmd, args);
|
2006-04-29 21:33:40 +05:30
|
|
|
}
|
2007-09-27 15:53:34 +05:30
|
|
|
#define ioctl_alt_or_warn(cmd,args,alt) ioctl_alt_func(cmd,args,alt)
|
2007-07-15 03:37:14 +05:30
|
|
|
#endif
|
2006-04-29 21:33:40 +05:30
|
|
|
|
2007-03-28 06:30:45 +05:30
|
|
|
static void on_off(int value)
|
|
|
|
{
|
2007-07-15 03:37:14 +05:30
|
|
|
puts(value ? " (on)" : " (off)");
|
2007-03-28 06:30:45 +05:30
|
|
|
}
|
2003-10-09 12:58:22 +05:30
|
|
|
|
2007-03-28 06:30:45 +05:30
|
|
|
static void print_flag_on_off(int get_arg, const char *s, unsigned long arg)
|
2003-10-09 12:58:22 +05:30
|
|
|
{
|
2007-01-30 04:21:25 +05:30
|
|
|
if (get_arg) {
|
2006-05-16 21:02:30 +05:30
|
|
|
printf(" setting %s to %ld", s, arg);
|
2003-10-09 12:58:22 +05:30
|
|
|
on_off(arg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-07-15 03:37:14 +05:30
|
|
|
static void print_value_on_off(const char *str, unsigned long argp)
|
2003-10-09 12:58:22 +05:30
|
|
|
{
|
2007-07-15 03:37:14 +05:30
|
|
|
printf(" %s\t= %2ld", str, argp);
|
|
|
|
on_off(argp != 0);
|
2003-10-09 12:58:22 +05:30
|
|
|
}
|
2003-12-12 05:38:57 +05:30
|
|
|
|
2007-02-18 19:06:04 +05:30
|
|
|
#if ENABLE_FEATURE_HDPARM_GET_IDENTITY
|
2007-09-27 15:50:47 +05:30
|
|
|
static void print_ascii(const char *p, int length)
|
|
|
|
{
|
|
|
|
#if BB_BIG_ENDIAN
|
|
|
|
#define LE_ONLY(x)
|
|
|
|
enum { ofs = 0 };
|
|
|
|
#else
|
|
|
|
#define LE_ONLY(x) x
|
|
|
|
/* every 16bit word is big-endian (i.e. inverted) */
|
|
|
|
/* accessing bytes in 1,0, 3,2, 5,4... sequence */
|
|
|
|
int ofs = 1;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
length *= 2;
|
|
|
|
/* find first non-space & print it */
|
|
|
|
while (length && p[ofs] != ' ') {
|
|
|
|
p++;
|
|
|
|
LE_ONLY(ofs = -ofs;)
|
|
|
|
length--;
|
|
|
|
}
|
|
|
|
while (length && p[ofs]) {
|
|
|
|
bb_putchar(p[ofs]);
|
|
|
|
p++;
|
|
|
|
LE_ONLY(ofs = -ofs;)
|
|
|
|
length--;
|
|
|
|
}
|
|
|
|
bb_putchar('\n');
|
|
|
|
#undef LE_ONLY
|
|
|
|
}
|
2003-10-09 12:58:22 +05:30
|
|
|
|
2007-03-28 05:44:01 +05:30
|
|
|
static void xprint_ascii(uint16_t *val, int i, const char *string, int n)
|
2003-10-09 12:58:22 +05:30
|
|
|
{
|
2007-01-30 04:21:25 +05:30
|
|
|
if (val[i]) {
|
|
|
|
printf("\t%-20s", string);
|
2007-09-27 15:50:47 +05:30
|
|
|
print_ascii((void*)&val[i], n);
|
2003-10-09 12:58:22 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint8_t mode_loop(uint16_t mode_sup, uint16_t mode_sel, int cc, uint8_t *have_mode)
|
|
|
|
{
|
2003-07-22 13:00:36 +05:30
|
|
|
uint16_t ii;
|
|
|
|
uint8_t err_dma = 0;
|
2003-10-09 12:58:22 +05:30
|
|
|
|
2007-02-18 19:06:04 +05:30
|
|
|
for (ii = 0; ii <= MODE_MAX; ii++) {
|
|
|
|
if (mode_sel & 0x0001) {
|
2007-03-28 05:44:01 +05:30
|
|
|
printf("*%cdma%u ", cc, ii);
|
2006-04-29 21:36:31 +05:30
|
|
|
if (*have_mode)
|
2003-10-09 12:58:22 +05:30
|
|
|
err_dma = 1;
|
2003-07-22 13:00:36 +05:30
|
|
|
*have_mode = 1;
|
2007-02-18 19:06:04 +05:30
|
|
|
} else if (mode_sup & 0x0001)
|
2007-03-28 05:44:01 +05:30
|
|
|
printf("%cdma%u ", cc, ii);
|
2003-10-09 12:58:22 +05:30
|
|
|
|
2007-02-18 19:06:04 +05:30
|
|
|
mode_sup >>= 1;
|
|
|
|
mode_sel >>= 1;
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
|
|
|
return err_dma;
|
|
|
|
}
|
2003-10-09 12:58:22 +05:30
|
|
|
|
2007-10-31 01:06:54 +05:30
|
|
|
static const char pkt_str[] ALIGN1 =
|
|
|
|
"Direct-access device" "\0" /* word 0, bits 12-8 = 00 */
|
|
|
|
"Sequential-access device" "\0" /* word 0, bits 12-8 = 01 */
|
|
|
|
"Printer" "\0" /* word 0, bits 12-8 = 02 */
|
|
|
|
"Processor" "\0" /* word 0, bits 12-8 = 03 */
|
|
|
|
"Write-once device" "\0" /* word 0, bits 12-8 = 04 */
|
|
|
|
"CD-ROM" "\0" /* word 0, bits 12-8 = 05 */
|
|
|
|
"Scanner" "\0" /* word 0, bits 12-8 = 06 */
|
|
|
|
"Optical memory" "\0" /* word 0, bits 12-8 = 07 */
|
|
|
|
"Medium changer" "\0" /* word 0, bits 12-8 = 08 */
|
|
|
|
"Communications device" "\0" /* word 0, bits 12-8 = 09 */
|
|
|
|
"ACS-IT8 device" "\0" /* word 0, bits 12-8 = 0a */
|
|
|
|
"ACS-IT8 device" "\0" /* word 0, bits 12-8 = 0b */
|
|
|
|
"Array controller" "\0" /* word 0, bits 12-8 = 0c */
|
|
|
|
"Enclosure services" "\0" /* word 0, bits 12-8 = 0d */
|
|
|
|
"Reduced block command device" "\0" /* word 0, bits 12-8 = 0e */
|
|
|
|
"Optical card reader/writer" "\0" /* word 0, bits 12-8 = 0f */
|
|
|
|
;
|
|
|
|
|
|
|
|
static const char ata1_cfg_str[] ALIGN1 = /* word 0 in ATA-1 mode */
|
|
|
|
"reserved" "\0" /* bit 0 */
|
|
|
|
"hard sectored" "\0" /* bit 1 */
|
|
|
|
"soft sectored" "\0" /* bit 2 */
|
|
|
|
"not MFM encoded " "\0" /* bit 3 */
|
|
|
|
"head switch time > 15us" "\0" /* bit 4 */
|
|
|
|
"spindle motor control option" "\0" /* bit 5 */
|
|
|
|
"fixed drive" "\0" /* bit 6 */
|
|
|
|
"removable drive" "\0" /* bit 7 */
|
|
|
|
"disk xfer rate <= 5Mbs" "\0" /* bit 8 */
|
|
|
|
"disk xfer rate > 5Mbs, <= 10Mbs" "\0" /* bit 9 */
|
|
|
|
"disk xfer rate > 5Mbs" "\0" /* bit 10 */
|
|
|
|
"rotational speed tol." "\0" /* bit 11 */
|
|
|
|
"data strobe offset option" "\0" /* bit 12 */
|
|
|
|
"track offset option" "\0" /* bit 13 */
|
|
|
|
"format speed tolerance gap reqd" "\0" /* bit 14 */
|
|
|
|
"ATAPI" /* bit 14 */
|
|
|
|
;
|
|
|
|
|
|
|
|
static const char minor_str[] ALIGN1 =
|
|
|
|
/* word 81 value: */
|
|
|
|
"Unspecified" "\0" /* 0x0000 */
|
|
|
|
"ATA-1 X3T9.2 781D prior to rev.4" "\0" /* 0x0001 */
|
|
|
|
"ATA-1 published, ANSI X3.221-1994" "\0" /* 0x0002 */
|
|
|
|
"ATA-1 X3T9.2 781D rev.4" "\0" /* 0x0003 */
|
|
|
|
"ATA-2 published, ANSI X3.279-1996" "\0" /* 0x0004 */
|
|
|
|
"ATA-2 X3T10 948D prior to rev.2k" "\0" /* 0x0005 */
|
|
|
|
"ATA-3 X3T10 2008D rev.1" "\0" /* 0x0006 */
|
|
|
|
"ATA-2 X3T10 948D rev.2k" "\0" /* 0x0007 */
|
|
|
|
"ATA-3 X3T10 2008D rev.0" "\0" /* 0x0008 */
|
|
|
|
"ATA-2 X3T10 948D rev.3" "\0" /* 0x0009 */
|
|
|
|
"ATA-3 published, ANSI X3.298-199x" "\0" /* 0x000a */
|
|
|
|
"ATA-3 X3T10 2008D rev.6" "\0" /* 0x000b */
|
|
|
|
"ATA-3 X3T13 2008D rev.7 and 7a" "\0" /* 0x000c */
|
|
|
|
"ATA/ATAPI-4 X3T13 1153D rev.6" "\0" /* 0x000d */
|
|
|
|
"ATA/ATAPI-4 T13 1153D rev.13" "\0" /* 0x000e */
|
|
|
|
"ATA/ATAPI-4 X3T13 1153D rev.7" "\0" /* 0x000f */
|
|
|
|
"ATA/ATAPI-4 T13 1153D rev.18" "\0" /* 0x0010 */
|
|
|
|
"ATA/ATAPI-4 T13 1153D rev.15" "\0" /* 0x0011 */
|
|
|
|
"ATA/ATAPI-4 published, ANSI INCITS 317-1998" "\0" /* 0x0012 */
|
|
|
|
"ATA/ATAPI-5 T13 1321D rev.3" "\0" /* 0x0013 */
|
|
|
|
"ATA/ATAPI-4 T13 1153D rev.14" "\0" /* 0x0014 */
|
|
|
|
"ATA/ATAPI-5 T13 1321D rev.1" "\0" /* 0x0015 */
|
|
|
|
"ATA/ATAPI-5 published, ANSI INCITS 340-2000" "\0" /* 0x0016 */
|
|
|
|
"ATA/ATAPI-4 T13 1153D rev.17" "\0" /* 0x0017 */
|
|
|
|
"ATA/ATAPI-6 T13 1410D rev.0" "\0" /* 0x0018 */
|
|
|
|
"ATA/ATAPI-6 T13 1410D rev.3a" "\0" /* 0x0019 */
|
|
|
|
"ATA/ATAPI-7 T13 1532D rev.1" "\0" /* 0x001a */
|
|
|
|
"ATA/ATAPI-6 T13 1410D rev.2" "\0" /* 0x001b */
|
|
|
|
"ATA/ATAPI-6 T13 1410D rev.1" "\0" /* 0x001c */
|
|
|
|
"ATA/ATAPI-7 published, ANSI INCITS 397-2005" "\0" /* 0x001d */
|
|
|
|
"ATA/ATAPI-7 T13 1532D rev.0" "\0" /* 0x001e */
|
|
|
|
"reserved" "\0" /* 0x001f */
|
|
|
|
"reserved" "\0" /* 0x0020 */
|
|
|
|
"ATA/ATAPI-7 T13 1532D rev.4a" "\0" /* 0x0021 */
|
|
|
|
"ATA/ATAPI-6 published, ANSI INCITS 361-2002" "\0" /* 0x0022 */
|
|
|
|
"reserved" /* 0x0023-0xfffe */
|
|
|
|
;
|
|
|
|
static const char actual_ver[MINOR_MAX + 2] ALIGN1 = {
|
|
|
|
/* word 81 value: */
|
|
|
|
0, /* 0x0000 WARNING: actual_ver[] array */
|
|
|
|
1, /* 0x0001 WARNING: corresponds */
|
|
|
|
1, /* 0x0002 WARNING: *exactly* */
|
|
|
|
1, /* 0x0003 WARNING: to the ATA/ */
|
|
|
|
2, /* 0x0004 WARNING: ATAPI version */
|
|
|
|
2, /* 0x0005 WARNING: listed in */
|
|
|
|
3, /* 0x0006 WARNING: the */
|
|
|
|
2, /* 0x0007 WARNING: minor_str */
|
|
|
|
3, /* 0x0008 WARNING: array */
|
|
|
|
2, /* 0x0009 WARNING: above. */
|
|
|
|
3, /* 0x000a WARNING: */
|
|
|
|
3, /* 0x000b WARNING: If you change */
|
|
|
|
3, /* 0x000c WARNING: that one, */
|
|
|
|
4, /* 0x000d WARNING: change this one */
|
|
|
|
4, /* 0x000e WARNING: too!!! */
|
|
|
|
4, /* 0x000f */
|
|
|
|
4, /* 0x0010 */
|
|
|
|
4, /* 0x0011 */
|
|
|
|
4, /* 0x0012 */
|
|
|
|
5, /* 0x0013 */
|
|
|
|
4, /* 0x0014 */
|
|
|
|
5, /* 0x0015 */
|
|
|
|
5, /* 0x0016 */
|
|
|
|
4, /* 0x0017 */
|
|
|
|
6, /* 0x0018 */
|
|
|
|
6, /* 0x0019 */
|
|
|
|
7, /* 0x001a */
|
|
|
|
6, /* 0x001b */
|
|
|
|
6, /* 0x001c */
|
|
|
|
7, /* 0x001d */
|
|
|
|
7, /* 0x001e */
|
|
|
|
0, /* 0x001f */
|
|
|
|
0, /* 0x0020 */
|
|
|
|
7, /* 0x0021 */
|
|
|
|
6, /* 0x0022 */
|
|
|
|
0 /* 0x0023-0xfffe */
|
|
|
|
};
|
|
|
|
|
|
|
|
static const char cmd_feat_str[] ALIGN1 =
|
|
|
|
"" "\0" /* word 82 bit 15: obsolete */
|
|
|
|
"NOP cmd" "\0" /* word 82 bit 14 */
|
|
|
|
"READ BUFFER cmd" "\0" /* word 82 bit 13 */
|
|
|
|
"WRITE BUFFER cmd" "\0" /* word 82 bit 12 */
|
|
|
|
"" "\0" /* word 82 bit 11: obsolete */
|
|
|
|
"Host Protected Area feature set" "\0" /* word 82 bit 10 */
|
|
|
|
"DEVICE RESET cmd" "\0" /* word 82 bit 9 */
|
|
|
|
"SERVICE interrupt" "\0" /* word 82 bit 8 */
|
|
|
|
"Release interrupt" "\0" /* word 82 bit 7 */
|
|
|
|
"Look-ahead" "\0" /* word 82 bit 6 */
|
|
|
|
"Write cache" "\0" /* word 82 bit 5 */
|
|
|
|
"PACKET command feature set" "\0" /* word 82 bit 4 */
|
|
|
|
"Power Management feature set" "\0" /* word 82 bit 3 */
|
|
|
|
"Removable Media feature set" "\0" /* word 82 bit 2 */
|
|
|
|
"Security Mode feature set" "\0" /* word 82 bit 1 */
|
|
|
|
"SMART feature set" "\0" /* word 82 bit 0 */
|
|
|
|
/* -------------- */
|
|
|
|
"" "\0" /* word 83 bit 15: !valid bit */
|
|
|
|
"" "\0" /* word 83 bit 14: valid bit */
|
|
|
|
"FLUSH CACHE EXT cmd" "\0" /* word 83 bit 13 */
|
|
|
|
"Mandatory FLUSH CACHE cmd " "\0" /* word 83 bit 12 */
|
|
|
|
"Device Configuration Overlay feature set " "\0"
|
|
|
|
"48-bit Address feature set " "\0" /* word 83 bit 10 */
|
|
|
|
"" "\0"
|
|
|
|
"SET MAX security extension" "\0" /* word 83 bit 8 */
|
|
|
|
"Address Offset Reserved Area Boot" "\0" /* word 83 bit 7 */
|
|
|
|
"SET FEATURES subcommand required to spinup after power up" "\0"
|
|
|
|
"Power-Up In Standby feature set" "\0" /* word 83 bit 5 */
|
|
|
|
"Removable Media Status Notification feature set" "\0"
|
|
|
|
"Adv. Power Management feature set" "\0" /* word 83 bit 3 */
|
|
|
|
"CFA feature set" "\0" /* word 83 bit 2 */
|
|
|
|
"READ/WRITE DMA QUEUED" "\0" /* word 83 bit 1 */
|
|
|
|
"DOWNLOAD MICROCODE cmd" "\0" /* word 83 bit 0 */
|
|
|
|
/* -------------- */
|
|
|
|
"" "\0" /* word 84 bit 15: !valid bit */
|
|
|
|
"" "\0" /* word 84 bit 14: valid bit */
|
|
|
|
"" "\0" /* word 84 bit 13: reserved */
|
|
|
|
"" "\0" /* word 84 bit 12: reserved */
|
|
|
|
"" "\0" /* word 84 bit 11: reserved */
|
|
|
|
"" "\0" /* word 84 bit 10: reserved */
|
|
|
|
"" "\0" /* word 84 bit 9: reserved */
|
|
|
|
"" "\0" /* word 84 bit 8: reserved */
|
|
|
|
"" "\0" /* word 84 bit 7: reserved */
|
|
|
|
"" "\0" /* word 84 bit 6: reserved */
|
|
|
|
"General Purpose Logging feature set" "\0" /* word 84 bit 5 */
|
|
|
|
"" "\0" /* word 84 bit 4: reserved */
|
|
|
|
"Media Card Pass Through Command feature set " "\0"
|
|
|
|
"Media serial number " "\0" /* word 84 bit 2 */
|
|
|
|
"SMART self-test " "\0" /* word 84 bit 1 */
|
|
|
|
"SMART error logging " /* word 84 bit 0 */
|
|
|
|
;
|
|
|
|
|
|
|
|
static const char secu_str[] ALIGN1 =
|
|
|
|
"supported" "\0" /* word 128, bit 0 */
|
|
|
|
"enabled" "\0" /* word 128, bit 1 */
|
|
|
|
"locked" "\0" /* word 128, bit 2 */
|
|
|
|
"frozen" "\0" /* word 128, bit 3 */
|
|
|
|
"expired: security count" "\0" /* word 128, bit 4 */
|
|
|
|
"supported: enhanced erase" /* word 128, bit 5 */
|
|
|
|
;
|
|
|
|
|
|
|
|
// Parse 512 byte disk identification block and print much crap.
|
2008-07-05 14:48:54 +05:30
|
|
|
static void identify(uint16_t *val) NORETURN;
|
2007-09-27 15:50:47 +05:30
|
|
|
static void identify(uint16_t *val)
|
2003-07-22 13:00:36 +05:30
|
|
|
{
|
2007-09-27 15:50:47 +05:30
|
|
|
uint16_t ii, jj, kk;
|
2003-07-22 13:00:36 +05:30
|
|
|
uint16_t like_std = 1, std = 0, min_std = 0xffff;
|
|
|
|
uint16_t dev = NO_DEV, eqpt = NO_DEV;
|
|
|
|
uint8_t have_mode = 0, err_dma = 0;
|
|
|
|
uint8_t chksum = 0;
|
|
|
|
uint32_t ll, mm, nn, oo;
|
2006-04-29 20:53:33 +05:30
|
|
|
uint64_t bbbig; /* (:) */
|
2006-05-16 21:02:30 +05:30
|
|
|
const char *strng;
|
2007-09-27 15:50:47 +05:30
|
|
|
#if BB_BIG_ENDIAN
|
|
|
|
uint16_t buf[256];
|
2003-07-22 13:00:36 +05:30
|
|
|
|
2007-09-27 15:50:47 +05:30
|
|
|
// Adjust for endianness
|
|
|
|
swab(val, buf, sizeof(buf));
|
|
|
|
val = buf;
|
|
|
|
#endif
|
2003-07-22 13:00:36 +05:30
|
|
|
/* check if we recognise the device type */
|
2007-09-27 15:50:47 +05:30
|
|
|
bb_putchar('\n');
|
2007-02-18 19:06:04 +05:30
|
|
|
if (!(val[GEN_CONFIG] & NOT_ATA)) {
|
2003-07-22 13:00:36 +05:30
|
|
|
dev = ATA_DEV;
|
|
|
|
printf("ATA device, with ");
|
2007-02-18 19:06:04 +05:30
|
|
|
} else if (val[GEN_CONFIG]==CFA_SUPPORT_VAL) {
|
2003-07-22 13:00:36 +05:30
|
|
|
dev = ATA_DEV;
|
|
|
|
like_std = 4;
|
|
|
|
printf("CompactFlash ATA device, with ");
|
2007-02-18 19:06:04 +05:30
|
|
|
} else if (!(val[GEN_CONFIG] & NOT_ATAPI)) {
|
2003-07-22 13:00:36 +05:30
|
|
|
dev = ATAPI_DEV;
|
|
|
|
eqpt = (val[GEN_CONFIG] & EQPT_TYPE) >> SHIFT_EQPT;
|
2007-11-04 09:40:17 +05:30
|
|
|
printf("ATAPI %s, with ", eqpt <= 0xf ? nth_string(pkt_str, eqpt) : "unknown");
|
2003-07-22 13:00:36 +05:30
|
|
|
like_std = 3;
|
2007-02-18 19:06:04 +05:30
|
|
|
} else
|
2007-10-31 01:06:54 +05:30
|
|
|
/* "Unknown device type:\n\tbits 15&14 of general configuration word 0 both set to 1.\n" */
|
2006-10-20 18:58:22 +05:30
|
|
|
bb_error_msg_and_die("unknown device type");
|
2003-07-22 13:00:36 +05:30
|
|
|
|
2006-05-16 21:02:30 +05:30
|
|
|
printf("%sremovable media\n", !(val[GEN_CONFIG] & MEDIA_REMOVABLE) ? "non-" : "");
|
2003-07-22 13:00:36 +05:30
|
|
|
/* Info from the specific configuration word says whether or not the
|
|
|
|
* ID command completed correctly. It is only defined, however in
|
2003-10-09 12:58:22 +05:30
|
|
|
* ATA/ATAPI-5 & 6; it is reserved (value theoretically 0) in prior
|
2003-07-22 13:00:36 +05:30
|
|
|
* standards. Since the values allowed for this word are extremely
|
|
|
|
* specific, it should be safe to check it now, even though we don't
|
|
|
|
* know yet what standard this device is using.
|
|
|
|
*/
|
2007-02-18 19:06:04 +05:30
|
|
|
if ((val[CONFIG]==STBY_NID_VAL) || (val[CONFIG]==STBY_ID_VAL)
|
|
|
|
|| (val[CONFIG]==PWRD_NID_VAL) || (val[CONFIG]==PWRD_ID_VAL)
|
|
|
|
) {
|
2003-10-09 12:58:22 +05:30
|
|
|
like_std = 5;
|
2006-10-04 02:30:06 +05:30
|
|
|
if ((val[CONFIG]==STBY_NID_VAL) || (val[CONFIG]==STBY_ID_VAL))
|
2006-05-16 21:02:30 +05:30
|
|
|
printf("powers-up in standby; SET FEATURES subcmd spins-up.\n");
|
2006-10-04 02:30:06 +05:30
|
|
|
if (((val[CONFIG]==STBY_NID_VAL) || (val[CONFIG]==PWRD_NID_VAL)) && (val[GEN_CONFIG] & INCOMPLETE))
|
2006-05-16 21:02:30 +05:30
|
|
|
printf("\n\tWARNING: ID response incomplete.\n\tFollowing data may be incorrect.\n\n");
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
/* output the model and serial numbers and the fw revision */
|
2003-10-09 12:58:22 +05:30
|
|
|
xprint_ascii(val, START_MODEL, "Model Number:", LENGTH_MODEL);
|
|
|
|
xprint_ascii(val, START_SERIAL, "Serial Number:", LENGTH_SERIAL);
|
|
|
|
xprint_ascii(val, START_FW_REV, "Firmware Revision:", LENGTH_FW_REV);
|
|
|
|
xprint_ascii(val, START_MEDIA, "Media Serial Num:", LENGTH_MEDIA);
|
|
|
|
xprint_ascii(val, START_MANUF, "Media Manufacturer:", LENGTH_MANUF);
|
2003-07-22 13:00:36 +05:30
|
|
|
|
|
|
|
/* major & minor standards version number (Note: these words were not
|
|
|
|
* defined until ATA-3 & the CDROM std uses different words.) */
|
|
|
|
printf("Standards:");
|
2007-02-18 19:06:04 +05:30
|
|
|
if (eqpt != CDROM) {
|
|
|
|
if (val[MINOR] && (val[MINOR] <= MINOR_MAX)) {
|
2006-10-04 02:30:06 +05:30
|
|
|
if (like_std < 3) like_std = 3;
|
2003-07-22 13:00:36 +05:30
|
|
|
std = actual_ver[val[MINOR]];
|
2007-11-04 09:40:17 +05:30
|
|
|
if (std) printf("\n\tUsed: %s ", nth_string(minor_str, val[MINOR]));
|
2003-10-09 12:58:22 +05:30
|
|
|
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
|
|
|
/* looks like when they up-issue the std, they obsolete one;
|
2003-10-09 12:58:22 +05:30
|
|
|
* thus, only the newest 4 issues need be supported. (That's
|
2003-07-22 13:00:36 +05:30
|
|
|
* what "kk" and "min_std" are all about.) */
|
2007-02-18 19:06:04 +05:30
|
|
|
if (val[MAJOR] && (val[MAJOR] != NOVAL_1)) {
|
2003-07-22 13:00:36 +05:30
|
|
|
printf("\n\tSupported: ");
|
|
|
|
jj = val[MAJOR] << 1;
|
|
|
|
kk = like_std >4 ? like_std-4: 0;
|
2007-02-18 19:06:04 +05:30
|
|
|
for (ii = 14; (ii >0)&&(ii>kk); ii--) {
|
|
|
|
if (jj & 0x8000) {
|
2003-07-22 13:00:36 +05:30
|
|
|
printf("%u ", ii);
|
2007-02-18 19:06:04 +05:30
|
|
|
if (like_std < ii) {
|
2003-07-22 13:00:36 +05:30
|
|
|
like_std = ii;
|
|
|
|
kk = like_std >4 ? like_std-4: 0;
|
|
|
|
}
|
2006-10-04 02:30:06 +05:30
|
|
|
if (min_std > ii) min_std = ii;
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
|
|
|
jj <<= 1;
|
|
|
|
}
|
2006-10-04 02:30:06 +05:30
|
|
|
if (like_std < 3) like_std = 3;
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
|
|
|
/* Figure out what standard the device is using if it hasn't told
|
|
|
|
* us. If we know the std, check if the device is using any of
|
|
|
|
* the words from the next level up. It happens.
|
|
|
|
*/
|
2006-10-04 02:30:06 +05:30
|
|
|
if (like_std < std) like_std = std;
|
2003-10-09 12:58:22 +05:30
|
|
|
|
2006-04-29 21:36:31 +05:30
|
|
|
if (((std == 5) || (!std && (like_std < 6))) &&
|
2003-10-09 12:58:22 +05:30
|
|
|
((((val[CMDS_SUPP_1] & VALID) == VALID_VAL) &&
|
|
|
|
(( val[CMDS_SUPP_1] & CMDS_W83) > 0x00ff)) ||
|
|
|
|
((( val[CMDS_SUPP_2] & VALID) == VALID_VAL) &&
|
2007-02-18 19:06:04 +05:30
|
|
|
( val[CMDS_SUPP_2] & CMDS_W84) ) )
|
|
|
|
) {
|
2003-07-22 13:00:36 +05:30
|
|
|
like_std = 6;
|
2007-02-18 19:06:04 +05:30
|
|
|
} else if (((std == 4) || (!std && (like_std < 5))) &&
|
2006-01-25 05:38:53 +05:30
|
|
|
((((val[INTEGRITY] & SIG) == SIG_VAL) && !chksum) ||
|
2003-10-09 12:58:22 +05:30
|
|
|
(( val[HWRST_RSLT] & VALID) == VALID_VAL) ||
|
|
|
|
((( val[CMDS_SUPP_1] & VALID) == VALID_VAL) &&
|
|
|
|
(( val[CMDS_SUPP_1] & CMDS_W83) > 0x001f)) ) )
|
|
|
|
{
|
2003-07-22 13:00:36 +05:30
|
|
|
like_std = 5;
|
2007-02-18 19:06:04 +05:30
|
|
|
} else if (((std == 3) || (!std && (like_std < 4))) &&
|
2003-10-09 12:58:22 +05:30
|
|
|
((((val[CMDS_SUPP_1] & VALID) == VALID_VAL) &&
|
|
|
|
((( val[CMDS_SUPP_1] & CMDS_W83) > 0x0000) ||
|
|
|
|
(( val[CMDS_SUPP_0] & CMDS_W82) > 0x000f))) ||
|
|
|
|
(( val[CAPAB_1] & VALID) == VALID_VAL) ||
|
|
|
|
(( val[WHATS_VALID] & OK_W88) && val[ULTRA_DMA]) ||
|
2007-02-18 19:06:04 +05:30
|
|
|
(( val[RM_STAT] & RM_STAT_BITS) == RM_STAT_SUP) )
|
|
|
|
) {
|
2003-07-22 13:00:36 +05:30
|
|
|
like_std = 4;
|
2007-02-18 19:06:04 +05:30
|
|
|
} else if (((std == 2) || (!std && (like_std < 3)))
|
|
|
|
&& ((val[CMDS_SUPP_1] & VALID) == VALID_VAL)
|
|
|
|
) {
|
2003-07-22 13:00:36 +05:30
|
|
|
like_std = 3;
|
2007-02-18 19:06:04 +05:30
|
|
|
} else if (((std == 1) || (!std && (like_std < 2))) &&
|
2003-10-09 12:58:22 +05:30
|
|
|
((val[CAPAB_0] & (IORDY_SUP | IORDY_OFF)) ||
|
|
|
|
(val[WHATS_VALID] & OK_W64_70)) )
|
|
|
|
{
|
2003-07-22 13:00:36 +05:30
|
|
|
like_std = 2;
|
|
|
|
}
|
2007-02-18 19:06:04 +05:30
|
|
|
|
2006-04-29 21:36:31 +05:30
|
|
|
if (!std)
|
2007-02-18 19:06:04 +05:30
|
|
|
printf("\n\tLikely used: %u\n", like_std);
|
2006-04-29 21:36:31 +05:30
|
|
|
else if (like_std > std)
|
2007-02-18 19:06:04 +05:30
|
|
|
printf("& some of %u\n", like_std);
|
2003-10-09 12:58:22 +05:30
|
|
|
else
|
2007-09-27 15:50:47 +05:30
|
|
|
bb_putchar('\n');
|
2007-02-18 19:06:04 +05:30
|
|
|
} else {
|
2003-07-22 13:00:36 +05:30
|
|
|
/* TBD: do CDROM stuff more thoroughly. For now... */
|
2006-01-25 05:38:53 +05:30
|
|
|
kk = 0;
|
2007-02-18 19:06:04 +05:30
|
|
|
if (val[CDR_MINOR] == 9) {
|
2003-07-22 13:00:36 +05:30
|
|
|
kk = 1;
|
|
|
|
printf("\n\tUsed: ATAPI for CD-ROMs, SFF-8020i, r2.5");
|
|
|
|
}
|
2007-02-18 19:06:04 +05:30
|
|
|
if (val[CDR_MAJOR] && (val[CDR_MAJOR] !=NOVAL_1)) {
|
2003-07-22 13:00:36 +05:30
|
|
|
kk = 1;
|
|
|
|
printf("\n\tSupported: CD-ROM ATAPI");
|
|
|
|
jj = val[CDR_MAJOR] >> 1;
|
2007-02-18 19:06:04 +05:30
|
|
|
for (ii = 1; ii < 15; ii++) {
|
2006-10-04 02:30:06 +05:30
|
|
|
if (jj & 0x0001) printf("-%u ", ii);
|
2003-07-22 13:00:36 +05:30
|
|
|
jj >>= 1;
|
|
|
|
}
|
|
|
|
}
|
2007-10-01 17:35:12 +05:30
|
|
|
puts(kk ? "" : "\n\tLikely used CD-ROM ATAPI-1");
|
2003-07-22 13:00:36 +05:30
|
|
|
/* the cdrom stuff is more like ATA-2 than anything else, so: */
|
|
|
|
like_std = 2;
|
|
|
|
}
|
|
|
|
|
2006-04-29 21:36:31 +05:30
|
|
|
if (min_std == 0xffff)
|
2003-10-09 12:58:22 +05:30
|
|
|
min_std = like_std > 4 ? like_std - 3 : 1;
|
2003-07-22 13:00:36 +05:30
|
|
|
|
|
|
|
printf("Configuration:\n");
|
|
|
|
/* more info from the general configuration word */
|
2007-02-18 19:06:04 +05:30
|
|
|
if ((eqpt != CDROM) && (like_std == 1)) {
|
2003-07-22 13:00:36 +05:30
|
|
|
jj = val[GEN_CONFIG] >> 1;
|
2007-02-18 19:06:04 +05:30
|
|
|
for (ii = 1; ii < 15; ii++) {
|
2007-03-28 06:30:45 +05:30
|
|
|
if (jj & 0x0001)
|
2007-11-04 09:40:17 +05:30
|
|
|
printf("\t%s\n", nth_string(ata1_cfg_str, ii));
|
2003-07-22 13:00:36 +05:30
|
|
|
jj >>=1;
|
|
|
|
}
|
|
|
|
}
|
2007-02-18 19:06:04 +05:30
|
|
|
if (dev == ATAPI_DEV) {
|
2006-05-16 21:02:30 +05:30
|
|
|
if ((val[GEN_CONFIG] & DRQ_RESPONSE_TIME) == DRQ_3MS_VAL)
|
|
|
|
strng = "3ms";
|
|
|
|
else if ((val[GEN_CONFIG] & DRQ_RESPONSE_TIME) == DRQ_INTR_VAL)
|
|
|
|
strng = "<=10ms with INTRQ";
|
|
|
|
else if ((val[GEN_CONFIG] & DRQ_RESPONSE_TIME) == DRQ_50US_VAL)
|
|
|
|
strng ="50us";
|
2006-09-17 21:58:10 +05:30
|
|
|
else
|
2007-10-31 01:06:54 +05:30
|
|
|
strng = "unknown";
|
2006-05-16 21:02:30 +05:30
|
|
|
printf("\tDRQ response: %s\n\tPacket size: ", strng); /* Data Request (DRQ) */
|
|
|
|
|
|
|
|
if ((val[GEN_CONFIG] & PKT_SIZE_SUPPORTED) == PKT_SIZE_12_VAL)
|
|
|
|
strng = "12 bytes";
|
|
|
|
else if ((val[GEN_CONFIG] & PKT_SIZE_SUPPORTED) == PKT_SIZE_16_VAL)
|
|
|
|
strng = "16 bytes";
|
|
|
|
else
|
2007-10-31 01:06:54 +05:30
|
|
|
strng = "unknown";
|
2006-05-16 21:02:30 +05:30
|
|
|
puts(strng);
|
2007-02-18 19:06:04 +05:30
|
|
|
} else {
|
2003-10-09 12:58:22 +05:30
|
|
|
/* addressing...CHS? See section 6.2 of ATA specs 4 or 5 */
|
2003-07-22 13:00:36 +05:30
|
|
|
ll = (uint32_t)val[LBA_SECTS_MSB] << 16 | val[LBA_SECTS_LSB];
|
2009-05-20 18:18:03 +05:30
|
|
|
mm = 0;
|
|
|
|
bbbig = 0;
|
2007-03-28 06:30:45 +05:30
|
|
|
if ((ll > 0x00FBFC10) && (!val[LCYLS]))
|
2006-01-25 05:38:53 +05:30
|
|
|
printf("\tCHS addressing not supported\n");
|
2007-02-18 19:06:04 +05:30
|
|
|
else {
|
2003-07-22 13:00:36 +05:30
|
|
|
jj = val[WHATS_VALID] & OK_W54_58;
|
2009-05-20 18:18:03 +05:30
|
|
|
printf("\tLogical\t\tmax\tcurrent\n"
|
|
|
|
"\tcylinders\t%u\t%u\n"
|
|
|
|
"\theads\t\t%u\t%u\n"
|
|
|
|
"\tsectors/track\t%u\t%u\n"
|
|
|
|
"\t--\n",
|
|
|
|
val[LCYLS],
|
|
|
|
jj ? val[LCYLS_CUR] : 0,
|
|
|
|
val[LHEADS],
|
|
|
|
jj ? val[LHEADS_CUR] : 0,
|
|
|
|
val[LSECTS],
|
|
|
|
jj ? val[LSECTS_CUR] : 0);
|
2003-10-09 12:58:22 +05:30
|
|
|
|
2006-05-16 21:02:30 +05:30
|
|
|
if ((min_std == 1) && (val[TRACK_BYTES] || val[SECT_BYTES]))
|
2009-05-20 18:18:03 +05:30
|
|
|
printf("\tbytes/track: %u\tbytes/sector: %u\n",
|
|
|
|
val[TRACK_BYTES], val[SECT_BYTES]);
|
2003-10-09 12:58:22 +05:30
|
|
|
|
2007-02-18 19:06:04 +05:30
|
|
|
if (jj) {
|
2003-07-22 13:00:36 +05:30
|
|
|
mm = (uint32_t)val[CAPACITY_MSB] << 16 | val[CAPACITY_LSB];
|
2007-02-18 19:06:04 +05:30
|
|
|
if (like_std < 3) {
|
|
|
|
/* check Endian of capacity bytes */
|
2003-07-22 13:00:36 +05:30
|
|
|
nn = val[LCYLS_CUR] * val[LHEADS_CUR] * val[LSECTS_CUR];
|
|
|
|
oo = (uint32_t)val[CAPACITY_LSB] << 16 | val[CAPACITY_MSB];
|
2006-04-29 21:36:31 +05:30
|
|
|
if (abs(mm - nn) > abs(oo - nn))
|
2003-07-22 13:00:36 +05:30
|
|
|
mm = oo;
|
|
|
|
}
|
2007-03-28 05:44:01 +05:30
|
|
|
printf("\tCHS current addressable sectors:%11u\n", mm);
|
2003-10-09 12:58:22 +05:30
|
|
|
}
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
|
|
|
/* LBA addressing */
|
2007-03-28 05:44:01 +05:30
|
|
|
printf("\tLBA user addressable sectors:%11u\n", ll);
|
2007-02-18 19:06:04 +05:30
|
|
|
if (((val[CMDS_SUPP_1] & VALID) == VALID_VAL)
|
|
|
|
&& (val[CMDS_SUPP_1] & SUPPORT_48_BIT)
|
|
|
|
) {
|
2007-03-28 06:30:45 +05:30
|
|
|
bbbig = (uint64_t)val[LBA_64_MSB] << 48 |
|
|
|
|
(uint64_t)val[LBA_48_MSB] << 32 |
|
|
|
|
(uint64_t)val[LBA_MID] << 16 |
|
2007-05-23 03:16:11 +05:30
|
|
|
val[LBA_LSB];
|
2007-03-28 05:44:01 +05:30
|
|
|
printf("\tLBA48 user addressable sectors:%11"PRIu64"\n", bbbig);
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
2003-10-09 12:58:22 +05:30
|
|
|
|
|
|
|
if (!bbbig)
|
2006-04-29 20:53:33 +05:30
|
|
|
bbbig = (uint64_t)(ll>mm ? ll : mm); /* # 512 byte blocks */
|
2007-03-28 05:44:01 +05:30
|
|
|
printf("\tdevice size with M = 1024*1024: %11"PRIu64" MBytes\n", bbbig>>11);
|
|
|
|
bbbig = (bbbig << 9) / 1000000;
|
|
|
|
printf("\tdevice size with M = 1000*1000: %11"PRIu64" MBytes ", bbbig);
|
2003-10-09 12:58:22 +05:30
|
|
|
|
2006-05-16 21:02:30 +05:30
|
|
|
if (bbbig > 1000)
|
2006-05-28 07:26:08 +05:30
|
|
|
printf("(%"PRIu64" GB)\n", bbbig/1000);
|
2006-09-17 21:58:10 +05:30
|
|
|
else
|
2007-09-27 15:50:47 +05:30
|
|
|
bb_putchar('\n');
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
/* hw support of commands (capabilities) */
|
2003-10-09 12:58:22 +05:30
|
|
|
printf("Capabilities:\n\t");
|
|
|
|
|
2007-02-18 19:06:04 +05:30
|
|
|
if (dev == ATAPI_DEV) {
|
2009-05-20 18:18:03 +05:30
|
|
|
if (eqpt != CDROM && (val[CAPAB_0] & CMD_Q_SUP))
|
|
|
|
printf("Cmd queuing, ");
|
|
|
|
if (val[CAPAB_0] & OVLP_SUP)
|
|
|
|
printf("Cmd overlap, ");
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
2006-05-16 21:02:30 +05:30
|
|
|
if (val[CAPAB_0] & LBA_SUP) printf("LBA, ");
|
2003-10-09 12:58:22 +05:30
|
|
|
|
2007-02-18 19:06:04 +05:30
|
|
|
if (like_std != 1) {
|
2006-09-17 21:58:10 +05:30
|
|
|
printf("IORDY%s(can%s be disabled)\n",
|
2009-05-20 18:18:03 +05:30
|
|
|
!(val[CAPAB_0] & IORDY_SUP) ? "(may be)" : "",
|
|
|
|
(val[CAPAB_0] & IORDY_OFF) ? "" :"not");
|
2007-02-18 19:06:04 +05:30
|
|
|
} else
|
2003-10-09 12:58:22 +05:30
|
|
|
printf("no IORDY\n");
|
|
|
|
|
2007-02-18 19:06:04 +05:30
|
|
|
if ((like_std == 1) && val[BUF_TYPE]) {
|
2006-05-16 21:02:30 +05:30
|
|
|
printf("\tBuffer type: %04x: %s%s\n", val[BUF_TYPE],
|
2009-05-20 18:18:03 +05:30
|
|
|
(val[BUF_TYPE] < 2) ? "single port, single-sector" : "dual port, multi-sector",
|
|
|
|
(val[BUF_TYPE] > 2) ? " with read caching ability" : "");
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
2006-05-16 21:02:30 +05:30
|
|
|
|
2007-02-18 19:06:04 +05:30
|
|
|
if ((min_std == 1) && (val[BUFFER__SIZE] && (val[BUFFER__SIZE] != NOVAL_1))) {
|
2007-03-28 05:44:01 +05:30
|
|
|
printf("\tBuffer size: %.1fkB\n", (float)val[BUFFER__SIZE]/2);
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
2007-02-18 19:06:04 +05:30
|
|
|
if ((min_std < 4) && (val[RW_LONG])) {
|
2007-03-28 05:44:01 +05:30
|
|
|
printf("\tbytes avail on r/w long: %u\n", val[RW_LONG]);
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
2007-02-18 19:06:04 +05:30
|
|
|
if ((eqpt != CDROM) && (like_std > 3)) {
|
2007-03-28 05:44:01 +05:30
|
|
|
printf("\tQueue depth: %u\n", (val[QUEUE_DEPTH] & DEPTH_BITS) + 1);
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
2003-10-09 12:58:22 +05:30
|
|
|
|
2007-02-18 19:06:04 +05:30
|
|
|
if (dev == ATA_DEV) {
|
2006-04-29 21:36:31 +05:30
|
|
|
if (like_std == 1)
|
2007-03-28 05:44:01 +05:30
|
|
|
printf("\tCan%s perform double-word IO\n", (!val[DWORD_IO]) ? "not" : "");
|
2007-02-18 19:06:04 +05:30
|
|
|
else {
|
2009-05-20 18:18:03 +05:30
|
|
|
printf("\tStandby timer values: spec'd by %s",
|
|
|
|
(val[CAPAB_0] & STD_STBY) ? "standard" : "vendor");
|
2006-04-29 21:36:31 +05:30
|
|
|
if ((like_std > 3) && ((val[CAPAB_1] & VALID) == VALID_VAL))
|
2009-05-20 18:18:03 +05:30
|
|
|
printf(", %s device specific minimum\n",
|
|
|
|
(val[CAPAB_1] & MIN_STANDBY_TIMER) ? "with" : "no");
|
2003-10-09 12:58:22 +05:30
|
|
|
else
|
2007-09-27 15:50:47 +05:30
|
|
|
bb_putchar('\n');
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
|
|
|
printf("\tR/W multiple sector transfer: ");
|
2006-04-29 21:36:31 +05:30
|
|
|
if ((like_std < 3) && !(val[SECTOR_XFER_MAX] & SECTOR_XFER))
|
2003-07-22 13:00:36 +05:30
|
|
|
printf("not supported\n");
|
2007-02-18 19:06:04 +05:30
|
|
|
else {
|
2007-03-28 05:44:01 +05:30
|
|
|
printf("Max = %u\tCurrent = ", val[SECTOR_XFER_MAX] & SECTOR_XFER);
|
2006-05-16 21:02:30 +05:30
|
|
|
if (val[SECTOR_XFER_CUR] & MULTIPLE_SETTING_VALID)
|
|
|
|
printf("%u\n", val[SECTOR_XFER_CUR] & SECTOR_XFER);
|
|
|
|
else
|
|
|
|
printf("?\n");
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
2007-02-18 19:06:04 +05:30
|
|
|
if ((like_std > 3) && (val[CMDS_SUPP_1] & 0x0008)) {
|
2003-07-22 13:00:36 +05:30
|
|
|
/* We print out elsewhere whether the APM feature is enabled or
|
|
|
|
not. If it's not enabled, let's not repeat the info; just print
|
|
|
|
nothing here. */
|
2003-10-09 12:58:22 +05:30
|
|
|
printf("\tAdvancedPM level: ");
|
2007-02-18 19:06:04 +05:30
|
|
|
if ((val[ADV_PWR] & 0xFF00) == 0x4000) {
|
2003-07-22 13:00:36 +05:30
|
|
|
uint8_t apm_level = val[ADV_PWR] & 0x00FF;
|
|
|
|
printf("%u (0x%x)\n", apm_level, apm_level);
|
|
|
|
}
|
2003-10-09 12:58:22 +05:30
|
|
|
else
|
|
|
|
printf("unknown setting (0x%04x)\n", val[ADV_PWR]);
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
2006-05-16 21:02:30 +05:30
|
|
|
if (like_std > 5 && val[ACOUSTIC]) {
|
|
|
|
printf("\tRecommended acoustic management value: %u, current value: %u\n",
|
2009-05-20 18:18:03 +05:30
|
|
|
(val[ACOUSTIC] >> 8) & 0x00ff,
|
|
|
|
val[ACOUSTIC] & 0x00ff);
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
2007-02-18 19:06:04 +05:30
|
|
|
} else {
|
2003-10-09 12:58:22 +05:30
|
|
|
/* ATAPI */
|
2006-05-16 21:02:30 +05:30
|
|
|
if (eqpt != CDROM && (val[CAPAB_0] & SWRST_REQ))
|
|
|
|
printf("\tATA sw reset required\n");
|
2003-10-09 12:58:22 +05:30
|
|
|
|
2007-02-18 19:06:04 +05:30
|
|
|
if (val[PKT_REL] || val[SVC_NBSY]) {
|
2003-07-22 13:00:36 +05:30
|
|
|
printf("\tOverlap support:");
|
2009-05-20 18:18:03 +05:30
|
|
|
if (val[PKT_REL])
|
|
|
|
printf(" %uus to release bus.", val[PKT_REL]);
|
|
|
|
if (val[SVC_NBSY])
|
|
|
|
printf(" %uus to clear BSY after SERVICE cmd.",
|
|
|
|
val[SVC_NBSY]);
|
2007-09-27 15:50:47 +05:30
|
|
|
bb_putchar('\n');
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* DMA stuff. Check that only one DMA mode is selected. */
|
|
|
|
printf("\tDMA: ");
|
2006-04-29 21:36:31 +05:30
|
|
|
if (!(val[CAPAB_0] & DMA_SUP))
|
2003-07-22 13:00:36 +05:30
|
|
|
printf("not supported\n");
|
2007-02-18 19:06:04 +05:30
|
|
|
else {
|
2006-05-16 21:02:30 +05:30
|
|
|
if (val[DMA_MODE] && !val[SINGLE_DMA] && !val[MULTI_DMA])
|
2007-03-28 05:44:01 +05:30
|
|
|
printf(" sdma%u\n", (val[DMA_MODE] & MODE) >> 8);
|
2007-02-18 19:06:04 +05:30
|
|
|
if (val[SINGLE_DMA]) {
|
2003-10-09 12:58:22 +05:30
|
|
|
jj = val[SINGLE_DMA];
|
|
|
|
kk = val[SINGLE_DMA] >> 8;
|
2007-03-28 05:44:01 +05:30
|
|
|
err_dma += mode_loop(jj, kk, 's', &have_mode);
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
2007-02-18 19:06:04 +05:30
|
|
|
if (val[MULTI_DMA]) {
|
2003-10-09 12:58:22 +05:30
|
|
|
jj = val[MULTI_DMA];
|
|
|
|
kk = val[MULTI_DMA] >> 8;
|
2007-03-28 05:44:01 +05:30
|
|
|
err_dma += mode_loop(jj, kk, 'm', &have_mode);
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
2007-02-18 19:06:04 +05:30
|
|
|
if ((val[WHATS_VALID] & OK_W88) && val[ULTRA_DMA]) {
|
2003-10-09 12:58:22 +05:30
|
|
|
jj = val[ULTRA_DMA];
|
|
|
|
kk = val[ULTRA_DMA] >> 8;
|
2007-03-28 05:44:01 +05:30
|
|
|
err_dma += mode_loop(jj, kk, 'u', &have_mode);
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
2006-05-16 21:02:30 +05:30
|
|
|
if (err_dma || !have_mode) printf("(?)");
|
2007-09-27 15:50:47 +05:30
|
|
|
bb_putchar('\n');
|
2003-07-22 13:00:36 +05:30
|
|
|
|
2006-05-16 21:02:30 +05:30
|
|
|
if ((dev == ATAPI_DEV) && (eqpt != CDROM) && (val[CAPAB_0] & DMA_IL_SUP))
|
|
|
|
printf("\t\tInterleaved DMA support\n");
|
2003-07-22 13:00:36 +05:30
|
|
|
|
2007-02-18 19:06:04 +05:30
|
|
|
if ((val[WHATS_VALID] & OK_W64_70)
|
|
|
|
&& (val[DMA_TIME_MIN] || val[DMA_TIME_NORM])
|
|
|
|
) {
|
2006-05-16 21:02:30 +05:30
|
|
|
printf("\t\tCycle time:");
|
2007-03-28 05:44:01 +05:30
|
|
|
if (val[DMA_TIME_MIN]) printf(" min=%uns", val[DMA_TIME_MIN]);
|
|
|
|
if (val[DMA_TIME_NORM]) printf(" recommended=%uns", val[DMA_TIME_NORM]);
|
2007-09-27 15:50:47 +05:30
|
|
|
bb_putchar('\n');
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Programmed IO stuff */
|
|
|
|
printf("\tPIO: ");
|
2006-01-25 05:38:53 +05:30
|
|
|
/* If a drive supports mode n (e.g. 3), it also supports all modes less
|
2003-07-22 13:00:36 +05:30
|
|
|
* than n (e.g. 3, 2, 1 and 0). Print all the modes. */
|
2007-02-18 19:06:04 +05:30
|
|
|
if ((val[WHATS_VALID] & OK_W64_70) && (val[ADV_PIO_MODES] & PIO_SUP)) {
|
2003-07-22 13:00:36 +05:30
|
|
|
jj = ((val[ADV_PIO_MODES] & PIO_SUP) << 3) | 0x0007;
|
2007-05-23 03:16:11 +05:30
|
|
|
for (ii = 0; ii <= PIO_MODE_MAX; ii++) {
|
2007-03-28 05:44:01 +05:30
|
|
|
if (jj & 0x0001) printf("pio%d ", ii);
|
2003-07-22 13:00:36 +05:30
|
|
|
jj >>=1;
|
|
|
|
}
|
2007-09-27 15:50:47 +05:30
|
|
|
bb_putchar('\n');
|
2007-02-18 19:06:04 +05:30
|
|
|
} else if (((min_std < 5) || (eqpt == CDROM)) && (val[PIO_MODE] & MODE)) {
|
2006-04-29 21:36:31 +05:30
|
|
|
for (ii = 0; ii <= val[PIO_MODE]>>8; ii++)
|
2007-03-28 05:44:01 +05:30
|
|
|
printf("pio%d ", ii);
|
2007-09-27 15:50:47 +05:30
|
|
|
bb_putchar('\n');
|
2007-02-18 19:06:04 +05:30
|
|
|
} else
|
2007-10-31 01:06:54 +05:30
|
|
|
puts("unknown");
|
2003-10-09 12:58:22 +05:30
|
|
|
|
2007-02-18 19:06:04 +05:30
|
|
|
if (val[WHATS_VALID] & OK_W64_70) {
|
|
|
|
if (val[PIO_NO_FLOW] || val[PIO_FLOW]) {
|
2006-05-16 21:02:30 +05:30
|
|
|
printf("\t\tCycle time:");
|
2009-05-20 18:18:03 +05:30
|
|
|
if (val[PIO_NO_FLOW])
|
|
|
|
printf(" no flow control=%uns", val[PIO_NO_FLOW]);
|
|
|
|
if (val[PIO_FLOW])
|
|
|
|
printf(" IORDY flow control=%uns", val[PIO_FLOW]);
|
2007-09-27 15:50:47 +05:30
|
|
|
bb_putchar('\n');
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-02-18 19:06:04 +05:30
|
|
|
if ((val[CMDS_SUPP_1] & VALID) == VALID_VAL) {
|
2009-05-20 18:18:03 +05:30
|
|
|
printf("Commands/features:\n"
|
|
|
|
"\tEnabled\tSupported:\n");
|
2003-07-22 13:00:36 +05:30
|
|
|
jj = val[CMDS_SUPP_0];
|
|
|
|
kk = val[CMDS_EN_0];
|
2007-02-18 19:06:04 +05:30
|
|
|
for (ii = 0; ii < NUM_CMD_FEAT_STR; ii++) {
|
2007-11-04 09:40:17 +05:30
|
|
|
const char *feat_str = nth_string(cmd_feat_str, ii);
|
2007-10-31 01:06:54 +05:30
|
|
|
if ((jj & 0x8000) && (*feat_str != '\0')) {
|
|
|
|
printf("\t%s\t%s\n", (kk & 0x8000) ? " *" : "", feat_str);
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
2007-02-18 19:06:04 +05:30
|
|
|
jj <<= 1;
|
|
|
|
kk <<= 1;
|
|
|
|
if (ii % 16 == 15) {
|
2003-07-22 13:00:36 +05:30
|
|
|
jj = val[CMDS_SUPP_0+1+(ii/16)];
|
|
|
|
kk = val[CMDS_EN_0+1+(ii/16)];
|
|
|
|
}
|
2007-02-18 19:06:04 +05:30
|
|
|
if (ii == 31) {
|
2006-04-29 21:36:31 +05:30
|
|
|
if ((val[CMDS_SUPP_2] & VALID) != VALID_VAL)
|
2003-10-09 12:58:22 +05:30
|
|
|
ii +=16;
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-05-16 21:02:30 +05:30
|
|
|
/* Removable Media Status Notification feature set */
|
2006-10-04 02:30:06 +05:30
|
|
|
if ((val[RM_STAT] & RM_STAT_BITS) == RM_STAT_SUP)
|
2007-11-04 09:40:17 +05:30
|
|
|
printf("\t%s supported\n", nth_string(cmd_feat_str, 27));
|
2003-10-09 12:58:22 +05:30
|
|
|
|
2003-07-22 13:00:36 +05:30
|
|
|
/* security */
|
2007-02-18 19:06:04 +05:30
|
|
|
if ((eqpt != CDROM) && (like_std > 3)
|
|
|
|
&& (val[SECU_STATUS] || val[ERASE_TIME] || val[ENH_ERASE_TIME])
|
|
|
|
) {
|
2006-05-26 00:23:06 +05:30
|
|
|
printf("Security:\n");
|
2006-05-16 21:02:30 +05:30
|
|
|
if (val[PSWD_CODE] && (val[PSWD_CODE] != NOVAL_1))
|
2007-03-28 05:44:01 +05:30
|
|
|
printf("\tMaster password revision code = %u\n", val[PSWD_CODE]);
|
2003-07-22 13:00:36 +05:30
|
|
|
jj = val[SECU_STATUS];
|
2007-02-18 19:06:04 +05:30
|
|
|
if (jj) {
|
|
|
|
for (ii = 0; ii < NUM_SECU_STR; ii++) {
|
2009-05-20 18:18:03 +05:30
|
|
|
printf("\t%s\t%s\n",
|
|
|
|
(!(jj & 0x0001)) ? "not" : "",
|
|
|
|
nth_string(secu_str, ii));
|
2003-07-22 13:00:36 +05:30
|
|
|
jj >>=1;
|
|
|
|
}
|
2007-02-18 19:06:04 +05:30
|
|
|
if (val[SECU_STATUS] & SECU_ENABLED) {
|
2009-05-20 18:18:03 +05:30
|
|
|
printf("\tSecurity level %s\n",
|
|
|
|
(val[SECU_STATUS] & SECU_LEVEL) ? "maximum" : "high");
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
jj = val[ERASE_TIME] & ERASE_BITS;
|
|
|
|
kk = val[ENH_ERASE_TIME] & ERASE_BITS;
|
2007-02-18 19:06:04 +05:30
|
|
|
if (jj || kk) {
|
2008-06-05 12:21:06 +05:30
|
|
|
bb_putchar('\t');
|
2006-05-26 00:23:06 +05:30
|
|
|
if (jj) printf("%umin for %sSECURITY ERASE UNIT. ", jj==ERASE_BITS ? 508 : jj<<1, "");
|
|
|
|
if (kk) printf("%umin for %sSECURITY ERASE UNIT. ", kk==ERASE_BITS ? 508 : kk<<1, "ENHANCED ");
|
2007-09-27 15:50:47 +05:30
|
|
|
bb_putchar('\n');
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* reset result */
|
2006-05-16 21:02:30 +05:30
|
|
|
jj = val[HWRST_RSLT];
|
2007-02-18 19:06:04 +05:30
|
|
|
if ((jj & VALID) == VALID_VAL) {
|
2007-11-06 08:35:54 +05:30
|
|
|
oo = (jj & RST0);
|
|
|
|
if (!oo)
|
2006-05-16 21:02:30 +05:30
|
|
|
jj >>= 8;
|
2006-04-29 21:36:31 +05:30
|
|
|
if ((jj & DEV_DET) == JUMPER_VAL)
|
2006-05-16 21:02:30 +05:30
|
|
|
strng = " determined by the jumper";
|
2006-04-29 21:36:31 +05:30
|
|
|
else if ((jj & DEV_DET) == CSEL_VAL)
|
2006-05-16 21:02:30 +05:30
|
|
|
strng = " determined by CSEL";
|
2006-09-17 21:58:10 +05:30
|
|
|
else
|
2006-05-16 21:02:30 +05:30
|
|
|
strng = "";
|
2009-05-20 18:18:03 +05:30
|
|
|
printf("HW reset results:\n"
|
|
|
|
"\tCBLID- %s Vih\n"
|
|
|
|
"\tDevice num = %i%s\n",
|
|
|
|
(val[HWRST_RSLT] & CBLID) ? "above" : "below",
|
|
|
|
!(oo), strng);
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
/* more stuff from std 5 */
|
2007-02-18 19:06:04 +05:30
|
|
|
if ((like_std > 4) && (eqpt != CDROM)) {
|
|
|
|
if (val[CFA_PWR_MODE] & VALID_W160) {
|
2009-05-20 18:18:03 +05:30
|
|
|
printf("CFA power mode 1:\n"
|
|
|
|
"\t%s%s\n",
|
|
|
|
(val[CFA_PWR_MODE] & PWR_MODE_OFF) ? "disabled" : "enabled",
|
|
|
|
(val[CFA_PWR_MODE] & PWR_MODE_REQ) ? " and required by some commands" : "");
|
2007-02-18 19:06:04 +05:30
|
|
|
if (val[CFA_PWR_MODE] & MAX_AMPS)
|
2007-03-28 05:44:01 +05:30
|
|
|
printf("\tMaximum current = %uma\n", val[CFA_PWR_MODE] & MAX_AMPS);
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
2007-02-18 19:06:04 +05:30
|
|
|
if ((val[INTEGRITY] & SIG) == SIG_VAL) {
|
2006-05-16 21:02:30 +05:30
|
|
|
printf("Checksum: %scorrect\n", chksum ? "in" : "");
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-05-16 21:02:30 +05:30
|
|
|
exit(EXIT_SUCCESS);
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Historically, if there was no HDIO_OBSOLETE_IDENTITY, then
|
|
|
|
// then the HDIO_GET_IDENTITY only returned 142 bytes.
|
|
|
|
// Otherwise, HDIO_OBSOLETE_IDENTITY returns 142 bytes,
|
|
|
|
// and HDIO_GET_IDENTITY returns 512 bytes. But the latest
|
|
|
|
// 2.5.xx kernels no longer define HDIO_OBSOLETE_IDENTITY
|
|
|
|
// (which they should, but they should just return -EINVAL).
|
|
|
|
//
|
|
|
|
// So.. we must now assume that HDIO_GET_IDENTITY returns 512 bytes.
|
|
|
|
// On a really old system, it will not, and we will be confused.
|
|
|
|
// Too bad, really.
|
|
|
|
|
2007-02-18 19:06:04 +05:30
|
|
|
#if ENABLE_FEATURE_HDPARM_GET_IDENTITY
|
2007-10-31 01:06:54 +05:30
|
|
|
static const char cfg_str[] ALIGN1 =
|
2008-01-07 21:43:14 +05:30
|
|
|
"""\0" "HardSect""\0" "SoftSect""\0" "NotMFM""\0"
|
|
|
|
"HdSw>15uSec""\0" "SpinMotCtl""\0" "Fixed""\0" "Removeable""\0"
|
|
|
|
"DTR<=5Mbs""\0" "DTR>5Mbs""\0" "DTR>10Mbs""\0" "RotSpdTol>.5%""\0"
|
|
|
|
"dStbOff""\0" "TrkOff""\0" "FmtGapReq""\0" "nonMagnetic"
|
2007-10-31 01:06:54 +05:30
|
|
|
;
|
2003-07-22 13:00:36 +05:30
|
|
|
|
2007-10-31 01:06:54 +05:30
|
|
|
static const char BuffType[] ALIGN1 =
|
|
|
|
"unknown""\0" "1Sect""\0" "DualPort""\0" "DualPortCache"
|
|
|
|
;
|
2003-07-22 13:00:36 +05:30
|
|
|
|
2006-04-29 21:36:31 +05:30
|
|
|
static void dump_identity(const struct hd_driveid *id)
|
2003-07-22 13:00:36 +05:30
|
|
|
{
|
|
|
|
int i;
|
2008-02-16 18:48:17 +05:30
|
|
|
const unsigned short *id_regs = (const void*) id;
|
2006-02-22 22:31:00 +05:30
|
|
|
|
2003-10-09 12:58:22 +05:30
|
|
|
printf("\n Model=%.40s, FwRev=%.8s, SerialNo=%.20s\n Config={",
|
|
|
|
id->model, id->fw_rev, id->serial_no);
|
2007-03-28 06:30:45 +05:30
|
|
|
for (i = 0; i <= 15; i++) {
|
2006-05-26 00:23:06 +05:30
|
|
|
if (id->config & (1<<i))
|
2007-11-04 09:40:17 +05:30
|
|
|
printf(" %s", nth_string(cfg_str, i));
|
2006-05-16 21:02:30 +05:30
|
|
|
}
|
2007-03-28 06:30:45 +05:30
|
|
|
printf(" }\n RawCHS=%u/%u/%u, TrkSize=%u, SectSize=%u, ECCbytes=%u\n"
|
2009-05-20 18:18:03 +05:30
|
|
|
" BuffType=(%u) %s, BuffSize=%ukB, MaxMultSect=%u",
|
|
|
|
id->cyls, id->heads, id->sectors, id->track_bytes,
|
|
|
|
id->sector_bytes, id->ecc_bytes,
|
|
|
|
id->buf_type,
|
|
|
|
nth_string(BuffType, (id->buf_type > 3) ? 0 : id->buf_type),
|
|
|
|
id->buf_size/2, id->max_multsect);
|
2007-02-18 19:06:04 +05:30
|
|
|
if (id->max_multsect) {
|
2003-07-22 13:00:36 +05:30
|
|
|
printf(", MultSect=");
|
2007-02-18 19:06:04 +05:30
|
|
|
if (!(id->multsect_valid & 1))
|
2003-07-22 13:00:36 +05:30
|
|
|
printf("?%u?", id->multsect);
|
|
|
|
else if (id->multsect)
|
|
|
|
printf("%u", id->multsect);
|
|
|
|
else
|
|
|
|
printf("off");
|
|
|
|
}
|
2007-09-27 15:50:47 +05:30
|
|
|
bb_putchar('\n');
|
2003-10-09 12:58:22 +05:30
|
|
|
|
2007-02-18 19:06:04 +05:30
|
|
|
if (!(id->field_valid & 1))
|
2006-05-26 00:23:06 +05:30
|
|
|
printf(" (maybe):");
|
|
|
|
|
2007-03-28 05:44:01 +05:30
|
|
|
printf(" CurCHS=%u/%u/%u, CurSects=%lu, LBA=%s", id->cur_cyls, id->cur_heads,
|
2007-02-18 19:06:04 +05:30
|
|
|
id->cur_sectors,
|
|
|
|
(BB_BIG_ENDIAN) ?
|
2007-03-28 06:30:45 +05:30
|
|
|
(unsigned long)(id->cur_capacity0 << 16) | id->cur_capacity1 :
|
|
|
|
(unsigned long)(id->cur_capacity1 << 16) | id->cur_capacity0,
|
2007-02-18 19:06:04 +05:30
|
|
|
((id->capability&2) == 0) ? "no" : "yes");
|
2003-10-09 12:58:22 +05:30
|
|
|
|
2007-02-18 19:06:04 +05:30
|
|
|
if (id->capability & 2)
|
2006-05-26 00:23:06 +05:30
|
|
|
printf(", LBAsects=%u", id->lba_capacity);
|
2003-10-09 12:58:22 +05:30
|
|
|
|
2009-05-20 18:18:03 +05:30
|
|
|
printf("\n IORDY=%s",
|
|
|
|
(id->capability & 8)
|
|
|
|
? ((id->capability & 4) ? "on/off" : "yes")
|
|
|
|
: "no");
|
2006-05-26 00:23:06 +05:30
|
|
|
|
2007-02-18 19:06:04 +05:30
|
|
|
if (((id->capability & 8) || (id->field_valid & 2)) && (id->field_valid & 2))
|
2006-05-26 00:23:06 +05:30
|
|
|
printf(", tPIO={min:%u,w/IORDY:%u}", id->eide_pio, id->eide_pio_iordy);
|
2006-09-17 21:58:10 +05:30
|
|
|
|
2007-02-18 19:06:04 +05:30
|
|
|
if ((id->capability & 1) && (id->field_valid & 2))
|
2006-05-26 00:23:06 +05:30
|
|
|
printf(", tDMA={min:%u,rec:%u}", id->eide_dma_min, id->eide_dma_time);
|
|
|
|
|
|
|
|
printf("\n PIO modes: ");
|
2007-02-18 19:06:04 +05:30
|
|
|
if (id->tPIO <= 5) {
|
2006-05-26 00:23:06 +05:30
|
|
|
printf("pio0 ");
|
|
|
|
if (id->tPIO >= 1) printf("pio1 ");
|
|
|
|
if (id->tPIO >= 2) printf("pio2 ");
|
|
|
|
}
|
2007-02-18 19:06:04 +05:30
|
|
|
if (id->field_valid & 2) {
|
2008-06-07 20:40:29 +05:30
|
|
|
static const masks_labels_t pio_modes = {
|
|
|
|
.masks = { 1, 2, ~3 },
|
|
|
|
.labels = "pio3 \0""pio4 \0""pio? \0",
|
|
|
|
};
|
|
|
|
print_flags(&pio_modes, id->eide_pio_modes);
|
2006-05-26 00:23:06 +05:30
|
|
|
}
|
2007-02-18 19:06:04 +05:30
|
|
|
if (id->capability & 1) {
|
|
|
|
if (id->dma_1word | id->dma_mword) {
|
2008-06-07 20:40:29 +05:30
|
|
|
static const int dma_wmode_masks[] = { 0x100, 1, 0x200, 2, 0x400, 4, 0xf800, 0xf8 };
|
2006-05-26 00:23:06 +05:30
|
|
|
printf("\n DMA modes: ");
|
2008-06-07 20:40:29 +05:30
|
|
|
print_flags_separated(dma_wmode_masks,
|
|
|
|
"*\0""sdma0 \0""*\0""sdma1 \0""*\0""sdma2 \0""*\0""sdma? \0",
|
|
|
|
id->dma_1word, NULL);
|
|
|
|
print_flags_separated(dma_wmode_masks,
|
2009-05-20 19:41:41 +05:30
|
|
|
"*\0""mdma0 \0""*\0""mdma1 \0""*\0""mdma2 \0""*\0""mdma? \0",
|
2008-06-07 20:40:29 +05:30
|
|
|
id->dma_mword, NULL);
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
|
|
|
}
|
2007-02-18 19:06:04 +05:30
|
|
|
if (((id->capability & 8) || (id->field_valid & 2)) && id->field_valid & 4) {
|
2008-06-07 20:40:29 +05:30
|
|
|
static const masks_labels_t ultra_modes1 = {
|
|
|
|
.masks = { 0x100, 0x001, 0x200, 0x002, 0x400, 0x004 },
|
|
|
|
.labels = "*\0""udma0 \0""*\0""udma1 \0""*\0""udma2 \0",
|
|
|
|
};
|
2008-06-25 15:23:17 +05:30
|
|
|
|
2006-05-26 00:23:06 +05:30
|
|
|
printf("\n UDMA modes: ");
|
2008-06-07 20:40:29 +05:30
|
|
|
print_flags(&ultra_modes1, id->dma_ultra);
|
2003-07-22 13:00:36 +05:30
|
|
|
#ifdef __NEW_HD_DRIVE_ID
|
2007-02-18 19:06:04 +05:30
|
|
|
if (id->hw_config & 0x2000) {
|
2003-07-22 13:00:36 +05:30
|
|
|
#else /* !__NEW_HD_DRIVE_ID */
|
2007-02-18 19:06:04 +05:30
|
|
|
if (id->word93 & 0x2000) {
|
2003-07-22 13:00:36 +05:30
|
|
|
#endif /* __NEW_HD_DRIVE_ID */
|
2008-06-07 20:40:29 +05:30
|
|
|
static const masks_labels_t ultra_modes2 = {
|
|
|
|
.masks = { 0x0800, 0x0008, 0x1000, 0x0010,
|
|
|
|
0x2000, 0x0020, 0x4000, 0x0040,
|
|
|
|
0x8000, 0x0080 },
|
|
|
|
.labels = "*\0""udma3 \0""*\0""udma4 \0"
|
|
|
|
"*\0""udma5 \0""*\0""udma6 \0"
|
|
|
|
"*\0""udma7 \0"
|
|
|
|
};
|
|
|
|
print_flags(&ultra_modes2, id->dma_ultra);
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
|
|
|
}
|
2007-03-28 05:44:01 +05:30
|
|
|
printf("\n AdvancedPM=%s", (!(id_regs[83] & 8)) ? "no" : "yes");
|
2007-02-18 19:06:04 +05:30
|
|
|
if (id_regs[83] & 8) {
|
|
|
|
if (!(id_regs[86] & 8))
|
2003-10-09 12:58:22 +05:30
|
|
|
printf(": disabled (255)");
|
2007-02-18 19:06:04 +05:30
|
|
|
else if ((id_regs[91] & 0xFF00) != 0x4000)
|
2003-10-09 12:58:22 +05:30
|
|
|
printf(": unknown setting");
|
|
|
|
else
|
2007-03-28 05:44:01 +05:30
|
|
|
printf(": mode=0x%02X (%u)", id_regs[91] & 0xFF, id_regs[91] & 0xFF);
|
2003-10-09 12:58:22 +05:30
|
|
|
}
|
2007-02-18 19:06:04 +05:30
|
|
|
if (id_regs[82] & 0x20)
|
2007-03-28 05:44:01 +05:30
|
|
|
printf(" WriteCache=%s", (id_regs[85] & 0x20) ? "enabled" : "disabled");
|
2003-07-22 13:00:36 +05:30
|
|
|
#ifdef __NEW_HD_DRIVE_ID
|
2007-02-18 19:06:04 +05:30
|
|
|
if ((id->minor_rev_num && id->minor_rev_num <= 31)
|
|
|
|
|| (id->major_rev_num && id->minor_rev_num <= 31)
|
|
|
|
) {
|
2009-05-20 18:18:03 +05:30
|
|
|
printf("\n Drive conforms to: %s: ",
|
|
|
|
(id->minor_rev_num <= 31) ? nth_string(minor_str, id->minor_rev_num) : "unknown");
|
|
|
|
if (id->major_rev_num != 0x0000 /* NOVAL_0 */
|
|
|
|
&& id->major_rev_num != 0xFFFF /* NOVAL_1 */
|
|
|
|
) {
|
2007-03-28 06:30:45 +05:30
|
|
|
for (i = 0; i <= 15; i++) {
|
2006-05-16 21:02:30 +05:30
|
|
|
if (id->major_rev_num & (1<<i))
|
2009-05-20 18:18:03 +05:30
|
|
|
printf(" ATA/ATAPI-%u", i);
|
2006-05-16 21:02:30 +05:30
|
|
|
}
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif /* __NEW_HD_DRIVE_ID */
|
2006-05-26 00:23:06 +05:30
|
|
|
printf("\n\n * current active mode\n\n");
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2007-09-27 15:53:34 +05:30
|
|
|
static void flush_buffer_cache(/*int fd*/ void)
|
2003-07-22 13:00:36 +05:30
|
|
|
{
|
2006-04-29 21:36:31 +05:30
|
|
|
fsync(fd); /* flush buffers */
|
2007-07-15 03:37:14 +05:30
|
|
|
ioctl_or_warn(fd, BLKFLSBUF, NULL); /* do it again, big time */
|
2003-07-22 13:00:36 +05:30
|
|
|
#ifdef HDIO_DRIVE_CMD
|
2003-10-09 12:58:22 +05:30
|
|
|
sleep(1);
|
2007-07-15 03:37:14 +05:30
|
|
|
if (ioctl(fd, HDIO_DRIVE_CMD, NULL) && errno != EINVAL) { /* await completion */
|
|
|
|
if (ENABLE_IOCTL_HEX2STR_ERROR) /* To be coherent with ioctl_or_warn */
|
|
|
|
bb_perror_msg("HDIO_DRIVE_CMD");
|
|
|
|
else
|
|
|
|
bb_perror_msg("ioctl %#x failed", HDIO_DRIVE_CMD);
|
|
|
|
}
|
2003-07-22 13:00:36 +05:30
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2007-09-28 15:55:32 +05:30
|
|
|
static void seek_to_zero(/*int fd*/ void)
|
2003-07-22 13:00:36 +05:30
|
|
|
{
|
2007-09-28 15:55:32 +05:30
|
|
|
xlseek(fd, (off_t) 0, SEEK_SET);
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
|
|
|
|
2007-09-28 15:58:03 +05:30
|
|
|
static void read_big_block(/*int fd,*/ char *buf)
|
2003-07-22 13:00:36 +05:30
|
|
|
{
|
2006-05-16 21:02:30 +05:30
|
|
|
int i;
|
|
|
|
|
2007-09-28 15:58:03 +05:30
|
|
|
xread(fd, buf, TIMING_BUF_BYTES);
|
2003-07-22 13:00:36 +05:30
|
|
|
/* access all sectors of buf to ensure the read fully completed */
|
|
|
|
for (i = 0; i < TIMING_BUF_BYTES; i += 512)
|
|
|
|
buf[i] &= 1;
|
|
|
|
}
|
|
|
|
|
2007-09-28 19:08:08 +05:30
|
|
|
static unsigned dev_size_mb(/*int fd*/ void)
|
2006-05-16 21:02:30 +05:30
|
|
|
{
|
2007-09-28 15:55:32 +05:30
|
|
|
union {
|
|
|
|
unsigned long long blksize64;
|
|
|
|
unsigned blksize32;
|
|
|
|
} u;
|
2006-05-16 21:02:30 +05:30
|
|
|
|
2007-09-28 19:08:08 +05:30
|
|
|
if (0 == ioctl(fd, BLKGETSIZE64, &u.blksize64)) { // bytes
|
|
|
|
u.blksize64 /= (1024 * 1024);
|
|
|
|
} else {
|
|
|
|
xioctl(fd, BLKGETSIZE, &u.blksize32); // sectors
|
|
|
|
u.blksize64 = u.blksize32 / (2 * 1024);
|
2006-05-16 21:02:30 +05:30
|
|
|
}
|
2007-09-28 19:08:08 +05:30
|
|
|
if (u.blksize64 > UINT_MAX)
|
|
|
|
return UINT_MAX;
|
|
|
|
return u.blksize64;
|
2006-05-16 21:02:30 +05:30
|
|
|
}
|
2003-08-06 14:17:59 +05:30
|
|
|
|
2007-09-28 19:08:08 +05:30
|
|
|
static void print_timing(unsigned m, unsigned elapsed_us)
|
2007-05-23 03:16:11 +05:30
|
|
|
{
|
2007-09-28 15:58:03 +05:30
|
|
|
unsigned sec = elapsed_us / 1000000;
|
|
|
|
unsigned hs = (elapsed_us % 1000000) / 10000;
|
|
|
|
|
2007-09-28 19:08:08 +05:30
|
|
|
printf("%5u MB in %u.%02u seconds = %u kB/s\n",
|
2007-09-28 15:58:03 +05:30
|
|
|
m, sec, hs,
|
2007-09-28 19:11:41 +05:30
|
|
|
/* "| 1" prevents div-by-0 */
|
|
|
|
(unsigned) ((unsigned long long)m * (1024 * 1000000) / (elapsed_us | 1))
|
2007-09-28 19:08:08 +05:30
|
|
|
// ~= (m * 1024) / (elapsed_us / 1000000)
|
2007-09-28 15:58:03 +05:30
|
|
|
// = kb / elapsed_sec
|
|
|
|
);
|
2007-05-23 03:16:11 +05:30
|
|
|
}
|
|
|
|
|
2007-09-28 15:58:03 +05:30
|
|
|
static void do_time(int cache /*,int fd*/)
|
|
|
|
/* cache=1: time cache: repeatedly read N MB at offset 0
|
|
|
|
* cache=0: time device: linear read, starting at offset 0
|
|
|
|
*/
|
2003-07-22 13:00:36 +05:30
|
|
|
{
|
2007-09-28 15:58:03 +05:30
|
|
|
unsigned max_iterations, iterations;
|
2007-09-28 19:08:08 +05:30
|
|
|
unsigned start; /* doesn't need to be long long */
|
2007-05-23 03:16:11 +05:30
|
|
|
unsigned elapsed, elapsed2;
|
2007-09-28 19:08:08 +05:30
|
|
|
unsigned total_MB;
|
2007-09-28 15:55:32 +05:30
|
|
|
char *buf = xmalloc(TIMING_BUF_BYTES);
|
2006-05-16 21:02:30 +05:30
|
|
|
|
2007-09-28 15:58:03 +05:30
|
|
|
if (mlock(buf, TIMING_BUF_BYTES))
|
|
|
|
bb_perror_msg_and_die("mlock");
|
2003-07-22 13:00:36 +05:30
|
|
|
|
2007-09-28 15:58:03 +05:30
|
|
|
/* Clear out the device request queues & give them time to complete.
|
|
|
|
* NB: *small* delay. User is expected to have a clue and to not run
|
|
|
|
* heavy io in parallel with measurements. */
|
2006-05-16 21:02:30 +05:30
|
|
|
sync();
|
2007-09-28 15:58:03 +05:30
|
|
|
sleep(1);
|
|
|
|
if (cache) { /* Time cache */
|
2007-09-28 15:55:32 +05:30
|
|
|
seek_to_zero();
|
2007-09-28 15:58:03 +05:30
|
|
|
read_big_block(buf);
|
|
|
|
printf("Timing buffer-cache reads: ");
|
2007-05-23 03:16:11 +05:30
|
|
|
} else { /* Time device */
|
2007-09-28 15:58:03 +05:30
|
|
|
printf("Timing buffered disk reads:");
|
2007-05-23 03:16:11 +05:30
|
|
|
}
|
|
|
|
fflush(stdout);
|
2007-09-28 15:58:03 +05:30
|
|
|
|
2007-05-23 03:16:11 +05:30
|
|
|
/* Now do the timing */
|
2007-09-28 15:58:03 +05:30
|
|
|
iterations = 0;
|
2007-09-28 16:51:47 +05:30
|
|
|
/* Max time to run (small for cache, avoids getting
|
2007-09-28 19:08:08 +05:30
|
|
|
* huge total_MB which can overlow unsigned type) */
|
2007-09-28 16:51:47 +05:30
|
|
|
elapsed2 = 510000; /* cache */
|
2007-09-28 19:08:08 +05:30
|
|
|
max_iterations = UINT_MAX;
|
|
|
|
if (!cache) {
|
2007-09-28 16:51:47 +05:30
|
|
|
elapsed2 = 3000000; /* not cache */
|
2007-09-28 19:08:08 +05:30
|
|
|
/* Don't want to read past the end! */
|
|
|
|
max_iterations = dev_size_mb() / TIMING_BUF_MB;
|
|
|
|
}
|
2007-09-28 15:58:03 +05:30
|
|
|
start = monotonic_us();
|
2007-05-23 03:16:11 +05:30
|
|
|
do {
|
2007-09-28 15:58:03 +05:30
|
|
|
if (cache)
|
2007-09-28 15:55:32 +05:30
|
|
|
seek_to_zero();
|
2007-09-28 15:58:03 +05:30
|
|
|
read_big_block(buf);
|
|
|
|
elapsed = (unsigned)monotonic_us() - start;
|
|
|
|
++iterations;
|
2007-09-28 16:51:47 +05:30
|
|
|
} while (elapsed < elapsed2 && iterations < max_iterations);
|
2007-09-28 19:08:08 +05:30
|
|
|
total_MB = iterations * TIMING_BUF_MB;
|
2007-09-28 15:58:03 +05:30
|
|
|
//printf(" elapsed:%u iterations:%u ", elapsed, iterations);
|
|
|
|
if (cache) {
|
2007-09-28 16:51:47 +05:30
|
|
|
/* Cache: remove lseek() and monotonic_us() overheads
|
2007-09-28 15:58:03 +05:30
|
|
|
* from elapsed */
|
|
|
|
start = monotonic_us();
|
2006-05-16 21:02:30 +05:30
|
|
|
do {
|
2007-09-28 15:55:32 +05:30
|
|
|
seek_to_zero();
|
2007-09-28 15:58:03 +05:30
|
|
|
elapsed2 = (unsigned)monotonic_us() - start;
|
2006-05-16 21:02:30 +05:30
|
|
|
} while (--iterations);
|
2007-09-28 15:58:03 +05:30
|
|
|
//printf(" elapsed2:%u ", elapsed2);
|
2006-05-16 21:02:30 +05:30
|
|
|
elapsed -= elapsed2;
|
2007-09-28 15:58:03 +05:30
|
|
|
total_MB *= 2; // BUFCACHE_FACTOR (why?)
|
2007-09-27 15:53:34 +05:30
|
|
|
flush_buffer_cache();
|
2003-10-09 12:58:22 +05:30
|
|
|
}
|
2007-09-28 15:58:03 +05:30
|
|
|
print_timing(total_MB, elapsed);
|
2006-05-19 22:54:26 +05:30
|
|
|
munlock(buf, TIMING_BUF_BYTES);
|
2007-09-28 15:55:32 +05:30
|
|
|
free(buf);
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
|
|
|
|
2007-02-18 19:06:04 +05:30
|
|
|
#if ENABLE_FEATURE_HDPARM_HDIO_TRISTATE_HWIF
|
2007-03-28 06:30:45 +05:30
|
|
|
static void bus_state_value(unsigned value)
|
2003-07-22 13:00:36 +05:30
|
|
|
{
|
2006-05-16 21:02:30 +05:30
|
|
|
if (value == BUSSTATE_ON)
|
|
|
|
on_off(1);
|
|
|
|
else if (value == BUSSTATE_OFF)
|
|
|
|
on_off(0);
|
|
|
|
else if (value == BUSSTATE_TRISTATE)
|
|
|
|
printf(" (tristate)\n");
|
|
|
|
else
|
|
|
|
printf(" (unknown: %d)\n", value);
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HDIO_DRIVE_CMD
|
2008-03-20 19:14:50 +05:30
|
|
|
static void interpret_standby(uint8_t standby)
|
2003-07-22 13:00:36 +05:30
|
|
|
{
|
2006-08-04 01:52:37 +05:30
|
|
|
printf(" (");
|
2008-03-20 19:14:50 +05:30
|
|
|
if (standby == 0) {
|
2006-05-16 21:02:30 +05:30
|
|
|
printf("off");
|
2008-03-20 19:14:50 +05:30
|
|
|
} else if (standby <= 240 || standby == 252 || standby == 255) {
|
|
|
|
/* standby is in 5 sec units */
|
2009-05-21 02:51:42 +05:30
|
|
|
unsigned t = standby * 5;
|
|
|
|
printf("%u minutes %u seconds", t / 60, t % 60);
|
2008-03-20 19:14:50 +05:30
|
|
|
} else if (standby <= 251) {
|
|
|
|
unsigned t = (standby - 240); /* t is in 30 min units */;
|
2009-05-20 18:18:03 +05:30
|
|
|
printf("%u.%c hours", t / 2, (t & 1) ? '5' : '0');
|
2008-03-20 19:14:50 +05:30
|
|
|
}
|
|
|
|
if (standby == 253)
|
2006-05-16 21:02:30 +05:30
|
|
|
printf("vendor-specific");
|
2008-03-20 19:14:50 +05:30
|
|
|
if (standby == 254)
|
2007-10-31 01:06:54 +05:30
|
|
|
printf("reserved");
|
2003-07-22 13:00:36 +05:30
|
|
|
printf(")\n");
|
|
|
|
}
|
|
|
|
|
2007-08-16 16:07:49 +05:30
|
|
|
static const uint8_t xfermode_val[] ALIGN1 = {
|
|
|
|
8, 9, 10, 11, 12, 13, 14, 15,
|
|
|
|
16, 17, 18, 19, 20, 21, 22, 23,
|
|
|
|
32, 33, 34, 35, 36, 37, 38, 39,
|
|
|
|
64, 65, 66, 67, 68, 69, 70, 71
|
2003-07-22 13:00:36 +05:30
|
|
|
};
|
2007-08-16 16:07:49 +05:30
|
|
|
/* NB: we save size by _not_ storing terninating NUL! */
|
|
|
|
static const char xfermode_name[][5] ALIGN1 = {
|
|
|
|
"pio0", "pio1", "pio2", "pio3", "pio4", "pio5", "pio6", "pio7",
|
|
|
|
"sdma0","sdma1","sdma2","sdma3","sdma4","sdma5","sdma6","sdma7",
|
|
|
|
"mdma0","mdma1","mdma2","mdma3","mdma4","mdma5","mdma6","mdma7",
|
|
|
|
"udma0","udma1","udma2","udma3","udma4","udma5","udma6","udma7"
|
2003-07-22 13:00:36 +05:30
|
|
|
};
|
|
|
|
|
2007-08-16 16:07:49 +05:30
|
|
|
static int translate_xfermode(const char *name)
|
2003-07-22 13:00:36 +05:30
|
|
|
{
|
2008-05-16 03:00:45 +05:30
|
|
|
int val;
|
|
|
|
unsigned i;
|
2003-10-09 12:58:22 +05:30
|
|
|
|
2007-08-16 16:07:49 +05:30
|
|
|
for (i = 0; i < ARRAY_SIZE(xfermode_val); i++) {
|
|
|
|
if (!strncmp(name, xfermode_name[i], 5))
|
|
|
|
if (strlen(name) <= 5)
|
|
|
|
return xfermode_val[i];
|
2003-10-09 12:58:22 +05:30
|
|
|
}
|
2007-08-16 16:07:49 +05:30
|
|
|
/* Negative numbers are invalid and are caught later */
|
|
|
|
val = bb_strtoi(name, NULL, 10);
|
|
|
|
if (!errno)
|
2003-10-09 12:58:22 +05:30
|
|
|
return val;
|
|
|
|
return -1;
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
|
|
|
|
2007-03-28 06:30:45 +05:30
|
|
|
static void interpret_xfermode(unsigned xfermode)
|
2003-07-22 13:00:36 +05:30
|
|
|
{
|
|
|
|
printf(" (");
|
2006-05-16 21:02:30 +05:30
|
|
|
if (xfermode == 0)
|
|
|
|
printf("default PIO mode");
|
|
|
|
else if (xfermode == 1)
|
|
|
|
printf("default PIO mode, disable IORDY");
|
|
|
|
else if (xfermode >= 8 && xfermode <= 15)
|
2007-08-16 16:07:49 +05:30
|
|
|
printf("PIO flow control mode%u", xfermode - 8);
|
2006-05-16 21:02:30 +05:30
|
|
|
else if (xfermode >= 16 && xfermode <= 23)
|
2007-08-16 16:07:49 +05:30
|
|
|
printf("singleword DMA mode%u", xfermode - 16);
|
2006-05-16 21:02:30 +05:30
|
|
|
else if (xfermode >= 32 && xfermode <= 39)
|
2007-08-16 16:07:49 +05:30
|
|
|
printf("multiword DMA mode%u", xfermode - 32);
|
2006-05-16 21:02:30 +05:30
|
|
|
else if (xfermode >= 64 && xfermode <= 71)
|
2007-08-16 16:07:49 +05:30
|
|
|
printf("UltraDMA mode%u", xfermode - 64);
|
2006-05-16 21:02:30 +05:30
|
|
|
else
|
2007-10-31 01:06:54 +05:30
|
|
|
printf("unknown");
|
2003-07-22 13:00:36 +05:30
|
|
|
printf(")\n");
|
|
|
|
}
|
|
|
|
#endif /* HDIO_DRIVE_CMD */
|
|
|
|
|
2007-03-28 06:30:45 +05:30
|
|
|
static void print_flag(int flag, const char *s, unsigned long value)
|
2006-05-16 21:02:30 +05:30
|
|
|
{
|
2006-10-04 02:30:06 +05:30
|
|
|
if (flag)
|
2006-05-16 21:02:30 +05:30
|
|
|
printf(" setting %s to %ld\n", s, value);
|
|
|
|
}
|
|
|
|
|
2006-04-29 21:36:31 +05:30
|
|
|
static void process_dev(char *devname)
|
2003-07-22 13:00:36 +05:30
|
|
|
{
|
2007-09-27 15:53:34 +05:30
|
|
|
/*int fd;*/
|
2007-03-28 06:30:45 +05:30
|
|
|
long parm, multcount;
|
2003-07-22 13:00:36 +05:30
|
|
|
#ifndef HDIO_DRIVE_CMD
|
|
|
|
int force_operation = 0;
|
|
|
|
#endif
|
2006-05-05 22:22:28 +05:30
|
|
|
/* Please restore args[n] to these values after each ioctl
|
|
|
|
except for args[2] */
|
2007-03-28 05:44:01 +05:30
|
|
|
unsigned char args[4] = { WIN_SETFEATURES, 0, 0, 0 };
|
2006-05-16 21:02:30 +05:30
|
|
|
const char *fmt = " %s\t= %2ld";
|
2006-04-29 21:19:18 +05:30
|
|
|
|
2007-09-27 15:53:34 +05:30
|
|
|
/*fd = xopen(devname, O_RDONLY | O_NONBLOCK);*/
|
|
|
|
xmove_fd(xopen(devname, O_RDONLY | O_NONBLOCK), fd);
|
2006-05-26 00:23:06 +05:30
|
|
|
printf("\n%s:\n", devname);
|
2003-07-22 13:00:36 +05:30
|
|
|
|
2009-05-20 19:41:41 +05:30
|
|
|
if (getset_readahead == IS_SET) {
|
|
|
|
print_flag(getset_readahead, "fs readahead", Xreadahead);
|
2007-07-15 03:37:14 +05:30
|
|
|
ioctl_or_warn(fd, BLKRASET, (int *)Xreadahead);
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
2007-02-18 19:06:04 +05:30
|
|
|
#if ENABLE_FEATURE_HDPARM_HDIO_UNREGISTER_HWIF
|
|
|
|
if (unregister_hwif) {
|
2006-05-08 05:04:15 +05:30
|
|
|
printf(" attempting to unregister hwif#%lu\n", hwif);
|
2007-07-15 03:37:14 +05:30
|
|
|
ioctl_or_warn(fd, HDIO_UNREGISTER_HWIF, (int *)(unsigned long)hwif);
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
|
|
|
#endif
|
2007-02-18 19:06:04 +05:30
|
|
|
#if ENABLE_FEATURE_HDPARM_HDIO_SCAN_HWIF
|
2009-05-20 19:41:41 +05:30
|
|
|
if (scan_hwif == IS_SET) {
|
2006-05-08 05:04:15 +05:30
|
|
|
printf(" attempting to scan hwif (0x%lx, 0x%lx, %lu)\n", hwif_data, hwif_ctrl, hwif_irq);
|
2003-07-22 13:00:36 +05:30
|
|
|
args[0] = hwif_data;
|
|
|
|
args[1] = hwif_ctrl;
|
|
|
|
args[2] = hwif_irq;
|
2007-07-15 03:37:14 +05:30
|
|
|
ioctl_or_warn(fd, HDIO_SCAN_HWIF, args);
|
2006-05-05 22:22:28 +05:30
|
|
|
args[0] = WIN_SETFEATURES;
|
|
|
|
args[1] = 0;
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
|
|
|
#endif
|
2007-02-18 19:06:04 +05:30
|
|
|
if (set_piomode) {
|
|
|
|
if (noisy_piomode) {
|
2003-10-09 12:58:22 +05:30
|
|
|
printf(" attempting to ");
|
2003-07-22 13:00:36 +05:30
|
|
|
if (piomode == 255)
|
2003-10-09 12:58:22 +05:30
|
|
|
printf("auto-tune PIO mode\n");
|
2003-07-22 13:00:36 +05:30
|
|
|
else if (piomode < 100)
|
2003-10-09 12:58:22 +05:30
|
|
|
printf("set PIO mode to %d\n", piomode);
|
2003-07-22 13:00:36 +05:30
|
|
|
else if (piomode < 200)
|
2003-10-09 12:58:22 +05:30
|
|
|
printf("set MDMA mode to %d\n", (piomode-100));
|
2003-07-22 13:00:36 +05:30
|
|
|
else
|
2003-10-09 12:58:22 +05:30
|
|
|
printf("set UDMA mode to %d\n", (piomode-200));
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
2007-07-15 03:37:14 +05:30
|
|
|
ioctl_or_warn(fd, HDIO_SET_PIO_MODE, (int *)(unsigned long)piomode);
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
2009-05-20 19:41:41 +05:30
|
|
|
if (getset_io32bit == IS_SET) {
|
|
|
|
print_flag(getset_io32bit, "32-bit IO_support flag", io32bit);
|
2007-07-15 03:37:14 +05:30
|
|
|
ioctl_or_warn(fd, HDIO_SET_32BIT, (int *)io32bit);
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
2009-05-20 19:41:41 +05:30
|
|
|
if (getset_mult == IS_SET) {
|
|
|
|
print_flag(getset_mult, "multcount", mult);
|
2006-05-26 00:23:06 +05:30
|
|
|
#ifdef HDIO_DRIVE_CMD
|
2007-07-15 03:37:14 +05:30
|
|
|
ioctl_or_warn(fd, HDIO_SET_MULTCOUNT, (void *)mult);
|
2006-05-26 00:23:06 +05:30
|
|
|
#else
|
2007-07-15 03:37:14 +05:30
|
|
|
force_operation |= (!ioctl_or_warn(fd, HDIO_SET_MULTCOUNT, (void *)mult));
|
2003-07-22 13:00:36 +05:30
|
|
|
#endif
|
|
|
|
}
|
2009-05-20 19:41:41 +05:30
|
|
|
if (getset_readonly == IS_SET) {
|
|
|
|
print_flag_on_off(getset_readonly, "readonly", readonly);
|
2007-07-15 03:37:14 +05:30
|
|
|
ioctl_or_warn(fd, BLKROSET, &readonly);
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
2009-05-20 19:41:41 +05:30
|
|
|
if (getset_unmask == IS_SET) {
|
|
|
|
print_flag_on_off(getset_unmask, "unmaskirq", unmask);
|
2007-07-15 03:37:14 +05:30
|
|
|
ioctl_or_warn(fd, HDIO_SET_UNMASKINTR, (int *)unmask);
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
2007-02-18 19:06:04 +05:30
|
|
|
#if ENABLE_FEATURE_HDPARM_HDIO_GETSET_DMA
|
2009-05-20 19:41:41 +05:30
|
|
|
if (getset_dma == IS_SET) {
|
|
|
|
print_flag_on_off(getset_dma, "using_dma", dma);
|
2007-07-15 03:37:14 +05:30
|
|
|
ioctl_or_warn(fd, HDIO_SET_DMA, (int *)dma);
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
2007-02-18 19:06:04 +05:30
|
|
|
#endif /* FEATURE_HDPARM_HDIO_GETSET_DMA */
|
2008-03-20 19:14:50 +05:30
|
|
|
#ifdef HDIO_SET_QDMA
|
2009-05-20 19:41:41 +05:30
|
|
|
if (getset_dma_q == IS_SET) {
|
|
|
|
print_flag_on_off(getset_dma_q, "DMA queue_depth", dma_q);
|
2007-07-15 03:37:14 +05:30
|
|
|
ioctl_or_warn(fd, HDIO_SET_QDMA, (int *)dma_q);
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
2008-03-20 19:14:50 +05:30
|
|
|
#endif
|
2009-05-20 19:41:41 +05:30
|
|
|
if (getset_nowerr == IS_SET) {
|
|
|
|
print_flag_on_off(getset_nowerr, "nowerr", nowerr);
|
2007-07-15 03:37:14 +05:30
|
|
|
ioctl_or_warn(fd, HDIO_SET_NOWERR, (int *)nowerr);
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
2009-05-20 19:41:41 +05:30
|
|
|
if (getset_keep == IS_SET) {
|
|
|
|
print_flag_on_off(getset_keep, "keep_settings", keep);
|
2007-07-15 03:37:14 +05:30
|
|
|
ioctl_or_warn(fd, HDIO_SET_KEEPSETTINGS, (int *)keep);
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
|
|
|
#ifdef HDIO_DRIVE_CMD
|
2009-05-20 19:41:41 +05:30
|
|
|
if (getset_doorlock == IS_SET) {
|
2003-07-22 13:00:36 +05:30
|
|
|
args[0] = doorlock ? WIN_DOORLOCK : WIN_DOORUNLOCK;
|
2006-05-05 22:22:28 +05:30
|
|
|
args[2] = 0;
|
2009-05-20 19:41:41 +05:30
|
|
|
print_flag_on_off(getset_doorlock, "drive doorlock", doorlock);
|
2007-07-15 03:37:14 +05:30
|
|
|
ioctl_or_warn(fd, HDIO_DRIVE_CMD, &args);
|
2006-05-05 22:22:28 +05:30
|
|
|
args[0] = WIN_SETFEATURES;
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
2009-05-20 19:41:41 +05:30
|
|
|
if (getset_dkeep == IS_SET) {
|
2003-07-22 13:00:36 +05:30
|
|
|
/* lock/unlock the drive's "feature" settings */
|
2009-05-20 19:41:41 +05:30
|
|
|
print_flag_on_off(getset_dkeep, "drive keep features", dkeep);
|
2003-07-22 13:00:36 +05:30
|
|
|
args[2] = dkeep ? 0x66 : 0xcc;
|
2007-07-15 03:37:14 +05:30
|
|
|
ioctl_or_warn(fd, HDIO_DRIVE_CMD, &args);
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
2009-05-20 19:41:41 +05:30
|
|
|
if (getset_defects == IS_SET) {
|
2003-07-22 13:00:36 +05:30
|
|
|
args[2] = defects ? 0x04 : 0x84;
|
2009-05-20 19:41:41 +05:30
|
|
|
print_flag(getset_defects, "drive defect-mgmt", defects);
|
2007-07-15 03:37:14 +05:30
|
|
|
ioctl_or_warn(fd, HDIO_DRIVE_CMD, &args);
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
2009-05-20 19:41:41 +05:30
|
|
|
if (getset_prefetch == IS_SET) {
|
2003-07-22 13:00:36 +05:30
|
|
|
args[1] = prefetch;
|
2006-04-29 21:19:18 +05:30
|
|
|
args[2] = 0xab;
|
2009-05-20 19:41:41 +05:30
|
|
|
print_flag(getset_prefetch, "drive prefetch", prefetch);
|
2007-07-15 03:37:14 +05:30
|
|
|
ioctl_or_warn(fd, HDIO_DRIVE_CMD, &args);
|
2006-05-05 22:22:28 +05:30
|
|
|
args[1] = 0;
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
2007-02-18 19:06:04 +05:30
|
|
|
if (set_xfermode) {
|
2003-07-22 13:00:36 +05:30
|
|
|
args[1] = xfermode_requested;
|
2006-04-29 21:19:18 +05:30
|
|
|
args[2] = 3;
|
2009-05-20 19:41:41 +05:30
|
|
|
print_flag(1, "xfermode", xfermode_requested);
|
|
|
|
interpret_xfermode(xfermode_requested);
|
2007-07-15 03:37:14 +05:30
|
|
|
ioctl_or_warn(fd, HDIO_DRIVE_CMD, &args);
|
2006-05-05 22:22:28 +05:30
|
|
|
args[1] = 0;
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
2009-05-20 19:41:41 +05:30
|
|
|
if (getset_lookahead == IS_SET) {
|
2003-07-22 13:00:36 +05:30
|
|
|
args[2] = lookahead ? 0xaa : 0x55;
|
2009-05-20 19:41:41 +05:30
|
|
|
print_flag_on_off(getset_lookahead, "drive read-lookahead", lookahead);
|
2007-07-15 03:37:14 +05:30
|
|
|
ioctl_or_warn(fd, HDIO_DRIVE_CMD, &args);
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
2009-05-20 19:41:41 +05:30
|
|
|
if (getset_apmmode == IS_SET) {
|
2009-05-20 18:18:03 +05:30
|
|
|
/* feature register */
|
|
|
|
args[2] = (apmmode == 255) ? 0x85 /* disable */ : 0x05 /* set */;
|
2006-05-16 21:02:30 +05:30
|
|
|
args[1] = apmmode; /* sector count register 1-255 */
|
2009-05-20 19:41:41 +05:30
|
|
|
printf(" setting APM level to %s 0x%02lX (%ld)\n",
|
|
|
|
(apmmode == 255) ? "disabled" : "",
|
|
|
|
apmmode, apmmode);
|
2007-07-15 03:37:14 +05:30
|
|
|
ioctl_or_warn(fd, HDIO_DRIVE_CMD, &args);
|
2006-05-05 22:22:28 +05:30
|
|
|
args[1] = 0;
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
2009-05-20 19:41:41 +05:30
|
|
|
if (getset_wcache == IS_SET) {
|
2003-07-22 13:00:36 +05:30
|
|
|
#ifdef DO_FLUSHCACHE
|
|
|
|
#ifndef WIN_FLUSHCACHE
|
|
|
|
#define WIN_FLUSHCACHE 0xe7
|
|
|
|
#endif
|
|
|
|
#endif /* DO_FLUSHCACHE */
|
|
|
|
args[2] = wcache ? 0x02 : 0x82;
|
2009-05-20 19:41:41 +05:30
|
|
|
print_flag_on_off(getset_wcache, "drive write-caching", wcache);
|
2003-07-22 13:00:36 +05:30
|
|
|
#ifdef DO_FLUSHCACHE
|
2006-04-29 21:33:40 +05:30
|
|
|
if (!wcache)
|
2007-07-15 03:37:14 +05:30
|
|
|
ioctl_or_warn(fd, HDIO_DRIVE_CMD, &flushcache);
|
2003-07-22 13:00:36 +05:30
|
|
|
#endif /* DO_FLUSHCACHE */
|
2007-07-15 03:37:14 +05:30
|
|
|
ioctl_or_warn(fd, HDIO_DRIVE_CMD, &args);
|
2003-07-22 13:00:36 +05:30
|
|
|
#ifdef DO_FLUSHCACHE
|
2006-04-29 21:33:40 +05:30
|
|
|
if (!wcache)
|
2007-07-15 03:37:14 +05:30
|
|
|
ioctl_or_warn(fd, HDIO_DRIVE_CMD, &flushcache);
|
2003-07-22 13:00:36 +05:30
|
|
|
#endif /* DO_FLUSHCACHE */
|
|
|
|
}
|
2006-05-05 22:22:28 +05:30
|
|
|
|
|
|
|
/* In code below, we do not preserve args[0], but the rest
|
|
|
|
is preserved, including args[2] */
|
|
|
|
args[2] = 0;
|
|
|
|
|
2007-02-18 19:06:04 +05:30
|
|
|
if (set_standbynow) {
|
2003-07-22 13:00:36 +05:30
|
|
|
#ifndef WIN_STANDBYNOW1
|
|
|
|
#define WIN_STANDBYNOW1 0xE0
|
|
|
|
#endif
|
|
|
|
#ifndef WIN_STANDBYNOW2
|
|
|
|
#define WIN_STANDBYNOW2 0x94
|
|
|
|
#endif
|
2009-05-20 19:41:41 +05:30
|
|
|
printf(" issuing standby command\n");
|
2006-04-29 21:33:40 +05:30
|
|
|
args[0] = WIN_STANDBYNOW1;
|
2007-09-27 15:53:34 +05:30
|
|
|
ioctl_alt_or_warn(HDIO_DRIVE_CMD, args, WIN_STANDBYNOW2);
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
2007-02-18 19:06:04 +05:30
|
|
|
if (set_sleepnow) {
|
2003-07-22 13:00:36 +05:30
|
|
|
#ifndef WIN_SLEEPNOW1
|
|
|
|
#define WIN_SLEEPNOW1 0xE6
|
|
|
|
#endif
|
|
|
|
#ifndef WIN_SLEEPNOW2
|
|
|
|
#define WIN_SLEEPNOW2 0x99
|
|
|
|
#endif
|
2009-05-20 19:41:41 +05:30
|
|
|
printf(" issuing sleep command\n");
|
2006-04-29 21:33:40 +05:30
|
|
|
args[0] = WIN_SLEEPNOW1;
|
2007-09-27 15:53:34 +05:30
|
|
|
ioctl_alt_or_warn(HDIO_DRIVE_CMD, args, WIN_SLEEPNOW2);
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
2007-02-18 19:06:04 +05:30
|
|
|
if (set_seagate) {
|
2006-04-29 21:19:18 +05:30
|
|
|
args[0] = 0xfb;
|
2009-05-20 19:41:41 +05:30
|
|
|
printf(" disabling Seagate auto powersaving mode\n");
|
2007-07-15 03:37:14 +05:30
|
|
|
ioctl_or_warn(fd, HDIO_DRIVE_CMD, &args);
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
2009-05-20 19:41:41 +05:30
|
|
|
if (getset_standby == IS_SET) {
|
2006-04-29 21:19:18 +05:30
|
|
|
args[0] = WIN_SETIDLE1;
|
|
|
|
args[1] = standby_requested;
|
2009-05-20 19:41:41 +05:30
|
|
|
print_flag(1, "standby", standby_requested);
|
|
|
|
interpret_standby(standby_requested);
|
2007-07-15 03:37:14 +05:30
|
|
|
ioctl_or_warn(fd, HDIO_DRIVE_CMD, &args);
|
2006-05-05 22:22:28 +05:30
|
|
|
args[1] = 0;
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
|
|
|
#else /* HDIO_DRIVE_CMD */
|
2007-02-18 19:06:04 +05:30
|
|
|
if (force_operation) {
|
2003-07-22 13:00:36 +05:30
|
|
|
char buf[512];
|
2007-09-27 15:53:34 +05:30
|
|
|
flush_buffer_cache();
|
2003-07-22 13:00:36 +05:30
|
|
|
if (-1 == read(fd, buf, sizeof(buf)))
|
2009-05-20 18:18:03 +05:30
|
|
|
bb_perror_msg("read of 512 bytes failed");
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
|
|
|
#endif /* HDIO_DRIVE_CMD */
|
2009-05-20 19:41:41 +05:30
|
|
|
if (getset_mult || get_identity) {
|
2003-07-22 13:00:36 +05:30
|
|
|
multcount = -1;
|
2007-02-18 19:06:04 +05:30
|
|
|
if (ioctl(fd, HDIO_GET_MULTCOUNT, &multcount)) {
|
2009-05-20 18:18:03 +05:30
|
|
|
/* To be coherent with ioctl_or_warn. */
|
2009-05-20 19:41:41 +05:30
|
|
|
if (getset_mult && ENABLE_IOCTL_HEX2STR_ERROR)
|
2004-03-19 16:23:52 +05:30
|
|
|
bb_perror_msg("HDIO_GET_MULTCOUNT");
|
2007-07-15 03:37:14 +05:30
|
|
|
else
|
|
|
|
bb_perror_msg("ioctl %#x failed", HDIO_GET_MULTCOUNT);
|
2009-05-20 19:41:41 +05:30
|
|
|
} else if (getset_mult) {
|
2006-05-16 21:02:30 +05:30
|
|
|
printf(fmt, "multcount", multcount);
|
2007-03-28 06:30:45 +05:30
|
|
|
on_off(multcount != 0);
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
|
|
|
}
|
2009-05-20 19:41:41 +05:30
|
|
|
if (getset_io32bit) {
|
2007-07-15 03:37:14 +05:30
|
|
|
if (!ioctl_or_warn(fd, HDIO_GET_32BIT, &parm)) {
|
2006-05-16 21:02:30 +05:30
|
|
|
printf(" IO_support\t=%3ld (", parm);
|
|
|
|
if (parm == 0)
|
|
|
|
printf("default 16-bit)\n");
|
|
|
|
else if (parm == 2)
|
|
|
|
printf("16-bit)\n");
|
|
|
|
else if (parm == 1)
|
|
|
|
printf("32-bit)\n");
|
|
|
|
else if (parm == 3)
|
|
|
|
printf("32-bit w/sync)\n");
|
|
|
|
else if (parm == 8)
|
|
|
|
printf("Request-Queue-Bypass)\n");
|
|
|
|
else
|
|
|
|
printf("\?\?\?)\n");
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
|
|
|
}
|
2009-05-20 19:41:41 +05:30
|
|
|
if (getset_unmask) {
|
2008-09-27 19:33:25 +05:30
|
|
|
if (!ioctl_or_warn(fd, HDIO_GET_UNMASKINTR, &parm))
|
2007-07-15 03:37:14 +05:30
|
|
|
print_value_on_off("unmaskirq", parm);
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
2007-02-18 19:06:04 +05:30
|
|
|
#if ENABLE_FEATURE_HDPARM_HDIO_GETSET_DMA
|
2009-05-20 19:41:41 +05:30
|
|
|
if (getset_dma) {
|
2007-07-15 03:37:14 +05:30
|
|
|
if (!ioctl_or_warn(fd, HDIO_GET_DMA, &parm)) {
|
2006-05-16 21:02:30 +05:30
|
|
|
printf(fmt, "using_dma", parm);
|
2003-07-22 13:00:36 +05:30
|
|
|
if (parm == 8)
|
|
|
|
printf(" (DMA-Assisted-PIO)\n");
|
|
|
|
else
|
2007-03-28 06:30:45 +05:30
|
|
|
on_off(parm != 0);
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2008-03-20 19:14:50 +05:30
|
|
|
#ifdef HDIO_GET_QDMA
|
2009-05-20 19:41:41 +05:30
|
|
|
if (getset_dma_q) {
|
2008-09-27 19:33:25 +05:30
|
|
|
if (!ioctl_or_warn(fd, HDIO_GET_QDMA, &parm))
|
2007-07-15 03:37:14 +05:30
|
|
|
print_value_on_off("queue_depth", parm);
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
2008-03-20 19:14:50 +05:30
|
|
|
#endif
|
2009-05-20 19:41:41 +05:30
|
|
|
if (getset_keep) {
|
2008-09-27 19:33:25 +05:30
|
|
|
if (!ioctl_or_warn(fd, HDIO_GET_KEEPSETTINGS, &parm))
|
2007-07-15 03:37:14 +05:30
|
|
|
print_value_on_off("keepsettings", parm);
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
2009-05-20 19:41:41 +05:30
|
|
|
if (getset_nowerr) {
|
2008-09-27 19:33:25 +05:30
|
|
|
if (!ioctl_or_warn(fd, HDIO_GET_NOWERR, &parm))
|
2007-07-15 03:37:14 +05:30
|
|
|
print_value_on_off("nowerr", parm);
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
2009-05-20 19:41:41 +05:30
|
|
|
if (getset_readonly) {
|
2008-09-27 19:33:25 +05:30
|
|
|
if (!ioctl_or_warn(fd, BLKROGET, &parm))
|
2007-07-15 03:37:14 +05:30
|
|
|
print_value_on_off("readonly", parm);
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
2009-05-20 19:41:41 +05:30
|
|
|
if (getset_readahead) {
|
2008-09-27 19:33:25 +05:30
|
|
|
if (!ioctl_or_warn(fd, BLKRAGET, &parm))
|
2007-07-15 03:37:14 +05:30
|
|
|
print_value_on_off("readahead", parm);
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
2007-02-18 19:06:04 +05:30
|
|
|
if (get_geom) {
|
2007-07-15 03:37:14 +05:30
|
|
|
if (!ioctl_or_warn(fd, BLKGETSIZE, &parm)) {
|
2006-05-04 01:30:00 +05:30
|
|
|
struct hd_geometry g;
|
|
|
|
|
2007-07-15 03:37:14 +05:30
|
|
|
if (!ioctl_or_warn(fd, HDIO_GETGEO, &g))
|
2006-05-16 21:02:30 +05:30
|
|
|
printf(" geometry\t= %u/%u/%u, sectors = %ld, start = %ld\n",
|
2009-05-20 18:18:03 +05:30
|
|
|
g.cylinders, g.heads, g.sectors, parm, g.start);
|
2006-04-29 21:33:40 +05:30
|
|
|
}
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
|
|
|
#ifdef HDIO_DRIVE_CMD
|
2007-02-18 19:06:04 +05:30
|
|
|
if (get_powermode) {
|
2003-07-22 13:00:36 +05:30
|
|
|
#ifndef WIN_CHECKPOWERMODE1
|
|
|
|
#define WIN_CHECKPOWERMODE1 0xE5
|
|
|
|
#endif
|
|
|
|
#ifndef WIN_CHECKPOWERMODE2
|
|
|
|
#define WIN_CHECKPOWERMODE2 0x98
|
|
|
|
#endif
|
|
|
|
const char *state;
|
2006-04-29 21:33:40 +05:30
|
|
|
|
2006-04-29 21:19:18 +05:30
|
|
|
args[0] = WIN_CHECKPOWERMODE1;
|
2007-09-27 15:53:34 +05:30
|
|
|
if (ioctl_alt_or_warn(HDIO_DRIVE_CMD, args, WIN_CHECKPOWERMODE2)) {
|
2003-07-22 13:00:36 +05:30
|
|
|
if (errno != EIO || args[0] != 0 || args[1] != 0)
|
2007-03-28 06:30:45 +05:30
|
|
|
state = "unknown";
|
2003-07-22 13:00:36 +05:30
|
|
|
else
|
|
|
|
state = "sleeping";
|
2007-02-18 19:06:04 +05:30
|
|
|
} else
|
2003-10-09 12:58:22 +05:30
|
|
|
state = (args[2] == 255) ? "active/idle" : "standby";
|
2006-05-05 22:22:28 +05:30
|
|
|
args[1] = args[2] = 0;
|
2003-10-09 12:58:22 +05:30
|
|
|
|
2003-07-22 13:00:36 +05:30
|
|
|
printf(" drive state is: %s\n", state);
|
|
|
|
}
|
|
|
|
#endif
|
2007-02-18 19:06:04 +05:30
|
|
|
#if ENABLE_FEATURE_HDPARM_HDIO_DRIVE_RESET
|
|
|
|
if (perform_reset) {
|
2007-07-15 03:37:14 +05:30
|
|
|
ioctl_or_warn(fd, HDIO_DRIVE_RESET, NULL);
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
2007-02-18 19:06:04 +05:30
|
|
|
#endif /* FEATURE_HDPARM_HDIO_DRIVE_RESET */
|
|
|
|
#if ENABLE_FEATURE_HDPARM_HDIO_TRISTATE_HWIF
|
|
|
|
if (perform_tristate) {
|
2006-04-29 21:19:18 +05:30
|
|
|
args[0] = 0;
|
|
|
|
args[1] = tristate;
|
2007-07-15 03:37:14 +05:30
|
|
|
ioctl_or_warn(fd, HDIO_TRISTATE_HWIF, &args);
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
2007-02-18 19:06:04 +05:30
|
|
|
#endif /* FEATURE_HDPARM_HDIO_TRISTATE_HWIF */
|
|
|
|
#if ENABLE_FEATURE_HDPARM_GET_IDENTITY
|
|
|
|
if (get_identity) {
|
2007-03-28 05:44:54 +05:30
|
|
|
struct hd_driveid id;
|
2003-07-22 13:00:36 +05:30
|
|
|
|
2007-02-18 19:06:04 +05:30
|
|
|
if (!ioctl(fd, HDIO_GET_IDENTITY, &id)) {
|
|
|
|
if (multcount != -1) {
|
2003-07-22 13:00:36 +05:30
|
|
|
id.multsect = multcount;
|
|
|
|
id.multsect_valid |= 1;
|
2007-02-18 19:06:04 +05:30
|
|
|
} else
|
2003-07-22 13:00:36 +05:30
|
|
|
id.multsect_valid &= ~1;
|
|
|
|
dump_identity(&id);
|
2007-02-18 19:06:04 +05:30
|
|
|
} else if (errno == -ENOMSG)
|
2003-07-22 13:00:36 +05:30
|
|
|
printf(" no identification info available\n");
|
2007-07-15 03:37:14 +05:30
|
|
|
else if (ENABLE_IOCTL_HEX2STR_ERROR) /* To be coherent with ioctl_or_warn */
|
2007-07-18 03:12:59 +05:30
|
|
|
bb_perror_msg("HDIO_GET_IDENTITY");
|
2003-07-22 13:00:36 +05:30
|
|
|
else
|
2007-07-15 03:37:14 +05:30
|
|
|
bb_perror_msg("ioctl %#x failed", HDIO_GET_IDENTITY);
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
2003-10-09 12:58:22 +05:30
|
|
|
|
2007-02-18 19:06:04 +05:30
|
|
|
if (get_IDentity) {
|
2006-04-29 21:33:40 +05:30
|
|
|
unsigned char args1[4+512]; /* = { ... } will eat 0.5k of rodata! */
|
2003-10-09 12:58:22 +05:30
|
|
|
|
2006-04-29 21:33:40 +05:30
|
|
|
memset(args1, 0, sizeof(args1));
|
|
|
|
args1[0] = WIN_IDENTIFY;
|
|
|
|
args1[3] = 1;
|
2007-09-27 15:53:34 +05:30
|
|
|
if (!ioctl_alt_or_warn(HDIO_DRIVE_CMD, args1, WIN_PIDENTIFY))
|
2006-06-07 05:57:25 +05:30
|
|
|
identify((void *)(args1 + 4));
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
|
|
|
#endif
|
2007-02-18 19:06:04 +05:30
|
|
|
#if ENABLE_FEATURE_HDPARM_HDIO_TRISTATE_HWIF
|
2009-05-20 19:41:41 +05:30
|
|
|
if (getset_busstate == IS_SET) {
|
|
|
|
print_flag(1, "bus state", busstate);
|
|
|
|
bus_state_value(busstate);
|
2007-07-15 03:37:14 +05:30
|
|
|
ioctl_or_warn(fd, HDIO_SET_BUSSTATE, (int *)(unsigned long)busstate);
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
2009-05-20 19:41:41 +05:30
|
|
|
if (getset_busstate) {
|
2007-07-15 03:37:14 +05:30
|
|
|
if (!ioctl_or_warn(fd, HDIO_GET_BUSSTATE, &parm)) {
|
2006-05-16 21:02:30 +05:30
|
|
|
printf(fmt, "bus state", parm);
|
2003-07-22 13:00:36 +05:30
|
|
|
bus_state_value(parm);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2003-10-09 12:58:22 +05:30
|
|
|
if (reread_partn)
|
2007-07-15 03:37:14 +05:30
|
|
|
ioctl_or_warn(fd, BLKRRPART, NULL);
|
2003-10-09 12:58:22 +05:30
|
|
|
|
2003-07-22 13:00:36 +05:30
|
|
|
if (do_ctimings)
|
2007-09-28 15:58:03 +05:30
|
|
|
do_time(1 /*,fd*/); /* time cache */
|
2003-07-22 13:00:36 +05:30
|
|
|
if (do_timings)
|
2007-09-28 15:58:03 +05:30
|
|
|
do_time(0 /*,fd*/); /* time device */
|
2003-07-22 13:00:36 +05:30
|
|
|
if (do_flush)
|
2007-09-27 15:53:34 +05:30
|
|
|
flush_buffer_cache();
|
2006-04-29 21:36:31 +05:30
|
|
|
close(fd);
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
|
|
|
|
2007-02-18 19:06:04 +05:30
|
|
|
#if ENABLE_FEATURE_HDPARM_GET_IDENTITY
|
2006-04-29 21:36:31 +05:30
|
|
|
static int fromhex(unsigned char c)
|
2003-07-22 13:00:36 +05:30
|
|
|
{
|
2007-01-13 03:40:34 +05:30
|
|
|
if (isdigit(c))
|
2003-07-22 13:00:36 +05:30
|
|
|
return (c - '0');
|
2007-01-13 03:40:34 +05:30
|
|
|
if (c >= 'a' && c <= 'f')
|
|
|
|
return (c - ('a' - 10));
|
2003-07-22 13:00:36 +05:30
|
|
|
bb_error_msg_and_die("bad char: '%c' 0x%02x", c, c);
|
|
|
|
}
|
|
|
|
|
2008-07-05 14:48:54 +05:30
|
|
|
static void identify_from_stdin(void) NORETURN;
|
2006-05-03 23:58:06 +05:30
|
|
|
static void identify_from_stdin(void)
|
2003-07-22 13:00:36 +05:30
|
|
|
{
|
2006-06-07 05:57:25 +05:30
|
|
|
uint16_t sbuf[256];
|
2007-01-13 03:40:34 +05:30
|
|
|
unsigned char buf[1280];
|
|
|
|
unsigned char *b = (unsigned char *)buf;
|
|
|
|
int i;
|
2003-07-22 13:00:36 +05:30
|
|
|
|
2008-05-19 15:18:17 +05:30
|
|
|
xread(STDIN_FILENO, buf, 1280);
|
2006-05-26 00:23:06 +05:30
|
|
|
|
2006-06-07 05:57:25 +05:30
|
|
|
// Convert the newline-separated hex data into an identify block.
|
|
|
|
|
2007-02-18 19:06:04 +05:30
|
|
|
for (i = 0; i < 256; i++) {
|
2006-06-07 05:57:25 +05:30
|
|
|
int j;
|
2006-12-26 16:12:51 +05:30
|
|
|
for (j = 0; j < 4; j++)
|
2007-01-13 03:40:34 +05:30
|
|
|
sbuf[i] = (sbuf[i] << 4) + fromhex(*(b++));
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
2006-06-07 05:57:25 +05:30
|
|
|
|
|
|
|
// Parse the data.
|
|
|
|
|
2006-05-02 00:58:53 +05:30
|
|
|
identify(sbuf);
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|
2007-09-28 15:55:32 +05:30
|
|
|
#else
|
|
|
|
void identify_from_stdin(void);
|
2003-07-22 13:00:36 +05:30
|
|
|
#endif
|
|
|
|
|
2006-05-08 05:04:15 +05:30
|
|
|
/* busybox specific stuff */
|
2009-05-20 19:41:41 +05:30
|
|
|
static int parse_opts(unsigned long *value, int min, int max)
|
2004-04-05 18:38:08 +05:30
|
|
|
{
|
2006-09-23 17:52:11 +05:30
|
|
|
if (optarg) {
|
2006-10-08 18:19:22 +05:30
|
|
|
*value = xatol_range(optarg, min, max);
|
2009-05-20 19:41:41 +05:30
|
|
|
return IS_SET;
|
2006-09-23 17:52:11 +05:30
|
|
|
}
|
2009-05-20 19:41:41 +05:30
|
|
|
return IS_GET;
|
|
|
|
}
|
|
|
|
static int parse_opts_0_max(unsigned long *value, int max)
|
|
|
|
{
|
|
|
|
return parse_opts(value, 0, max);
|
|
|
|
}
|
|
|
|
static int parse_opts_0_1(unsigned long *value)
|
|
|
|
{
|
|
|
|
return parse_opts(value, 0, 1);
|
|
|
|
}
|
|
|
|
static int parse_opts_0_INTMAX(unsigned long *value)
|
|
|
|
{
|
|
|
|
return parse_opts(value, 0, INT_MAX);
|
2004-04-05 18:38:08 +05:30
|
|
|
}
|
|
|
|
|
2007-03-28 06:30:45 +05:30
|
|
|
static void parse_xfermode(int flag, smallint *get, smallint *set, int *value)
|
2003-07-22 13:00:36 +05:30
|
|
|
{
|
2006-05-08 05:04:15 +05:30
|
|
|
if (flag) {
|
2009-05-20 19:41:41 +05:30
|
|
|
*get = IS_GET;
|
2006-05-08 05:04:15 +05:30
|
|
|
if (optarg) {
|
2007-03-28 05:44:01 +05:30
|
|
|
*value = translate_xfermode(optarg);
|
|
|
|
*set = (*value > -1);
|
2006-05-08 05:04:15 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2003-10-09 12:58:22 +05:30
|
|
|
|
2006-06-01 04:22:57 +05:30
|
|
|
/*------- getopt short options --------*/
|
2007-08-13 02:28:27 +05:30
|
|
|
static const char hdparm_options[] ALIGN1 =
|
2007-09-27 15:50:47 +05:30
|
|
|
"gfu::n::p:r::m::c::k::a::B:tT"
|
2009-04-21 16:39:40 +05:30
|
|
|
IF_FEATURE_HDPARM_GET_IDENTITY("iI")
|
|
|
|
IF_FEATURE_HDPARM_HDIO_GETSET_DMA("d::")
|
2003-07-22 13:00:36 +05:30
|
|
|
#ifdef HDIO_DRIVE_CMD
|
2006-10-04 02:30:06 +05:30
|
|
|
"S:D:P:X:K:A:L:W:CyYzZ"
|
2006-05-08 05:04:15 +05:30
|
|
|
#endif
|
2009-04-21 16:39:40 +05:30
|
|
|
IF_FEATURE_HDPARM_HDIO_UNREGISTER_HWIF("U:")
|
2004-03-19 16:23:52 +05:30
|
|
|
#ifdef HDIO_GET_QDMA
|
|
|
|
#ifdef HDIO_SET_QDMA
|
2006-10-04 02:30:06 +05:30
|
|
|
"Q:"
|
2006-05-08 05:04:15 +05:30
|
|
|
#else
|
2006-10-04 02:30:06 +05:30
|
|
|
"Q"
|
2004-03-19 16:23:52 +05:30
|
|
|
#endif
|
|
|
|
#endif
|
2009-04-21 16:39:40 +05:30
|
|
|
IF_FEATURE_HDPARM_HDIO_DRIVE_RESET("w")
|
|
|
|
IF_FEATURE_HDPARM_HDIO_TRISTATE_HWIF("x::b:")
|
|
|
|
IF_FEATURE_HDPARM_HDIO_SCAN_HWIF("R:");
|
2006-05-08 05:04:15 +05:30
|
|
|
/*-------------------------------------*/
|
2004-03-19 16:23:52 +05:30
|
|
|
|
2006-05-08 05:04:15 +05:30
|
|
|
/* our main() routine: */
|
2007-10-11 15:35:36 +05:30
|
|
|
int hdparm_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
2006-05-08 05:04:15 +05:30
|
|
|
int hdparm_main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
int c;
|
2006-05-26 00:23:06 +05:30
|
|
|
int flagcount = 0;
|
2006-05-08 05:04:15 +05:30
|
|
|
|
2006-06-01 04:22:57 +05:30
|
|
|
while ((c = getopt(argc, argv, hdparm_options)) >= 0) {
|
2006-05-08 05:04:15 +05:30
|
|
|
flagcount++;
|
2009-04-21 16:39:40 +05:30
|
|
|
IF_FEATURE_HDPARM_GET_IDENTITY(get_IDentity |= (c == 'I'));
|
|
|
|
IF_FEATURE_HDPARM_GET_IDENTITY(get_identity |= (c == 'i'));
|
2006-05-16 21:02:30 +05:30
|
|
|
get_geom |= (c == 'g');
|
|
|
|
do_flush |= (c == 'f');
|
2009-05-20 19:41:41 +05:30
|
|
|
if (c == 'u') getset_unmask = parse_opts_0_1(&unmask);
|
|
|
|
IF_FEATURE_HDPARM_HDIO_GETSET_DMA(
|
|
|
|
if (c == 'd') getset_dma = parse_opts_0_max(&dma, 9);
|
|
|
|
)
|
|
|
|
if (c == 'n') getset_nowerr = parse_opts_0_1(&nowerr);
|
2007-03-28 05:44:01 +05:30
|
|
|
parse_xfermode((c == 'p'), &noisy_piomode, &set_piomode, &piomode);
|
2009-05-20 19:41:41 +05:30
|
|
|
if (c == 'r') getset_readonly = parse_opts_0_1(&readonly);
|
|
|
|
if (c == 'm') getset_mult = parse_opts_0_INTMAX(&mult /*32*/);
|
|
|
|
if (c == 'c') getset_io32bit = parse_opts_0_INTMAX(&io32bit /*8*/);
|
|
|
|
if (c == 'k') getset_keep = parse_opts_0_1(&keep);
|
|
|
|
if (c == 'a') getset_readahead = parse_opts_0_INTMAX(&Xreadahead);
|
|
|
|
if (c == 'B') getset_apmmode = parse_opts(&apmmode, 1, 255);
|
2006-05-16 21:02:30 +05:30
|
|
|
do_flush |= do_timings |= (c == 't');
|
|
|
|
do_flush |= do_ctimings |= (c == 'T');
|
2006-05-08 05:04:15 +05:30
|
|
|
#ifdef HDIO_DRIVE_CMD
|
2009-05-20 19:41:41 +05:30
|
|
|
if (c == 'S') getset_standby = parse_opts_0_max(&standby_requested, 255);
|
|
|
|
if (c == 'D') getset_defects = parse_opts_0_INTMAX(&defects);
|
|
|
|
if (c == 'P') getset_prefetch = parse_opts_0_INTMAX(&prefetch);
|
2006-05-26 00:23:06 +05:30
|
|
|
parse_xfermode((c == 'X'), &get_xfermode, &set_xfermode, &xfermode_requested);
|
2009-05-20 19:41:41 +05:30
|
|
|
if (c == 'K') getset_dkeep = parse_opts_0_1(&prefetch);
|
|
|
|
if (c == 'A') getset_lookahead = parse_opts_0_1(&lookahead);
|
|
|
|
if (c == 'L') getset_doorlock = parse_opts_0_1(&doorlock);
|
|
|
|
if (c == 'W') getset_wcache = parse_opts_0_1(&wcache);
|
2006-05-26 00:23:06 +05:30
|
|
|
get_powermode |= (c == 'C');
|
2009-05-20 19:41:41 +05:30
|
|
|
set_standbynow |= (c == 'y');
|
|
|
|
set_sleepnow |= (c == 'Y');
|
2006-05-16 21:02:30 +05:30
|
|
|
reread_partn |= (c == 'z');
|
2009-05-20 19:41:41 +05:30
|
|
|
set_seagate |= (c == 'Z');
|
2006-05-08 05:04:15 +05:30
|
|
|
#endif
|
2009-05-20 19:41:41 +05:30
|
|
|
IF_FEATURE_HDPARM_HDIO_UNREGISTER_HWIF(if (c == 'U') unregister_hwif = parse_opts_0_INTMAX(&hwif));
|
2006-05-08 05:04:15 +05:30
|
|
|
#ifdef HDIO_GET_QDMA
|
2006-05-08 21:05:46 +05:30
|
|
|
if (c == 'Q') {
|
2009-05-20 19:41:41 +05:30
|
|
|
getset_dma_q = parse_opts_0_INTMAX(&dma_q);
|
2006-05-08 21:05:46 +05:30
|
|
|
}
|
2006-09-17 21:58:10 +05:30
|
|
|
#endif
|
2009-04-21 16:39:40 +05:30
|
|
|
IF_FEATURE_HDPARM_HDIO_DRIVE_RESET(perform_reset = (c == 'r'));
|
2009-05-20 19:41:41 +05:30
|
|
|
IF_FEATURE_HDPARM_HDIO_TRISTATE_HWIF(if (c == 'x') perform_tristate = parse_opts_0_1(&tristate));
|
|
|
|
IF_FEATURE_HDPARM_HDIO_TRISTATE_HWIF(if (c == 'b') getset_busstate = parse_opts_0_max(&busstate, 2));
|
2006-05-08 05:04:15 +05:30
|
|
|
#if ENABLE_FEATURE_HDPARM_HDIO_SCAN_HWIF
|
|
|
|
if (c == 'R') {
|
2009-05-20 19:41:41 +05:30
|
|
|
scan_hwif = parse_opts_0_INTMAX(&hwif_data);
|
2006-10-08 18:19:22 +05:30
|
|
|
hwif_ctrl = xatoi_u((argv[optind]) ? argv[optind] : "");
|
|
|
|
hwif_irq = xatoi_u((argv[optind+1]) ? argv[optind+1] : "");
|
2006-05-08 05:04:15 +05:30
|
|
|
/* Move past the 2 additional arguments */
|
|
|
|
argv += 2;
|
|
|
|
argc -= 2;
|
2004-03-19 16:23:52 +05:30
|
|
|
}
|
2006-05-08 05:04:15 +05:30
|
|
|
#endif
|
|
|
|
}
|
2006-05-26 00:23:06 +05:30
|
|
|
/* When no flags are given (flagcount = 0), -acdgkmnru is assumed. */
|
2006-10-04 02:30:06 +05:30
|
|
|
if (!flagcount) {
|
2009-05-20 19:41:41 +05:30
|
|
|
getset_mult = getset_io32bit = getset_unmask = getset_keep = getset_readonly = getset_readahead = get_geom = IS_GET;
|
|
|
|
IF_FEATURE_HDPARM_HDIO_GETSET_DMA(getset_dma = IS_GET);
|
2006-05-26 00:23:06 +05:30
|
|
|
}
|
2006-05-08 05:04:15 +05:30
|
|
|
argv += optind;
|
|
|
|
|
2007-03-28 05:44:01 +05:30
|
|
|
if (!*argv) {
|
2006-06-08 02:52:42 +05:30
|
|
|
if (ENABLE_FEATURE_HDPARM_GET_IDENTITY && !isatty(STDIN_FILENO))
|
|
|
|
identify_from_stdin(); /* EXIT */
|
2007-09-27 15:50:47 +05:30
|
|
|
bb_show_usage();
|
2006-05-08 05:04:15 +05:30
|
|
|
}
|
|
|
|
|
2007-03-28 05:44:01 +05:30
|
|
|
do {
|
|
|
|
process_dev(*argv++);
|
|
|
|
} while (*argv);
|
|
|
|
|
|
|
|
return EXIT_SUCCESS;
|
2003-07-22 13:00:36 +05:30
|
|
|
}
|