Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

kernel: Nuke the old (and deprecated) ata(4) driver and atacontrol(8).

It's been replaced by nata(4)/natacontrol(8) since more than 4 years.
  • Loading branch information...
commit df75ede470fab24d56d3b5c23e1a07c011577f7c 1 parent 6774395
Sascha Wildner authored
Showing with 51 additions and 14,033 deletions.
  1. +7 −0 Makefile_upgrade.inc
  2. +0 −1  sbin/Makefile
  3. +0 −7 sbin/atacontrol/Makefile
  4. +0 −255 sbin/atacontrol/atacontrol.8
  5. +0 −428 sbin/atacontrol/atacontrol.c
  6. +1 −2  share/man/man4/Makefile
  7. +0 −263 share/man/man4/ata.4
  8. +0 −2  share/man/man4/isa.4
  9. +1 −11 share/man/man4/nata.4
  10. +25 −15 share/man/man4/{atapicam.4 → natapicam.4}
  11. +0 −15 sys/conf/files
  12. +1 −1  sys/conf/options
  13. +0 −11 sys/config/GENERIC
  14. +8 −18 sys/config/LINT
  15. +8 −18 sys/config/LINT64
  16. +0 −11 sys/config/X86_64_GENERIC
  17. +0 −1,599 sys/dev/disk/ata/ata-all.c
  18. +0 −345 sys/dev/disk/ata/ata-all.h
  19. +0 −147 sys/dev/disk/ata/ata-card.c
  20. +0 −988 sys/dev/disk/ata/ata-disk.c
  21. +0 −86 sys/dev/disk/ata/ata-disk.h
  22. +0 −1,628 sys/dev/disk/ata/ata-dma.c
  23. +0 −155 sys/dev/disk/ata/ata-isa.c
  24. +0 −987 sys/dev/disk/ata/ata-pci.c
  25. +0 −1,470 sys/dev/disk/ata/ata-raid.c
  26. +0 −233 sys/dev/disk/ata/ata-raid.h
  27. +0 −741 sys/dev/disk/ata/atapi-all.c
  28. +0 −199 sys/dev/disk/ata/atapi-all.h
  29. +0 −735 sys/dev/disk/ata/atapi-cam.c
  30. +0 −1,998 sys/dev/disk/ata/atapi-cd.c
  31. +0 −330 sys/dev/disk/ata/atapi-cd.h
  32. +0 −430 sys/dev/disk/ata/atapi-fd.c
  33. +0 −81 sys/dev/disk/ata/atapi-fd.h
  34. +0 −661 sys/dev/disk/ata/atapi-tape.c
  35. +0 −162 sys/dev/disk/ata/atapi-tape.h
View
7 Makefile_upgrade.inc
@@ -1883,6 +1883,13 @@ TO_REMOVE+=/usr/share/man/man3/archive_write_set_format_shar_binary.3.gz
TO_REMOVE+=/usr/share/man/cat3/archive_write_set_format_shar_binary.3.gz
TO_REMOVE+=/usr/share/man/man3/archive_write_set_format_ustar.3.gz
TO_REMOVE+=/usr/share/man/cat3/archive_write_set_format_ustar.3.gz
+TO_REMOVE+=/sbin/atacontrol
+TO_REMOVE+=/usr/share/man/cat8/atacontrol.8.gz
+TO_REMOVE+=/usr/share/man/man8/atacontrol.8.gz
+TO_REMOVE+=/usr/share/man/cat4/ata.4.gz
+TO_REMOVE+=/usr/share/man/man4/ata.4.gz
+TO_REMOVE+=/usr/share/man/cat4/atapicam.4.gz
+TO_REMOVE+=/usr/share/man/man4/atapicam.4.gz
.if ${MACHINE_ARCH} == "x86_64"
TO_REMOVE+=/usr/libdata/stallion/2681.sys
View
1  sbin/Makefile
@@ -4,7 +4,6 @@
# XXX MISSING: icheck ncheck
SUBDIR= adjkerntz \
- atacontrol \
atm \
badsect \
camcontrol \
View
7 sbin/atacontrol/Makefile
@@ -1,7 +0,0 @@
-#$FreeBSD: src/sbin/atacontrol/Makefile,v 1.6.2.1 2002/03/18 08:40:00 sos Exp $
-#$DragonFly: src/sbin/atacontrol/Makefile,v 1.5 2006/10/17 00:55:39 pavalos Exp $
-
-PROG= atacontrol
-MAN= atacontrol.8
-
-.include <bsd.prog.mk>
View
255 sbin/atacontrol/atacontrol.8
@@ -1,255 +0,0 @@
-.\"
-.\" Copyright (c) 2000,2001,2002 Søren Schmidt <sos@FreeBSD.org>
-.\" All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" $FreeBSD: src/sbin/atacontrol/atacontrol.8,v 1.13.2.7 2003/01/26 03:01:09 keramida Exp $
-.\" $DragonFly: src/sbin/atacontrol/atacontrol.8,v 1.3 2004/03/11 12:28:53 hmp Exp $
-.\"
-.Dd May 17, 2001
-.Dt ATACONTROL 8
-.Os
-.Sh NAME
-.Nm atacontrol
-.Nd ATA device driver control program
-.Sh SYNOPSIS
-.Nm
-.Aq Ar command
-.Ar args
-.Pp
-.Nm
-.Ic attach
-.Ar channel
-.Nm
-.Ic detach
-.Ar channel
-.Nm
-.Ic reinit
-.Ar channel
-.Nm
-.Ic create
-.Ar type Oo Ar interleave Oc Ar disk0 ... diskN
-.Nm
-.Ic delete
-.Ar raid
-.Nm
-.Ic rebuild
-.Ar raid
-.Nm
-.Ic status
-.Ar raid
-.Nm
-.Ic mode
-.Ar channel
-.Op Ar mastermode slavemode
-.Nm
-.Ic info
-.Ar channel
-.Nm
-.Ic cap
-.Ar channel device
-.Nm
-.Ic enclosure
-.Ar channel device
-.Nm
-.Ic list
-.Sh DESCRIPTION
-The
-.Nm
-utility is a control program that provides the user access and control to the
-.Dx
-.Xr ata 4
-subsystem.
-.Pp
-The
-.Nm
-utility
-can cause severe system crashes and loss of data if used improperly.
-Please
-exercise caution when using this command!
-.Pp
-The
-.Ar channel
-argument is the number of the ATA channel on which to operate.
-The following commands are supported:
-.Bl -tag -width "rebuild"
-.It Ic attach
-Attach an ATA
-.Ar channel .
-Devices on the channel are probed and attached as
-is done on boot.
-.It Ic detach
-Detach an ATA
-.Ar channel .
-Devices on the channel are removed from the kernel,
-and all outstanding transfers etc. are returned back to the system marked
-as failed.
-.It Ic reinit
-Reinitialize an ATA
-.Ar channel .
-Both devices on the channel are reset and
-initialized to the parameters the ATA driver has stored internally.
-Devices that have gone bad and no longer respond to the probe, or devices
-that have physically been removed, are removed from the kernel.
-Likewise are devices that show up during a reset, probed and attached.
-.It Ic create
-Create a
-.Ar type
-ATA RAID.
-The type can be
-.Cm RAID0
-(stripe),
-.Cm RAID1
-(mirror),
-.Cm RAID0+1
-or
-.Cm SPAN
-(JBOD).
-In case the RAID has a
-.Cm RAID0
-component,
-the
-.Ar interleave
-must be specified in number of sectors.
-The RAID will be created
-of the individual disks named
-.Bk -words
-.Ar disk0 ... diskN .
-.Ek
-.Pp
-Although the ATA driver allows for creating an ATA RAID on disks with any
-controller, there are restrictions.
-It is only possible to boot on
-an array if it is either located on a
-.Dq real
-ATA RAID controller like
-the Promise or Highpoint controllers, or if the RAID declared is of
-.Cm RAID1
-or
-.Cm SPAN
-type; in case of a
-.Cm SPAN ,
-the partition to boot must
-reside on the first disk in the SPAN.
-.It Ic delete
-Delete a RAID array on a RAID capable ATA controller.
-.It Ic rebuild
-Rebuild a RAID1 array on a RAID capable ATA controller.
-.It Ic status
-Get the status of an ATA RAID.
-.It Ic mode
-Without the two mode arguments, the current transfer modes of both
-devices are printed.
-If the mode arguments are given, the ATA driver
-is asked to change the transfer modes to those given.
-The ATA driver
-will reject modes that are not supported by the hardware.
-Modes are given like
-.Dq Li PIO3 ,
-.Dq Li udma2 ,
-.Dq Li udma100 ,
-case does not matter.
-If one of the devices mode should not be changed, use a nonexisting mode
-as argument (i.e.\&
-.Dq Li XXX ) ,
-and the mode will remain unchanged.
-.Pp
-Currently supported modes are:
-.Cm BIOSDMA ,
-.Cm PIO0
-(alias
-.Cm BIOSPIO ) ,
-.Cm PIO1 , PIO2 , PIO3 , PIO4 ,
-.Cm WDMA2 ,
-.Cm UDMA2
-(alias
-.Cm UDMA33 ) ,
-.Cm UDMA4
-(alias
-.Cm UDMA66 ) ,
-.Cm UDMA5
-(alias
-.Cm UDMA100 )
-and
-.Cm UDMA6
-(alias
-.Cm UDMA133 ) .
-.It Ic info
-Show info about the attached devices on the
-.Ar channel .
-The device name and manufacture/version strings are shown.
-.It Ic cap
-Show detailed info about the device on
-.Ar channel device
-where device is 0 for master and 1 for slave.
-.It Ic enclosure
-Show detailed info about the enclosure on
-.Ar channel device
-where device is 0 for master and 1 for slave.
-Fan RPM speed, enclosure temperature, 5V and 12V levels are shown.
-.It Ic list
-Show info about all attached devices on all active controllers.
-.El
-.Sh EXAMPLES
-To see the devices' current access modes, use the command line:
-.Pp
-.Dl "atacontrol mode 0"
-.Pp
-which results in the modes of the devices being displayed as a string
-like this:
-.Bd -literal -offset indent
-Master = WDMA2
-Slave = PIO4
-.Ed
-.Pp
-This means that ata0-master is in DMA mode,
-ata0-slave is in PIO mode,
-and so forth.
-You can set the mode with
-.Nm
-and a string like the above,
-for example:
-.Pp
-.Dl "atacontrol mode 0 PIO4 PIO4"
-.Pp
-The new modes are set as soon as the
-.Nm
-command returns.
-.Sh SEE ALSO
-.Xr ata 4
-.Sh HISTORY
-The
-.Nm
-utility first appeared in
-.Fx 4.6 .
-.Sh AUTHORS
-.An -nosplit
-The
-.Nm
-utility was written by
-.An S\(/oren Schmidt
-.Aq sos@FreeBSD.org .
-.Pp
-This manual page was written by
-.An S\(/oren Schmidt
-.Aq sos@FreeBSD.org .
View
428 sbin/atacontrol/atacontrol.c
@@ -1,428 +0,0 @@
-/*-
- * Copyright (c) 2000,2001,2002 Søren Schmidt <sos@FreeBSD.org>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer,
- * without modification, immediately at the beginning of the file.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * $FreeBSD: src/sbin/atacontrol/atacontrol.c,v 1.11.2.5 2002/08/21 13:18:17 sos Exp $
- * $DragonFly: src/sbin/atacontrol/atacontrol.c,v 1.4 2005/01/09 04:43:33 cpressey Exp $
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <err.h>
-#include <sys/ata.h>
-
-static const char *mode2str(int);
-static int str2mode(char *);
-static void usage(void);
-static int version(int);
-static void param_print(struct ata_params *);
-static void cap_print(struct ata_params *);
-static int ata_cap_print(int, int, int);
-static int info_print(int, int, int);
-
-const char *
-mode2str(int mode)
-{
- switch (mode) {
- case ATA_PIO: return "BIOSPIO";
- case ATA_PIO0: return "PIO0";
- case ATA_PIO1: return "PIO1";
- case ATA_PIO2: return "PIO2";
- case ATA_PIO3: return "PIO3";
- case ATA_PIO4: return "PIO4";
- case ATA_WDMA2: return "WDMA2";
- case ATA_UDMA2: return "UDMA33";
- case ATA_UDMA4: return "UDMA66";
- case ATA_UDMA5: return "UDMA100";
- case ATA_UDMA6: return "UDMA133";
- case ATA_DMA: return "BIOSDMA";
- default: return "???";
- }
-}
-
-int
-str2mode(char *str)
-{
- if (!strcasecmp(str, "BIOSPIO")) return ATA_PIO;
- if (!strcasecmp(str, "PIO0")) return ATA_PIO0;
- if (!strcasecmp(str, "PIO1")) return ATA_PIO1;
- if (!strcasecmp(str, "PIO2")) return ATA_PIO2;
- if (!strcasecmp(str, "PIO3")) return ATA_PIO3;
- if (!strcasecmp(str, "PIO4")) return ATA_PIO4;
- if (!strcasecmp(str, "WDMA2")) return ATA_WDMA2;
- if (!strcasecmp(str, "UDMA2")) return ATA_UDMA2;
- if (!strcasecmp(str, "UDMA33")) return ATA_UDMA2;
- if (!strcasecmp(str, "UDMA4")) return ATA_UDMA4;
- if (!strcasecmp(str, "UDMA66")) return ATA_UDMA4;
- if (!strcasecmp(str, "UDMA5")) return ATA_UDMA5;
- if (!strcasecmp(str, "UDMA100")) return ATA_UDMA5;
- if (!strcasecmp(str, "UDMA6")) return ATA_UDMA6;
- if (!strcasecmp(str, "UDMA133")) return ATA_UDMA6;
- if (!strcasecmp(str, "BIOSDMA")) return ATA_DMA;
- return -1;
-}
-
-
-void
-usage(void)
-{
- fprintf(stderr, "usage: atacontrol <command> channel [args]\n");
- exit(1);
-}
-
-int
-version(int ver)
-{
- int bit;
-
- if (ver == 0xffff)
- return 0;
- for (bit = 15; bit >= 0; bit--)
- if (ver & (1 << bit))
- return bit;
- return 0;
-}
-
-void
-param_print(struct ata_params *parm)
-{
- printf("<%.40s/%.8s> ATA/ATAPI rev %d\n",
- parm->model, parm->revision, version(parm->version_major));
-}
-
-void
-cap_print(struct ata_params *parm)
-{
- printf("\n");
- printf("ATA/ATAPI revision %d\n", version(parm->version_major));
- printf("device model %.40s\n", parm->model);
- printf("serial number %.20s\n", parm->serial);
- printf("firmware revision %.8s\n", parm->revision);
-
- printf("cylinders %d\n", parm->cylinders);
- printf("heads %d\n", parm->heads);
- printf("sectors/track %d\n", parm->sectors);
-
- printf("lba%ssupported ", parm->support_lba ? " " : " not ");
- if (parm->lba_size)
- printf("%d sectors\n", parm->lba_size);
- else
- printf("\n");
-
- printf("lba48%ssupported ", parm->support.address48 ? " " : " not ");
- if (parm->lba_size48)
- printf("%ju sectors\n", (uintmax_t)parm->lba_size48);
- else
- printf("\n");
- printf("dma%ssupported\n", parm->support_dma ? " " : " not");
-
- printf("overlap%ssupported\n", parm->support_queueing ? " " : " not ");
-
- printf("\nFeature Support Enable Value Vendor\n");
-
- printf("write cache %s %s\n",
- parm->support.write_cache ? "yes" : "no",
- parm->enabled.write_cache ? "yes" : "no");
-
- printf("read ahead %s %s\n",
- parm->support.look_ahead ? "yes" : "no",
- parm->enabled.look_ahead ? "yes" : "no");
-
- printf("dma queued %s %s %d/%02X\n",
- parm->support.queued ? "yes" : "no",
- parm->enabled.queued ? "yes" : "no",
- parm->queuelen, parm->queuelen);
-
- printf("SMART %s %s\n",
- parm->support.smart ? "yes" : "no",
- parm->enabled.smart ? "yes" : "no");
-
- printf("microcode download %s %s\n",
- parm->support.microcode ? "yes" : "no",
- parm->enabled.microcode ? "yes" : "no");
-
- printf("security %s %s\n",
- parm->support.smart ? "yes" : "no",
- parm->enabled.smart ? "yes" : "no");
-
- printf("power management %s %s\n",
- parm->support.power_mngt ? "yes" : "no",
- parm->enabled.power_mngt ? "yes" : "no");
-
- printf("advanced power management %s %s %d/%02X\n",
- parm->support.apm ? "yes" : "no",
- parm->enabled.apm ? "yes" : "no",
- parm->apm_value, parm->apm_value);
-
- printf("automatic acoustic management %s %s %d/%02X %d/%02X\n",
- parm->support.auto_acoustic ? "yes" : "no",
- parm->enabled.auto_acoustic ? "yes" : "no",
- parm->current_acoustic, parm->current_acoustic,
- parm->vendor_acoustic, parm->vendor_acoustic);
-}
-
-int
-ata_cap_print(int fd, int channel, int device)
-{
- struct ata_cmd iocmd;
-
- bzero(&iocmd, sizeof(struct ata_cmd));
-
- iocmd.channel = channel;
- iocmd.device = -1;
- iocmd.cmd = ATAGPARM;
-
- if (ioctl(fd, IOCATA, &iocmd) < 0)
- return errno;
-
- printf("ATA channel %d, %s", channel, device==0 ? "Master" : "Slave");
-
- if (iocmd.u.param.type[device]) {
- printf(", device %s:\n", iocmd.u.param.name[device]);
- cap_print(&iocmd.u.param.params[device]);
- }
- else
- printf(": no device present\n");
- return 0;
-}
-
-int
-info_print(int fd, int channel, int prchan)
-{
- struct ata_cmd iocmd;
-
- bzero(&iocmd, sizeof(struct ata_cmd));
- iocmd.channel = channel;
- iocmd.device = -1;
- iocmd.cmd = ATAGPARM;
- if (ioctl(fd, IOCATA, &iocmd) < 0)
- return errno;
- if (prchan)
- printf("ATA channel %d:\n", channel);
- printf("%sMaster: ", prchan ? " " : "");
- if (iocmd.u.param.type[0]) {
- printf("%4.4s ", iocmd.u.param.name[0]);
- param_print(&iocmd.u.param.params[0]);
- }
- else
- printf(" no device present\n");
- printf("%sSlave: ", prchan ? " " : "");
- if (iocmd.u.param.type[1]) {
- printf("%4.4s ", iocmd.u.param.name[1]);
- param_print(&iocmd.u.param.params[1]);
- }
- else
- printf(" no device present\n");
- return 0;
-}
-
-int
-main(int argc, char **argv)
-{
- struct ata_cmd iocmd;
- int fd;
-
- if ((fd = open("/dev/ata", O_RDWR)) < 0)
- err(1, "control device not found");
-
- if (argc < 2)
- usage();
-
- bzero(&iocmd, sizeof(struct ata_cmd));
-
- if (argc > 2 && strcmp(argv[1], "create")) {
- int chan;
-
- if (!strcmp(argv[1], "delete") ||
- !strcmp(argv[1], "status") ||
- !strcmp(argv[1], "rebuild")) {
- if (!(sscanf(argv[2], "%d", &chan) == 1 ||
- sscanf(argv[2], "ar%d", &chan) == 1))
- usage();
- }
- else {
- if (!(sscanf(argv[2], "%d", &chan) == 1 ||
- sscanf(argv[2], "ata%d", &chan) == 1))
- usage();
- }
- iocmd.channel = chan;
- }
-
- if (!strcmp(argv[1], "list") && argc == 2) {
- int unit = 0;
-
- while (info_print(fd, unit++, 1) != ENXIO);
- }
- else if (!strcmp(argv[1], "info") && argc == 3) {
- info_print(fd, iocmd.channel, 0);
- }
- else if (!strcmp(argv[1], "cap") && argc == 4) {
- ata_cap_print(fd, iocmd.channel, atoi(argv[3]));
- }
- else if (!strcmp(argv[1], "enclosure") && argc == 4) {
- iocmd.device = atoi(argv[3]);
- iocmd.cmd = ATAENCSTAT;
- if (ioctl(fd, IOCATA, &iocmd) < 0)
- err(1, "ioctl(ATAENCSTAT)");
- printf("fan RPM: %d temp: %.1f 5V: %.2f 12V: %.2f\n",
- iocmd.u.enclosure.fan,
- (double)iocmd.u.enclosure.temp / 10,
- (double)iocmd.u.enclosure.v05 / 1000,
- (double)iocmd.u.enclosure.v12 / 1000);
- }
- else if (!strcmp(argv[1], "detach") && argc == 3) {
- iocmd.cmd = ATADETACH;
- if (ioctl(fd, IOCATA, &iocmd) < 0)
- err(1, "ioctl(ATADETACH)");
- }
- else if (!strcmp(argv[1], "attach") && argc == 3) {
- iocmd.cmd = ATAATTACH;
- if (ioctl(fd, IOCATA, &iocmd) < 0)
- err(1, "ioctl(ATAATTACH)");
- info_print(fd, iocmd.channel, 0);
- }
- else if (!strcmp(argv[1], "reinit") && argc == 3) {
- iocmd.cmd = ATAREINIT;
- if (ioctl(fd, IOCATA, &iocmd) < 0)
- warn("ioctl(ATAREINIT)");
- info_print(fd, iocmd.channel, 0);
- }
- else if (!strcmp(argv[1], "create")) {
- int disk, dev, offset;
-
- iocmd.cmd = ATARAIDCREATE;
- if (!strcmp(argv[2], "RAID0") || !strcmp(argv[2], "stripe"))
- iocmd.u.raid_setup.type = 1;
- if (!strcmp(argv[2], "RAID1") || !strcmp(argv[2],"mirror"))
- iocmd.u.raid_setup.type = 2;
- if (!strcmp(argv[2], "RAID0+1"))
- iocmd.u.raid_setup.type = 3;
- if (!strcmp(argv[2], "SPAN") || !strcmp(argv[2], "JBOD"))
- iocmd.u.raid_setup.type = 4;
- if (!iocmd.u.raid_setup.type)
- usage();
-
- if (iocmd.u.raid_setup.type & 1) {
- if (!sscanf(argv[3], "%d",
- &iocmd.u.raid_setup.interleave) == 1)
- usage();
- offset = 4;
- }
- else
- offset = 3;
-
- for (disk = 0; disk < 16 && (offset + disk) < argc; disk++) {
- if (!(sscanf(argv[offset + disk], "%d", &dev) == 1 ||
- sscanf(argv[offset + disk], "ad%d", &dev) == 1))
- usage();
- iocmd.u.raid_setup.disks[disk] = dev;
- }
- iocmd.u.raid_setup.total_disks = disk;
- if (ioctl(fd, IOCATA, &iocmd) < 0)
- err(1, "ioctl(ATARAIDCREATE)");
- else
- printf("ar%d created\n", iocmd.u.raid_setup.unit);
- }
- else if (!strcmp(argv[1], "delete") && argc == 3) {
- iocmd.cmd = ATARAIDDELETE;
- if (ioctl(fd, IOCATA, &iocmd) < 0)
- warn("ioctl(ATARAIDDELETE)");
- }
- else if (!strcmp(argv[1], "rebuild") && argc == 3) {
- iocmd.cmd = ATARAIDREBUILD;
- if (ioctl(fd, IOCATA, &iocmd) < 0)
- warn("ioctl(ATARAIDREBUILD)");
- }
- else if (!strcmp(argv[1], "status") && argc == 3) {
- int i;
-
- iocmd.cmd = ATARAIDSTATUS;
- if (ioctl(fd, IOCATA, &iocmd) < 0)
- err(1, "ioctl(ATARAIDSTATUS)");
- printf("ar%d: ATA ", iocmd.channel);
- switch (iocmd.u.raid_status.type) {
- case AR_RAID0:
- printf("RAID0");
- break;
- case AR_RAID1:
- printf("RAID1");
- break;
- case AR_RAID0 | AR_RAID1:
- printf("RAID0+1");
- break;
- case AR_SPAN:
- printf("SPAN");
- break;
- }
- printf(" subdisks: ");
- for (i = 0; i < iocmd.u.raid_status.total_disks; i++) {
- if (iocmd.u.raid_status.disks[i] >= 0)
- printf("ad%d ", iocmd.u.raid_status.disks[i]);
- else
- printf("DOWN ");
- }
- printf("status: ");
- switch (iocmd.u.raid_status.status) {
- case AR_READY:
- printf("READY\n");
- break;
- case AR_READY | AR_DEGRADED:
- printf("DEGRADED\n");
- break;
- case AR_READY | AR_DEGRADED | AR_REBUILDING:
- printf("REBUILDING %d%% completed\n",
- iocmd.u.raid_status.progress);
- break;
- default:
- printf("BROKEN\n");
- }
- }
- else if (!strcmp(argv[1], "mode") && (argc == 3 || argc == 5)) {
- if (argc == 5) {
- iocmd.cmd = ATASMODE;
- iocmd.device = -1;
- iocmd.u.mode.mode[0] = str2mode(argv[3]);
- iocmd.u.mode.mode[1] = str2mode(argv[4]);
- if (ioctl(fd, IOCATA, &iocmd) < 0)
- warn("ioctl(ATASMODE)");
- }
- if (argc == 3 || argc == 5) {
- iocmd.cmd = ATAGMODE;
- iocmd.device = -1;
- if (ioctl(fd, IOCATA, &iocmd) < 0)
- err(1, "ioctl(ATAGMODE)");
- printf("Master = %s \nSlave = %s\n",
- mode2str(iocmd.u.mode.mode[0]),
- mode2str(iocmd.u.mode.mode[1]));
- }
- }
- else
- usage();
- exit(0);
-}
View
3  share/man/man4/Makefile
@@ -33,8 +33,6 @@ MAN= aac.4 \
aps.4 \
arcmsr.4 \
arp.4 \
- ata.4 \
- atapicam.4 \
ath.4 \
ath_hal.4 \
atkbd.4 \
@@ -166,6 +164,7 @@ MAN= aac.4 \
mxge.4 \
my.4 \
nata.4 \
+ natapicam.4 \
nataraid.4 \
natm.4 \
ncr.4 \
View
263 share/man/man4/ata.4
@@ -1,263 +0,0 @@
-.\"
-.\" Copyright (c) 2000,2004 Jeroen Ruigrok van der Werven
-.\" Copyright (c) 2000,2001,2002 Søren Schmidt
-.\" All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" $FreeBSD: src/share/man/man4/ata.4,v 1.3.2.18 2002/10/16 13:40:51 fjoe Exp $
-.\" $DragonFly: src/share/man/man4/ata.4,v 1.9 2008/07/08 14:12:45 thomas Exp $
-.\"
-.Dd June 15, 2007
-.Dt ATA 4
-.Os
-.Sh NAME
-.Nm ata
-.Nd deprecated (S)ATA/ATAPI disk controller driver
-.Sh SYNOPSIS
-For ISA based ATA/ATAPI support:
-.Cd device isa
-.Cd device ata0 at isa? port IO_WD1 irq 14
-.Cd device ata1 at isa? port IO_WD2 irq 15
-.Pp
-For PCI based (S)ATA/ATAPI support:
-.Cd device pci
-.Cd device ata
-.Pp
-To support (S)ATA compliant disk drives:
-.Cd device atadisk
-.Pp
-To support ATAPI CD-ROM, CDR, CDRW, DVD-ROM and DVD-RAM drives:
-.Cd device atapicd
-.Pp
-To support ATAPI floppy drives,
-such as the ZIP and LS120:
-.Cd device atapifd
-.Pp
-To support ATAPI tape drives:
-.Cd device atapist
-.Pp
-The following tunables are settable from the loader:
-.Bl -ohang
-.It Va hw.ata.ata_dma
-set to 1 for DMA access, 0 for PIO (default is DMA).
-.It Va hw.ata.atapi_dma
-set to 1 for DMA access, 0 for PIO (default is PIO).
-.It Va hw.ata.wc
-set to 1 to enable Write Caching, 0 to disable (default is enabled).
-(WARNING: might cause data loss on power failures.)
-.It Va hw.ata.tags
-set to 1 to enable Tagged Queuing support, 0 to disable (default is disabled).
-(Only IBM DPTA, DTLA, ICxxxxxxAT, ICxxxxxxAV drives support that.)
-.El
-.Sh DESCRIPTION
-The
-.Nm
-driver is the deprecated
-.Fx 4.8
-ATA driver.
-.Dx Ap s
-default ATA driver is
-.Xr nata 4
-which was ported from newer
-.Fx
-code.
-.Pp
-This driver provides access to disk drives, ATAPI CD-ROM and DVD drives,
-ZIP drives and tape streamers connected to controllers
-according to the ATA and ATAPI standards.
-These devices are also commonly known as IDE or EIDE devices.
-.Pp
-The currently supported ATA controllers with their maximum speed include:
-.Pp
-.Bl -tag -width "Promise Ultra/Fasttrak-100 TX2/TX2000" -compact
-.It Acerlabs Aladdin
-Ultra DMA 100 (UDMA5), 100 MB/sec (depending on model, max stated at boot)
-.It AMD 756
-Ultra DMA 66 (UDMA4), 66 MB/sec
-.It AMD 766
-Ultra DMA 100 (UDMA5), 100 MB/sec
-.It AMD 768
-Ultra DMA 100 (UDMA5), 100 MB/sec
-.It AMD 8111
-Ultra DMA 133 (UDMA6), 133 MB/sec
-.It Cenatek Rocket Drive
-Ultra DMA 133 (UDMA6), 133 MB/sec
-.It CMD 646
-DMA 2 (WDMA2), 16 MB/sec
-.It CMD 648
-Ultra DMA 66 (UDMA4), 66 MB/sec
-.It CMD 649
-Ultra DMA 100 (UDMA5), 100 MB/sec
-.It Cypress 82C693
-DMA 2 (WDMA2), 16 MB/sec
-.It Cyrix 5530
-Ultra DMA 33 (UDMA2), 33 MB/sec
-.It HighPoint HPT366
-Ultra DMA 66 (UDMA4), 66 MB/sec
-.It HighPoint HPT370
-Ultra DMA 100 (UDMA5), 100 MB/sec
-.It HighPoint HPT372/HPT374
-Ultra DMA 133 (UDMA6), 133 MB/sec
-.It Intel PIIX/PIIX3
-DMA 2 (WDMA2), 16 MB/sec
-.It Intel PIIX4
-Ultra DMA 33 (UDMA2), 33 MB/sec
-.It Intel ICH0
-Ultra DMA 33 (UDMA2), 33 MB/sec
-.It Intel ICH
-Ultra DMA 66 (UDMA4), 66 MB/sec
-.It Intel ICH2/ICH3/ICH4/ICH5
-Ultra DMA 100 (UDMA5), 100 MB/sec
-.It Intel ICH6R/RW
-Ultra DMA 100 (UDMA5), 100 MB/sec
-.It NVIDIA nForce ATA100
-Ultra DMA 100 (UDMA5), 100 MB/sec
-.It NVIDIA nForce2/nForce3 ATA133
-Ultra DMA 133 (UDMA6), 133 MB/sec
-.It Promise Ultra/Fasttrak-33
-Ultra DMA 33 (UDMA2), 33 MB/sec
-.It Promise Ultra/Fasttrak-66
-Ultra DMA 66 (UDMA4), 66 MB/sec
-.It Promise Ultra/Fasttrak-100 (TX2/TX4)
-Ultra DMA 100 (UDMA5), 100 MB/sec
-.It Promise Ultra/Fasttrak-133 TX2/TX2000
-Ultra DMA 133 (UDMA6), 133 MB/sec
-.It ServerWorks ROSB4
-Ultra DMA 33 (UDMA2), 33 MB/sec
-.It ServerWorks CSB5
-Ultra DMA 100 (UDMA5), 100 MB/sec (depending on model, max stated at boot)
-.It SiI 0680
-Ultra DMA 133 (UDMA6), 133 MB/sec (depending on model, max stated at boot)
-.It SiS 5591
-Ultra DMA 133 (UDMA5), 133 MB/sec (depending on model, max stated at boot)
-.It VIA 82C586
-Ultra DMA 33 (UDMA2), 33 MB/sec
-.It VIA 82C596
-Ultra DMA 66 (UDMA4), 66 MB/sec (depending on model, max stated at boot)
-.It VIA 82C686a
-Ultra DMA 66 (UDMA4), 66 MB/sec
-.It VIA 82C686b
-Ultra DMA 100 (UDMA5), 100 MB/sec
-.It VIA 8233/8235/8237
-Ultra DMA 133 (UDMA6), 133 MB/sec (depending on model, max stated at boot)
-.El
-.Pp
-The currently supported SATA controllers with their maximum speed include:
-.Pp
-.Bl -tag -width "SiI 3112/3114/3124/3512" -compact
-.It Intel ICH5
-Serial ATA 150, 150 MB/sec
-.It Intel ICH6(R)/(R)W
-Serial ATA 150, 150 MB/sec
-.It SiI 3112/3114/3124/3512
-Serial ATA 150, 150 MB/sec
-.It VIA 8237
-Serial ATA 150, 150 MB/sec
-.El
-.Pp
-All unknown chipsets are supported at the maximum speed of 16 MB/sec.
-.Pp
-The
-.Nm
-driver also allows for changes to the transfer mode of the devices
-at a later time when the system is up and running, see
-.Xr atacontrol 8 .
-.Pp
-The driver attempts to set the maximum performance transfer mode on your disk
-drives by selecting the highest possible DMA mode. However the
-.Nm
-driver sometimes issue the message
-"DMA limited to UDMA33, non-ATA66 cable or device",
-if the cable is ATA66 (or above) compliant, it is because the other device
-on this channel states it can only accept up to UDMA2/ATA33 signals.
-ATAPI devices are left in PIO mode because DMA problems are common despite the
-device specifications.
-You can always try to set DMA mode on an ATAPI device using
-.Xr atacontrol 8 ,
-but be aware that your hardware might
-.Em not
-support it and can
-.Em hang
-the system.
-.Sh FILES
-.Bl -tag -width "/dev/acd* " -compact
-.It Pa /dev/ad*
-ATA disk device nodes
-.It Pa /dev/acd*
-ATAPI CD-ROM device nodes
-.It Pa /dev/afd*
-ATAPI floppy drive device nodes
-.It Pa /dev/ast*
-ATAPI tape drive device nodes
-.El
-.Sh NOTES
-Static numbering
-(enabled with the
-.Dv ATA_STATIC_ID
-kernel option)
-reserves a number for each possibly connected disk,
-even when not present.
-This may result in odd situations where,
-for example,
-ad0 and ad2 exist in the absence of ad1.
-The advantage is that the addition of the formerly absent drive
-does not cause the numbers of the other drives to change.
-.Pp
-The
-.Nm
-driver does not support MFM/RLL/ESDI (ST-506) style disks.
-.Pp
-Remember that in order to use UDMA4 (and above) mode you
-.Em have
-to use a special 80 conductor cable,
-and the driver tries to determine if you have such a cable
-attached before setting UDMA4 mode.
-.Pp
-The use of UDMA4(66MHz) and higher together with non-UDMA4 devices on
-the same ATA channel is not recommended,
-unless they are run at the non-UDMA4 device's lower speed.
-The driver has been designed to handle that kind of setup but lots of
-older devices do not like this.
-.Sh SEE ALSO
-.Xr nata 4 ,
-.Xr atacontrol 8 ,
-.Xr burncd 8
-.Sh HISTORY
-The
-.Nm
-driver first appeared in
-.Fx 4.0 .
-.Sh AUTHORS
-.An -nosplit
-The
-.Nm
-driver was written by
-.An S\(/oren Schmidt
-.Aq sos@FreeBSD.org .
-.Pp
-This manual page was written by
-.An Jeroen Ruigrok van der Werven
-.Aq asmodai@FreeBSD.org
-and
-.An S\(/oren Schmidt
-.Aq sos@FreeBSD.org .
View
2  share/man/man4/isa.4
@@ -73,8 +73,6 @@ Future Domain based SCSI controller driver
PC architecture floppy disk controller driver
.It Xr nata 4
Generic ATA/ATAPI disk controller driver
-.It Xr ata 4
-Generic ATA/ATAPI disk controller driver (deprecated)
.El
.Ss Serial and parallel interfaces
.Bl -tag -width 12n -offset indent -compact
View
12 share/man/man4/nata.4
@@ -26,7 +26,6 @@
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.\" $FreeBSD: src/share/man/man4/ata.4,v 1.72 2007/03/10 12:44:22 brueffer Exp $
-.\" $DragonFly: src/share/man/man4/nata.4,v 1.4 2008/01/01 12:16:40 swildner Exp $
.\"
.Dd January 1, 2008
.Dt NATA 4
@@ -81,15 +80,6 @@ driver provides access to ATA (IDE) and SerialATA disk drives,
ATAPI CDROM/DVD drives, ZIP/LS120 ATAPI drives and ATAPI tape drives
connected to controllers according to the ATA/ATAPI standards.
.Pp
-.Nm Nata
-is the default ATA driver of
-.Dx .
-The old
-.Fx 4.8
-driver is still available, but deprecated.
-For more information, see
-.Xr ata 4 .
-.Pp
The currently supported ATA/SATA controller chips are:
.Pp
.Bl -tag -width "Silicon Image:" -compact
@@ -207,7 +197,7 @@ as the same numbered device, and not depend on attach order.
Native Command Queuing (NCQ) on SATA drives is not yet supported.
.Sh SEE ALSO
.Xr ahci 4 ,
-.Xr ata 4 ,
+.Xr natapicam 4 ,
.Xr nataraid 4 ,
.Xr sili 4 ,
.Xr burncd 8 ,
View
40 share/man/man4/atapicam.4 → share/man/man4/natapicam.4
@@ -1,4 +1,4 @@
-.\" Copyright (c) 2002
+.\" Copyright (c) 2002, 2004
.\" Thomas Quinot <thomas@FreeBSD.org>. All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
@@ -16,7 +16,7 @@
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR THE VOICES IN HIS HEAD
+.\" ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS
.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
@@ -25,17 +25,30 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
.\" THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.\" $FreeBSD: src/share/man/man4/atapicam.4,v 1.2.2.2 2003/03/03 18:51:16 trhodes Exp $
-.\" $DragonFly: src/share/man/man4/atapicam.4,v 1.3 2008/09/06 10:36:27 thomas Exp $
+.\" $FreeBSD: src/share/man/man4/atapicam.4,v 1.8 2009/10/29 15:59:27 brueffer Exp $
.\"
-.Dd October 23, 2002
-.Dt ATAPICAM 4
+.Dd January 22, 2012
+.Dt NATAPICAM 4
.Os
.Sh NAME
-.Nm atapicam
+.Nm natapicam
.Nd CAM XPT (transport) module for ATAPI devices
.Sh SYNOPSIS
-.Cd "device atapicam"
+To compile this driver into the kernel,
+place the following lines in your
+kernel configuration file:
+.Bd -ragged -offset indent
+.Cd "device scbus"
+.Cd "device nata"
+.Cd "device natapicam"
+.Ed
+.Pp
+Alternatively, to load the driver as a
+module at boot time, place the following line in
+.Xr loader.conf 5 :
+.Bd -literal -offset indent
+natapicam_load="YES"
+.Ed
.Sh DESCRIPTION
The ATAPI/CAM module allows ATAPI devices (CD-ROM, CD-RW, DVD drives,
floppy drives such as Iomega Zip, tape drives) to be accessed through
@@ -43,8 +56,6 @@ the SCSI subsystem,
.Xr cam 4 .
.Pp
.Xr nata 4
-or
-.Xr ata 4
and
.Xr scbus 4
must be configured in the kernel as well.
@@ -78,7 +89,8 @@ extended
information.
.Sh EXAMPLES
.Bd -literal -offset indent
-device atapicam
+device nata
+device natapicam
device scbus
device cd
device pass
@@ -92,17 +104,15 @@ driver to the kernel.
.Pp
Print the list of all devices available through CAM.
.Pp
-.Dl "mount -t cd9660 /dev/cd0c /mnt"
+.Dl "mount -t cd9660 /dev/cd0 /mnt"
.Pp
Mount a CD-ROM from an ATAPI CD-ROM drive
(the command above assumes that the ATAPI drive is the only CD-ROM unit).
.Sh SEE ALSO
-.Xr ata 4 ,
.Xr cam 4 ,
.Xr nata 4 ,
.Xr scsi 4 ,
-.Xr atacontrol 8 ,
-.Xr camcontrol 8
+.Xr camcontrol 8 ,
.Xr natacontrol 8
.Sh HISTORY
The ATAPI/CAM driver first appeared in
View
15 sys/conf/files
@@ -142,21 +142,6 @@ dev/netif/an/if_an_pccard.c optional an pccard
dev/netif/ar/if_ar.c optional ar
dev/netif/ar/if_ar_pci.c optional ar pci
dev/raid/asr/asr.c optional asr pci
-dev/disk/ata/ata-all.c optional ata
-dev/disk/ata/ata-isa.c optional ata isa
-dev/disk/ata/ata-card.c optional ata pccard
-dev/disk/ata/ata-pci.c optional ata pci
-dev/disk/ata/ata-dma.c optional ata pci
-dev/disk/ata/ata-disk.c optional atadisk
-dev/disk/ata/ata-raid.c optional atadisk
-dev/disk/ata/atapi-all.c optional atapicd
-dev/disk/ata/atapi-all.c optional atapifd
-dev/disk/ata/atapi-all.c optional atapist
-dev/disk/ata/atapi-all.c optional atapicam
-dev/disk/ata/atapi-cd.c optional atapicd
-dev/disk/ata/atapi-fd.c optional atapifd
-dev/disk/ata/atapi-tape.c optional atapist
-dev/disk/ata/atapi-cam.c optional atapicam
dev/disk/ahci/ahci.c optional ahci
dev/disk/ahci/ahci_dragonfly.c optional ahci
dev/disk/ahci/ahci_attach.c optional ahci
View
2  sys/conf/options
@@ -253,7 +253,7 @@ SCSI_NCR_MYADDR opt_ncr.h
# Options used only in pci/isp_pci.c
ISP_TARGET_MODE opt_isp.h
-# Options used in the 'ata' ATA/ATAPI driver
+# Options used in the 'nata' ATA/ATAPI driver
ATA_STATIC_ID opt_ata.h
# Net stuff.
View
11 sys/config/GENERIC
@@ -109,17 +109,6 @@ device nataraid # support for ATA software RAID
device natausb # ATA-over-USB support
options ATA_STATIC_ID # Static device numbering
-# LEGACY ATA and ATAPI devices
-#device ata0 at isa? port IO_WD1 irq 14
-#device ata1 at isa? port IO_WD2 irq 15
-#device ata
-#device atadisk # ATA disk drives
-#device atapicd # ATAPI CDROM drives
-#device atapifd # ATAPI floppy drives
-#device atapist # ATAPI tape drives
-#device atapicam # Emulate ATAPI devices as SCSI via CAM
-#options ATA_STATIC_ID #Static device numbering
-
# SCSI Controllers
device ahc # AHA2940 and onboard AIC7xxx devices
device ahd # AHA39320/29320 and onboard AIC79xx devices
View
26 sys/config/LINT
@@ -1253,17 +1253,6 @@ device pst
#
device ips
-#
-# The 'ATA' driver supports all ATA and ATAPI devices.
-# You only need one "device ata" for it to find all
-# PCI ATA/ATAPI devices on modern machines.
-#device ata
-#device atadisk # ATA disk drives
-#device atapicd # ATAPI CDROM drives
-#device atapifd # ATAPI floppy drives
-#device atapist # ATAPI tape drives
-#device atapicam # emulate ATAPI devices as SCSI ditto via CAM
- # needs CAM to be present (scbus & pass)
# AHCI driver, this will override NATA for AHCI devices,
# both drivers may be included.
#
@@ -1273,9 +1262,10 @@ device ahci
#
device sili
-# The 'NATA' set of drivers are set to replace the previous ATA drivers,
-# and this set of drivers is mutually exclusive with the old ones. This means,
-# you can't have both at the same time!
+# The 'NATA' driver supports all ATA and ATAPI devices.
+# You only need one "device nata" for it to find all
+# PCI ATA/ATAPI devices on modern machines.
+#
device nata
device natadisk # ATA disk drives
device natapicd # ATAPI CD/DVD drives
@@ -1285,16 +1275,16 @@ device natapicam # ATAPI CAM layer emulation
device nataraid # support for ATA software RAID controllers
device natausb # ATA-over-USB support
-#The following options are valid on the ATA & NATA drivers:
+# The following options are valid for the NATA driver:
#
# ATA_STATIC_ID: controller numbering is static (like the old driver)
# else the device numbers are dynamically allocated.
options ATA_STATIC_ID
-#
# For older non-PCI systems, these are the lines to use:
-#device ata0 at isa? port IO_WD1 irq 14
-#device ata1 at isa? port IO_WD2 irq 15
+#
+#device nata0 at isa? port IO_WD1 irq 14
+#device nata1 at isa? port IO_WD2 irq 15
#
# Standard floppy disk controllers: `fdc' and `fd'
View
26 sys/config/LINT64
@@ -1076,17 +1076,6 @@ device tws # 3ware 9750 series SATA/SAS RAID
#
device ips
-#
-# The 'ATA' driver supports all ATA and ATAPI devices.
-# You only need one "device ata" for it to find all
-# PCI ATA/ATAPI devices on modern machines.
-#device ata
-#device atadisk # ATA disk drives
-#device atapicd # ATAPI CDROM drives
-#device atapifd # ATAPI floppy drives
-#device atapist # ATAPI tape drives
-#device atapicam # emulate ATAPI devices as SCSI ditto via CAM
- # needs CAM to be present (scbus & pass)
# AHCI driver, this will override NATA for AHCI devices,
# both drivers may be included.
#
@@ -1096,9 +1085,10 @@ device ahci
#
device sili
-# The 'NATA' set of drivers are set to replace the previous ATA drivers,
-# and this set of drivers is mutually exclusive with the old ones. This means,
-# you can't have both at the same time!
+# The 'NATA' driver supports all ATA and ATAPI devices.
+# You only need one "device nata" for it to find all
+# PCI ATA/ATAPI devices on modern machines.
+#
device nata
device natadisk # ATA disk drives
device natapicd # ATAPI CD/DVD drives
@@ -1108,16 +1098,16 @@ device natapicam # ATAPI CAM layer emulation
device nataraid # support for ATA software RAID controllers
device natausb # ATA-over-USB support
-#The following options are valid on the ATA & NATA drivers:
+# The following options are valid for the NATA driver:
#
# ATA_STATIC_ID: controller numbering is static (like the old driver)
# else the device numbers are dynamically allocated.
options ATA_STATIC_ID
-#
# For older non-PCI systems, these are the lines to use:
-#device ata0 at isa? port IO_WD1 irq 14
-#device ata1 at isa? port IO_WD2 irq 15
+#
+#device nata0 at isa? port IO_WD1 irq 14
+#device nata1 at isa? port IO_WD2 irq 15
#
# Standard floppy disk controllers: `fdc' and `fd'
View
11 sys/config/X86_64_GENERIC
@@ -95,17 +95,6 @@ device nataraid # support for ATA software RAID
device natausb # ATA-over-USB support
options ATA_STATIC_ID # Static device numbering
-# LEGACY ATA and ATAPI devices
-#device ata0 at isa? port IO_WD1 irq 14
-#device ata1 at isa? port IO_WD2 irq 15
-#device ata
-#device atadisk # ATA disk drives
-#device atapicd # ATAPI CDROM drives
-#device atapifd # ATAPI floppy drives
-#device atapist # ATAPI tape drives
-#device atapicam # Emulate ATAPI devices as SCSI via CAM
-#options ATA_STATIC_ID #Static device numbering
-
# SCSI Controllers
device ahc # AHA2940 and onboard AIC7xxx devices
device ahd # AHA39320/29320 and onboard AIC79xx devices
View
1,599 sys/dev/disk/ata/ata-all.c
@@ -1,1599 +0,0 @@
-/*-
- * Copyright (c) 1998,1999,2000,2001,2002 Søren Schmidt <sos@FreeBSD.org>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer,
- * without modification, immediately at the beginning of the file.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * $FreeBSD: src/sys/dev/ata/ata-all.c,v 1.50.2.45 2003/03/12 14:47:12 sos Exp $
- */
-
-#include "opt_ata.h"
-#include "use_atadisk.h"
-#include "use_atapicd.h"
-#include "use_atapifd.h"
-#include "use_atapist.h"
-#include "use_atapicam.h"
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/ata.h>
-#include <sys/kernel.h>
-#include <sys/conf.h>
-#include <sys/disk.h>
-#include <sys/module.h>
-#include <sys/bus.h>
-#include <sys/buf.h>
-#include <sys/malloc.h>
-#include <sys/devicestat.h>
-#include <sys/sysctl.h>
-#include <sys/thread2.h>
-#include <sys/rman.h>
-
-#include <machine/stdarg.h>
-#include <machine/clock.h>
-
-#include "ata-all.h"
-#include "ata-disk.h"
-#include "ata-raid.h"
-#include "atapi-all.h"
-
-union ata_request {
- struct ad_request ad;
- struct atapi_request atapi;
-};
-
-/* device structures */
-static d_ioctl_t ataioctl;
-static struct dev_ops ata_ops = {
- { "ata", 159, 0 },
- .d_open = nullopen,
- .d_close = nullclose,
- .d_ioctl = ataioctl,
-};
-
-/* prototypes */
-#if 0
-static void ata_boot_attach(void);
-#endif
-static void ata_intr(void *);
-static int ata_getparam(struct ata_device *, u_int8_t);
-static int ata_service(struct ata_channel *);
-static void bswap(int8_t *, int);
-static void btrim(int8_t *, int);
-static void bpack(int8_t *, int8_t *, int);
-static void ata_change_mode(struct ata_device *, int);
-static u_int8_t ata_enclosure_sensor(struct ata_device *, int, u_int8_t, u_int8_t);
-static int ata_enclosure_status(struct ata_device *, int *, int *, int *, int *);
-
-/* sysctl vars */
-SYSCTL_NODE(_hw, OID_AUTO, ata, CTLFLAG_RD, 0, "ATA driver parameters");
-
-int ata_mpipe_size = 4;
-TUNABLE_INT("hw.ata.mpipe_size", &ata_mpipe_size);
-SYSCTL_INT(_hw_ata, OID_AUTO, mpipe_size, CTLFLAG_RW, &ata_mpipe_size, 0,
- "ATA global I/O pipeline max size");
-
-
-/* global vars */
-devclass_t ata_devclass;
-
-/* local vars */
-static MALLOC_DEFINE(M_ATA, "ATA generic", "ATA driver generic layer");
-
-/* misc defines */
-#define DEV_ATAPIALL NATAPICD > 0 || NATAPIFD > 0 || \
- NATAPIST > 0 || NATAPICAM > 0
-
-int
-ata_probe(device_t dev)
-{
- struct ata_channel *ch;
- int rid;
-
- if (!dev || !(ch = device_get_softc(dev)))
- return ENXIO;
-
- if (ch->r_io || ch->r_altio || ch->r_irq)
- return EEXIST;
-
- /* initialize the softc basics */
- ch->active = ATA_IDLE;
- ch->dev = dev;
-
- rid = ATA_IOADDR_RID;
- ch->r_io = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 0, ~0,
- ATA_IOSIZE, RF_ACTIVE);
- if (!ch->r_io)
- goto failure;
-
- rid = ATA_ALTADDR_RID;
- ch->r_altio = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 0, ~0,
- ATA_ALTIOSIZE, RF_ACTIVE);
- if (!ch->r_altio)
- goto failure;
-
- rid = ATA_BMADDR_RID;
- ch->r_bmio = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 0, ~0,
- ATA_BMIOSIZE, RF_ACTIVE);
- if (bootverbose)
- ata_printf(ch, -1, "iobase=0x%04x altiobase=0x%04x bmaddr=0x%04x\n",
- (int)rman_get_start(ch->r_io),
- (int)rman_get_start(ch->r_altio),
- (ch->r_bmio) ? (int)rman_get_start(ch->r_bmio) : 0);
-
- ata_reset(ch);
-
- ch->device[MASTER].channel = ch;
- ch->device[MASTER].unit = ATA_MASTER;
- ch->device[MASTER].mode = ATA_PIO;
- ch->device[SLAVE].channel = ch;
- ch->device[SLAVE].unit = ATA_SLAVE;
- ch->device[SLAVE].mode = ATA_PIO;
- TAILQ_INIT(&ch->ata_queue);
- TAILQ_INIT(&ch->atapi_queue);
-
- mpipe_init(&ch->req_mpipe, M_ATA, sizeof(union ata_request),
- 4, ata_mpipe_size, 0, NULL, NULL, NULL);
- mpipe_init(&ch->dma_mpipe, M_DEVBUF, PAGE_SIZE,
- 4, ata_mpipe_size, MPF_NOZERO, NULL, NULL, NULL);
-
- return 0;
-
-failure:
- if (ch->r_io)
- bus_release_resource(dev, SYS_RES_IOPORT, ATA_IOADDR_RID, ch->r_io);
- if (ch->r_altio)
- bus_release_resource(dev, SYS_RES_IOPORT, ATA_ALTADDR_RID, ch->r_altio);
- if (ch->r_bmio)
- bus_release_resource(dev, SYS_RES_IOPORT, ATA_BMADDR_RID, ch->r_bmio);
- if (bootverbose)
- ata_printf(ch, -1, "probe allocation failed\n");
- return ENXIO;
-}
-
-int
-ata_attach(device_t dev)
-{
- struct ata_channel *ch;
- int error, rid;
-
- if (!dev || !(ch = device_get_softc(dev)))
- return ENXIO;
-
- rid = ATA_IRQ_RID;
- ch->r_irq = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, 0, ~0, 1,
- RF_SHAREABLE | RF_ACTIVE);
- if (!ch->r_irq) {
- ata_printf(ch, -1, "unable to allocate interrupt\n");
- return ENXIO;
- }
-
- /*
- * Traditional ata registers are sensitive to when they can be accessed
- * in the face of e.g. ongoing DMA. Do not allow the interrupt to be
- * polled.
- */
- if ((error = bus_setup_intr(dev, ch->r_irq, INTR_NOPOLL,
- ata_intr, ch, &ch->ih, NULL))) {
- ata_printf(ch, -1, "unable to setup interrupt\n");
- return error;
- }
-
- /*
- * do not attach devices if we are in early boot, this is done later
- * when interrupts are enabled by a hook into the boot process.
- * otherwise attach what the probe has found in ch->devices.
- */
- crit_enter();
-
- if (ch->devices & ATA_ATA_SLAVE)
- if (ata_getparam(&ch->device[SLAVE], ATA_C_ATA_IDENTIFY))
- ch->devices &= ~ATA_ATA_SLAVE;
- if (ch->devices & ATA_ATAPI_SLAVE)
- if (ata_getparam(&ch->device[SLAVE], ATA_C_ATAPI_IDENTIFY))
- ch->devices &= ~ATA_ATAPI_SLAVE;
- if (ch->devices & ATA_ATA_MASTER)
- if (ata_getparam(&ch->device[MASTER], ATA_C_ATA_IDENTIFY))
- ch->devices &= ~ATA_ATA_MASTER;
- if (ch->devices & ATA_ATAPI_MASTER)
- if (ata_getparam(&ch->device[MASTER], ATA_C_ATAPI_IDENTIFY))
- ch->devices &= ~ATA_ATAPI_MASTER;
-#if NATADISK > 0
- if (ch->devices & ATA_ATA_MASTER)
- ad_attach(&ch->device[MASTER], 0);
- if (ch->devices & ATA_ATA_SLAVE)
- ad_attach(&ch->device[SLAVE], 0);
-#endif
-#if DEV_ATAPIALL
- if (ch->devices & ATA_ATAPI_MASTER)
- atapi_attach(&ch->device[MASTER], 0);
- if (ch->devices & ATA_ATAPI_SLAVE)
- atapi_attach(&ch->device[SLAVE], 0);
-#endif
-#if NATAPICAM > 0
- atapi_cam_attach_bus(ch);
-#endif
- crit_exit();
- return 0;
-}
-
-int
-ata_detach(device_t dev)
-{
- struct ata_channel *ch;
-
- if (!dev || !(ch = device_get_softc(dev)) ||
- !ch->r_io || !ch->r_altio || !ch->r_irq)
- return ENXIO;
-
- /* make sure channel is not busy */
- crit_enter();
- ATA_SLEEPLOCK_CH(ch, ATA_CONTROL);
-#if NATADISK > 0
- if (ch->devices & ATA_ATA_MASTER && ch->device[MASTER].driver)
- ad_detach(&ch->device[MASTER], 1);
- if (ch->devices & ATA_ATA_SLAVE && ch->device[SLAVE].driver)
- ad_detach(&ch->device[SLAVE], 1);
-#endif
-#if DEV_ATAPIALL
- if (ch->devices & ATA_ATAPI_MASTER && ch->device[MASTER].driver)
- atapi_detach(&ch->device[MASTER]);
- if (ch->devices & ATA_ATAPI_SLAVE && ch->device[SLAVE].driver)
- atapi_detach(&ch->device[SLAVE]);
-#endif
-#if NATAPICAM > 0
- atapi_cam_detach_bus(ch);
-#endif
- crit_exit();
-
- if (ch->device[MASTER].param) {
- kfree(ch->device[MASTER].param, M_ATA);
- ch->device[MASTER].param = NULL;
- }
- if (ch->device[SLAVE].param) {
- kfree(ch->device[SLAVE].param, M_ATA);
- ch->device[SLAVE].param = NULL;
- }
- ch->device[MASTER].driver = NULL;
- ch->device[SLAVE].driver = NULL;
- ch->device[MASTER].mode = ATA_PIO;
- ch->device[SLAVE].mode = ATA_PIO;
- ch->devices = 0;
- ata_dmafreetags(ch);
-
- bus_teardown_intr(dev, ch->r_irq, ch->ih);
- bus_release_resource(dev, SYS_RES_IRQ, ATA_IRQ_RID, ch->r_irq);
- if (ch->r_bmio)
- bus_release_resource(dev, SYS_RES_IOPORT, ATA_BMADDR_RID, ch->r_bmio);
- bus_release_resource(dev, SYS_RES_IOPORT, ATA_ALTADDR_RID, ch->r_altio);
- bus_release_resource(dev, SYS_RES_IOPORT, ATA_IOADDR_RID, ch->r_io);
- ch->r_io = NULL;
- ch->r_altio = NULL;
- ch->r_bmio = NULL;
- ch->r_irq = NULL;
- mpipe_done(&ch->req_mpipe);
- mpipe_done(&ch->dma_mpipe);
-
- ATA_UNLOCK_CH(ch);
- return 0;
-}
-
-int
-ata_suspend(device_t dev)
-{
- struct ata_channel *ch;
-
- if (dev == NULL || (ch = device_get_softc(dev)) == NULL)
- return ENXIO;
-
- /* wait for the channel to be IDLE or detached before suspending */
- while (ch->r_irq) {
- crit_enter();
- if (ch->active == ATA_IDLE) {
- ch->active = ATA_CONTROL;
- crit_exit();
- break;
- }
- crit_exit();
- tsleep(ch, 0, "atasusp", hz / 10);
- }
- return 0;
-}
-
-int
-ata_resume(device_t dev)
-{
- return ata_reinit(device_get_softc(dev));
-}
-
-static int
-ataioctl(struct dev_ioctl_args *ap)
-{
- struct ata_cmd *iocmd = (struct ata_cmd *)ap->a_data;
- struct ata_channel *ch;
- device_t device = devclass_get_device(ata_devclass, iocmd->channel);
- int error;
-
- if (ap->a_cmd != IOCATA)
- return ENOTTY;
-
- if (iocmd->channel < -1 || iocmd->device < -1 || iocmd->device > SLAVE)
- return ENXIO;
-
- switch (iocmd->cmd) {
- case ATAATTACH:
- /* should enable channel HW on controller that can SOS XXX */
- error = ata_probe(device);
- if (!error)
- error = ata_attach(device);
- return error;
-
- case ATADETACH:
- error = ata_detach(device);
- /* should disable channel HW on controller that can SOS XXX */
- return error;
-
- case ATAREINIT:
- if (!device || !(ch = device_get_softc(device)))
- return ENXIO;
- crit_enter(); /* interlock non-atomic channel lock */
- ATA_SLEEPLOCK_CH(ch, ATA_ACTIVE);
- if ((error = ata_reinit(ch)))
- ATA_UNLOCK_CH(ch);
- crit_exit();
- return error;
-
- case ATAGMODE:
- if (!device || !(ch = device_get_softc(device)))
- return ENXIO;
-
- if ((iocmd->device == MASTER || iocmd->device == -1) &&
- ch->device[MASTER].driver)
- iocmd->u.mode.mode[MASTER] = ch->device[MASTER].mode;
- else
- iocmd->u.mode.mode[MASTER] = -1;
-
- if ((iocmd->device == SLAVE || iocmd->device == -1) &&
- ch->device[SLAVE].param)
- iocmd->u.mode.mode[SLAVE] = ch->device[SLAVE].mode;
- else
- iocmd->u.mode.mode[SLAVE] = -1;
- return 0;
-
- case ATASMODE:
- if (!device || !(ch = device_get_softc(device)))
- return ENXIO;
-
- if ((iocmd->device == MASTER || iocmd->device == -1) &&
- iocmd->u.mode.mode[MASTER] >= 0 && ch->device[MASTER].param) {
- ata_change_mode(&ch->device[MASTER],iocmd->u.mode.mode[MASTER]);
- iocmd->u.mode.mode[MASTER] = ch->device[MASTER].mode;
- }
- else
- iocmd->u.mode.mode[MASTER] = -1;
-
- if ((iocmd->device == SLAVE || iocmd->device == -1) &&
- iocmd->u.mode.mode[SLAVE] >= 0 && ch->device[SLAVE].param) {
- ata_change_mode(&ch->device[SLAVE], iocmd->u.mode.mode[SLAVE]);
- iocmd->u.mode.mode[SLAVE] = ch->device[SLAVE].mode;
- }
- else
- iocmd->u.mode.mode[SLAVE] = -1;
- return 0;
-
- case ATAGPARM:
- if (!device || !(ch = device_get_softc(device)))
- return ENXIO;
-
- iocmd->u.param.type[MASTER] =
- ch->devices & (ATA_ATA_MASTER | ATA_ATAPI_MASTER);
- iocmd->u.param.type[SLAVE] =
- ch->devices & (ATA_ATA_SLAVE | ATA_ATAPI_SLAVE);
-
- if (ch->device[MASTER].name)
- strcpy(iocmd->u.param.name[MASTER], ch->device[MASTER].name);
- if (ch->device[SLAVE].name)
- strcpy(iocmd->u.param.name[SLAVE], ch->device[SLAVE].name);
-
- if (ch->device[MASTER].param)
- bcopy(ch->device[MASTER].param, &iocmd->u.param.params[MASTER],
- sizeof(struct ata_params));
- if (ch->device[SLAVE].param)
- bcopy(ch->device[SLAVE].param, &iocmd->u.param.params[SLAVE],
- sizeof(struct ata_params));
- return 0;
-
- case ATAENCSTAT: {
- struct ata_device *atadev;
-
- if (!device || !(ch = device_get_softc(device)))
- return ENXIO;
-
- if (iocmd->device == SLAVE)
- atadev = &ch->device[SLAVE];
- else
- atadev = &ch->device[MASTER];
-
- return ata_enclosure_status(atadev,
- &iocmd->u.enclosure.fan,
- &iocmd->u.enclosure.temp,
- &iocmd->u.enclosure.v05,
- &iocmd->u.enclosure.v12);
- }
-
-#if NATADISK > 0
- case ATARAIDREBUILD:
- return ata_raid_rebuild(iocmd->channel);
-
- case ATARAIDCREATE:
- return ata_raid_create(&iocmd->u.raid_setup);
-
- case ATARAIDDELETE:
- return ata_raid_delete(iocmd->channel);
-
- case ATARAIDSTATUS:
- return ata_raid_status(iocmd->channel, &iocmd->u.raid_status);
-#endif
-#if DEV_ATAPIALL
- case ATAPICMD: {
- struct ata_device *atadev;
- caddr_t buf;
-
- if (!device || !(ch = device_get_softc(device)))
- return ENXIO;
-
- if (!(atadev = &ch->device[iocmd->device]) ||
- !(ch->devices & (iocmd->device == MASTER ?
- ATA_ATAPI_MASTER : ATA_ATAPI_SLAVE)))
- return ENODEV;
-
- buf = kmalloc(iocmd->u.atapi.count, M_ATA, M_INTWAIT);
-
- if (iocmd->u.atapi.flags & ATAPI_CMD_WRITE) {
- error = copyin(iocmd->u.atapi.data, buf, iocmd->u.atapi.count);
- if (error)
- return error;
- }
- error = atapi_queue_cmd(atadev, iocmd->u.atapi.ccb,
- buf, iocmd->u.atapi.count,
- (iocmd->u.atapi.flags == ATAPI_CMD_READ ?
- ATPR_F_READ : 0) | ATPR_F_QUIET,
- iocmd->u.atapi.timeout, NULL, NULL);
- if (error) {
- iocmd->u.atapi.error = error;
- bcopy(&atadev->result, iocmd->u.atapi.sense_data,
- sizeof(struct atapi_reqsense));
- error = 0;
- }
- else if (iocmd->u.atapi.flags & ATAPI_CMD_READ)
- error = copyout(buf, iocmd->u.atapi.data, iocmd->u.atapi.count);
-
- kfree(buf, M_ATA);
- return error;
- }
-#endif
- default:
- break;
- }
- return ENOTTY;
-}
-
-static int
-ata_getparam(struct ata_device *atadev, u_int8_t command)
-{
- struct ata_params *ata_parm;
- int retry = 0;
-
- ata_parm = kmalloc(sizeof(struct ata_params), M_ATA, M_INTWAIT);
-
- /* apparently some devices needs this repeated */
- do {
- if (ata_command(atadev, command, 0, 0, 0, ATA_IMMEDIATE)) {
- ata_prtdev(atadev, "%s identify failed\n",
- command == ATA_C_ATAPI_IDENTIFY ? "ATAPI" : "ATA");
- kfree(ata_parm, M_ATA);
- return -1;
- }
- if (retry++ > 4) {
- ata_prtdev(atadev, "%s identify retries exceeded\n",
- command == ATA_C_ATAPI_IDENTIFY ? "ATAPI" : "ATA");
- kfree(ata_parm, M_ATA);
- return -1;
- }
- } while (ata_wait(atadev, ((command == ATA_C_ATAPI_IDENTIFY) ?
- ATA_S_DRQ : (ATA_S_READY|ATA_S_DSC|ATA_S_DRQ))));
- ATA_INSW(atadev->channel->r_io, ATA_DATA, (int16_t *)ata_parm,
- sizeof(struct ata_params)/sizeof(int16_t));
-
- if (command == ATA_C_ATA_IDENTIFY ||
- !((ata_parm->model[0] == 'N' && ata_parm->model[1] == 'E') ||
- (ata_parm->model[0] == 'F' && ata_parm->model[1] == 'X') ||
- (ata_parm->model[0] == 'P' && ata_parm->model[1] == 'i')))
- bswap(ata_parm->model, sizeof(ata_parm->model));
- btrim(ata_parm->model, sizeof(ata_parm->model));
- bpack(ata_parm->model, ata_parm->model, sizeof(ata_parm->model));
- bswap(ata_parm->revision, sizeof(ata_parm->revision));
- btrim(ata_parm->revision, sizeof(ata_parm->revision));
- bpack(ata_parm->revision, ata_parm->revision, sizeof(ata_parm->revision));
- bswap(ata_parm->serial, sizeof(ata_parm->serial));
- btrim(ata_parm->serial, sizeof(ata_parm->serial));
- bpack(ata_parm->serial, ata_parm->serial, sizeof(ata_parm->serial));
- atadev->param = ata_parm;
- return 0;
-}
-
-#if 0
-
-static void
-ata_boot_attach(void)
-{
- struct ata_channel *ch;
- int ctlr;
-
- crit_enter();
-
- /*
- * run through all ata devices and look for real ATA & ATAPI devices
- * using the hints we found in the early probe, this avoids some of
- * the delays probing of non-exsistent devices can cause.
- */
- for (ctlr=0; ctlr<devclass_get_maxunit(ata_devclass); ctlr++) {
- if (!(ch = devclass_get_softc(ata_devclass, ctlr)))
- continue;
- if (ch->devices & ATA_ATA_SLAVE)
- if (ata_getparam(&ch->device[SLAVE], ATA_C_ATA_IDENTIFY))
- ch->devices &= ~ATA_ATA_SLAVE;
- if (ch->devices & ATA_ATAPI_SLAVE)
- if (ata_getparam(&ch->device[SLAVE], ATA_C_ATAPI_IDENTIFY))
- ch->devices &= ~ATA_ATAPI_SLAVE;
- if (ch->devices & ATA_ATA_MASTER)
- if (ata_getparam(&ch->device[MASTER], ATA_C_ATA_IDENTIFY))
- ch->devices &= ~ATA_ATA_MASTER;
- if (ch->devices & ATA_ATAPI_MASTER)
- if (ata_getparam(&ch->device[MASTER], ATA_C_ATAPI_IDENTIFY))
- ch->devices &= ~ATA_ATAPI_MASTER;
- }
-
-#if NATADISK > 0
- /* now we know whats there, do the real attach, first the ATA disks */
- for (ctlr=0; ctlr<devclass_get_maxunit(ata_devclass); ctlr++) {
- if (!(ch = devclass_get_softc(ata_devclass, ctlr)))
- continue;
- if (ch->devices & ATA_ATA_MASTER)
- ad_attach(&ch->device[MASTER], 0);
- if (ch->devices & ATA_ATA_SLAVE)
- ad_attach(&ch->device[SLAVE], 0);
- }
- ata_raid_attach();
-#endif
-#if DEV_ATAPIALL
- /* then the atapi devices */
- for (ctlr=0; ctlr<devclass_get_maxunit(ata_devclass); ctlr++) {
- if (!(ch = devclass_get_softc(ata_devclass, ctlr)))
- continue;
- if (ch->devices & ATA_ATAPI_MASTER)
- atapi_attach(&ch->device[MASTER], 0);
- if (ch->devices & ATA_ATAPI_SLAVE)
- atapi_attach(&ch->device[SLAVE], 0);
-#if NATAPICAM > 0
- atapi_cam_attach_bus(ch);
-#endif
- }
-#endif
- crit_exit();
-}
-
-#endif
-
-static void
-ata_intr(void *data)
-{
- struct ata_channel *ch = (struct ata_channel *)data;
- /*
- * on PCI systems we might share an interrupt line with another
- * device or our twin ATA channel, so call ch->intr_func to figure
- * out if it is really an interrupt we should process here
- */
- if (ch->intr_func && ch->intr_func(ch))
- return;
-
- /* if drive is busy it didn't interrupt */
- if (ATA_INB(ch->r_altio, ATA_ALTSTAT) & ATA_S_BUSY) {
- DELAY(100);
- if (!(ATA_INB(ch->r_altio, ATA_ALTSTAT) & ATA_S_DRQ))
- return;
- }
-
- /* clear interrupt and get status */
- ch->status = ATA_INB(ch->r_io, ATA_STATUS);
-
- if (ch->status & ATA_S_ERROR)
- ch->error = ATA_INB(ch->r_io, ATA_ERROR);
-
- /* find & call the responsible driver to process this interrupt */
- switch (ch->active) {
-#if NATADISK > 0
- case ATA_ACTIVE_ATA:
- if (!ch->running || ad_interrupt(ch->running) == ATA_OP_CONTINUES)
- return;
- break;
-#endif
-#if DEV_ATAPIALL
- case ATA_ACTIVE_ATAPI:
- if (!ch->running || atapi_interrupt(ch->running) == ATA_OP_CONTINUES)
- return;
- break;
-#endif
- case ATA_WAIT_INTR:
- case ATA_WAIT_INTR | ATA_CONTROL:
- wakeup((caddr_t)ch);
- break;
-
- case ATA_WAIT_READY:
- case ATA_WAIT_READY | ATA_CONTROL:
- break;
-
- case ATA_IDLE:
- if (ch->flags & ATA_QUEUED) {
- ch->active = ATA_ACTIVE;
- if (ata_service(ch) == ATA_OP_CONTINUES)
- return;
- }
- /* FALLTHROUGH */
-
- default:
-#ifdef ATA_DEBUG
- {
- static int intr_count = 0;
-
- if (intr_count++ < 10)
- ata_printf(ch, -1, "unwanted interrupt #%d active=%02x s=%02x\n",
- intr_count, ch->active, ch->status);
- }
-#endif
- break;
- }
- ch->active &= ATA_CONTROL;
- if (ch->active & ATA_CONTROL)
- return;
- ch->running = NULL;
- ata_start(ch);
- return;
-}
-
-void
-ata_start(struct ata_channel *ch)
-{
-#if NATADISK > 0
- struct ad_request *ad_request;
-#endif
-#if DEV_ATAPIALL
- struct atapi_request *atapi_request;
-#endif
-
- crit_enter(); /* interlock non-atomic channel lock */
- if (!ATA_LOCK_CH(ch, ATA_ACTIVE)) {
- crit_exit();
- return;
- }
-
-#if NATADISK > 0
- /* find & call the responsible driver if anything on the ATA queue */
- if (TAILQ_EMPTY(&ch->ata_queue)) {
- if (ch->devices & (ATA_ATA_MASTER) && ch->device[MASTER].driver)
- ad_start(&ch->device[MASTER]);
- if (ch->devices & (ATA_ATA_SLAVE) && ch->device[SLAVE].driver)
- ad_start(&ch->device[SLAVE]);
- }
- if ((ad_request = TAILQ_FIRST(&ch->ata_queue))) {
- TAILQ_REMOVE(&ch->ata_queue, ad_request, chain);
- ch->active = ATA_ACTIVE_ATA;
- ch->running = ad_request;
-
- /*
- * The donecount had better be 0 here because the channel may not
- * have retained the setup for the request (if a retry).
- */
- KKASSERT(ad_request->donecount == 0);
- if (ad_transfer(ad_request) == ATA_OP_CONTINUES) {
- crit_exit();
- return;
- }
- }
-
-#endif
-#if DEV_ATAPIALL
- /* find & call the responsible driver if anything on the ATAPI queue */
- if (TAILQ_EMPTY(&ch->atapi_queue)) {
- if (ch->devices & (ATA_ATAPI_MASTER) && ch->device[MASTER].driver)
- atapi_start(&ch->device[MASTER]);
- if (ch->devices & (ATA_ATAPI_SLAVE) && ch->device[SLAVE].driver)
- atapi_start(&ch->device[SLAVE]);
- }
- if ((atapi_request = TAILQ_FIRST(&ch->atapi_queue))) {
- TAILQ_REMOVE(&ch->atapi_queue, atapi_request, chain);
- ch->active = ATA_ACTIVE_ATAPI;
- ch->running = atapi_request;
- if (atapi_transfer(atapi_request) == ATA_OP_CONTINUES) {
- crit_exit();
- return;
- }
- }
-#endif
- ATA_UNLOCK_CH(ch);
- crit_exit();
-}
-
-void
-ata_reset(struct ata_channel *ch)
-{
- u_int8_t lsb, msb, ostat0, ostat1;
- u_int8_t stat0 = 0, stat1 = 0;
- int mask = 0, timeout;
-
- /* do we have any signs of ATA/ATAPI HW being present ? */
- ATA_OUTB(ch->r_io, ATA_DRIVE, ATA_D_IBM | ATA_MASTER);
- DELAY(10);
- ostat0 = ATA_INB(ch->r_io, ATA_STATUS);
- if ((ostat0 & 0xf8) != 0xf8 && ostat0 != 0xa5) {
- stat0 = ATA_S_BUSY;
- mask |= 0x01;
- }
- ATA_OUTB(ch->r_io, ATA_DRIVE, ATA_D_IBM | ATA_SLAVE);
- DELAY(10);
- ostat1 = ATA_INB(ch->r_io, ATA_STATUS);
- if ((ostat1 & 0xf8) != 0xf8 && ostat1 != 0xa5) {
- stat1 = ATA_S_BUSY;
- mask |= 0x02;
- }
-
- ch->devices = 0;
- if (!mask)
- return;
-
- /* in some setups we dont want to test for a slave */
- if (ch->flags & ATA_NO_SLAVE) {
- stat1 = 0x0;
- mask &= ~0x02;
- }
-
- if (bootverbose)
- ata_printf(ch, -1, "mask=%02x ostat0=%02x ostat2=%02x\n",
- mask, ostat0, ostat1);
-
- /* reset channel */
- ATA_OUTB(ch->r_io, ATA_DRIVE, ATA_D_IBM | ATA_MASTER);
- DELAY(10);
- ATA_OUTB(ch->r_altio, ATA_ALTSTAT, ATA_A_IDS | ATA_A_RESET);
- DRIVERSLEEP(10000);
- ATA_OUTB(ch->r_altio, ATA_ALTSTAT, ATA_A_IDS);
- DRIVERSLEEP(100000);
- ATA_INB(ch->r_io, ATA_ERROR);
-
- /* wait for BUSY to go inactive */
- for (timeout = 0; timeout < 3100; timeout++) {
- if (stat0 & ATA_S_BUSY) {
- ATA_OUTB(ch->r_io, ATA_DRIVE, ATA_D_IBM | ATA_MASTER);
- DELAY(10);
-
- /* check for ATAPI signature while its still there */
- lsb = ATA_INB(ch->r_io, ATA_CYL_LSB);
- msb = ATA_INB(ch->r_io, ATA_CYL_MSB);
- stat0 = ATA_INB(ch->r_io, ATA_STATUS);
- if (!(stat0 & ATA_S_BUSY)) {
- if (bootverbose)
- ata_printf(ch, ATA_MASTER, "ATAPI %02x %02x\n", lsb, msb);
- if (lsb == ATAPI_MAGIC_LSB && msb == ATAPI_MAGIC_MSB)
- ch->devices |= ATA_ATAPI_MASTER;
- }
- }
- if (stat1 & ATA_S_BUSY) {
- ATA_OUTB(ch->r_io, ATA_DRIVE, ATA_D_IBM | ATA_SLAVE);
- DELAY(10);
-
- /* check for ATAPI signature while its still there */
- lsb = ATA_INB(ch->r_io, ATA_CYL_LSB);
- msb = ATA_INB(ch->r_io, ATA_CYL_MSB);
- stat1 = ATA_INB(ch->r_io, ATA_STATUS);
- if (!(stat1 & ATA_S_BUSY)) {
- if (bootverbose)
- ata_printf(ch, ATA_SLAVE, "ATAPI %02x %02x\n", lsb, msb);
- if (lsb == ATAPI_MAGIC_LSB && msb == ATAPI_MAGIC_MSB)
- ch->devices |= ATA_ATAPI_SLAVE;
- }
- }
- if (mask == 0x01) /* wait for master only */
- if (!(stat0 & ATA_S_BUSY))
- break;
- if (mask == 0x02) /* wait for slave only */
- if (!(stat1 & ATA_S_BUSY))
- break;
- if (mask == 0x03) /* wait for both master & slave */
- if (!(stat0 & ATA_S_BUSY) && !(stat1 & ATA_S_BUSY))
- break;
- DRIVERSLEEP(10000);
- }
- /*
- * some devices release BUSY before they are ready to accept commands.
- * We must wait at least 50ms before attempting to issue a command after
- * BUSY is released.
- */
- DRIVERSLEEP(50000);
- ATA_OUTB(ch->r_altio, ATA_ALTSTAT, ATA_A_4BIT);
-
- if (stat0 & ATA_S_BUSY)
- mask &= ~0x01;
- if (stat1 & ATA_S_BUSY)
- mask &= ~0x02;
- if (bootverbose)
- ata_printf(ch, -1, "mask=%02x stat0=%02x stat1=%02x\n",
- mask, stat0, stat1);
- if (!mask)
- return;
-
- if (mask & 0x01 && ostat0 != 0x00 && !(ch->devices & ATA_ATAPI_MASTER)) {
- ATA_OUTB(ch->r_io, ATA_DRIVE, ATA_D_IBM | ATA_MASTER);
- DELAY(10);
- ATA_OUTB(ch->r_io, ATA_ERROR, 0x58);
- ATA_OUTB(ch->r_io, ATA_CYL_LSB, 0xa5);
- lsb = ATA_INB(ch->r_io, ATA_ERROR);
- msb = ATA_INB(ch->r_io, ATA_CYL_LSB);
- if (bootverbose)
- ata_printf(ch, ATA_MASTER, "ATA %02x %02x\n", lsb, msb);
- if (lsb != 0x58 && msb == 0xa5)
- ch->devices |= ATA_ATA_MASTER;
- }
- if (mask & 0x02 && ostat1 != 0x00 && !(ch->devices & ATA_ATAPI_SLAVE)) {
- ATA_OUTB(ch->r_io, ATA_DRIVE, ATA_D_IBM | ATA_SLAVE);
- DELAY(10);
- ATA_OUTB(ch->r_io, ATA_ERROR, 0x58);
- ATA_OUTB(ch->r_io, ATA_CYL_LSB, 0xa5);
- lsb = ATA_INB(ch->r_io, ATA_ERROR);
- msb = ATA_INB(ch->r_io, ATA_CYL_LSB);
- if (bootverbose)
- ata_printf(ch, ATA_SLAVE, "ATA %02x %02x\n", lsb, msb);
- if (lsb != 0x58 && msb == 0xa5)
- ch->devices |= ATA_ATA_SLAVE;
- }
- if (bootverbose)
- ata_printf(ch, -1, "devices=%02x\n", ch->devices);
-}
-
-int
-ata_reinit(struct ata_channel *ch)
-{
- int devices, misdev, newdev;
-
- if (!ch->r_io || !ch->r_altio || !ch->r_irq)
- return ENXIO;
-
- ATA_FORCELOCK_CH(ch, ATA_CONTROL);
- ch->running = NULL;
- devices = ch->devices;
- ata_printf(ch, -1, "resetting devices .. ");
- ata_reset(ch);
-
- if ((misdev = devices & ~ch->devices)) {
- if (misdev)
- kprintf("\n");
-#if NATADISK > 0
- if (misdev & ATA_ATA_MASTER && ch->device[MASTER].driver)
- ad_detach(&ch->device[MASTER], 0);
- if (misdev & ATA_ATA_SLAVE && ch->device[SLAVE].driver)
- ad_detach(&ch->device[SLAVE], 0);
-#endif
-#if DEV_ATAPIALL
- if (misdev & ATA_ATAPI_MASTER && ch->device[MASTER].driver)
- atapi_detach(&ch->device[MASTER]);
- if (misdev & ATA_ATAPI_SLAVE && ch->device[SLAVE].driver)
- atapi_detach(&ch->device[SLAVE]);
-#endif
- if (misdev & ATA_ATA_MASTER || misdev & ATA_ATAPI_MASTER) {
- if (ch->device[MASTER].param)
- kfree(ch->device[MASTER].param, M_ATA);
- ch->device[MASTER].param = NULL;
- }
- if (misdev & ATA_ATA_SLAVE || misdev & ATA_ATAPI_SLAVE) {
- if (ch->device[SLAVE].param)
- kfree(ch->device[SLAVE].param, M_ATA);
- ch->device[SLAVE].param = NULL;
- }
- }
- if ((newdev = ~devices & ch->devices)) {
- if (newdev & ATA_ATA_MASTER)
- if (ata_getparam(&ch->device[MASTER], ATA_C_ATA_IDENTIFY))
- ch->devices &= ~ATA_ATA_MASTER;
- if (newdev & ATA_ATA_SLAVE)
- if (ata_getparam(&ch->device[SLAVE], ATA_C_ATA_IDENTIFY))
- ch->devices &= ~ATA_ATA_SLAVE;
- if (newdev & ATA_ATAPI_MASTER)
- if (ata_getparam(&ch->device[MASTER], ATA_C_ATAPI_IDENTIFY))
- ch->devices &= ~ATA_ATAPI_MASTER;
- if (newdev & ATA_ATAPI_SLAVE)
- if (ata_getparam(&ch->device[SLAVE], ATA_C_ATAPI_IDENTIFY))
- ch->devices &= ~ATA_ATAPI_SLAVE;
- }
- newdev = ~devices & ch->devices;
- if (!misdev && newdev)
- kprintf("\n");
-#if NATADISK > 0
- if (newdev & ATA_ATA_MASTER && !ch->device[MASTER].driver)
- ad_attach(&ch->device[MASTER], 1);
- else if (ch->devices & ATA_ATA_MASTER && ch->device[MASTER].driver) {
- ata_getparam(&ch->device[MASTER], ATA_C_ATA_IDENTIFY);
- ad_reinit(&ch->device[MASTER]);
- }
- if (newdev & ATA_ATA_SLAVE && !ch->device[SLAVE].driver)
- ad_attach(&ch->device[SLAVE], 1);
- else if (ch->devices & (ATA_ATA_SLAVE) && ch->device[SLAVE].driver) {
- ata_getparam(&ch->device[SLAVE], ATA_C_ATA_IDENTIFY);
- ad_reinit(&ch->device[SLAVE]);
- }
-#endif
-#if DEV_ATAPIALL
- if (newdev & ATA_ATAPI_MASTER && !ch->device[MASTER].driver)
- atapi_attach(&ch->device[MASTER], 1);
- else if (ch->devices & (ATA_ATAPI_MASTER) && ch->device[MASTER].driver) {
- ata_getparam(&ch->device[MASTER], ATA_C_ATAPI_IDENTIFY);
- atapi_reinit(&ch->device[MASTER]);
- }
- if (newdev & ATA_ATAPI_SLAVE && !ch->device[SLAVE].driver)
- atapi_attach(&ch->device[SLAVE], 1);
- else if (ch->devices & (ATA_ATAPI_SLAVE) && ch->device[SLAVE].driver) {
- ata_getparam(&ch->device[SLAVE], ATA_C_ATAPI_IDENTIFY);
- atapi_reinit(&ch->device[SLAVE]);
- }
-#endif
-#if NATAPICAM > 0
- if (ch->devices & (ATA_ATAPI_MASTER | ATA_ATAPI_SLAVE))
- atapi_cam_reinit_bus(ch);
-#endif
- kprintf("done\n");
- ATA_UNLOCK_CH(ch);
- ata_start(ch);
- return 0;
-}
-
-static int
-ata_service(struct ata_channel *ch)
-{
- /* do we have a SERVICE request from the drive ? */
- if ((ch->status & (ATA_S_SERVICE|ATA_S_ERROR|ATA_S_DRQ)) == ATA_S_SERVICE) {
- ATA_OUTB(ch->r_bmio, ATA_BMSTAT_PORT,
- ata_dmastatus(ch) | ATA_BMSTAT_INTERRUPT);
-#if NATADISK > 0
- if ((ATA_INB(ch->r_io, ATA_DRIVE) & ATA_SLAVE) == ATA_MASTER) {
- if ((ch->devices & ATA_ATA_MASTER) && ch->device[MASTER].driver)
- return ad_service((struct ad_softc *)
- ch->device[MASTER].driver, 0);
- }
- else {
- if ((ch->devices & ATA_ATA_SLAVE) && ch->device[SLAVE].driver)
- return ad_service((struct ad_softc *)
- ch->device[SLAVE].driver, 0);
- }
-#endif
- }
- return ATA_OP_FINISHED;
-}
-
-int
-ata_wait(struct ata_device *atadev, u_int8_t mask)
-{
- int timeout = 0;
-
- DELAY(1);
- while (timeout < 5000000) { /* timeout 5 secs */
- atadev->channel->status = ATA_INB(atadev->channel->r_io, ATA_STATUS);
-
- /* if drive fails status, reselect the drive just to be sure */
- if (atadev->channel->status == 0xff) {
- ata_prtdev(atadev, "no status, reselecting device\n");
- ATA_OUTB(atadev->channel->r_io, ATA_DRIVE, ATA_D_IBM|atadev->unit);
- DELAY(10);
- atadev->channel->status = ATA_INB(atadev->channel->r_io,ATA_STATUS);
- if (atadev->channel->status == 0xff)
- return -1;
- }
-
- /* are we done ? */
- if (!(atadev->channel->status & ATA_S_BUSY))
- break;
-
- if (timeout > 1000) {
- timeout += 1000;
- DELAY(1000);
- }
- else {
- timeout += 10;
- DELAY(10);
- }
- }
- if (atadev->channel->status & ATA_S_ERROR)
- atadev->channel->error = ATA_INB(atadev->channel->r_io, ATA_ERROR);
- if (timeout >= 5000000)
- return -1;
- if (!mask)
- return (atadev->channel->status & ATA_S_ERROR);
-
- /* Wait 50 msec for bits wanted. */
- timeout = 5000;
- while (timeout--) {
- atadev->channel->status = ATA_INB(atadev->channel->r_io, ATA_STATUS);
- if ((atadev->channel->status & mask) == mask) {
- if (atadev->channel->status & ATA_S_ERROR)
- atadev->channel->error=ATA_INB(atadev->channel->r_io,ATA_ERROR);
- return (atadev->channel->status & ATA_S_ERROR);
- }
- DELAY (10);
- }
- return -1;