CVS commit: src/sbin/atactl
Module Name:src Committed By: wiz Date: Fri May 31 16:38:27 UTC 2019 Modified Files: src/sbin/atactl: atactl.8 Log Message: New sentence, new line. To generate a diff of this commit: cvs rdiff -u -r1.30 -r1.31 src/sbin/atactl/atactl.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sbin/atactl
Module Name:src Committed By: wiz Date: Fri May 31 16:38:27 UTC 2019 Modified Files: src/sbin/atactl: atactl.8 Log Message: New sentence, new line. To generate a diff of this commit: cvs rdiff -u -r1.30 -r1.31 src/sbin/atactl/atactl.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/atactl/atactl.8 diff -u src/sbin/atactl/atactl.8:1.30 src/sbin/atactl/atactl.8:1.31 --- src/sbin/atactl/atactl.8:1.30 Fri May 31 05:47:22 2019 +++ src/sbin/atactl/atactl.8 Fri May 31 16:38:27 2019 @@ -1,4 +1,4 @@ -.\" $NetBSD: atactl.8,v 1.30 2019/05/31 05:47:22 mlelstv Exp $ +.\" $NetBSD: atactl.8,v 1.31 2019/05/31 16:38:27 wiz Exp $ .\" .\" Copyright (c) 1998, 2019 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -50,7 +50,8 @@ It is used by specifying a device or bus the command to perform, and any arguments the command may require. .Pp You may also control devices which are inside a SCSI enclosure, this -includes many USB disks. In this case ATA commands are passed through +includes many USB disks. +In this case ATA commands are passed through the SCSI layer using SATL commands. .Sh DEVICE COMMANDS The following commands may be used on IDE and ATA devices.
CVS commit: src/sbin/atactl
Module Name:src Committed By: mlelstv Date: Fri May 31 05:47:22 UTC 2019 Modified Files: src/sbin/atactl: atactl.8 Log Message: Mention SATL support. To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.30 src/sbin/atactl/atactl.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sbin/atactl
Module Name:src Committed By: mlelstv Date: Fri May 31 05:47:22 UTC 2019 Modified Files: src/sbin/atactl: atactl.8 Log Message: Mention SATL support. To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.30 src/sbin/atactl/atactl.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/atactl/atactl.8 diff -u src/sbin/atactl/atactl.8:1.29 src/sbin/atactl/atactl.8:1.30 --- src/sbin/atactl/atactl.8:1.29 Sun Mar 3 04:51:57 2019 +++ src/sbin/atactl/atactl.8 Fri May 31 05:47:22 2019 @@ -1,4 +1,4 @@ -.\" $NetBSD: atactl.8,v 1.29 2019/03/03 04:51:57 mrg Exp $ +.\" $NetBSD: atactl.8,v 1.30 2019/05/31 05:47:22 mlelstv Exp $ .\" .\" Copyright (c) 1998, 2019 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -48,6 +48,10 @@ control devices which reside on standard the ATA bus itself. It is used by specifying a device or bus to manipulate, the command to perform, and any arguments the command may require. +.Pp +You may also control devices which are inside a SCSI enclosure, this +includes many USB disks. In this case ATA commands are passed through +the SCSI layer using SATL commands. .Sh DEVICE COMMANDS The following commands may be used on IDE and ATA devices. Note that not all devices support all commands. @@ -279,6 +283,8 @@ command written by significantly enhanced the .Cm smart status support. +.An Michael van Elst +added support for SATL. .Sh BUGS The output from the .Cm identify @@ -295,3 +301,5 @@ The .Cm smart status command currently guesses the vendor attribute name table to use, and may be wrong or miss supported devices. +.Pp +SATL bus commands don't work yet.
CVS commit: src/sbin/atactl
Module Name:src Committed By: mlelstv Date: Thu May 30 21:32:08 UTC 2019 Modified Files: src/sbin/atactl: atactl.c Log Message: Add support for ATA command pass-through to SCSI devices. To generate a diff of this commit: cvs rdiff -u -r1.82 -r1.83 src/sbin/atactl/atactl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sbin/atactl
Module Name:src Committed By: mlelstv Date: Thu May 30 21:32:08 UTC 2019 Modified Files: src/sbin/atactl: atactl.c Log Message: Add support for ATA command pass-through to SCSI devices. To generate a diff of this commit: cvs rdiff -u -r1.82 -r1.83 src/sbin/atactl/atactl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sbin/atactl/atactl.c diff -u src/sbin/atactl/atactl.c:1.82 src/sbin/atactl/atactl.c:1.83 --- src/sbin/atactl/atactl.c:1.82 Sun Mar 3 04:51:57 2019 +++ src/sbin/atactl/atactl.c Thu May 30 21:32:08 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: atactl.c,v 1.82 2019/03/03 04:51:57 mrg Exp $ */ +/* $NetBSD: atactl.c,v 1.83 2019/05/30 21:32:08 mlelstv Exp $ */ /*- * Copyright (c) 1998, 2019 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ #include #ifndef lint -__RCSID("$NetBSD: atactl.c,v 1.82 2019/03/03 04:51:57 mrg Exp $"); +__RCSID("$NetBSD: atactl.c,v 1.83 2019/05/30 21:32:08 mlelstv Exp $"); #endif @@ -54,6 +54,9 @@ __RCSID("$NetBSD: atactl.c,v 1.82 2019/0 #include #include +#include +#include + struct ata_smart_error { struct { uint8_t device_control; @@ -90,6 +93,53 @@ struct ata_smart_errorlog { uint8_t checksum; } __packed; +#define SCSI_ATA_PASS_THROUGH_16 0x85 +struct scsi_ata_pass_through_16 { + uint8_t opcode; + uint8_t byte2; +#define SATL_NODATA 0x06 +#define SATL_PIO_IN 0x08 +#define SATL_PIO_OUT 0x0a +#define SATL_EXTEND 0x01 + uint8_t byte3; +#define SATL_CKCOND 0x20 +#define SATL_READ 0x08 +#define SATL_BLOCKS 0x04 +#define SATL_LEN(x) ((x) & 0x03) + uint8_t features[2]; + uint8_t sector_count[2]; + uint8_t lba[6]; + uint8_t device; + uint8_t ata_cmd; + uint8_t control; +} __packed; + +#define SCSI_ATA_PASS_THROUGH_12 0xa1 +struct scsi_ata_pass_through_12 { + uint8_t opcode; + uint8_t byte2; + uint8_t byte3; + uint8_t features[1]; + uint8_t sector_count[1]; + uint8_t lba[3]; + uint8_t device; + uint8_t ata_cmd; + uint8_t reserved; + uint8_t control; +} __packed; + +struct scsi_ata_return_descriptor { + uint8_t descr; +#define SCSI_ATA_RETURN_DESCRIPTOR 9 + uint8_t additional_length; + uint8_t extend; + uint8_t error; + uint8_t sector_count[2]; + uint8_t lba[6]; + uint8_t device; + uint8_t status; +} __packed; + struct command { const char *cmd_name; const char *arg_names; @@ -103,6 +153,8 @@ struct bitinfo { __dead static void usage(void); static void ata_command(struct atareq *); +static int satl_command(struct atareq *, int); +static const uint8_t *satl_return_desc(const uint8_t *, size_t, uint8_t); static void print_bitinfo(const char *, const char *, u_int, const struct bitinfo *); static void print_bitinfo2(const char *, const char *, u_int, u_int, @@ -119,6 +171,7 @@ static void fillataparams(void); static int is_smart(void); static int fd;/* file descriptor for device */ +static int use_satl; /* tunnel through SATL */ static const char *dvname; /* device name */ static char dvname_store[MAXPATHLEN]; /* for opendisk(3) */ static const char *cmdname; /* command user issued */ @@ -531,10 +584,25 @@ ata_command(struct atareq *req) { int error; - error = ioctl(fd, ATAIOCCOMMAND, req); - - if (error == -1) - err(1, "ATAIOCCOMMAND failed"); + switch (use_satl) { + case 0: + error = ioctl(fd, ATAIOCCOMMAND, req); + if (error == 0) + break; + if (errno != ENOTTY) + err(1, "ATAIOCCOMMAND failed"); + use_satl = 1; + /* FALLTHROUGH */ + case 1: + error = satl_command(req, 16); + if (error == 0) + return; + use_satl = 2; + /* FALLTHROUGH */ + case 2: + (void) satl_command(req, 12); + return; + } switch (req->retsts) { @@ -562,6 +630,191 @@ ata_command(struct atareq *req) } /* + * Wrapper that calls SCIOCCOMMAND for a tunneled ATA command + */ +static int +satl_command(struct atareq *req, int cmdlen) +{ + scsireq_t sreq; + int error; + union { + struct scsi_ata_pass_through_12 cmd12; + struct scsi_ata_pass_through_16 cmd16; + } c; + uint8_t b2, b3; + const uint8_t *desc; + + b2 = SATL_NODATA; + if (req->datalen > 0) { + if (req->flags & ATACMD_READ) + b2 = SATL_PIO_IN; + else + b2 = SATL_PIO_OUT; + } + + b3 = SATL_BLOCKS; + if (req->datalen > 0) { + b3 |= 2; /* sector count holds count */ + } else { + b3 |= SATL_CKCOND; + } + if (req->datalen == 0 || req->flags & ATACMD_READ) + b3 |= SATL_READ; + + switch (cmdlen) { + case 16: + c.cmd16.opcode = SCSI_ATA_PASS_THROUGH_16; + c.cmd16.byte2 = b2; + c.cmd16.byte3 = b3; + c.cmd16.features[0] = 0; + c.cmd16.features[1] = req->features; + c.cmd16.sector_count[0] = 0; + c.cmd16.sector_count[1] = req->sec_count; + c.cmd16.lba[0] = 0; + c.cmd16.lba[1] = req->sec_num; + c.cmd16.lba[2] = 0; + c.cmd16.lba[3] = req->cylinder; + c.cmd16.lba[4] = 0; + c.cmd16.lba[5] = req->cylinder >> 8; + c.cmd16.device = 0; + c.cmd16.ata_cmd = req->command; + c.cmd16.control = 0;
Re: CVS commit: src/sbin/atactl
On Mon, Oct 24, 2011 at 07:13:04PM +, Jonathan A. Kollasch wrote: Module Name: src Committed By: jakllsch Date: Mon Oct 24 19:13:04 UTC 2011 Modified Files: src/sbin/atactl: atactl.c Log Message: constify Can you follow common style guidelines and wrap longs line to 80 characters? Those long lines are painful to read with many editors. - Jukka.
Re: CVS commit: src/sbin/atactl
On Sat, Mar 13, 2010 at 07:49:50PM +, matthew green wrote: Log Message: add SMART code 187: Reported uncorrect. from smartmontools. Is that supposed to be read as uncorrected or incorrect? (And can we edit it or does it need to stay verbatim?) -- David A. Holland dholl...@netbsd.org
CVS commit: src/sbin/atactl
Module Name:src Committed By: jakllsch Date: Mon Jan 25 01:24:11 UTC 2010 Modified Files: src/sbin/atactl: atactl.c Log Message: Add display of Long Physical Sector and Long Logical Sectors feature set information to atactl identify output. Also: - remove caddr_t cast - warn about invalid IDENTIFY data checksum (when possible) - humanize capacity in power-of-10 format - remove semi-pointless ATAPI check - slightly rework command queue depth output to be less conversational To generate a diff of this commit: cvs rdiff -u -r1.55 -r1.56 src/sbin/atactl/atactl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.