2003-08-24 09:22:26 +00:00
|
|
|
/*-
|
2012-01-15 13:23:18 +00:00
|
|
|
* Copyright (c) 1998 - 2008 Søren Schmidt <sos@FreeBSD.org>
|
2003-08-24 09:22:26 +00:00
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2003-08-24 17:55:58 +00:00
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
2003-08-24 09:22:26 +00:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/kernel.h>
|
This is the much rumoured ATA mkIII update that I've been working on.
o ATA is now fully newbus'd and split into modules.
This means that on a modern system you just load "atapci and ata"
to get the base support, and then one or more of the device
subdrivers "atadisk atapicd atapifd atapist ataraid".
All can be loaded/unloaded anytime, but for obvious reasons you
dont want to unload atadisk when you have mounted filesystems.
o The device identify part of the probe has been rewritten to fix
the problems with odd devices the old had, and to try to remove
so of the long delays some HW could provoke. Also probing is done
without the need for interrupts, making earlier probing possible.
o SATA devices can be hot inserted/removed and devices will be created/
removed in /dev accordingly.
NOTE: only supported on controllers that has this feature:
Promise and Silicon Image for now.
On other controllers the usual atacontrol detach/attach dance is
still needed.
o Support for "atomic" composite ATA requests used for RAID.
o ATA RAID support has been rewritten and and now supports these
metadata formats:
"Adaptec HostRAID"
"Highpoint V2 RocketRAID"
"Highpoint V3 RocketRAID"
"Intel MatrixRAID"
"Integrated Technology Express"
"LSILogic V2 MegaRAID"
"LSILogic V3 MegaRAID"
"Promise FastTrak"
"Silicon Image Medley"
"FreeBSD PseudoRAID"
o Update the ioctl API to match new RAID levels etc.
o Update atacontrol to know about the new RAID levels etc
NOTE: you need to recompile atacontrol with the new sys/ata.h,
make world will take care of that.
NOTE2: that rebuild is done differently from the old system as
the rebuild is now done piggybacked on read requests to the
array, so atacontrol simply starts a background "dd" to rebuild
the array.
o The reinit code has been worked over to be much more robust.
o The timeout code has been overhauled for races.
o Support of new chipsets.
o Lots of fixes for bugs found while doing the modulerization and
reviewing the old code.
Missing or changed features from current ATA:
o atapi-cd no longer has support for ATAPI changers. Todays its
much cheaper and alot faster to copy those CD images to disk
and serve them from there. Besides they dont seem to be made
anymore, maybe for that exact reason.
o ATA RAID can only read metadata from all the above metadata formats,
not write all of them (Promise and Highpoint V2 so far). This means
that arrays can be picked up from the BIOS, but they cannot be
created from FreeBSD. There is more to it than just the missing
write metadata support, those formats are not unique to a given
controller like Promise and Highpoint formats, instead they exist
for several types, and even worse, some controllers can have
different formats and its impossible to tell which one.
The outcome is that we cannot reliably create the metadata of those
formats and be sure the controller BIOS will understand it.
However write support is needed to update/fail/rebuild the arrays
properly so it sits fairly high on the TODO list.
o So far atapicam is not supported with these changes. When/if this
will change is up to the maintainer of atapi-cam so go there for
questions.
HW donated by: Webveveriet AS
HW donated by: Frode Nordahl
HW donated by: Yahoo!
HW donated by: Sentex
Patience by: Vife and my boys (and even the cats)
2005-03-30 12:03:40 +00:00
|
|
|
#include <sys/endian.h>
|
|
|
|
#include <sys/ata.h>
|
2015-08-07 14:38:26 +00:00
|
|
|
#include <sys/bio.h>
|
2003-08-24 09:22:26 +00:00
|
|
|
#include <sys/conf.h>
|
This is the much rumoured ATA mkIII update that I've been working on.
o ATA is now fully newbus'd and split into modules.
This means that on a modern system you just load "atapci and ata"
to get the base support, and then one or more of the device
subdrivers "atadisk atapicd atapifd atapist ataraid".
All can be loaded/unloaded anytime, but for obvious reasons you
dont want to unload atadisk when you have mounted filesystems.
o The device identify part of the probe has been rewritten to fix
the problems with odd devices the old had, and to try to remove
so of the long delays some HW could provoke. Also probing is done
without the need for interrupts, making earlier probing possible.
o SATA devices can be hot inserted/removed and devices will be created/
removed in /dev accordingly.
NOTE: only supported on controllers that has this feature:
Promise and Silicon Image for now.
On other controllers the usual atacontrol detach/attach dance is
still needed.
o Support for "atomic" composite ATA requests used for RAID.
o ATA RAID support has been rewritten and and now supports these
metadata formats:
"Adaptec HostRAID"
"Highpoint V2 RocketRAID"
"Highpoint V3 RocketRAID"
"Intel MatrixRAID"
"Integrated Technology Express"
"LSILogic V2 MegaRAID"
"LSILogic V3 MegaRAID"
"Promise FastTrak"
"Silicon Image Medley"
"FreeBSD PseudoRAID"
o Update the ioctl API to match new RAID levels etc.
o Update atacontrol to know about the new RAID levels etc
NOTE: you need to recompile atacontrol with the new sys/ata.h,
make world will take care of that.
NOTE2: that rebuild is done differently from the old system as
the rebuild is now done piggybacked on read requests to the
array, so atacontrol simply starts a background "dd" to rebuild
the array.
o The reinit code has been worked over to be much more robust.
o The timeout code has been overhauled for races.
o Support of new chipsets.
o Lots of fixes for bugs found while doing the modulerization and
reviewing the old code.
Missing or changed features from current ATA:
o atapi-cd no longer has support for ATAPI changers. Todays its
much cheaper and alot faster to copy those CD images to disk
and serve them from there. Besides they dont seem to be made
anymore, maybe for that exact reason.
o ATA RAID can only read metadata from all the above metadata formats,
not write all of them (Promise and Highpoint V2 so far). This means
that arrays can be picked up from the BIOS, but they cannot be
created from FreeBSD. There is more to it than just the missing
write metadata support, those formats are not unique to a given
controller like Promise and Highpoint formats, instead they exist
for several types, and even worse, some controllers can have
different formats and its impossible to tell which one.
The outcome is that we cannot reliably create the metadata of those
formats and be sure the controller BIOS will understand it.
However write support is needed to update/fail/rebuild the arrays
properly so it sits fairly high on the TODO list.
o So far atapicam is not supported with these changes. When/if this
will change is up to the maintainer of atapi-cam so go there for
questions.
HW donated by: Webveveriet AS
HW donated by: Frode Nordahl
HW donated by: Yahoo!
HW donated by: Sentex
Patience by: Vife and my boys (and even the cats)
2005-03-30 12:03:40 +00:00
|
|
|
#include <sys/ctype.h>
|
2003-08-24 09:22:26 +00:00
|
|
|
#include <sys/bus.h>
|
2004-01-11 22:08:34 +00:00
|
|
|
#include <sys/sema.h>
|
2003-08-24 09:22:26 +00:00
|
|
|
#include <sys/taskqueue.h>
|
2004-01-14 21:26:35 +00:00
|
|
|
#include <vm/uma.h>
|
2003-08-24 09:22:26 +00:00
|
|
|
#include <machine/bus.h>
|
|
|
|
#include <sys/rman.h>
|
|
|
|
#include <dev/ata/ata-all.h>
|
This is the much rumoured ATA mkIII update that I've been working on.
o ATA is now fully newbus'd and split into modules.
This means that on a modern system you just load "atapci and ata"
to get the base support, and then one or more of the device
subdrivers "atadisk atapicd atapifd atapist ataraid".
All can be loaded/unloaded anytime, but for obvious reasons you
dont want to unload atadisk when you have mounted filesystems.
o The device identify part of the probe has been rewritten to fix
the problems with odd devices the old had, and to try to remove
so of the long delays some HW could provoke. Also probing is done
without the need for interrupts, making earlier probing possible.
o SATA devices can be hot inserted/removed and devices will be created/
removed in /dev accordingly.
NOTE: only supported on controllers that has this feature:
Promise and Silicon Image for now.
On other controllers the usual atacontrol detach/attach dance is
still needed.
o Support for "atomic" composite ATA requests used for RAID.
o ATA RAID support has been rewritten and and now supports these
metadata formats:
"Adaptec HostRAID"
"Highpoint V2 RocketRAID"
"Highpoint V3 RocketRAID"
"Intel MatrixRAID"
"Integrated Technology Express"
"LSILogic V2 MegaRAID"
"LSILogic V3 MegaRAID"
"Promise FastTrak"
"Silicon Image Medley"
"FreeBSD PseudoRAID"
o Update the ioctl API to match new RAID levels etc.
o Update atacontrol to know about the new RAID levels etc
NOTE: you need to recompile atacontrol with the new sys/ata.h,
make world will take care of that.
NOTE2: that rebuild is done differently from the old system as
the rebuild is now done piggybacked on read requests to the
array, so atacontrol simply starts a background "dd" to rebuild
the array.
o The reinit code has been worked over to be much more robust.
o The timeout code has been overhauled for races.
o Support of new chipsets.
o Lots of fixes for bugs found while doing the modulerization and
reviewing the old code.
Missing or changed features from current ATA:
o atapi-cd no longer has support for ATAPI changers. Todays its
much cheaper and alot faster to copy those CD images to disk
and serve them from there. Besides they dont seem to be made
anymore, maybe for that exact reason.
o ATA RAID can only read metadata from all the above metadata formats,
not write all of them (Promise and Highpoint V2 so far). This means
that arrays can be picked up from the BIOS, but they cannot be
created from FreeBSD. There is more to it than just the missing
write metadata support, those formats are not unique to a given
controller like Promise and Highpoint formats, instead they exist
for several types, and even worse, some controllers can have
different formats and its impossible to tell which one.
The outcome is that we cannot reliably create the metadata of those
formats and be sure the controller BIOS will understand it.
However write support is needed to update/fail/rebuild the arrays
properly so it sits fairly high on the TODO list.
o So far atapicam is not supported with these changes. When/if this
will change is up to the maintainer of atapi-cam so go there for
questions.
HW donated by: Webveveriet AS
HW donated by: Frode Nordahl
HW donated by: Yahoo!
HW donated by: Sentex
Patience by: Vife and my boys (and even the cats)
2005-03-30 12:03:40 +00:00
|
|
|
#include <dev/ata/ata-pci.h>
|
|
|
|
#include <ata_if.h>
|
2003-08-24 09:22:26 +00:00
|
|
|
|
2015-08-07 14:38:26 +00:00
|
|
|
#include <vm/vm.h>
|
|
|
|
#include <vm/pmap.h>
|
|
|
|
|
|
|
|
#include <cam/cam.h>
|
|
|
|
#include <cam/cam_ccb.h>
|
|
|
|
|
2003-08-24 09:22:26 +00:00
|
|
|
/* prototypes */
|
2006-01-18 09:14:55 +00:00
|
|
|
static int ata_generic_status(device_t dev);
|
2009-10-31 13:24:14 +00:00
|
|
|
static int ata_wait(struct ata_channel *ch, int unit, u_int8_t);
|
2003-08-25 09:01:49 +00:00
|
|
|
static void ata_pio_read(struct ata_request *, int);
|
|
|
|
static void ata_pio_write(struct ata_request *, int);
|
2007-12-13 11:47:36 +00:00
|
|
|
static void ata_tf_read(struct ata_request *);
|
|
|
|
static void ata_tf_write(struct ata_request *);
|
2003-08-24 09:22:26 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* low level ATA functions
|
|
|
|
*/
|
|
|
|
void
|
2005-04-30 16:22:07 +00:00
|
|
|
ata_generic_hw(device_t dev)
|
2003-08-24 09:22:26 +00:00
|
|
|
{
|
2005-04-30 16:22:07 +00:00
|
|
|
struct ata_channel *ch = device_get_softc(dev);
|
|
|
|
|
2004-09-26 11:48:43 +00:00
|
|
|
ch->hw.begin_transaction = ata_begin_transaction;
|
|
|
|
ch->hw.end_transaction = ata_end_transaction;
|
2006-01-18 09:14:55 +00:00
|
|
|
ch->hw.status = ata_generic_status;
|
2008-04-10 13:05:05 +00:00
|
|
|
ch->hw.softreset = NULL;
|
2004-04-13 09:44:20 +00:00
|
|
|
ch->hw.command = ata_generic_command;
|
2007-12-13 11:47:36 +00:00
|
|
|
ch->hw.tf_read = ata_tf_read;
|
|
|
|
ch->hw.tf_write = ata_tf_write;
|
2008-04-10 13:05:05 +00:00
|
|
|
ch->hw.pm_read = NULL;
|
|
|
|
ch->hw.pm_write = NULL;
|
2003-08-24 09:22:26 +00:00
|
|
|
}
|
|
|
|
|
2005-04-21 11:13:39 +00:00
|
|
|
/* must be called with ATA channel locked and state_mtx held */
|
2006-01-18 09:14:55 +00:00
|
|
|
int
|
2004-09-26 11:48:43 +00:00
|
|
|
ata_begin_transaction(struct ata_request *request)
|
2003-08-24 09:22:26 +00:00
|
|
|
{
|
2008-04-10 13:05:05 +00:00
|
|
|
struct ata_channel *ch = device_get_softc(request->parent);
|
2005-12-05 22:31:55 +00:00
|
|
|
int dummy, error;
|
2004-01-11 22:08:34 +00:00
|
|
|
|
2004-09-26 11:48:43 +00:00
|
|
|
ATA_DEBUG_RQ(request, "begin transaction");
|
2004-01-11 22:08:34 +00:00
|
|
|
|
2003-08-24 09:22:26 +00:00
|
|
|
/* disable ATAPI DMA writes if HW doesn't support it */
|
2009-12-06 00:10:13 +00:00
|
|
|
if ((ch->flags & ATA_NO_ATAPI_DMA) &&
|
|
|
|
(request->flags & ATA_R_ATAPI) == ATA_R_ATAPI)
|
|
|
|
request->flags &= ~ATA_R_DMA;
|
2004-04-13 09:44:20 +00:00
|
|
|
if ((ch->flags & ATA_ATAPI_DMA_RO) &&
|
2003-10-09 14:33:06 +00:00
|
|
|
((request->flags & (ATA_R_ATAPI | ATA_R_DMA | ATA_R_WRITE)) ==
|
|
|
|
(ATA_R_ATAPI | ATA_R_DMA | ATA_R_WRITE)))
|
2003-08-24 09:22:26 +00:00
|
|
|
request->flags &= ~ATA_R_DMA;
|
|
|
|
|
|
|
|
switch (request->flags & (ATA_R_ATAPI | ATA_R_DMA)) {
|
|
|
|
|
|
|
|
/* ATA PIO data transfer and control commands */
|
|
|
|
default:
|
|
|
|
{
|
2004-01-11 22:08:34 +00:00
|
|
|
/* record command direction here as our request might be gone later */
|
2003-08-24 09:22:26 +00:00
|
|
|
int write = (request->flags & ATA_R_WRITE);
|
|
|
|
|
|
|
|
/* issue command */
|
2005-05-03 07:55:07 +00:00
|
|
|
if (ch->hw.command(request)) {
|
2009-10-31 13:24:14 +00:00
|
|
|
device_printf(request->parent, "error issuing %s command\n",
|
2004-08-16 09:32:35 +00:00
|
|
|
ata_cmd2str(request));
|
2003-08-24 09:22:26 +00:00
|
|
|
request->result = EIO;
|
2005-04-21 11:13:39 +00:00
|
|
|
goto begin_finished;
|
2003-08-24 09:22:26 +00:00
|
|
|
}
|
|
|
|
|
2004-07-23 17:01:47 +00:00
|
|
|
/* device reset doesn't interrupt */
|
This is the much rumoured ATA mkIII update that I've been working on.
o ATA is now fully newbus'd and split into modules.
This means that on a modern system you just load "atapci and ata"
to get the base support, and then one or more of the device
subdrivers "atadisk atapicd atapifd atapist ataraid".
All can be loaded/unloaded anytime, but for obvious reasons you
dont want to unload atadisk when you have mounted filesystems.
o The device identify part of the probe has been rewritten to fix
the problems with odd devices the old had, and to try to remove
so of the long delays some HW could provoke. Also probing is done
without the need for interrupts, making earlier probing possible.
o SATA devices can be hot inserted/removed and devices will be created/
removed in /dev accordingly.
NOTE: only supported on controllers that has this feature:
Promise and Silicon Image for now.
On other controllers the usual atacontrol detach/attach dance is
still needed.
o Support for "atomic" composite ATA requests used for RAID.
o ATA RAID support has been rewritten and and now supports these
metadata formats:
"Adaptec HostRAID"
"Highpoint V2 RocketRAID"
"Highpoint V3 RocketRAID"
"Intel MatrixRAID"
"Integrated Technology Express"
"LSILogic V2 MegaRAID"
"LSILogic V3 MegaRAID"
"Promise FastTrak"
"Silicon Image Medley"
"FreeBSD PseudoRAID"
o Update the ioctl API to match new RAID levels etc.
o Update atacontrol to know about the new RAID levels etc
NOTE: you need to recompile atacontrol with the new sys/ata.h,
make world will take care of that.
NOTE2: that rebuild is done differently from the old system as
the rebuild is now done piggybacked on read requests to the
array, so atacontrol simply starts a background "dd" to rebuild
the array.
o The reinit code has been worked over to be much more robust.
o The timeout code has been overhauled for races.
o Support of new chipsets.
o Lots of fixes for bugs found while doing the modulerization and
reviewing the old code.
Missing or changed features from current ATA:
o atapi-cd no longer has support for ATAPI changers. Todays its
much cheaper and alot faster to copy those CD images to disk
and serve them from there. Besides they dont seem to be made
anymore, maybe for that exact reason.
o ATA RAID can only read metadata from all the above metadata formats,
not write all of them (Promise and Highpoint V2 so far). This means
that arrays can be picked up from the BIOS, but they cannot be
created from FreeBSD. There is more to it than just the missing
write metadata support, those formats are not unique to a given
controller like Promise and Highpoint formats, instead they exist
for several types, and even worse, some controllers can have
different formats and its impossible to tell which one.
The outcome is that we cannot reliably create the metadata of those
formats and be sure the controller BIOS will understand it.
However write support is needed to update/fail/rebuild the arrays
properly so it sits fairly high on the TODO list.
o So far atapicam is not supported with these changes. When/if this
will change is up to the maintainer of atapi-cam so go there for
questions.
HW donated by: Webveveriet AS
HW donated by: Frode Nordahl
HW donated by: Yahoo!
HW donated by: Sentex
Patience by: Vife and my boys (and even the cats)
2005-03-30 12:03:40 +00:00
|
|
|
if (request->u.ata.command == ATA_DEVICE_RESET) {
|
2007-04-06 16:18:59 +00:00
|
|
|
|
2004-07-24 19:03:28 +00:00
|
|
|
int timeout = 1000000;
|
|
|
|
do {
|
|
|
|
DELAY(10);
|
|
|
|
request->status = ATA_IDX_INB(ch, ATA_STATUS);
|
|
|
|
} while (request->status & ATA_S_BUSY && timeout--);
|
2004-08-05 21:13:41 +00:00
|
|
|
if (request->status & ATA_S_ERROR)
|
2004-07-23 17:01:47 +00:00
|
|
|
request->error = ATA_IDX_INB(ch, ATA_ERROR);
|
2012-10-26 20:03:08 +00:00
|
|
|
ch->hw.tf_read(request);
|
2005-04-21 11:13:39 +00:00
|
|
|
goto begin_finished;
|
2004-07-23 17:01:47 +00:00
|
|
|
}
|
|
|
|
|
2003-08-24 09:22:26 +00:00
|
|
|
/* if write command output the data */
|
|
|
|
if (write) {
|
2009-10-31 13:24:14 +00:00
|
|
|
if (ata_wait(ch, request->unit, (ATA_S_READY | ATA_S_DRQ)) < 0) {
|
|
|
|
device_printf(request->parent,
|
2005-09-14 12:45:06 +00:00
|
|
|
"timeout waiting for write DRQ\n");
|
2003-08-24 09:22:26 +00:00
|
|
|
request->result = EIO;
|
2005-04-21 11:13:39 +00:00
|
|
|
goto begin_finished;
|
2003-08-24 09:22:26 +00:00
|
|
|
}
|
|
|
|
ata_pio_write(request, request->transfersize);
|
|
|
|
}
|
|
|
|
}
|
2005-04-21 11:13:39 +00:00
|
|
|
goto begin_continue;
|
2003-08-24 09:22:26 +00:00
|
|
|
|
|
|
|
/* ATA DMA data transfer commands */
|
|
|
|
case ATA_R_DMA:
|
2003-10-21 19:20:37 +00:00
|
|
|
/* check sanity, setup SG list and DMA engine */
|
2008-04-10 13:05:05 +00:00
|
|
|
if ((error = ch->dma.load(request, NULL, &dummy))) {
|
2009-10-31 13:24:14 +00:00
|
|
|
device_printf(request->parent, "setting up DMA failed\n");
|
2005-12-05 22:31:55 +00:00
|
|
|
request->result = error;
|
2005-04-21 11:13:39 +00:00
|
|
|
goto begin_finished;
|
2003-08-24 09:22:26 +00:00
|
|
|
}
|
|
|
|
|
2010-06-06 14:09:48 +00:00
|
|
|
/* start DMA engine if necessary */
|
|
|
|
if ((ch->flags & ATA_DMA_BEFORE_CMD) &&
|
|
|
|
ch->dma.start && ch->dma.start(request)) {
|
|
|
|
device_printf(request->parent, "error starting DMA\n");
|
|
|
|
request->result = EIO;
|
|
|
|
goto begin_finished;
|
|
|
|
}
|
|
|
|
|
2003-08-24 09:22:26 +00:00
|
|
|
/* issue command */
|
2005-05-03 07:55:07 +00:00
|
|
|
if (ch->hw.command(request)) {
|
2009-10-31 13:24:14 +00:00
|
|
|
device_printf(request->parent, "error issuing %s command\n",
|
2004-08-16 09:32:35 +00:00
|
|
|
ata_cmd2str(request));
|
2003-08-24 09:22:26 +00:00
|
|
|
request->result = EIO;
|
2005-04-21 11:13:39 +00:00
|
|
|
goto begin_finished;
|
2003-08-24 09:22:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* start DMA engine */
|
2010-06-06 14:09:48 +00:00
|
|
|
if (!(ch->flags & ATA_DMA_BEFORE_CMD) &&
|
|
|
|
ch->dma.start && ch->dma.start(request)) {
|
2009-10-31 13:24:14 +00:00
|
|
|
device_printf(request->parent, "error starting DMA\n");
|
2003-08-24 09:22:26 +00:00
|
|
|
request->result = EIO;
|
2005-04-21 11:13:39 +00:00
|
|
|
goto begin_finished;
|
2003-08-24 09:22:26 +00:00
|
|
|
}
|
2005-04-21 11:13:39 +00:00
|
|
|
goto begin_continue;
|
2003-08-24 09:22:26 +00:00
|
|
|
|
|
|
|
/* ATAPI PIO commands */
|
|
|
|
case ATA_R_ATAPI:
|
|
|
|
/* is this just a POLL DSC command ? */
|
|
|
|
if (request->u.atapi.ccb[0] == ATAPI_POLL_DSC) {
|
2009-10-31 13:24:14 +00:00
|
|
|
ATA_IDX_OUTB(ch, ATA_DRIVE, ATA_D_IBM | ATA_DEV(request->unit));
|
2003-08-24 09:22:26 +00:00
|
|
|
DELAY(10);
|
2005-04-06 10:22:56 +00:00
|
|
|
if (!(ATA_IDX_INB(ch, ATA_ALTSTAT) & ATA_S_DSC))
|
2003-08-24 09:22:26 +00:00
|
|
|
request->result = EBUSY;
|
2005-04-21 11:13:39 +00:00
|
|
|
goto begin_finished;
|
2003-08-24 09:22:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* start ATAPI operation */
|
2005-05-03 07:55:07 +00:00
|
|
|
if (ch->hw.command(request)) {
|
2009-10-31 13:24:14 +00:00
|
|
|
device_printf(request->parent, "error issuing ATA PACKET command\n");
|
2003-08-24 09:22:26 +00:00
|
|
|
request->result = EIO;
|
2005-04-21 11:13:39 +00:00
|
|
|
goto begin_finished;
|
2003-08-24 09:22:26 +00:00
|
|
|
}
|
2005-04-21 11:13:39 +00:00
|
|
|
goto begin_continue;
|
2003-08-24 09:22:26 +00:00
|
|
|
|
2005-04-30 16:22:07 +00:00
|
|
|
/* ATAPI DMA commands */
|
2003-08-24 09:22:26 +00:00
|
|
|
case ATA_R_ATAPI|ATA_R_DMA:
|
|
|
|
/* is this just a POLL DSC command ? */
|
|
|
|
if (request->u.atapi.ccb[0] == ATAPI_POLL_DSC) {
|
2009-10-31 13:24:14 +00:00
|
|
|
ATA_IDX_OUTB(ch, ATA_DRIVE, ATA_D_IBM | ATA_DEV(request->unit));
|
2003-08-24 09:22:26 +00:00
|
|
|
DELAY(10);
|
2005-04-06 10:22:56 +00:00
|
|
|
if (!(ATA_IDX_INB(ch, ATA_ALTSTAT) & ATA_S_DSC))
|
2003-08-24 09:22:26 +00:00
|
|
|
request->result = EBUSY;
|
2005-04-21 11:13:39 +00:00
|
|
|
goto begin_finished;
|
2003-08-24 09:22:26 +00:00
|
|
|
}
|
|
|
|
|
2003-10-21 19:20:37 +00:00
|
|
|
/* check sanity, setup SG list and DMA engine */
|
2008-04-10 13:05:05 +00:00
|
|
|
if ((error = ch->dma.load(request, NULL, &dummy))) {
|
2009-10-31 13:24:14 +00:00
|
|
|
device_printf(request->parent, "setting up DMA failed\n");
|
2005-12-05 22:31:55 +00:00
|
|
|
request->result = error;
|
2005-04-21 11:13:39 +00:00
|
|
|
goto begin_finished;
|
2003-08-24 09:22:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* start ATAPI operation */
|
2005-05-03 07:55:07 +00:00
|
|
|
if (ch->hw.command(request)) {
|
2009-10-31 13:24:14 +00:00
|
|
|
device_printf(request->parent, "error issuing ATA PACKET command\n");
|
2003-08-24 09:22:26 +00:00
|
|
|
request->result = EIO;
|
2005-04-21 11:13:39 +00:00
|
|
|
goto begin_finished;
|
2003-08-24 09:22:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* start DMA engine */
|
2008-04-10 13:05:05 +00:00
|
|
|
if (ch->dma.start && ch->dma.start(request)) {
|
2003-08-24 09:22:26 +00:00
|
|
|
request->result = EIO;
|
2005-04-21 11:13:39 +00:00
|
|
|
goto begin_finished;
|
2003-08-24 09:22:26 +00:00
|
|
|
}
|
2005-04-21 11:13:39 +00:00
|
|
|
goto begin_continue;
|
2003-08-24 09:22:26 +00:00
|
|
|
}
|
2005-04-21 11:13:39 +00:00
|
|
|
/* NOT REACHED */
|
|
|
|
printf("ata_begin_transaction OOPS!!!\n");
|
2003-10-07 13:45:56 +00:00
|
|
|
|
2005-04-21 11:13:39 +00:00
|
|
|
begin_finished:
|
2008-05-08 17:55:44 +00:00
|
|
|
if (ch->dma.unload) {
|
|
|
|
ch->dma.unload(request);
|
|
|
|
}
|
2003-10-07 13:45:56 +00:00
|
|
|
return ATA_OP_FINISHED;
|
2005-04-21 11:13:39 +00:00
|
|
|
|
|
|
|
begin_continue:
|
|
|
|
callout_reset(&request->callout, request->timeout * hz,
|
|
|
|
(timeout_t*)ata_timeout, request);
|
|
|
|
return ATA_OP_CONTINUES;
|
2003-08-24 09:22:26 +00:00
|
|
|
}
|
|
|
|
|
2005-04-21 11:13:39 +00:00
|
|
|
/* must be called with ATA channel locked and state_mtx held */
|
2006-01-18 09:14:55 +00:00
|
|
|
int
|
2004-09-26 11:48:43 +00:00
|
|
|
ata_end_transaction(struct ata_request *request)
|
2003-08-24 09:22:26 +00:00
|
|
|
{
|
2008-04-10 13:05:05 +00:00
|
|
|
struct ata_channel *ch = device_get_softc(request->parent);
|
2003-08-24 09:22:26 +00:00
|
|
|
int length;
|
|
|
|
|
2004-09-26 11:48:43 +00:00
|
|
|
ATA_DEBUG_RQ(request, "end transaction");
|
2004-01-11 22:08:34 +00:00
|
|
|
|
2003-09-08 08:32:25 +00:00
|
|
|
/* clear interrupt and get status */
|
2003-09-16 15:21:37 +00:00
|
|
|
request->status = ATA_IDX_INB(ch, ATA_STATUS);
|
2003-08-24 09:22:26 +00:00
|
|
|
|
2003-11-02 22:04:53 +00:00
|
|
|
switch (request->flags & (ATA_R_ATAPI | ATA_R_DMA | ATA_R_CONTROL)) {
|
2003-08-24 09:22:26 +00:00
|
|
|
|
|
|
|
/* ATA PIO data transfer and control commands */
|
|
|
|
default:
|
This is the much rumoured ATA mkIII update that I've been working on.
o ATA is now fully newbus'd and split into modules.
This means that on a modern system you just load "atapci and ata"
to get the base support, and then one or more of the device
subdrivers "atadisk atapicd atapifd atapist ataraid".
All can be loaded/unloaded anytime, but for obvious reasons you
dont want to unload atadisk when you have mounted filesystems.
o The device identify part of the probe has been rewritten to fix
the problems with odd devices the old had, and to try to remove
so of the long delays some HW could provoke. Also probing is done
without the need for interrupts, making earlier probing possible.
o SATA devices can be hot inserted/removed and devices will be created/
removed in /dev accordingly.
NOTE: only supported on controllers that has this feature:
Promise and Silicon Image for now.
On other controllers the usual atacontrol detach/attach dance is
still needed.
o Support for "atomic" composite ATA requests used for RAID.
o ATA RAID support has been rewritten and and now supports these
metadata formats:
"Adaptec HostRAID"
"Highpoint V2 RocketRAID"
"Highpoint V3 RocketRAID"
"Intel MatrixRAID"
"Integrated Technology Express"
"LSILogic V2 MegaRAID"
"LSILogic V3 MegaRAID"
"Promise FastTrak"
"Silicon Image Medley"
"FreeBSD PseudoRAID"
o Update the ioctl API to match new RAID levels etc.
o Update atacontrol to know about the new RAID levels etc
NOTE: you need to recompile atacontrol with the new sys/ata.h,
make world will take care of that.
NOTE2: that rebuild is done differently from the old system as
the rebuild is now done piggybacked on read requests to the
array, so atacontrol simply starts a background "dd" to rebuild
the array.
o The reinit code has been worked over to be much more robust.
o The timeout code has been overhauled for races.
o Support of new chipsets.
o Lots of fixes for bugs found while doing the modulerization and
reviewing the old code.
Missing or changed features from current ATA:
o atapi-cd no longer has support for ATAPI changers. Todays its
much cheaper and alot faster to copy those CD images to disk
and serve them from there. Besides they dont seem to be made
anymore, maybe for that exact reason.
o ATA RAID can only read metadata from all the above metadata formats,
not write all of them (Promise and Highpoint V2 so far). This means
that arrays can be picked up from the BIOS, but they cannot be
created from FreeBSD. There is more to it than just the missing
write metadata support, those formats are not unique to a given
controller like Promise and Highpoint formats, instead they exist
for several types, and even worse, some controllers can have
different formats and its impossible to tell which one.
The outcome is that we cannot reliably create the metadata of those
formats and be sure the controller BIOS will understand it.
However write support is needed to update/fail/rebuild the arrays
properly so it sits fairly high on the TODO list.
o So far atapicam is not supported with these changes. When/if this
will change is up to the maintainer of atapi-cam so go there for
questions.
HW donated by: Webveveriet AS
HW donated by: Frode Nordahl
HW donated by: Yahoo!
HW donated by: Sentex
Patience by: Vife and my boys (and even the cats)
2005-03-30 12:03:40 +00:00
|
|
|
|
|
|
|
/* on timeouts we have no data or anything so just return */
|
2005-03-02 03:59:28 +00:00
|
|
|
if (request->flags & ATA_R_TIMEOUT)
|
2005-04-21 11:13:39 +00:00
|
|
|
goto end_finished;
|
2003-08-24 09:22:26 +00:00
|
|
|
|
2012-10-26 20:03:08 +00:00
|
|
|
/* Read back registers to the request struct. */
|
|
|
|
if ((request->status & ATA_S_ERROR) ||
|
|
|
|
(request->flags & (ATA_R_CONTROL | ATA_R_NEEDRESULT))) {
|
2007-12-13 11:47:36 +00:00
|
|
|
ch->hw.tf_read(request);
|
2003-11-02 22:04:53 +00:00
|
|
|
}
|
|
|
|
|
2003-08-24 09:22:26 +00:00
|
|
|
/* if we got an error we are done with the HW */
|
|
|
|
if (request->status & ATA_S_ERROR) {
|
|
|
|
request->error = ATA_IDX_INB(ch, ATA_ERROR);
|
2005-04-21 11:13:39 +00:00
|
|
|
goto end_finished;
|
2003-08-24 09:22:26 +00:00
|
|
|
}
|
|
|
|
|
2003-11-02 22:04:53 +00:00
|
|
|
/* are we moving data ? */
|
|
|
|
if (request->flags & (ATA_R_READ | ATA_R_WRITE)) {
|
|
|
|
|
|
|
|
/* if read data get it */
|
This is the much rumoured ATA mkIII update that I've been working on.
o ATA is now fully newbus'd and split into modules.
This means that on a modern system you just load "atapci and ata"
to get the base support, and then one or more of the device
subdrivers "atadisk atapicd atapifd atapist ataraid".
All can be loaded/unloaded anytime, but for obvious reasons you
dont want to unload atadisk when you have mounted filesystems.
o The device identify part of the probe has been rewritten to fix
the problems with odd devices the old had, and to try to remove
so of the long delays some HW could provoke. Also probing is done
without the need for interrupts, making earlier probing possible.
o SATA devices can be hot inserted/removed and devices will be created/
removed in /dev accordingly.
NOTE: only supported on controllers that has this feature:
Promise and Silicon Image for now.
On other controllers the usual atacontrol detach/attach dance is
still needed.
o Support for "atomic" composite ATA requests used for RAID.
o ATA RAID support has been rewritten and and now supports these
metadata formats:
"Adaptec HostRAID"
"Highpoint V2 RocketRAID"
"Highpoint V3 RocketRAID"
"Intel MatrixRAID"
"Integrated Technology Express"
"LSILogic V2 MegaRAID"
"LSILogic V3 MegaRAID"
"Promise FastTrak"
"Silicon Image Medley"
"FreeBSD PseudoRAID"
o Update the ioctl API to match new RAID levels etc.
o Update atacontrol to know about the new RAID levels etc
NOTE: you need to recompile atacontrol with the new sys/ata.h,
make world will take care of that.
NOTE2: that rebuild is done differently from the old system as
the rebuild is now done piggybacked on read requests to the
array, so atacontrol simply starts a background "dd" to rebuild
the array.
o The reinit code has been worked over to be much more robust.
o The timeout code has been overhauled for races.
o Support of new chipsets.
o Lots of fixes for bugs found while doing the modulerization and
reviewing the old code.
Missing or changed features from current ATA:
o atapi-cd no longer has support for ATAPI changers. Todays its
much cheaper and alot faster to copy those CD images to disk
and serve them from there. Besides they dont seem to be made
anymore, maybe for that exact reason.
o ATA RAID can only read metadata from all the above metadata formats,
not write all of them (Promise and Highpoint V2 so far). This means
that arrays can be picked up from the BIOS, but they cannot be
created from FreeBSD. There is more to it than just the missing
write metadata support, those formats are not unique to a given
controller like Promise and Highpoint formats, instead they exist
for several types, and even worse, some controllers can have
different formats and its impossible to tell which one.
The outcome is that we cannot reliably create the metadata of those
formats and be sure the controller BIOS will understand it.
However write support is needed to update/fail/rebuild the arrays
properly so it sits fairly high on the TODO list.
o So far atapicam is not supported with these changes. When/if this
will change is up to the maintainer of atapi-cam so go there for
questions.
HW donated by: Webveveriet AS
HW donated by: Frode Nordahl
HW donated by: Yahoo!
HW donated by: Sentex
Patience by: Vife and my boys (and even the cats)
2005-03-30 12:03:40 +00:00
|
|
|
if (request->flags & ATA_R_READ) {
|
2005-09-19 07:35:42 +00:00
|
|
|
int flags = ATA_S_DRQ;
|
|
|
|
|
|
|
|
if (request->u.ata.command != ATA_ATAPI_IDENTIFY)
|
|
|
|
flags |= ATA_S_READY;
|
2009-10-31 13:24:14 +00:00
|
|
|
if (ata_wait(ch, request->unit, flags) < 0) {
|
|
|
|
device_printf(request->parent,
|
2005-09-14 12:45:06 +00:00
|
|
|
"timeout waiting for read DRQ\n");
|
This is the much rumoured ATA mkIII update that I've been working on.
o ATA is now fully newbus'd and split into modules.
This means that on a modern system you just load "atapci and ata"
to get the base support, and then one or more of the device
subdrivers "atadisk atapicd atapifd atapist ataraid".
All can be loaded/unloaded anytime, but for obvious reasons you
dont want to unload atadisk when you have mounted filesystems.
o The device identify part of the probe has been rewritten to fix
the problems with odd devices the old had, and to try to remove
so of the long delays some HW could provoke. Also probing is done
without the need for interrupts, making earlier probing possible.
o SATA devices can be hot inserted/removed and devices will be created/
removed in /dev accordingly.
NOTE: only supported on controllers that has this feature:
Promise and Silicon Image for now.
On other controllers the usual atacontrol detach/attach dance is
still needed.
o Support for "atomic" composite ATA requests used for RAID.
o ATA RAID support has been rewritten and and now supports these
metadata formats:
"Adaptec HostRAID"
"Highpoint V2 RocketRAID"
"Highpoint V3 RocketRAID"
"Intel MatrixRAID"
"Integrated Technology Express"
"LSILogic V2 MegaRAID"
"LSILogic V3 MegaRAID"
"Promise FastTrak"
"Silicon Image Medley"
"FreeBSD PseudoRAID"
o Update the ioctl API to match new RAID levels etc.
o Update atacontrol to know about the new RAID levels etc
NOTE: you need to recompile atacontrol with the new sys/ata.h,
make world will take care of that.
NOTE2: that rebuild is done differently from the old system as
the rebuild is now done piggybacked on read requests to the
array, so atacontrol simply starts a background "dd" to rebuild
the array.
o The reinit code has been worked over to be much more robust.
o The timeout code has been overhauled for races.
o Support of new chipsets.
o Lots of fixes for bugs found while doing the modulerization and
reviewing the old code.
Missing or changed features from current ATA:
o atapi-cd no longer has support for ATAPI changers. Todays its
much cheaper and alot faster to copy those CD images to disk
and serve them from there. Besides they dont seem to be made
anymore, maybe for that exact reason.
o ATA RAID can only read metadata from all the above metadata formats,
not write all of them (Promise and Highpoint V2 so far). This means
that arrays can be picked up from the BIOS, but they cannot be
created from FreeBSD. There is more to it than just the missing
write metadata support, those formats are not unique to a given
controller like Promise and Highpoint formats, instead they exist
for several types, and even worse, some controllers can have
different formats and its impossible to tell which one.
The outcome is that we cannot reliably create the metadata of those
formats and be sure the controller BIOS will understand it.
However write support is needed to update/fail/rebuild the arrays
properly so it sits fairly high on the TODO list.
o So far atapicam is not supported with these changes. When/if this
will change is up to the maintainer of atapi-cam so go there for
questions.
HW donated by: Webveveriet AS
HW donated by: Frode Nordahl
HW donated by: Yahoo!
HW donated by: Sentex
Patience by: Vife and my boys (and even the cats)
2005-03-30 12:03:40 +00:00
|
|
|
request->result = EIO;
|
2005-04-21 11:13:39 +00:00
|
|
|
goto end_finished;
|
This is the much rumoured ATA mkIII update that I've been working on.
o ATA is now fully newbus'd and split into modules.
This means that on a modern system you just load "atapci and ata"
to get the base support, and then one or more of the device
subdrivers "atadisk atapicd atapifd atapist ataraid".
All can be loaded/unloaded anytime, but for obvious reasons you
dont want to unload atadisk when you have mounted filesystems.
o The device identify part of the probe has been rewritten to fix
the problems with odd devices the old had, and to try to remove
so of the long delays some HW could provoke. Also probing is done
without the need for interrupts, making earlier probing possible.
o SATA devices can be hot inserted/removed and devices will be created/
removed in /dev accordingly.
NOTE: only supported on controllers that has this feature:
Promise and Silicon Image for now.
On other controllers the usual atacontrol detach/attach dance is
still needed.
o Support for "atomic" composite ATA requests used for RAID.
o ATA RAID support has been rewritten and and now supports these
metadata formats:
"Adaptec HostRAID"
"Highpoint V2 RocketRAID"
"Highpoint V3 RocketRAID"
"Intel MatrixRAID"
"Integrated Technology Express"
"LSILogic V2 MegaRAID"
"LSILogic V3 MegaRAID"
"Promise FastTrak"
"Silicon Image Medley"
"FreeBSD PseudoRAID"
o Update the ioctl API to match new RAID levels etc.
o Update atacontrol to know about the new RAID levels etc
NOTE: you need to recompile atacontrol with the new sys/ata.h,
make world will take care of that.
NOTE2: that rebuild is done differently from the old system as
the rebuild is now done piggybacked on read requests to the
array, so atacontrol simply starts a background "dd" to rebuild
the array.
o The reinit code has been worked over to be much more robust.
o The timeout code has been overhauled for races.
o Support of new chipsets.
o Lots of fixes for bugs found while doing the modulerization and
reviewing the old code.
Missing or changed features from current ATA:
o atapi-cd no longer has support for ATAPI changers. Todays its
much cheaper and alot faster to copy those CD images to disk
and serve them from there. Besides they dont seem to be made
anymore, maybe for that exact reason.
o ATA RAID can only read metadata from all the above metadata formats,
not write all of them (Promise and Highpoint V2 so far). This means
that arrays can be picked up from the BIOS, but they cannot be
created from FreeBSD. There is more to it than just the missing
write metadata support, those formats are not unique to a given
controller like Promise and Highpoint formats, instead they exist
for several types, and even worse, some controllers can have
different formats and its impossible to tell which one.
The outcome is that we cannot reliably create the metadata of those
formats and be sure the controller BIOS will understand it.
However write support is needed to update/fail/rebuild the arrays
properly so it sits fairly high on the TODO list.
o So far atapicam is not supported with these changes. When/if this
will change is up to the maintainer of atapi-cam so go there for
questions.
HW donated by: Webveveriet AS
HW donated by: Frode Nordahl
HW donated by: Yahoo!
HW donated by: Sentex
Patience by: Vife and my boys (and even the cats)
2005-03-30 12:03:40 +00:00
|
|
|
}
|
2003-11-02 22:04:53 +00:00
|
|
|
ata_pio_read(request, request->transfersize);
|
This is the much rumoured ATA mkIII update that I've been working on.
o ATA is now fully newbus'd and split into modules.
This means that on a modern system you just load "atapci and ata"
to get the base support, and then one or more of the device
subdrivers "atadisk atapicd atapifd atapist ataraid".
All can be loaded/unloaded anytime, but for obvious reasons you
dont want to unload atadisk when you have mounted filesystems.
o The device identify part of the probe has been rewritten to fix
the problems with odd devices the old had, and to try to remove
so of the long delays some HW could provoke. Also probing is done
without the need for interrupts, making earlier probing possible.
o SATA devices can be hot inserted/removed and devices will be created/
removed in /dev accordingly.
NOTE: only supported on controllers that has this feature:
Promise and Silicon Image for now.
On other controllers the usual atacontrol detach/attach dance is
still needed.
o Support for "atomic" composite ATA requests used for RAID.
o ATA RAID support has been rewritten and and now supports these
metadata formats:
"Adaptec HostRAID"
"Highpoint V2 RocketRAID"
"Highpoint V3 RocketRAID"
"Intel MatrixRAID"
"Integrated Technology Express"
"LSILogic V2 MegaRAID"
"LSILogic V3 MegaRAID"
"Promise FastTrak"
"Silicon Image Medley"
"FreeBSD PseudoRAID"
o Update the ioctl API to match new RAID levels etc.
o Update atacontrol to know about the new RAID levels etc
NOTE: you need to recompile atacontrol with the new sys/ata.h,
make world will take care of that.
NOTE2: that rebuild is done differently from the old system as
the rebuild is now done piggybacked on read requests to the
array, so atacontrol simply starts a background "dd" to rebuild
the array.
o The reinit code has been worked over to be much more robust.
o The timeout code has been overhauled for races.
o Support of new chipsets.
o Lots of fixes for bugs found while doing the modulerization and
reviewing the old code.
Missing or changed features from current ATA:
o atapi-cd no longer has support for ATAPI changers. Todays its
much cheaper and alot faster to copy those CD images to disk
and serve them from there. Besides they dont seem to be made
anymore, maybe for that exact reason.
o ATA RAID can only read metadata from all the above metadata formats,
not write all of them (Promise and Highpoint V2 so far). This means
that arrays can be picked up from the BIOS, but they cannot be
created from FreeBSD. There is more to it than just the missing
write metadata support, those formats are not unique to a given
controller like Promise and Highpoint formats, instead they exist
for several types, and even worse, some controllers can have
different formats and its impossible to tell which one.
The outcome is that we cannot reliably create the metadata of those
formats and be sure the controller BIOS will understand it.
However write support is needed to update/fail/rebuild the arrays
properly so it sits fairly high on the TODO list.
o So far atapicam is not supported with these changes. When/if this
will change is up to the maintainer of atapi-cam so go there for
questions.
HW donated by: Webveveriet AS
HW donated by: Frode Nordahl
HW donated by: Yahoo!
HW donated by: Sentex
Patience by: Vife and my boys (and even the cats)
2005-03-30 12:03:40 +00:00
|
|
|
}
|
2003-11-02 22:04:53 +00:00
|
|
|
|
|
|
|
/* update how far we've gotten */
|
2005-03-06 10:17:30 +00:00
|
|
|
request->donecount += request->transfersize;
|
2003-11-02 22:04:53 +00:00
|
|
|
|
|
|
|
/* do we need a scoop more ? */
|
|
|
|
if (request->bytecount > request->donecount) {
|
|
|
|
|
|
|
|
/* set this transfer size according to HW capabilities */
|
|
|
|
request->transfersize =
|
|
|
|
min((request->bytecount - request->donecount),
|
|
|
|
request->transfersize);
|
|
|
|
|
|
|
|
/* if data write command, output the data */
|
|
|
|
if (request->flags & ATA_R_WRITE) {
|
|
|
|
|
|
|
|
/* if we get an error here we are done with the HW */
|
2009-10-31 13:24:14 +00:00
|
|
|
if (ata_wait(ch, request->unit, (ATA_S_READY | ATA_S_DRQ)) < 0) {
|
|
|
|
device_printf(request->parent,
|
2005-09-14 12:45:06 +00:00
|
|
|
"timeout waiting for write DRQ\n");
|
2003-11-02 22:04:53 +00:00
|
|
|
request->status = ATA_IDX_INB(ch, ATA_STATUS);
|
2005-04-21 11:13:39 +00:00
|
|
|
goto end_finished;
|
2003-11-02 22:04:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* output data and return waiting for new interrupt */
|
|
|
|
ata_pio_write(request, request->transfersize);
|
2005-04-21 11:13:39 +00:00
|
|
|
goto end_continue;
|
2003-08-24 09:22:26 +00:00
|
|
|
}
|
2003-09-18 16:44:54 +00:00
|
|
|
|
2003-11-02 22:04:53 +00:00
|
|
|
/* if data read command, return & wait for interrupt */
|
|
|
|
if (request->flags & ATA_R_READ)
|
2005-04-21 11:13:39 +00:00
|
|
|
goto end_continue;
|
2003-08-24 09:22:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/* done with HW */
|
2005-04-21 11:13:39 +00:00
|
|
|
goto end_finished;
|
2003-08-24 09:22:26 +00:00
|
|
|
|
|
|
|
/* ATA DMA data transfer commands */
|
|
|
|
case ATA_R_DMA:
|
2004-04-13 09:44:20 +00:00
|
|
|
|
2003-08-24 09:22:26 +00:00
|
|
|
/* stop DMA engine and get status */
|
2008-04-10 13:05:05 +00:00
|
|
|
if (ch->dma.stop)
|
2008-04-17 12:29:35 +00:00
|
|
|
request->dma->status = ch->dma.stop(request);
|
2003-08-24 09:22:26 +00:00
|
|
|
|
|
|
|
/* did we get error or data */
|
|
|
|
if (request->status & ATA_S_ERROR)
|
|
|
|
request->error = ATA_IDX_INB(ch, ATA_ERROR);
|
2008-04-17 12:29:35 +00:00
|
|
|
else if (request->dma->status & ATA_BMSTAT_ERROR)
|
2003-08-24 09:22:26 +00:00
|
|
|
request->status |= ATA_S_ERROR;
|
This is the much rumoured ATA mkIII update that I've been working on.
o ATA is now fully newbus'd and split into modules.
This means that on a modern system you just load "atapci and ata"
to get the base support, and then one or more of the device
subdrivers "atadisk atapicd atapifd atapist ataraid".
All can be loaded/unloaded anytime, but for obvious reasons you
dont want to unload atadisk when you have mounted filesystems.
o The device identify part of the probe has been rewritten to fix
the problems with odd devices the old had, and to try to remove
so of the long delays some HW could provoke. Also probing is done
without the need for interrupts, making earlier probing possible.
o SATA devices can be hot inserted/removed and devices will be created/
removed in /dev accordingly.
NOTE: only supported on controllers that has this feature:
Promise and Silicon Image for now.
On other controllers the usual atacontrol detach/attach dance is
still needed.
o Support for "atomic" composite ATA requests used for RAID.
o ATA RAID support has been rewritten and and now supports these
metadata formats:
"Adaptec HostRAID"
"Highpoint V2 RocketRAID"
"Highpoint V3 RocketRAID"
"Intel MatrixRAID"
"Integrated Technology Express"
"LSILogic V2 MegaRAID"
"LSILogic V3 MegaRAID"
"Promise FastTrak"
"Silicon Image Medley"
"FreeBSD PseudoRAID"
o Update the ioctl API to match new RAID levels etc.
o Update atacontrol to know about the new RAID levels etc
NOTE: you need to recompile atacontrol with the new sys/ata.h,
make world will take care of that.
NOTE2: that rebuild is done differently from the old system as
the rebuild is now done piggybacked on read requests to the
array, so atacontrol simply starts a background "dd" to rebuild
the array.
o The reinit code has been worked over to be much more robust.
o The timeout code has been overhauled for races.
o Support of new chipsets.
o Lots of fixes for bugs found while doing the modulerization and
reviewing the old code.
Missing or changed features from current ATA:
o atapi-cd no longer has support for ATAPI changers. Todays its
much cheaper and alot faster to copy those CD images to disk
and serve them from there. Besides they dont seem to be made
anymore, maybe for that exact reason.
o ATA RAID can only read metadata from all the above metadata formats,
not write all of them (Promise and Highpoint V2 so far). This means
that arrays can be picked up from the BIOS, but they cannot be
created from FreeBSD. There is more to it than just the missing
write metadata support, those formats are not unique to a given
controller like Promise and Highpoint formats, instead they exist
for several types, and even worse, some controllers can have
different formats and its impossible to tell which one.
The outcome is that we cannot reliably create the metadata of those
formats and be sure the controller BIOS will understand it.
However write support is needed to update/fail/rebuild the arrays
properly so it sits fairly high on the TODO list.
o So far atapicam is not supported with these changes. When/if this
will change is up to the maintainer of atapi-cam so go there for
questions.
HW donated by: Webveveriet AS
HW donated by: Frode Nordahl
HW donated by: Yahoo!
HW donated by: Sentex
Patience by: Vife and my boys (and even the cats)
2005-03-30 12:03:40 +00:00
|
|
|
else if (!(request->flags & ATA_R_TIMEOUT))
|
2003-08-24 09:22:26 +00:00
|
|
|
request->donecount = request->bytecount;
|
|
|
|
|
2012-10-26 20:03:08 +00:00
|
|
|
/* Read back registers to the request struct. */
|
|
|
|
if ((request->status & ATA_S_ERROR) ||
|
|
|
|
(request->flags & (ATA_R_CONTROL | ATA_R_NEEDRESULT))) {
|
|
|
|
ch->hw.tf_read(request);
|
|
|
|
}
|
|
|
|
|
2003-10-21 19:20:37 +00:00
|
|
|
/* release SG list etc */
|
2008-04-10 13:05:05 +00:00
|
|
|
ch->dma.unload(request);
|
2003-10-21 19:20:37 +00:00
|
|
|
|
2003-08-24 09:22:26 +00:00
|
|
|
/* done with HW */
|
2005-04-21 11:13:39 +00:00
|
|
|
goto end_finished;
|
2003-08-24 09:22:26 +00:00
|
|
|
|
|
|
|
/* ATAPI PIO commands */
|
|
|
|
case ATA_R_ATAPI:
|
|
|
|
length = ATA_IDX_INB(ch, ATA_CYL_LSB)|(ATA_IDX_INB(ch, ATA_CYL_MSB)<<8);
|
|
|
|
|
This is the much rumoured ATA mkIII update that I've been working on.
o ATA is now fully newbus'd and split into modules.
This means that on a modern system you just load "atapci and ata"
to get the base support, and then one or more of the device
subdrivers "atadisk atapicd atapifd atapist ataraid".
All can be loaded/unloaded anytime, but for obvious reasons you
dont want to unload atadisk when you have mounted filesystems.
o The device identify part of the probe has been rewritten to fix
the problems with odd devices the old had, and to try to remove
so of the long delays some HW could provoke. Also probing is done
without the need for interrupts, making earlier probing possible.
o SATA devices can be hot inserted/removed and devices will be created/
removed in /dev accordingly.
NOTE: only supported on controllers that has this feature:
Promise and Silicon Image for now.
On other controllers the usual atacontrol detach/attach dance is
still needed.
o Support for "atomic" composite ATA requests used for RAID.
o ATA RAID support has been rewritten and and now supports these
metadata formats:
"Adaptec HostRAID"
"Highpoint V2 RocketRAID"
"Highpoint V3 RocketRAID"
"Intel MatrixRAID"
"Integrated Technology Express"
"LSILogic V2 MegaRAID"
"LSILogic V3 MegaRAID"
"Promise FastTrak"
"Silicon Image Medley"
"FreeBSD PseudoRAID"
o Update the ioctl API to match new RAID levels etc.
o Update atacontrol to know about the new RAID levels etc
NOTE: you need to recompile atacontrol with the new sys/ata.h,
make world will take care of that.
NOTE2: that rebuild is done differently from the old system as
the rebuild is now done piggybacked on read requests to the
array, so atacontrol simply starts a background "dd" to rebuild
the array.
o The reinit code has been worked over to be much more robust.
o The timeout code has been overhauled for races.
o Support of new chipsets.
o Lots of fixes for bugs found while doing the modulerization and
reviewing the old code.
Missing or changed features from current ATA:
o atapi-cd no longer has support for ATAPI changers. Todays its
much cheaper and alot faster to copy those CD images to disk
and serve them from there. Besides they dont seem to be made
anymore, maybe for that exact reason.
o ATA RAID can only read metadata from all the above metadata formats,
not write all of them (Promise and Highpoint V2 so far). This means
that arrays can be picked up from the BIOS, but they cannot be
created from FreeBSD. There is more to it than just the missing
write metadata support, those formats are not unique to a given
controller like Promise and Highpoint formats, instead they exist
for several types, and even worse, some controllers can have
different formats and its impossible to tell which one.
The outcome is that we cannot reliably create the metadata of those
formats and be sure the controller BIOS will understand it.
However write support is needed to update/fail/rebuild the arrays
properly so it sits fairly high on the TODO list.
o So far atapicam is not supported with these changes. When/if this
will change is up to the maintainer of atapi-cam so go there for
questions.
HW donated by: Webveveriet AS
HW donated by: Frode Nordahl
HW donated by: Yahoo!
HW donated by: Sentex
Patience by: Vife and my boys (and even the cats)
2005-03-30 12:03:40 +00:00
|
|
|
/* on timeouts we have no data or anything so just return */
|
|
|
|
if (request->flags & ATA_R_TIMEOUT)
|
2005-04-21 11:13:39 +00:00
|
|
|
goto end_finished;
|
This is the much rumoured ATA mkIII update that I've been working on.
o ATA is now fully newbus'd and split into modules.
This means that on a modern system you just load "atapci and ata"
to get the base support, and then one or more of the device
subdrivers "atadisk atapicd atapifd atapist ataraid".
All can be loaded/unloaded anytime, but for obvious reasons you
dont want to unload atadisk when you have mounted filesystems.
o The device identify part of the probe has been rewritten to fix
the problems with odd devices the old had, and to try to remove
so of the long delays some HW could provoke. Also probing is done
without the need for interrupts, making earlier probing possible.
o SATA devices can be hot inserted/removed and devices will be created/
removed in /dev accordingly.
NOTE: only supported on controllers that has this feature:
Promise and Silicon Image for now.
On other controllers the usual atacontrol detach/attach dance is
still needed.
o Support for "atomic" composite ATA requests used for RAID.
o ATA RAID support has been rewritten and and now supports these
metadata formats:
"Adaptec HostRAID"
"Highpoint V2 RocketRAID"
"Highpoint V3 RocketRAID"
"Intel MatrixRAID"
"Integrated Technology Express"
"LSILogic V2 MegaRAID"
"LSILogic V3 MegaRAID"
"Promise FastTrak"
"Silicon Image Medley"
"FreeBSD PseudoRAID"
o Update the ioctl API to match new RAID levels etc.
o Update atacontrol to know about the new RAID levels etc
NOTE: you need to recompile atacontrol with the new sys/ata.h,
make world will take care of that.
NOTE2: that rebuild is done differently from the old system as
the rebuild is now done piggybacked on read requests to the
array, so atacontrol simply starts a background "dd" to rebuild
the array.
o The reinit code has been worked over to be much more robust.
o The timeout code has been overhauled for races.
o Support of new chipsets.
o Lots of fixes for bugs found while doing the modulerization and
reviewing the old code.
Missing or changed features from current ATA:
o atapi-cd no longer has support for ATAPI changers. Todays its
much cheaper and alot faster to copy those CD images to disk
and serve them from there. Besides they dont seem to be made
anymore, maybe for that exact reason.
o ATA RAID can only read metadata from all the above metadata formats,
not write all of them (Promise and Highpoint V2 so far). This means
that arrays can be picked up from the BIOS, but they cannot be
created from FreeBSD. There is more to it than just the missing
write metadata support, those formats are not unique to a given
controller like Promise and Highpoint formats, instead they exist
for several types, and even worse, some controllers can have
different formats and its impossible to tell which one.
The outcome is that we cannot reliably create the metadata of those
formats and be sure the controller BIOS will understand it.
However write support is needed to update/fail/rebuild the arrays
properly so it sits fairly high on the TODO list.
o So far atapicam is not supported with these changes. When/if this
will change is up to the maintainer of atapi-cam so go there for
questions.
HW donated by: Webveveriet AS
HW donated by: Frode Nordahl
HW donated by: Yahoo!
HW donated by: Sentex
Patience by: Vife and my boys (and even the cats)
2005-03-30 12:03:40 +00:00
|
|
|
|
2003-08-24 09:22:26 +00:00
|
|
|
switch ((ATA_IDX_INB(ch, ATA_IREASON) & (ATA_I_CMD | ATA_I_IN)) |
|
|
|
|
(request->status & ATA_S_DRQ)) {
|
|
|
|
|
|
|
|
case ATAPI_P_CMDOUT:
|
|
|
|
/* this seems to be needed for some (slow) devices */
|
|
|
|
DELAY(10);
|
|
|
|
|
|
|
|
if (!(request->status & ATA_S_DRQ)) {
|
2009-10-31 13:24:14 +00:00
|
|
|
device_printf(request->parent, "command interrupt without DRQ\n");
|
2003-08-24 09:22:26 +00:00
|
|
|
request->status = ATA_S_ERROR;
|
2005-04-21 11:13:39 +00:00
|
|
|
goto end_finished;
|
2003-08-24 09:22:26 +00:00
|
|
|
}
|
|
|
|
ATA_IDX_OUTSW_STRM(ch, ATA_DATA, (int16_t *)request->u.atapi.ccb,
|
2009-10-31 13:24:14 +00:00
|
|
|
(request->flags & ATA_R_ATAPI16) ? 8 : 6);
|
2003-08-24 09:22:26 +00:00
|
|
|
/* return wait for interrupt */
|
2005-04-21 11:13:39 +00:00
|
|
|
goto end_continue;
|
2003-08-24 09:22:26 +00:00
|
|
|
|
|
|
|
case ATAPI_P_WRITE:
|
|
|
|
if (request->flags & ATA_R_READ) {
|
|
|
|
request->status = ATA_S_ERROR;
|
2009-10-31 13:24:14 +00:00
|
|
|
device_printf(request->parent,
|
This is the much rumoured ATA mkIII update that I've been working on.
o ATA is now fully newbus'd and split into modules.
This means that on a modern system you just load "atapci and ata"
to get the base support, and then one or more of the device
subdrivers "atadisk atapicd atapifd atapist ataraid".
All can be loaded/unloaded anytime, but for obvious reasons you
dont want to unload atadisk when you have mounted filesystems.
o The device identify part of the probe has been rewritten to fix
the problems with odd devices the old had, and to try to remove
so of the long delays some HW could provoke. Also probing is done
without the need for interrupts, making earlier probing possible.
o SATA devices can be hot inserted/removed and devices will be created/
removed in /dev accordingly.
NOTE: only supported on controllers that has this feature:
Promise and Silicon Image for now.
On other controllers the usual atacontrol detach/attach dance is
still needed.
o Support for "atomic" composite ATA requests used for RAID.
o ATA RAID support has been rewritten and and now supports these
metadata formats:
"Adaptec HostRAID"
"Highpoint V2 RocketRAID"
"Highpoint V3 RocketRAID"
"Intel MatrixRAID"
"Integrated Technology Express"
"LSILogic V2 MegaRAID"
"LSILogic V3 MegaRAID"
"Promise FastTrak"
"Silicon Image Medley"
"FreeBSD PseudoRAID"
o Update the ioctl API to match new RAID levels etc.
o Update atacontrol to know about the new RAID levels etc
NOTE: you need to recompile atacontrol with the new sys/ata.h,
make world will take care of that.
NOTE2: that rebuild is done differently from the old system as
the rebuild is now done piggybacked on read requests to the
array, so atacontrol simply starts a background "dd" to rebuild
the array.
o The reinit code has been worked over to be much more robust.
o The timeout code has been overhauled for races.
o Support of new chipsets.
o Lots of fixes for bugs found while doing the modulerization and
reviewing the old code.
Missing or changed features from current ATA:
o atapi-cd no longer has support for ATAPI changers. Todays its
much cheaper and alot faster to copy those CD images to disk
and serve them from there. Besides they dont seem to be made
anymore, maybe for that exact reason.
o ATA RAID can only read metadata from all the above metadata formats,
not write all of them (Promise and Highpoint V2 so far). This means
that arrays can be picked up from the BIOS, but they cannot be
created from FreeBSD. There is more to it than just the missing
write metadata support, those formats are not unique to a given
controller like Promise and Highpoint formats, instead they exist
for several types, and even worse, some controllers can have
different formats and its impossible to tell which one.
The outcome is that we cannot reliably create the metadata of those
formats and be sure the controller BIOS will understand it.
However write support is needed to update/fail/rebuild the arrays
properly so it sits fairly high on the TODO list.
o So far atapicam is not supported with these changes. When/if this
will change is up to the maintainer of atapi-cam so go there for
questions.
HW donated by: Webveveriet AS
HW donated by: Frode Nordahl
HW donated by: Yahoo!
HW donated by: Sentex
Patience by: Vife and my boys (and even the cats)
2005-03-30 12:03:40 +00:00
|
|
|
"%s trying to write on read buffer\n",
|
2003-08-24 09:22:26 +00:00
|
|
|
ata_cmd2str(request));
|
2005-04-21 11:13:39 +00:00
|
|
|
goto end_finished;
|
2003-08-24 09:22:26 +00:00
|
|
|
}
|
|
|
|
ata_pio_write(request, length);
|
|
|
|
request->donecount += length;
|
|
|
|
|
|
|
|
/* set next transfer size according to HW capabilities */
|
|
|
|
request->transfersize = min((request->bytecount-request->donecount),
|
|
|
|
request->transfersize);
|
|
|
|
/* return wait for interrupt */
|
2005-04-21 11:13:39 +00:00
|
|
|
goto end_continue;
|
2003-08-24 09:22:26 +00:00
|
|
|
|
|
|
|
case ATAPI_P_READ:
|
|
|
|
if (request->flags & ATA_R_WRITE) {
|
|
|
|
request->status = ATA_S_ERROR;
|
2009-10-31 13:24:14 +00:00
|
|
|
device_printf(request->parent,
|
This is the much rumoured ATA mkIII update that I've been working on.
o ATA is now fully newbus'd and split into modules.
This means that on a modern system you just load "atapci and ata"
to get the base support, and then one or more of the device
subdrivers "atadisk atapicd atapifd atapist ataraid".
All can be loaded/unloaded anytime, but for obvious reasons you
dont want to unload atadisk when you have mounted filesystems.
o The device identify part of the probe has been rewritten to fix
the problems with odd devices the old had, and to try to remove
so of the long delays some HW could provoke. Also probing is done
without the need for interrupts, making earlier probing possible.
o SATA devices can be hot inserted/removed and devices will be created/
removed in /dev accordingly.
NOTE: only supported on controllers that has this feature:
Promise and Silicon Image for now.
On other controllers the usual atacontrol detach/attach dance is
still needed.
o Support for "atomic" composite ATA requests used for RAID.
o ATA RAID support has been rewritten and and now supports these
metadata formats:
"Adaptec HostRAID"
"Highpoint V2 RocketRAID"
"Highpoint V3 RocketRAID"
"Intel MatrixRAID"
"Integrated Technology Express"
"LSILogic V2 MegaRAID"
"LSILogic V3 MegaRAID"
"Promise FastTrak"
"Silicon Image Medley"
"FreeBSD PseudoRAID"
o Update the ioctl API to match new RAID levels etc.
o Update atacontrol to know about the new RAID levels etc
NOTE: you need to recompile atacontrol with the new sys/ata.h,
make world will take care of that.
NOTE2: that rebuild is done differently from the old system as
the rebuild is now done piggybacked on read requests to the
array, so atacontrol simply starts a background "dd" to rebuild
the array.
o The reinit code has been worked over to be much more robust.
o The timeout code has been overhauled for races.
o Support of new chipsets.
o Lots of fixes for bugs found while doing the modulerization and
reviewing the old code.
Missing or changed features from current ATA:
o atapi-cd no longer has support for ATAPI changers. Todays its
much cheaper and alot faster to copy those CD images to disk
and serve them from there. Besides they dont seem to be made
anymore, maybe for that exact reason.
o ATA RAID can only read metadata from all the above metadata formats,
not write all of them (Promise and Highpoint V2 so far). This means
that arrays can be picked up from the BIOS, but they cannot be
created from FreeBSD. There is more to it than just the missing
write metadata support, those formats are not unique to a given
controller like Promise and Highpoint formats, instead they exist
for several types, and even worse, some controllers can have
different formats and its impossible to tell which one.
The outcome is that we cannot reliably create the metadata of those
formats and be sure the controller BIOS will understand it.
However write support is needed to update/fail/rebuild the arrays
properly so it sits fairly high on the TODO list.
o So far atapicam is not supported with these changes. When/if this
will change is up to the maintainer of atapi-cam so go there for
questions.
HW donated by: Webveveriet AS
HW donated by: Frode Nordahl
HW donated by: Yahoo!
HW donated by: Sentex
Patience by: Vife and my boys (and even the cats)
2005-03-30 12:03:40 +00:00
|
|
|
"%s trying to read on write buffer\n",
|
2003-08-24 09:22:26 +00:00
|
|
|
ata_cmd2str(request));
|
2005-04-21 11:13:39 +00:00
|
|
|
goto end_finished;
|
2003-08-24 09:22:26 +00:00
|
|
|
}
|
|
|
|
ata_pio_read(request, length);
|
|
|
|
request->donecount += length;
|
|
|
|
|
|
|
|
/* set next transfer size according to HW capabilities */
|
|
|
|
request->transfersize = min((request->bytecount-request->donecount),
|
|
|
|
request->transfersize);
|
|
|
|
/* return wait for interrupt */
|
2005-04-21 11:13:39 +00:00
|
|
|
goto end_continue;
|
2003-08-24 09:22:26 +00:00
|
|
|
|
|
|
|
case ATAPI_P_DONEDRQ:
|
2009-10-31 13:24:14 +00:00
|
|
|
device_printf(request->parent,
|
This is the much rumoured ATA mkIII update that I've been working on.
o ATA is now fully newbus'd and split into modules.
This means that on a modern system you just load "atapci and ata"
to get the base support, and then one or more of the device
subdrivers "atadisk atapicd atapifd atapist ataraid".
All can be loaded/unloaded anytime, but for obvious reasons you
dont want to unload atadisk when you have mounted filesystems.
o The device identify part of the probe has been rewritten to fix
the problems with odd devices the old had, and to try to remove
so of the long delays some HW could provoke. Also probing is done
without the need for interrupts, making earlier probing possible.
o SATA devices can be hot inserted/removed and devices will be created/
removed in /dev accordingly.
NOTE: only supported on controllers that has this feature:
Promise and Silicon Image for now.
On other controllers the usual atacontrol detach/attach dance is
still needed.
o Support for "atomic" composite ATA requests used for RAID.
o ATA RAID support has been rewritten and and now supports these
metadata formats:
"Adaptec HostRAID"
"Highpoint V2 RocketRAID"
"Highpoint V3 RocketRAID"
"Intel MatrixRAID"
"Integrated Technology Express"
"LSILogic V2 MegaRAID"
"LSILogic V3 MegaRAID"
"Promise FastTrak"
"Silicon Image Medley"
"FreeBSD PseudoRAID"
o Update the ioctl API to match new RAID levels etc.
o Update atacontrol to know about the new RAID levels etc
NOTE: you need to recompile atacontrol with the new sys/ata.h,
make world will take care of that.
NOTE2: that rebuild is done differently from the old system as
the rebuild is now done piggybacked on read requests to the
array, so atacontrol simply starts a background "dd" to rebuild
the array.
o The reinit code has been worked over to be much more robust.
o The timeout code has been overhauled for races.
o Support of new chipsets.
o Lots of fixes for bugs found while doing the modulerization and
reviewing the old code.
Missing or changed features from current ATA:
o atapi-cd no longer has support for ATAPI changers. Todays its
much cheaper and alot faster to copy those CD images to disk
and serve them from there. Besides they dont seem to be made
anymore, maybe for that exact reason.
o ATA RAID can only read metadata from all the above metadata formats,
not write all of them (Promise and Highpoint V2 so far). This means
that arrays can be picked up from the BIOS, but they cannot be
created from FreeBSD. There is more to it than just the missing
write metadata support, those formats are not unique to a given
controller like Promise and Highpoint formats, instead they exist
for several types, and even worse, some controllers can have
different formats and its impossible to tell which one.
The outcome is that we cannot reliably create the metadata of those
formats and be sure the controller BIOS will understand it.
However write support is needed to update/fail/rebuild the arrays
properly so it sits fairly high on the TODO list.
o So far atapicam is not supported with these changes. When/if this
will change is up to the maintainer of atapi-cam so go there for
questions.
HW donated by: Webveveriet AS
HW donated by: Frode Nordahl
HW donated by: Yahoo!
HW donated by: Sentex
Patience by: Vife and my boys (and even the cats)
2005-03-30 12:03:40 +00:00
|
|
|
"WARNING - %s DONEDRQ non conformant device\n",
|
|
|
|
ata_cmd2str(request));
|
2003-08-24 09:22:26 +00:00
|
|
|
if (request->flags & ATA_R_READ) {
|
|
|
|
ata_pio_read(request, length);
|
|
|
|
request->donecount += length;
|
|
|
|
}
|
|
|
|
else if (request->flags & ATA_R_WRITE) {
|
|
|
|
ata_pio_write(request, length);
|
|
|
|
request->donecount += length;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
request->status = ATA_S_ERROR;
|
|
|
|
/* FALLTHROUGH */
|
|
|
|
|
|
|
|
case ATAPI_P_ABORT:
|
|
|
|
case ATAPI_P_DONE:
|
|
|
|
if (request->status & (ATA_S_ERROR | ATA_S_DWF))
|
|
|
|
request->error = ATA_IDX_INB(ch, ATA_ERROR);
|
2005-04-21 11:13:39 +00:00
|
|
|
goto end_finished;
|
2003-08-24 09:22:26 +00:00
|
|
|
|
|
|
|
default:
|
2009-10-31 13:24:14 +00:00
|
|
|
device_printf(request->parent, "unknown transfer phase\n");
|
2003-08-24 09:22:26 +00:00
|
|
|
request->status = ATA_S_ERROR;
|
|
|
|
}
|
2003-10-21 19:20:37 +00:00
|
|
|
|
2003-08-24 09:22:26 +00:00
|
|
|
/* done with HW */
|
2005-04-21 11:13:39 +00:00
|
|
|
goto end_finished;
|
2003-08-24 09:22:26 +00:00
|
|
|
|
|
|
|
/* ATAPI DMA commands */
|
|
|
|
case ATA_R_ATAPI|ATA_R_DMA:
|
|
|
|
|
2005-05-03 07:55:07 +00:00
|
|
|
/* stop DMA engine and get status */
|
2008-04-10 13:05:05 +00:00
|
|
|
if (ch->dma.stop)
|
2008-04-17 12:29:35 +00:00
|
|
|
request->dma->status = ch->dma.stop(request);
|
2003-08-24 09:22:26 +00:00
|
|
|
|
|
|
|
/* did we get error or data */
|
|
|
|
if (request->status & (ATA_S_ERROR | ATA_S_DWF))
|
|
|
|
request->error = ATA_IDX_INB(ch, ATA_ERROR);
|
2008-04-17 12:29:35 +00:00
|
|
|
else if (request->dma->status & ATA_BMSTAT_ERROR)
|
2003-08-24 09:22:26 +00:00
|
|
|
request->status |= ATA_S_ERROR;
|
This is the much rumoured ATA mkIII update that I've been working on.
o ATA is now fully newbus'd and split into modules.
This means that on a modern system you just load "atapci and ata"
to get the base support, and then one or more of the device
subdrivers "atadisk atapicd atapifd atapist ataraid".
All can be loaded/unloaded anytime, but for obvious reasons you
dont want to unload atadisk when you have mounted filesystems.
o The device identify part of the probe has been rewritten to fix
the problems with odd devices the old had, and to try to remove
so of the long delays some HW could provoke. Also probing is done
without the need for interrupts, making earlier probing possible.
o SATA devices can be hot inserted/removed and devices will be created/
removed in /dev accordingly.
NOTE: only supported on controllers that has this feature:
Promise and Silicon Image for now.
On other controllers the usual atacontrol detach/attach dance is
still needed.
o Support for "atomic" composite ATA requests used for RAID.
o ATA RAID support has been rewritten and and now supports these
metadata formats:
"Adaptec HostRAID"
"Highpoint V2 RocketRAID"
"Highpoint V3 RocketRAID"
"Intel MatrixRAID"
"Integrated Technology Express"
"LSILogic V2 MegaRAID"
"LSILogic V3 MegaRAID"
"Promise FastTrak"
"Silicon Image Medley"
"FreeBSD PseudoRAID"
o Update the ioctl API to match new RAID levels etc.
o Update atacontrol to know about the new RAID levels etc
NOTE: you need to recompile atacontrol with the new sys/ata.h,
make world will take care of that.
NOTE2: that rebuild is done differently from the old system as
the rebuild is now done piggybacked on read requests to the
array, so atacontrol simply starts a background "dd" to rebuild
the array.
o The reinit code has been worked over to be much more robust.
o The timeout code has been overhauled for races.
o Support of new chipsets.
o Lots of fixes for bugs found while doing the modulerization and
reviewing the old code.
Missing or changed features from current ATA:
o atapi-cd no longer has support for ATAPI changers. Todays its
much cheaper and alot faster to copy those CD images to disk
and serve them from there. Besides they dont seem to be made
anymore, maybe for that exact reason.
o ATA RAID can only read metadata from all the above metadata formats,
not write all of them (Promise and Highpoint V2 so far). This means
that arrays can be picked up from the BIOS, but they cannot be
created from FreeBSD. There is more to it than just the missing
write metadata support, those formats are not unique to a given
controller like Promise and Highpoint formats, instead they exist
for several types, and even worse, some controllers can have
different formats and its impossible to tell which one.
The outcome is that we cannot reliably create the metadata of those
formats and be sure the controller BIOS will understand it.
However write support is needed to update/fail/rebuild the arrays
properly so it sits fairly high on the TODO list.
o So far atapicam is not supported with these changes. When/if this
will change is up to the maintainer of atapi-cam so go there for
questions.
HW donated by: Webveveriet AS
HW donated by: Frode Nordahl
HW donated by: Yahoo!
HW donated by: Sentex
Patience by: Vife and my boys (and even the cats)
2005-03-30 12:03:40 +00:00
|
|
|
else if (!(request->flags & ATA_R_TIMEOUT))
|
2003-08-24 09:22:26 +00:00
|
|
|
request->donecount = request->bytecount;
|
2003-10-21 19:20:37 +00:00
|
|
|
|
|
|
|
/* release SG list etc */
|
2008-04-10 13:05:05 +00:00
|
|
|
ch->dma.unload(request);
|
2003-08-24 09:22:26 +00:00
|
|
|
|
|
|
|
/* done with HW */
|
2005-04-21 11:13:39 +00:00
|
|
|
goto end_finished;
|
2003-08-24 09:22:26 +00:00
|
|
|
}
|
2005-04-21 11:13:39 +00:00
|
|
|
/* NOT REACHED */
|
|
|
|
printf("ata_end_transaction OOPS!!\n");
|
This is the much rumoured ATA mkIII update that I've been working on.
o ATA is now fully newbus'd and split into modules.
This means that on a modern system you just load "atapci and ata"
to get the base support, and then one or more of the device
subdrivers "atadisk atapicd atapifd atapist ataraid".
All can be loaded/unloaded anytime, but for obvious reasons you
dont want to unload atadisk when you have mounted filesystems.
o The device identify part of the probe has been rewritten to fix
the problems with odd devices the old had, and to try to remove
so of the long delays some HW could provoke. Also probing is done
without the need for interrupts, making earlier probing possible.
o SATA devices can be hot inserted/removed and devices will be created/
removed in /dev accordingly.
NOTE: only supported on controllers that has this feature:
Promise and Silicon Image for now.
On other controllers the usual atacontrol detach/attach dance is
still needed.
o Support for "atomic" composite ATA requests used for RAID.
o ATA RAID support has been rewritten and and now supports these
metadata formats:
"Adaptec HostRAID"
"Highpoint V2 RocketRAID"
"Highpoint V3 RocketRAID"
"Intel MatrixRAID"
"Integrated Technology Express"
"LSILogic V2 MegaRAID"
"LSILogic V3 MegaRAID"
"Promise FastTrak"
"Silicon Image Medley"
"FreeBSD PseudoRAID"
o Update the ioctl API to match new RAID levels etc.
o Update atacontrol to know about the new RAID levels etc
NOTE: you need to recompile atacontrol with the new sys/ata.h,
make world will take care of that.
NOTE2: that rebuild is done differently from the old system as
the rebuild is now done piggybacked on read requests to the
array, so atacontrol simply starts a background "dd" to rebuild
the array.
o The reinit code has been worked over to be much more robust.
o The timeout code has been overhauled for races.
o Support of new chipsets.
o Lots of fixes for bugs found while doing the modulerization and
reviewing the old code.
Missing or changed features from current ATA:
o atapi-cd no longer has support for ATAPI changers. Todays its
much cheaper and alot faster to copy those CD images to disk
and serve them from there. Besides they dont seem to be made
anymore, maybe for that exact reason.
o ATA RAID can only read metadata from all the above metadata formats,
not write all of them (Promise and Highpoint V2 so far). This means
that arrays can be picked up from the BIOS, but they cannot be
created from FreeBSD. There is more to it than just the missing
write metadata support, those formats are not unique to a given
controller like Promise and Highpoint formats, instead they exist
for several types, and even worse, some controllers can have
different formats and its impossible to tell which one.
The outcome is that we cannot reliably create the metadata of those
formats and be sure the controller BIOS will understand it.
However write support is needed to update/fail/rebuild the arrays
properly so it sits fairly high on the TODO list.
o So far atapicam is not supported with these changes. When/if this
will change is up to the maintainer of atapi-cam so go there for
questions.
HW donated by: Webveveriet AS
HW donated by: Frode Nordahl
HW donated by: Yahoo!
HW donated by: Sentex
Patience by: Vife and my boys (and even the cats)
2005-03-30 12:03:40 +00:00
|
|
|
|
2005-04-21 11:13:39 +00:00
|
|
|
end_finished:
|
|
|
|
callout_stop(&request->callout);
|
This is the much rumoured ATA mkIII update that I've been working on.
o ATA is now fully newbus'd and split into modules.
This means that on a modern system you just load "atapci and ata"
to get the base support, and then one or more of the device
subdrivers "atadisk atapicd atapifd atapist ataraid".
All can be loaded/unloaded anytime, but for obvious reasons you
dont want to unload atadisk when you have mounted filesystems.
o The device identify part of the probe has been rewritten to fix
the problems with odd devices the old had, and to try to remove
so of the long delays some HW could provoke. Also probing is done
without the need for interrupts, making earlier probing possible.
o SATA devices can be hot inserted/removed and devices will be created/
removed in /dev accordingly.
NOTE: only supported on controllers that has this feature:
Promise and Silicon Image for now.
On other controllers the usual atacontrol detach/attach dance is
still needed.
o Support for "atomic" composite ATA requests used for RAID.
o ATA RAID support has been rewritten and and now supports these
metadata formats:
"Adaptec HostRAID"
"Highpoint V2 RocketRAID"
"Highpoint V3 RocketRAID"
"Intel MatrixRAID"
"Integrated Technology Express"
"LSILogic V2 MegaRAID"
"LSILogic V3 MegaRAID"
"Promise FastTrak"
"Silicon Image Medley"
"FreeBSD PseudoRAID"
o Update the ioctl API to match new RAID levels etc.
o Update atacontrol to know about the new RAID levels etc
NOTE: you need to recompile atacontrol with the new sys/ata.h,
make world will take care of that.
NOTE2: that rebuild is done differently from the old system as
the rebuild is now done piggybacked on read requests to the
array, so atacontrol simply starts a background "dd" to rebuild
the array.
o The reinit code has been worked over to be much more robust.
o The timeout code has been overhauled for races.
o Support of new chipsets.
o Lots of fixes for bugs found while doing the modulerization and
reviewing the old code.
Missing or changed features from current ATA:
o atapi-cd no longer has support for ATAPI changers. Todays its
much cheaper and alot faster to copy those CD images to disk
and serve them from there. Besides they dont seem to be made
anymore, maybe for that exact reason.
o ATA RAID can only read metadata from all the above metadata formats,
not write all of them (Promise and Highpoint V2 so far). This means
that arrays can be picked up from the BIOS, but they cannot be
created from FreeBSD. There is more to it than just the missing
write metadata support, those formats are not unique to a given
controller like Promise and Highpoint formats, instead they exist
for several types, and even worse, some controllers can have
different formats and its impossible to tell which one.
The outcome is that we cannot reliably create the metadata of those
formats and be sure the controller BIOS will understand it.
However write support is needed to update/fail/rebuild the arrays
properly so it sits fairly high on the TODO list.
o So far atapicam is not supported with these changes. When/if this
will change is up to the maintainer of atapi-cam so go there for
questions.
HW donated by: Webveveriet AS
HW donated by: Frode Nordahl
HW donated by: Yahoo!
HW donated by: Sentex
Patience by: Vife and my boys (and even the cats)
2005-03-30 12:03:40 +00:00
|
|
|
return ATA_OP_FINISHED;
|
2005-04-21 11:13:39 +00:00
|
|
|
|
|
|
|
end_continue:
|
|
|
|
return ATA_OP_CONTINUES;
|
2003-08-24 09:22:26 +00:00
|
|
|
}
|
|
|
|
|
2006-01-18 09:14:55 +00:00
|
|
|
/* must be called with ATA channel locked and state_mtx held */
|
2005-04-28 22:08:08 +00:00
|
|
|
void
|
2005-04-30 16:22:07 +00:00
|
|
|
ata_generic_reset(device_t dev)
|
2003-08-24 09:22:26 +00:00
|
|
|
{
|
2005-04-30 16:22:07 +00:00
|
|
|
struct ata_channel *ch = device_get_softc(dev);
|
|
|
|
|
This is the much rumoured ATA mkIII update that I've been working on.
o ATA is now fully newbus'd and split into modules.
This means that on a modern system you just load "atapci and ata"
to get the base support, and then one or more of the device
subdrivers "atadisk atapicd atapifd atapist ataraid".
All can be loaded/unloaded anytime, but for obvious reasons you
dont want to unload atadisk when you have mounted filesystems.
o The device identify part of the probe has been rewritten to fix
the problems with odd devices the old had, and to try to remove
so of the long delays some HW could provoke. Also probing is done
without the need for interrupts, making earlier probing possible.
o SATA devices can be hot inserted/removed and devices will be created/
removed in /dev accordingly.
NOTE: only supported on controllers that has this feature:
Promise and Silicon Image for now.
On other controllers the usual atacontrol detach/attach dance is
still needed.
o Support for "atomic" composite ATA requests used for RAID.
o ATA RAID support has been rewritten and and now supports these
metadata formats:
"Adaptec HostRAID"
"Highpoint V2 RocketRAID"
"Highpoint V3 RocketRAID"
"Intel MatrixRAID"
"Integrated Technology Express"
"LSILogic V2 MegaRAID"
"LSILogic V3 MegaRAID"
"Promise FastTrak"
"Silicon Image Medley"
"FreeBSD PseudoRAID"
o Update the ioctl API to match new RAID levels etc.
o Update atacontrol to know about the new RAID levels etc
NOTE: you need to recompile atacontrol with the new sys/ata.h,
make world will take care of that.
NOTE2: that rebuild is done differently from the old system as
the rebuild is now done piggybacked on read requests to the
array, so atacontrol simply starts a background "dd" to rebuild
the array.
o The reinit code has been worked over to be much more robust.
o The timeout code has been overhauled for races.
o Support of new chipsets.
o Lots of fixes for bugs found while doing the modulerization and
reviewing the old code.
Missing or changed features from current ATA:
o atapi-cd no longer has support for ATAPI changers. Todays its
much cheaper and alot faster to copy those CD images to disk
and serve them from there. Besides they dont seem to be made
anymore, maybe for that exact reason.
o ATA RAID can only read metadata from all the above metadata formats,
not write all of them (Promise and Highpoint V2 so far). This means
that arrays can be picked up from the BIOS, but they cannot be
created from FreeBSD. There is more to it than just the missing
write metadata support, those formats are not unique to a given
controller like Promise and Highpoint formats, instead they exist
for several types, and even worse, some controllers can have
different formats and its impossible to tell which one.
The outcome is that we cannot reliably create the metadata of those
formats and be sure the controller BIOS will understand it.
However write support is needed to update/fail/rebuild the arrays
properly so it sits fairly high on the TODO list.
o So far atapicam is not supported with these changes. When/if this
will change is up to the maintainer of atapi-cam so go there for
questions.
HW donated by: Webveveriet AS
HW donated by: Frode Nordahl
HW donated by: Yahoo!
HW donated by: Sentex
Patience by: Vife and my boys (and even the cats)
2005-03-30 12:03:40 +00:00
|
|
|
u_int8_t ostat0 = 0, stat0 = 0, ostat1 = 0, stat1 = 0;
|
|
|
|
u_int8_t err = 0, lsb = 0, msb = 0;
|
2003-08-24 09:22:26 +00:00
|
|
|
int mask = 0, timeout;
|
|
|
|
|
|
|
|
/* do we have any signs of ATA/ATAPI HW being present ? */
|
2008-04-14 18:34:24 +00:00
|
|
|
ATA_IDX_OUTB(ch, ATA_DRIVE, ATA_D_IBM | ATA_D_LBA | ATA_DEV(ATA_MASTER));
|
2003-08-24 09:22:26 +00:00
|
|
|
DELAY(10);
|
|
|
|
ostat0 = ATA_IDX_INB(ch, ATA_STATUS);
|
2010-09-02 11:18:43 +00:00
|
|
|
if (((ostat0 & 0xf8) != 0xf8 || (ch->flags & ATA_KNOWN_PRESENCE)) &&
|
|
|
|
ostat0 != 0xa5) {
|
2003-08-24 09:22:26 +00:00
|
|
|
stat0 = ATA_S_BUSY;
|
|
|
|
mask |= 0x01;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* in some setups we dont want to test for a slave */
|
|
|
|
if (!(ch->flags & ATA_NO_SLAVE)) {
|
2008-04-14 18:34:24 +00:00
|
|
|
ATA_IDX_OUTB(ch, ATA_DRIVE, ATA_D_IBM | ATA_D_LBA | ATA_DEV(ATA_SLAVE));
|
This is the much rumoured ATA mkIII update that I've been working on.
o ATA is now fully newbus'd and split into modules.
This means that on a modern system you just load "atapci and ata"
to get the base support, and then one or more of the device
subdrivers "atadisk atapicd atapifd atapist ataraid".
All can be loaded/unloaded anytime, but for obvious reasons you
dont want to unload atadisk when you have mounted filesystems.
o The device identify part of the probe has been rewritten to fix
the problems with odd devices the old had, and to try to remove
so of the long delays some HW could provoke. Also probing is done
without the need for interrupts, making earlier probing possible.
o SATA devices can be hot inserted/removed and devices will be created/
removed in /dev accordingly.
NOTE: only supported on controllers that has this feature:
Promise and Silicon Image for now.
On other controllers the usual atacontrol detach/attach dance is
still needed.
o Support for "atomic" composite ATA requests used for RAID.
o ATA RAID support has been rewritten and and now supports these
metadata formats:
"Adaptec HostRAID"
"Highpoint V2 RocketRAID"
"Highpoint V3 RocketRAID"
"Intel MatrixRAID"
"Integrated Technology Express"
"LSILogic V2 MegaRAID"
"LSILogic V3 MegaRAID"
"Promise FastTrak"
"Silicon Image Medley"
"FreeBSD PseudoRAID"
o Update the ioctl API to match new RAID levels etc.
o Update atacontrol to know about the new RAID levels etc
NOTE: you need to recompile atacontrol with the new sys/ata.h,
make world will take care of that.
NOTE2: that rebuild is done differently from the old system as
the rebuild is now done piggybacked on read requests to the
array, so atacontrol simply starts a background "dd" to rebuild
the array.
o The reinit code has been worked over to be much more robust.
o The timeout code has been overhauled for races.
o Support of new chipsets.
o Lots of fixes for bugs found while doing the modulerization and
reviewing the old code.
Missing or changed features from current ATA:
o atapi-cd no longer has support for ATAPI changers. Todays its
much cheaper and alot faster to copy those CD images to disk
and serve them from there. Besides they dont seem to be made
anymore, maybe for that exact reason.
o ATA RAID can only read metadata from all the above metadata formats,
not write all of them (Promise and Highpoint V2 so far). This means
that arrays can be picked up from the BIOS, but they cannot be
created from FreeBSD. There is more to it than just the missing
write metadata support, those formats are not unique to a given
controller like Promise and Highpoint formats, instead they exist
for several types, and even worse, some controllers can have
different formats and its impossible to tell which one.
The outcome is that we cannot reliably create the metadata of those
formats and be sure the controller BIOS will understand it.
However write support is needed to update/fail/rebuild the arrays
properly so it sits fairly high on the TODO list.
o So far atapicam is not supported with these changes. When/if this
will change is up to the maintainer of atapi-cam so go there for
questions.
HW donated by: Webveveriet AS
HW donated by: Frode Nordahl
HW donated by: Yahoo!
HW donated by: Sentex
Patience by: Vife and my boys (and even the cats)
2005-03-30 12:03:40 +00:00
|
|
|
DELAY(10);
|
|
|
|
ostat1 = ATA_IDX_INB(ch, ATA_STATUS);
|
2010-09-02 11:18:43 +00:00
|
|
|
if (((ostat1 & 0xf8) != 0xf8 || (ch->flags & ATA_KNOWN_PRESENCE)) &&
|
|
|
|
ostat1 != 0xa5) {
|
2003-08-24 09:22:26 +00:00
|
|
|
stat1 = ATA_S_BUSY;
|
|
|
|
mask |= 0x02;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-04-19 18:29:43 +00:00
|
|
|
if (bootverbose)
|
2005-04-30 16:22:07 +00:00
|
|
|
device_printf(dev, "reset tp1 mask=%02x ostat0=%02x ostat1=%02x\n",
|
This is the much rumoured ATA mkIII update that I've been working on.
o ATA is now fully newbus'd and split into modules.
This means that on a modern system you just load "atapci and ata"
to get the base support, and then one or more of the device
subdrivers "atadisk atapicd atapifd atapist ataraid".
All can be loaded/unloaded anytime, but for obvious reasons you
dont want to unload atadisk when you have mounted filesystems.
o The device identify part of the probe has been rewritten to fix
the problems with odd devices the old had, and to try to remove
so of the long delays some HW could provoke. Also probing is done
without the need for interrupts, making earlier probing possible.
o SATA devices can be hot inserted/removed and devices will be created/
removed in /dev accordingly.
NOTE: only supported on controllers that has this feature:
Promise and Silicon Image for now.
On other controllers the usual atacontrol detach/attach dance is
still needed.
o Support for "atomic" composite ATA requests used for RAID.
o ATA RAID support has been rewritten and and now supports these
metadata formats:
"Adaptec HostRAID"
"Highpoint V2 RocketRAID"
"Highpoint V3 RocketRAID"
"Intel MatrixRAID"
"Integrated Technology Express"
"LSILogic V2 MegaRAID"
"LSILogic V3 MegaRAID"
"Promise FastTrak"
"Silicon Image Medley"
"FreeBSD PseudoRAID"
o Update the ioctl API to match new RAID levels etc.
o Update atacontrol to know about the new RAID levels etc
NOTE: you need to recompile atacontrol with the new sys/ata.h,
make world will take care of that.
NOTE2: that rebuild is done differently from the old system as
the rebuild is now done piggybacked on read requests to the
array, so atacontrol simply starts a background "dd" to rebuild
the array.
o The reinit code has been worked over to be much more robust.
o The timeout code has been overhauled for races.
o Support of new chipsets.
o Lots of fixes for bugs found while doing the modulerization and
reviewing the old code.
Missing or changed features from current ATA:
o atapi-cd no longer has support for ATAPI changers. Todays its
much cheaper and alot faster to copy those CD images to disk
and serve them from there. Besides they dont seem to be made
anymore, maybe for that exact reason.
o ATA RAID can only read metadata from all the above metadata formats,
not write all of them (Promise and Highpoint V2 so far). This means
that arrays can be picked up from the BIOS, but they cannot be
created from FreeBSD. There is more to it than just the missing
write metadata support, those formats are not unique to a given
controller like Promise and Highpoint formats, instead they exist
for several types, and even worse, some controllers can have
different formats and its impossible to tell which one.
The outcome is that we cannot reliably create the metadata of those
formats and be sure the controller BIOS will understand it.
However write support is needed to update/fail/rebuild the arrays
properly so it sits fairly high on the TODO list.
o So far atapicam is not supported with these changes. When/if this
will change is up to the maintainer of atapi-cam so go there for
questions.
HW donated by: Webveveriet AS
HW donated by: Frode Nordahl
HW donated by: Yahoo!
HW donated by: Sentex
Patience by: Vife and my boys (and even the cats)
2005-03-30 12:03:40 +00:00
|
|
|
mask, ostat0, ostat1);
|
2004-04-19 18:29:43 +00:00
|
|
|
|
2004-01-11 22:08:34 +00:00
|
|
|
/* if nothing showed up there is no need to get any further */
|
2013-05-12 16:43:26 +00:00
|
|
|
/* XXX SOS is that too strong?, we just might lose devices here */
|
2003-08-24 09:22:26 +00:00
|
|
|
ch->devices = 0;
|
|
|
|
if (!mask)
|
|
|
|
return;
|
|
|
|
|
2004-01-11 22:08:34 +00:00
|
|
|
/* reset (both) devices on this channel */
|
2008-04-14 18:34:24 +00:00
|
|
|
ATA_IDX_OUTB(ch, ATA_DRIVE, ATA_D_IBM | ATA_D_LBA | ATA_DEV(ATA_MASTER));
|
2003-08-24 09:22:26 +00:00
|
|
|
DELAY(10);
|
2005-04-06 10:22:56 +00:00
|
|
|
ATA_IDX_OUTB(ch, ATA_CONTROL, ATA_A_IDS | ATA_A_RESET);
|
2004-09-03 12:10:44 +00:00
|
|
|
ata_udelay(10000);
|
2005-04-06 10:22:56 +00:00
|
|
|
ATA_IDX_OUTB(ch, ATA_CONTROL, ATA_A_IDS);
|
2004-09-03 12:10:44 +00:00
|
|
|
ata_udelay(100000);
|
2003-10-20 13:44:33 +00:00
|
|
|
ATA_IDX_INB(ch, ATA_ERROR);
|
2003-08-24 09:22:26 +00:00
|
|
|
|
|
|
|
/* wait for BUSY to go inactive */
|
2003-08-27 11:21:30 +00:00
|
|
|
for (timeout = 0; timeout < 310; timeout++) {
|
This is the much rumoured ATA mkIII update that I've been working on.
o ATA is now fully newbus'd and split into modules.
This means that on a modern system you just load "atapci and ata"
to get the base support, and then one or more of the device
subdrivers "atadisk atapicd atapifd atapist ataraid".
All can be loaded/unloaded anytime, but for obvious reasons you
dont want to unload atadisk when you have mounted filesystems.
o The device identify part of the probe has been rewritten to fix
the problems with odd devices the old had, and to try to remove
so of the long delays some HW could provoke. Also probing is done
without the need for interrupts, making earlier probing possible.
o SATA devices can be hot inserted/removed and devices will be created/
removed in /dev accordingly.
NOTE: only supported on controllers that has this feature:
Promise and Silicon Image for now.
On other controllers the usual atacontrol detach/attach dance is
still needed.
o Support for "atomic" composite ATA requests used for RAID.
o ATA RAID support has been rewritten and and now supports these
metadata formats:
"Adaptec HostRAID"
"Highpoint V2 RocketRAID"
"Highpoint V3 RocketRAID"
"Intel MatrixRAID"
"Integrated Technology Express"
"LSILogic V2 MegaRAID"
"LSILogic V3 MegaRAID"
"Promise FastTrak"
"Silicon Image Medley"
"FreeBSD PseudoRAID"
o Update the ioctl API to match new RAID levels etc.
o Update atacontrol to know about the new RAID levels etc
NOTE: you need to recompile atacontrol with the new sys/ata.h,
make world will take care of that.
NOTE2: that rebuild is done differently from the old system as
the rebuild is now done piggybacked on read requests to the
array, so atacontrol simply starts a background "dd" to rebuild
the array.
o The reinit code has been worked over to be much more robust.
o The timeout code has been overhauled for races.
o Support of new chipsets.
o Lots of fixes for bugs found while doing the modulerization and
reviewing the old code.
Missing or changed features from current ATA:
o atapi-cd no longer has support for ATAPI changers. Todays its
much cheaper and alot faster to copy those CD images to disk
and serve them from there. Besides they dont seem to be made
anymore, maybe for that exact reason.
o ATA RAID can only read metadata from all the above metadata formats,
not write all of them (Promise and Highpoint V2 so far). This means
that arrays can be picked up from the BIOS, but they cannot be
created from FreeBSD. There is more to it than just the missing
write metadata support, those formats are not unique to a given
controller like Promise and Highpoint formats, instead they exist
for several types, and even worse, some controllers can have
different formats and its impossible to tell which one.
The outcome is that we cannot reliably create the metadata of those
formats and be sure the controller BIOS will understand it.
However write support is needed to update/fail/rebuild the arrays
properly so it sits fairly high on the TODO list.
o So far atapicam is not supported with these changes. When/if this
will change is up to the maintainer of atapi-cam so go there for
questions.
HW donated by: Webveveriet AS
HW donated by: Frode Nordahl
HW donated by: Yahoo!
HW donated by: Sentex
Patience by: Vife and my boys (and even the cats)
2005-03-30 12:03:40 +00:00
|
|
|
if ((mask & 0x01) && (stat0 & ATA_S_BUSY)) {
|
2008-04-14 18:34:24 +00:00
|
|
|
ATA_IDX_OUTB(ch, ATA_DRIVE, ATA_D_IBM | ATA_DEV(ATA_MASTER));
|
2003-08-24 09:22:26 +00:00
|
|
|
DELAY(10);
|
2010-09-09 13:17:30 +00:00
|
|
|
if (ch->flags & ATA_STATUS_IS_LONG)
|
|
|
|
stat0 = ATA_IDX_INL(ch, ATA_STATUS) & 0xff;
|
|
|
|
else
|
|
|
|
stat0 = ATA_IDX_INB(ch, ATA_STATUS);
|
This is the much rumoured ATA mkIII update that I've been working on.
o ATA is now fully newbus'd and split into modules.
This means that on a modern system you just load "atapci and ata"
to get the base support, and then one or more of the device
subdrivers "atadisk atapicd atapifd atapist ataraid".
All can be loaded/unloaded anytime, but for obvious reasons you
dont want to unload atadisk when you have mounted filesystems.
o The device identify part of the probe has been rewritten to fix
the problems with odd devices the old had, and to try to remove
so of the long delays some HW could provoke. Also probing is done
without the need for interrupts, making earlier probing possible.
o SATA devices can be hot inserted/removed and devices will be created/
removed in /dev accordingly.
NOTE: only supported on controllers that has this feature:
Promise and Silicon Image for now.
On other controllers the usual atacontrol detach/attach dance is
still needed.
o Support for "atomic" composite ATA requests used for RAID.
o ATA RAID support has been rewritten and and now supports these
metadata formats:
"Adaptec HostRAID"
"Highpoint V2 RocketRAID"
"Highpoint V3 RocketRAID"
"Intel MatrixRAID"
"Integrated Technology Express"
"LSILogic V2 MegaRAID"
"LSILogic V3 MegaRAID"
"Promise FastTrak"
"Silicon Image Medley"
"FreeBSD PseudoRAID"
o Update the ioctl API to match new RAID levels etc.
o Update atacontrol to know about the new RAID levels etc
NOTE: you need to recompile atacontrol with the new sys/ata.h,
make world will take care of that.
NOTE2: that rebuild is done differently from the old system as
the rebuild is now done piggybacked on read requests to the
array, so atacontrol simply starts a background "dd" to rebuild
the array.
o The reinit code has been worked over to be much more robust.
o The timeout code has been overhauled for races.
o Support of new chipsets.
o Lots of fixes for bugs found while doing the modulerization and
reviewing the old code.
Missing or changed features from current ATA:
o atapi-cd no longer has support for ATAPI changers. Todays its
much cheaper and alot faster to copy those CD images to disk
and serve them from there. Besides they dont seem to be made
anymore, maybe for that exact reason.
o ATA RAID can only read metadata from all the above metadata formats,
not write all of them (Promise and Highpoint V2 so far). This means
that arrays can be picked up from the BIOS, but they cannot be
created from FreeBSD. There is more to it than just the missing
write metadata support, those formats are not unique to a given
controller like Promise and Highpoint formats, instead they exist
for several types, and even worse, some controllers can have
different formats and its impossible to tell which one.
The outcome is that we cannot reliably create the metadata of those
formats and be sure the controller BIOS will understand it.
However write support is needed to update/fail/rebuild the arrays
properly so it sits fairly high on the TODO list.
o So far atapicam is not supported with these changes. When/if this
will change is up to the maintainer of atapi-cam so go there for
questions.
HW donated by: Webveveriet AS
HW donated by: Frode Nordahl
HW donated by: Yahoo!
HW donated by: Sentex
Patience by: Vife and my boys (and even the cats)
2005-03-30 12:03:40 +00:00
|
|
|
err = ATA_IDX_INB(ch, ATA_ERROR);
|
2003-09-01 11:13:21 +00:00
|
|
|
lsb = ATA_IDX_INB(ch, ATA_CYL_LSB);
|
|
|
|
msb = ATA_IDX_INB(ch, ATA_CYL_MSB);
|
|
|
|
if (bootverbose)
|
2005-04-30 16:22:07 +00:00
|
|
|
device_printf(dev,
|
This is the much rumoured ATA mkIII update that I've been working on.
o ATA is now fully newbus'd and split into modules.
This means that on a modern system you just load "atapci and ata"
to get the base support, and then one or more of the device
subdrivers "atadisk atapicd atapifd atapist ataraid".
All can be loaded/unloaded anytime, but for obvious reasons you
dont want to unload atadisk when you have mounted filesystems.
o The device identify part of the probe has been rewritten to fix
the problems with odd devices the old had, and to try to remove
so of the long delays some HW could provoke. Also probing is done
without the need for interrupts, making earlier probing possible.
o SATA devices can be hot inserted/removed and devices will be created/
removed in /dev accordingly.
NOTE: only supported on controllers that has this feature:
Promise and Silicon Image for now.
On other controllers the usual atacontrol detach/attach dance is
still needed.
o Support for "atomic" composite ATA requests used for RAID.
o ATA RAID support has been rewritten and and now supports these
metadata formats:
"Adaptec HostRAID"
"Highpoint V2 RocketRAID"
"Highpoint V3 RocketRAID"
"Intel MatrixRAID"
"Integrated Technology Express"
"LSILogic V2 MegaRAID"
"LSILogic V3 MegaRAID"
"Promise FastTrak"
"Silicon Image Medley"
"FreeBSD PseudoRAID"
o Update the ioctl API to match new RAID levels etc.
o Update atacontrol to know about the new RAID levels etc
NOTE: you need to recompile atacontrol with the new sys/ata.h,
make world will take care of that.
NOTE2: that rebuild is done differently from the old system as
the rebuild is now done piggybacked on read requests to the
array, so atacontrol simply starts a background "dd" to rebuild
the array.
o The reinit code has been worked over to be much more robust.
o The timeout code has been overhauled for races.
o Support of new chipsets.
o Lots of fixes for bugs found while doing the modulerization and
reviewing the old code.
Missing or changed features from current ATA:
o atapi-cd no longer has support for ATAPI changers. Todays its
much cheaper and alot faster to copy those CD images to disk
and serve them from there. Besides they dont seem to be made
anymore, maybe for that exact reason.
o ATA RAID can only read metadata from all the above metadata formats,
not write all of them (Promise and Highpoint V2 so far). This means
that arrays can be picked up from the BIOS, but they cannot be
created from FreeBSD. There is more to it than just the missing
write metadata support, those formats are not unique to a given
controller like Promise and Highpoint formats, instead they exist
for several types, and even worse, some controllers can have
different formats and its impossible to tell which one.
The outcome is that we cannot reliably create the metadata of those
formats and be sure the controller BIOS will understand it.
However write support is needed to update/fail/rebuild the arrays
properly so it sits fairly high on the TODO list.
o So far atapicam is not supported with these changes. When/if this
will change is up to the maintainer of atapi-cam so go there for
questions.
HW donated by: Webveveriet AS
HW donated by: Frode Nordahl
HW donated by: Yahoo!
HW donated by: Sentex
Patience by: Vife and my boys (and even the cats)
2005-03-30 12:03:40 +00:00
|
|
|
"stat0=0x%02x err=0x%02x lsb=0x%02x msb=0x%02x\n",
|
|
|
|
stat0, err, lsb, msb);
|
2005-04-21 11:13:39 +00:00
|
|
|
if (stat0 == err && lsb == err && msb == err &&
|
|
|
|
timeout > (stat0 & ATA_S_BUSY ? 100 : 10))
|
This is the much rumoured ATA mkIII update that I've been working on.
o ATA is now fully newbus'd and split into modules.
This means that on a modern system you just load "atapci and ata"
to get the base support, and then one or more of the device
subdrivers "atadisk atapicd atapifd atapist ataraid".
All can be loaded/unloaded anytime, but for obvious reasons you
dont want to unload atadisk when you have mounted filesystems.
o The device identify part of the probe has been rewritten to fix
the problems with odd devices the old had, and to try to remove
so of the long delays some HW could provoke. Also probing is done
without the need for interrupts, making earlier probing possible.
o SATA devices can be hot inserted/removed and devices will be created/
removed in /dev accordingly.
NOTE: only supported on controllers that has this feature:
Promise and Silicon Image for now.
On other controllers the usual atacontrol detach/attach dance is
still needed.
o Support for "atomic" composite ATA requests used for RAID.
o ATA RAID support has been rewritten and and now supports these
metadata formats:
"Adaptec HostRAID"
"Highpoint V2 RocketRAID"
"Highpoint V3 RocketRAID"
"Intel MatrixRAID"
"Integrated Technology Express"
"LSILogic V2 MegaRAID"
"LSILogic V3 MegaRAID"
"Promise FastTrak"
"Silicon Image Medley"
"FreeBSD PseudoRAID"
o Update the ioctl API to match new RAID levels etc.
o Update atacontrol to know about the new RAID levels etc
NOTE: you need to recompile atacontrol with the new sys/ata.h,
make world will take care of that.
NOTE2: that rebuild is done differently from the old system as
the rebuild is now done piggybacked on read requests to the
array, so atacontrol simply starts a background "dd" to rebuild
the array.
o The reinit code has been worked over to be much more robust.
o The timeout code has been overhauled for races.
o Support of new chipsets.
o Lots of fixes for bugs found while doing the modulerization and
reviewing the old code.
Missing or changed features from current ATA:
o atapi-cd no longer has support for ATAPI changers. Todays its
much cheaper and alot faster to copy those CD images to disk
and serve them from there. Besides they dont seem to be made
anymore, maybe for that exact reason.
o ATA RAID can only read metadata from all the above metadata formats,
not write all of them (Promise and Highpoint V2 so far). This means
that arrays can be picked up from the BIOS, but they cannot be
created from FreeBSD. There is more to it than just the missing
write metadata support, those formats are not unique to a given
controller like Promise and Highpoint formats, instead they exist
for several types, and even worse, some controllers can have
different formats and its impossible to tell which one.
The outcome is that we cannot reliably create the metadata of those
formats and be sure the controller BIOS will understand it.
However write support is needed to update/fail/rebuild the arrays
properly so it sits fairly high on the TODO list.
o So far atapicam is not supported with these changes. When/if this
will change is up to the maintainer of atapi-cam so go there for
questions.
HW donated by: Webveveriet AS
HW donated by: Frode Nordahl
HW donated by: Yahoo!
HW donated by: Sentex
Patience by: Vife and my boys (and even the cats)
2005-03-30 12:03:40 +00:00
|
|
|
mask &= ~0x01;
|
2003-09-10 09:57:16 +00:00
|
|
|
if (!(stat0 & ATA_S_BUSY)) {
|
2003-09-20 08:38:33 +00:00
|
|
|
if ((err & 0x7f) == ATA_E_ILI) {
|
2003-09-16 15:16:36 +00:00
|
|
|
if (lsb == ATAPI_MAGIC_LSB && msb == ATAPI_MAGIC_MSB) {
|
2003-09-10 09:57:16 +00:00
|
|
|
ch->devices |= ATA_ATAPI_MASTER;
|
|
|
|
}
|
2011-04-21 07:26:14 +00:00
|
|
|
else if (lsb == 0 && msb == 0 && (stat0 & ATA_S_READY)) {
|
2003-09-16 15:16:36 +00:00
|
|
|
ch->devices |= ATA_ATA_MASTER;
|
|
|
|
}
|
|
|
|
}
|
This is the much rumoured ATA mkIII update that I've been working on.
o ATA is now fully newbus'd and split into modules.
This means that on a modern system you just load "atapci and ata"
to get the base support, and then one or more of the device
subdrivers "atadisk atapicd atapifd atapist ataraid".
All can be loaded/unloaded anytime, but for obvious reasons you
dont want to unload atadisk when you have mounted filesystems.
o The device identify part of the probe has been rewritten to fix
the problems with odd devices the old had, and to try to remove
so of the long delays some HW could provoke. Also probing is done
without the need for interrupts, making earlier probing possible.
o SATA devices can be hot inserted/removed and devices will be created/
removed in /dev accordingly.
NOTE: only supported on controllers that has this feature:
Promise and Silicon Image for now.
On other controllers the usual atacontrol detach/attach dance is
still needed.
o Support for "atomic" composite ATA requests used for RAID.
o ATA RAID support has been rewritten and and now supports these
metadata formats:
"Adaptec HostRAID"
"Highpoint V2 RocketRAID"
"Highpoint V3 RocketRAID"
"Intel MatrixRAID"
"Integrated Technology Express"
"LSILogic V2 MegaRAID"
"LSILogic V3 MegaRAID"
"Promise FastTrak"
"Silicon Image Medley"
"FreeBSD PseudoRAID"
o Update the ioctl API to match new RAID levels etc.
o Update atacontrol to know about the new RAID levels etc
NOTE: you need to recompile atacontrol with the new sys/ata.h,
make world will take care of that.
NOTE2: that rebuild is done differently from the old system as
the rebuild is now done piggybacked on read requests to the
array, so atacontrol simply starts a background "dd" to rebuild
the array.
o The reinit code has been worked over to be much more robust.
o The timeout code has been overhauled for races.
o Support of new chipsets.
o Lots of fixes for bugs found while doing the modulerization and
reviewing the old code.
Missing or changed features from current ATA:
o atapi-cd no longer has support for ATAPI changers. Todays its
much cheaper and alot faster to copy those CD images to disk
and serve them from there. Besides they dont seem to be made
anymore, maybe for that exact reason.
o ATA RAID can only read metadata from all the above metadata formats,
not write all of them (Promise and Highpoint V2 so far). This means
that arrays can be picked up from the BIOS, but they cannot be
created from FreeBSD. There is more to it than just the missing
write metadata support, those formats are not unique to a given
controller like Promise and Highpoint formats, instead they exist
for several types, and even worse, some controllers can have
different formats and its impossible to tell which one.
The outcome is that we cannot reliably create the metadata of those
formats and be sure the controller BIOS will understand it.
However write support is needed to update/fail/rebuild the arrays
properly so it sits fairly high on the TODO list.
o So far atapicam is not supported with these changes. When/if this
will change is up to the maintainer of atapi-cam so go there for
questions.
HW donated by: Webveveriet AS
HW donated by: Frode Nordahl
HW donated by: Yahoo!
HW donated by: Sentex
Patience by: Vife and my boys (and even the cats)
2005-03-30 12:03:40 +00:00
|
|
|
else if ((stat0 & 0x0f) && err == lsb && err == msb) {
|
2003-09-18 16:43:08 +00:00
|
|
|
stat0 |= ATA_S_BUSY;
|
2003-08-28 09:15:05 +00:00
|
|
|
}
|
2003-08-24 09:22:26 +00:00
|
|
|
}
|
|
|
|
}
|
This is the much rumoured ATA mkIII update that I've been working on.
o ATA is now fully newbus'd and split into modules.
This means that on a modern system you just load "atapci and ata"
to get the base support, and then one or more of the device
subdrivers "atadisk atapicd atapifd atapist ataraid".
All can be loaded/unloaded anytime, but for obvious reasons you
dont want to unload atadisk when you have mounted filesystems.
o The device identify part of the probe has been rewritten to fix
the problems with odd devices the old had, and to try to remove
so of the long delays some HW could provoke. Also probing is done
without the need for interrupts, making earlier probing possible.
o SATA devices can be hot inserted/removed and devices will be created/
removed in /dev accordingly.
NOTE: only supported on controllers that has this feature:
Promise and Silicon Image for now.
On other controllers the usual atacontrol detach/attach dance is
still needed.
o Support for "atomic" composite ATA requests used for RAID.
o ATA RAID support has been rewritten and and now supports these
metadata formats:
"Adaptec HostRAID"
"Highpoint V2 RocketRAID"
"Highpoint V3 RocketRAID"
"Intel MatrixRAID"
"Integrated Technology Express"
"LSILogic V2 MegaRAID"
"LSILogic V3 MegaRAID"
"Promise FastTrak"
"Silicon Image Medley"
"FreeBSD PseudoRAID"
o Update the ioctl API to match new RAID levels etc.
o Update atacontrol to know about the new RAID levels etc
NOTE: you need to recompile atacontrol with the new sys/ata.h,
make world will take care of that.
NOTE2: that rebuild is done differently from the old system as
the rebuild is now done piggybacked on read requests to the
array, so atacontrol simply starts a background "dd" to rebuild
the array.
o The reinit code has been worked over to be much more robust.
o The timeout code has been overhauled for races.
o Support of new chipsets.
o Lots of fixes for bugs found while doing the modulerization and
reviewing the old code.
Missing or changed features from current ATA:
o atapi-cd no longer has support for ATAPI changers. Todays its
much cheaper and alot faster to copy those CD images to disk
and serve them from there. Besides they dont seem to be made
anymore, maybe for that exact reason.
o ATA RAID can only read metadata from all the above metadata formats,
not write all of them (Promise and Highpoint V2 so far). This means
that arrays can be picked up from the BIOS, but they cannot be
created from FreeBSD. There is more to it than just the missing
write metadata support, those formats are not unique to a given
controller like Promise and Highpoint formats, instead they exist
for several types, and even worse, some controllers can have
different formats and its impossible to tell which one.
The outcome is that we cannot reliably create the metadata of those
formats and be sure the controller BIOS will understand it.
However write support is needed to update/fail/rebuild the arrays
properly so it sits fairly high on the TODO list.
o So far atapicam is not supported with these changes. When/if this
will change is up to the maintainer of atapi-cam so go there for
questions.
HW donated by: Webveveriet AS
HW donated by: Frode Nordahl
HW donated by: Yahoo!
HW donated by: Sentex
Patience by: Vife and my boys (and even the cats)
2005-03-30 12:03:40 +00:00
|
|
|
|
2005-04-03 13:03:53 +00:00
|
|
|
if ((mask & 0x02) && (stat1 & ATA_S_BUSY) &&
|
|
|
|
!((mask & 0x01) && (stat0 & ATA_S_BUSY))) {
|
2008-04-14 18:34:24 +00:00
|
|
|
ATA_IDX_OUTB(ch, ATA_DRIVE, ATA_D_IBM | ATA_DEV(ATA_SLAVE));
|
2003-08-24 09:22:26 +00:00
|
|
|
DELAY(10);
|
2010-09-09 13:17:30 +00:00
|
|
|
if (ch->flags & ATA_STATUS_IS_LONG)
|
|
|
|
stat1 = ATA_IDX_INL(ch, ATA_STATUS) & 0xff;
|
|
|
|
else
|
|
|
|
stat1 = ATA_IDX_INB(ch, ATA_STATUS);
|
This is the much rumoured ATA mkIII update that I've been working on.
o ATA is now fully newbus'd and split into modules.
This means that on a modern system you just load "atapci and ata"
to get the base support, and then one or more of the device
subdrivers "atadisk atapicd atapifd atapist ataraid".
All can be loaded/unloaded anytime, but for obvious reasons you
dont want to unload atadisk when you have mounted filesystems.
o The device identify part of the probe has been rewritten to fix
the problems with odd devices the old had, and to try to remove
so of the long delays some HW could provoke. Also probing is done
without the need for interrupts, making earlier probing possible.
o SATA devices can be hot inserted/removed and devices will be created/
removed in /dev accordingly.
NOTE: only supported on controllers that has this feature:
Promise and Silicon Image for now.
On other controllers the usual atacontrol detach/attach dance is
still needed.
o Support for "atomic" composite ATA requests used for RAID.
o ATA RAID support has been rewritten and and now supports these
metadata formats:
"Adaptec HostRAID"
"Highpoint V2 RocketRAID"
"Highpoint V3 RocketRAID"
"Intel MatrixRAID"
"Integrated Technology Express"
"LSILogic V2 MegaRAID"
"LSILogic V3 MegaRAID"
"Promise FastTrak"
"Silicon Image Medley"
"FreeBSD PseudoRAID"
o Update the ioctl API to match new RAID levels etc.
o Update atacontrol to know about the new RAID levels etc
NOTE: you need to recompile atacontrol with the new sys/ata.h,
make world will take care of that.
NOTE2: that rebuild is done differently from the old system as
the rebuild is now done piggybacked on read requests to the
array, so atacontrol simply starts a background "dd" to rebuild
the array.
o The reinit code has been worked over to be much more robust.
o The timeout code has been overhauled for races.
o Support of new chipsets.
o Lots of fixes for bugs found while doing the modulerization and
reviewing the old code.
Missing or changed features from current ATA:
o atapi-cd no longer has support for ATAPI changers. Todays its
much cheaper and alot faster to copy those CD images to disk
and serve them from there. Besides they dont seem to be made
anymore, maybe for that exact reason.
o ATA RAID can only read metadata from all the above metadata formats,
not write all of them (Promise and Highpoint V2 so far). This means
that arrays can be picked up from the BIOS, but they cannot be
created from FreeBSD. There is more to it than just the missing
write metadata support, those formats are not unique to a given
controller like Promise and Highpoint formats, instead they exist
for several types, and even worse, some controllers can have
different formats and its impossible to tell which one.
The outcome is that we cannot reliably create the metadata of those
formats and be sure the controller BIOS will understand it.
However write support is needed to update/fail/rebuild the arrays
properly so it sits fairly high on the TODO list.
o So far atapicam is not supported with these changes. When/if this
will change is up to the maintainer of atapi-cam so go there for
questions.
HW donated by: Webveveriet AS
HW donated by: Frode Nordahl
HW donated by: Yahoo!
HW donated by: Sentex
Patience by: Vife and my boys (and even the cats)
2005-03-30 12:03:40 +00:00
|
|
|
err = ATA_IDX_INB(ch, ATA_ERROR);
|
2003-09-01 11:13:21 +00:00
|
|
|
lsb = ATA_IDX_INB(ch, ATA_CYL_LSB);
|
|
|
|
msb = ATA_IDX_INB(ch, ATA_CYL_MSB);
|
|
|
|
if (bootverbose)
|
2005-04-30 16:22:07 +00:00
|
|
|
device_printf(dev,
|
This is the much rumoured ATA mkIII update that I've been working on.
o ATA is now fully newbus'd and split into modules.
This means that on a modern system you just load "atapci and ata"
to get the base support, and then one or more of the device
subdrivers "atadisk atapicd atapifd atapist ataraid".
All can be loaded/unloaded anytime, but for obvious reasons you
dont want to unload atadisk when you have mounted filesystems.
o The device identify part of the probe has been rewritten to fix
the problems with odd devices the old had, and to try to remove
so of the long delays some HW could provoke. Also probing is done
without the need for interrupts, making earlier probing possible.
o SATA devices can be hot inserted/removed and devices will be created/
removed in /dev accordingly.
NOTE: only supported on controllers that has this feature:
Promise and Silicon Image for now.
On other controllers the usual atacontrol detach/attach dance is
still needed.
o Support for "atomic" composite ATA requests used for RAID.
o ATA RAID support has been rewritten and and now supports these
metadata formats:
"Adaptec HostRAID"
"Highpoint V2 RocketRAID"
"Highpoint V3 RocketRAID"
"Intel MatrixRAID"
"Integrated Technology Express"
"LSILogic V2 MegaRAID"
"LSILogic V3 MegaRAID"
"Promise FastTrak"
"Silicon Image Medley"
"FreeBSD PseudoRAID"
o Update the ioctl API to match new RAID levels etc.
o Update atacontrol to know about the new RAID levels etc
NOTE: you need to recompile atacontrol with the new sys/ata.h,
make world will take care of that.
NOTE2: that rebuild is done differently from the old system as
the rebuild is now done piggybacked on read requests to the
array, so atacontrol simply starts a background "dd" to rebuild
the array.
o The reinit code has been worked over to be much more robust.
o The timeout code has been overhauled for races.
o Support of new chipsets.
o Lots of fixes for bugs found while doing the modulerization and
reviewing the old code.
Missing or changed features from current ATA:
o atapi-cd no longer has support for ATAPI changers. Todays its
much cheaper and alot faster to copy those CD images to disk
and serve them from there. Besides they dont seem to be made
anymore, maybe for that exact reason.
o ATA RAID can only read metadata from all the above metadata formats,
not write all of them (Promise and Highpoint V2 so far). This means
that arrays can be picked up from the BIOS, but they cannot be
created from FreeBSD. There is more to it than just the missing
write metadata support, those formats are not unique to a given
controller like Promise and Highpoint formats, instead they exist
for several types, and even worse, some controllers can have
different formats and its impossible to tell which one.
The outcome is that we cannot reliably create the metadata of those
formats and be sure the controller BIOS will understand it.
However write support is needed to update/fail/rebuild the arrays
properly so it sits fairly high on the TODO list.
o So far atapicam is not supported with these changes. When/if this
will change is up to the maintainer of atapi-cam so go there for
questions.
HW donated by: Webveveriet AS
HW donated by: Frode Nordahl
HW donated by: Yahoo!
HW donated by: Sentex
Patience by: Vife and my boys (and even the cats)
2005-03-30 12:03:40 +00:00
|
|
|
"stat1=0x%02x err=0x%02x lsb=0x%02x msb=0x%02x\n",
|
|
|
|
stat1, err, lsb, msb);
|
2005-04-21 11:13:39 +00:00
|
|
|
if (stat1 == err && lsb == err && msb == err &&
|
|
|
|
timeout > (stat1 & ATA_S_BUSY ? 100 : 10))
|
This is the much rumoured ATA mkIII update that I've been working on.
o ATA is now fully newbus'd and split into modules.
This means that on a modern system you just load "atapci and ata"
to get the base support, and then one or more of the device
subdrivers "atadisk atapicd atapifd atapist ataraid".
All can be loaded/unloaded anytime, but for obvious reasons you
dont want to unload atadisk when you have mounted filesystems.
o The device identify part of the probe has been rewritten to fix
the problems with odd devices the old had, and to try to remove
so of the long delays some HW could provoke. Also probing is done
without the need for interrupts, making earlier probing possible.
o SATA devices can be hot inserted/removed and devices will be created/
removed in /dev accordingly.
NOTE: only supported on controllers that has this feature:
Promise and Silicon Image for now.
On other controllers the usual atacontrol detach/attach dance is
still needed.
o Support for "atomic" composite ATA requests used for RAID.
o ATA RAID support has been rewritten and and now supports these
metadata formats:
"Adaptec HostRAID"
"Highpoint V2 RocketRAID"
"Highpoint V3 RocketRAID"
"Intel MatrixRAID"
"Integrated Technology Express"
"LSILogic V2 MegaRAID"
"LSILogic V3 MegaRAID"
"Promise FastTrak"
"Silicon Image Medley"
"FreeBSD PseudoRAID"
o Update the ioctl API to match new RAID levels etc.
o Update atacontrol to know about the new RAID levels etc
NOTE: you need to recompile atacontrol with the new sys/ata.h,
make world will take care of that.
NOTE2: that rebuild is done differently from the old system as
the rebuild is now done piggybacked on read requests to the
array, so atacontrol simply starts a background "dd" to rebuild
the array.
o The reinit code has been worked over to be much more robust.
o The timeout code has been overhauled for races.
o Support of new chipsets.
o Lots of fixes for bugs found while doing the modulerization and
reviewing the old code.
Missing or changed features from current ATA:
o atapi-cd no longer has support for ATAPI changers. Todays its
much cheaper and alot faster to copy those CD images to disk
and serve them from there. Besides they dont seem to be made
anymore, maybe for that exact reason.
o ATA RAID can only read metadata from all the above metadata formats,
not write all of them (Promise and Highpoint V2 so far). This means
that arrays can be picked up from the BIOS, but they cannot be
created from FreeBSD. There is more to it than just the missing
write metadata support, those formats are not unique to a given
controller like Promise and Highpoint formats, instead they exist
for several types, and even worse, some controllers can have
different formats and its impossible to tell which one.
The outcome is that we cannot reliably create the metadata of those
formats and be sure the controller BIOS will understand it.
However write support is needed to update/fail/rebuild the arrays
properly so it sits fairly high on the TODO list.
o So far atapicam is not supported with these changes. When/if this
will change is up to the maintainer of atapi-cam so go there for
questions.
HW donated by: Webveveriet AS
HW donated by: Frode Nordahl
HW donated by: Yahoo!
HW donated by: Sentex
Patience by: Vife and my boys (and even the cats)
2005-03-30 12:03:40 +00:00
|
|
|
mask &= ~0x02;
|
2003-09-10 09:57:16 +00:00
|
|
|
if (!(stat1 & ATA_S_BUSY)) {
|
2003-09-20 08:38:33 +00:00
|
|
|
if ((err & 0x7f) == ATA_E_ILI) {
|
2003-09-16 15:16:36 +00:00
|
|
|
if (lsb == ATAPI_MAGIC_LSB && msb == ATAPI_MAGIC_MSB) {
|
2003-09-10 09:57:16 +00:00
|
|
|
ch->devices |= ATA_ATAPI_SLAVE;
|
|
|
|
}
|
2011-04-21 07:26:14 +00:00
|
|
|
else if (lsb == 0 && msb == 0 && (stat1 & ATA_S_READY)) {
|
2003-09-16 15:16:36 +00:00
|
|
|
ch->devices |= ATA_ATA_SLAVE;
|
|
|
|
}
|
|
|
|
}
|
2005-04-03 13:03:53 +00:00
|
|
|
else if ((stat1 & 0x0f) && err == lsb && err == msb) {
|
|
|
|
stat1 |= ATA_S_BUSY;
|
2003-08-28 09:15:05 +00:00
|
|
|
}
|
2003-08-24 09:22:26 +00:00
|
|
|
}
|
|
|
|
}
|
This is the much rumoured ATA mkIII update that I've been working on.
o ATA is now fully newbus'd and split into modules.
This means that on a modern system you just load "atapci and ata"
to get the base support, and then one or more of the device
subdrivers "atadisk atapicd atapifd atapist ataraid".
All can be loaded/unloaded anytime, but for obvious reasons you
dont want to unload atadisk when you have mounted filesystems.
o The device identify part of the probe has been rewritten to fix
the problems with odd devices the old had, and to try to remove
so of the long delays some HW could provoke. Also probing is done
without the need for interrupts, making earlier probing possible.
o SATA devices can be hot inserted/removed and devices will be created/
removed in /dev accordingly.
NOTE: only supported on controllers that has this feature:
Promise and Silicon Image for now.
On other controllers the usual atacontrol detach/attach dance is
still needed.
o Support for "atomic" composite ATA requests used for RAID.
o ATA RAID support has been rewritten and and now supports these
metadata formats:
"Adaptec HostRAID"
"Highpoint V2 RocketRAID"
"Highpoint V3 RocketRAID"
"Intel MatrixRAID"
"Integrated Technology Express"
"LSILogic V2 MegaRAID"
"LSILogic V3 MegaRAID"
"Promise FastTrak"
"Silicon Image Medley"
"FreeBSD PseudoRAID"
o Update the ioctl API to match new RAID levels etc.
o Update atacontrol to know about the new RAID levels etc
NOTE: you need to recompile atacontrol with the new sys/ata.h,
make world will take care of that.
NOTE2: that rebuild is done differently from the old system as
the rebuild is now done piggybacked on read requests to the
array, so atacontrol simply starts a background "dd" to rebuild
the array.
o The reinit code has been worked over to be much more robust.
o The timeout code has been overhauled for races.
o Support of new chipsets.
o Lots of fixes for bugs found while doing the modulerization and
reviewing the old code.
Missing or changed features from current ATA:
o atapi-cd no longer has support for ATAPI changers. Todays its
much cheaper and alot faster to copy those CD images to disk
and serve them from there. Besides they dont seem to be made
anymore, maybe for that exact reason.
o ATA RAID can only read metadata from all the above metadata formats,
not write all of them (Promise and Highpoint V2 so far). This means
that arrays can be picked up from the BIOS, but they cannot be
created from FreeBSD. There is more to it than just the missing
write metadata support, those formats are not unique to a given
controller like Promise and Highpoint formats, instead they exist
for several types, and even worse, some controllers can have
different formats and its impossible to tell which one.
The outcome is that we cannot reliably create the metadata of those
formats and be sure the controller BIOS will understand it.
However write support is needed to update/fail/rebuild the arrays
properly so it sits fairly high on the TODO list.
o So far atapicam is not supported with these changes. When/if this
will change is up to the maintainer of atapi-cam so go there for
questions.
HW donated by: Webveveriet AS
HW donated by: Frode Nordahl
HW donated by: Yahoo!
HW donated by: Sentex
Patience by: Vife and my boys (and even the cats)
2005-03-30 12:03:40 +00:00
|
|
|
|
2010-09-02 11:18:43 +00:00
|
|
|
if ((ch->flags & ATA_KNOWN_PRESENCE) == 0 &&
|
|
|
|
timeout > ((mask == 0x03) ? 20 : 10)) {
|
|
|
|
if ((mask & 0x01) && stat0 == 0xff)
|
|
|
|
mask &= ~0x01;
|
|
|
|
if ((mask & 0x02) && stat1 == 0xff)
|
|
|
|
mask &= ~0x02;
|
2003-12-10 23:06:24 +00:00
|
|
|
}
|
2010-09-02 11:18:43 +00:00
|
|
|
if (((mask & 0x01) == 0 || !(stat0 & ATA_S_BUSY)) &&
|
|
|
|
((mask & 0x02) == 0 || !(stat1 & ATA_S_BUSY)))
|
|
|
|
break;
|
2004-09-03 12:10:44 +00:00
|
|
|
ata_udelay(100000);
|
2005-03-02 03:34:51 +00:00
|
|
|
}
|
2003-08-24 09:22:26 +00:00
|
|
|
|
|
|
|
if (bootverbose)
|
2008-04-14 18:34:24 +00:00
|
|
|
device_printf(dev, "reset tp2 stat0=%02x stat1=%02x devices=0x%x\n",
|
|
|
|
stat0, stat1, ch->devices);
|
2003-08-24 09:22:26 +00:00
|
|
|
}
|
|
|
|
|
2006-01-18 09:14:55 +00:00
|
|
|
/* must be called with ATA channel locked and state_mtx held */
|
2013-04-06 15:02:06 +00:00
|
|
|
static int
|
2006-01-18 09:14:55 +00:00
|
|
|
ata_generic_status(device_t dev)
|
|
|
|
{
|
|
|
|
struct ata_channel *ch = device_get_softc(dev);
|
|
|
|
|
|
|
|
if (ATA_IDX_INB(ch, ATA_ALTSTAT) & ATA_S_BUSY) {
|
|
|
|
DELAY(100);
|
|
|
|
if (ATA_IDX_INB(ch, ATA_ALTSTAT) & ATA_S_BUSY)
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2003-08-24 09:22:26 +00:00
|
|
|
static int
|
2009-10-31 13:24:14 +00:00
|
|
|
ata_wait(struct ata_channel *ch, int unit, u_int8_t mask)
|
2003-08-24 09:22:26 +00:00
|
|
|
{
|
|
|
|
u_int8_t status;
|
2003-10-01 09:58:19 +00:00
|
|
|
int timeout = 0;
|
2003-08-24 09:22:26 +00:00
|
|
|
|
|
|
|
DELAY(1);
|
2003-10-01 09:58:19 +00:00
|
|
|
|
2005-04-08 09:37:47 +00:00
|
|
|
/* wait at max 1 second for device to get !BUSY */
|
|
|
|
while (timeout < 1000000) {
|
This is the much rumoured ATA mkIII update that I've been working on.
o ATA is now fully newbus'd and split into modules.
This means that on a modern system you just load "atapci and ata"
to get the base support, and then one or more of the device
subdrivers "atadisk atapicd atapifd atapist ataraid".
All can be loaded/unloaded anytime, but for obvious reasons you
dont want to unload atadisk when you have mounted filesystems.
o The device identify part of the probe has been rewritten to fix
the problems with odd devices the old had, and to try to remove
so of the long delays some HW could provoke. Also probing is done
without the need for interrupts, making earlier probing possible.
o SATA devices can be hot inserted/removed and devices will be created/
removed in /dev accordingly.
NOTE: only supported on controllers that has this feature:
Promise and Silicon Image for now.
On other controllers the usual atacontrol detach/attach dance is
still needed.
o Support for "atomic" composite ATA requests used for RAID.
o ATA RAID support has been rewritten and and now supports these
metadata formats:
"Adaptec HostRAID"
"Highpoint V2 RocketRAID"
"Highpoint V3 RocketRAID"
"Intel MatrixRAID"
"Integrated Technology Express"
"LSILogic V2 MegaRAID"
"LSILogic V3 MegaRAID"
"Promise FastTrak"
"Silicon Image Medley"
"FreeBSD PseudoRAID"
o Update the ioctl API to match new RAID levels etc.
o Update atacontrol to know about the new RAID levels etc
NOTE: you need to recompile atacontrol with the new sys/ata.h,
make world will take care of that.
NOTE2: that rebuild is done differently from the old system as
the rebuild is now done piggybacked on read requests to the
array, so atacontrol simply starts a background "dd" to rebuild
the array.
o The reinit code has been worked over to be much more robust.
o The timeout code has been overhauled for races.
o Support of new chipsets.
o Lots of fixes for bugs found while doing the modulerization and
reviewing the old code.
Missing or changed features from current ATA:
o atapi-cd no longer has support for ATAPI changers. Todays its
much cheaper and alot faster to copy those CD images to disk
and serve them from there. Besides they dont seem to be made
anymore, maybe for that exact reason.
o ATA RAID can only read metadata from all the above metadata formats,
not write all of them (Promise and Highpoint V2 so far). This means
that arrays can be picked up from the BIOS, but they cannot be
created from FreeBSD. There is more to it than just the missing
write metadata support, those formats are not unique to a given
controller like Promise and Highpoint formats, instead they exist
for several types, and even worse, some controllers can have
different formats and its impossible to tell which one.
The outcome is that we cannot reliably create the metadata of those
formats and be sure the controller BIOS will understand it.
However write support is needed to update/fail/rebuild the arrays
properly so it sits fairly high on the TODO list.
o So far atapicam is not supported with these changes. When/if this
will change is up to the maintainer of atapi-cam so go there for
questions.
HW donated by: Webveveriet AS
HW donated by: Frode Nordahl
HW donated by: Yahoo!
HW donated by: Sentex
Patience by: Vife and my boys (and even the cats)
2005-03-30 12:03:40 +00:00
|
|
|
status = ATA_IDX_INB(ch, ATA_ALTSTAT);
|
2003-08-24 09:22:26 +00:00
|
|
|
|
This is the much rumoured ATA mkIII update that I've been working on.
o ATA is now fully newbus'd and split into modules.
This means that on a modern system you just load "atapci and ata"
to get the base support, and then one or more of the device
subdrivers "atadisk atapicd atapifd atapist ataraid".
All can be loaded/unloaded anytime, but for obvious reasons you
dont want to unload atadisk when you have mounted filesystems.
o The device identify part of the probe has been rewritten to fix
the problems with odd devices the old had, and to try to remove
so of the long delays some HW could provoke. Also probing is done
without the need for interrupts, making earlier probing possible.
o SATA devices can be hot inserted/removed and devices will be created/
removed in /dev accordingly.
NOTE: only supported on controllers that has this feature:
Promise and Silicon Image for now.
On other controllers the usual atacontrol detach/attach dance is
still needed.
o Support for "atomic" composite ATA requests used for RAID.
o ATA RAID support has been rewritten and and now supports these
metadata formats:
"Adaptec HostRAID"
"Highpoint V2 RocketRAID"
"Highpoint V3 RocketRAID"
"Intel MatrixRAID"
"Integrated Technology Express"
"LSILogic V2 MegaRAID"
"LSILogic V3 MegaRAID"
"Promise FastTrak"
"Silicon Image Medley"
"FreeBSD PseudoRAID"
o Update the ioctl API to match new RAID levels etc.
o Update atacontrol to know about the new RAID levels etc
NOTE: you need to recompile atacontrol with the new sys/ata.h,
make world will take care of that.
NOTE2: that rebuild is done differently from the old system as
the rebuild is now done piggybacked on read requests to the
array, so atacontrol simply starts a background "dd" to rebuild
the array.
o The reinit code has been worked over to be much more robust.
o The timeout code has been overhauled for races.
o Support of new chipsets.
o Lots of fixes for bugs found while doing the modulerization and
reviewing the old code.
Missing or changed features from current ATA:
o atapi-cd no longer has support for ATAPI changers. Todays its
much cheaper and alot faster to copy those CD images to disk
and serve them from there. Besides they dont seem to be made
anymore, maybe for that exact reason.
o ATA RAID can only read metadata from all the above metadata formats,
not write all of them (Promise and Highpoint V2 so far). This means
that arrays can be picked up from the BIOS, but they cannot be
created from FreeBSD. There is more to it than just the missing
write metadata support, those formats are not unique to a given
controller like Promise and Highpoint formats, instead they exist
for several types, and even worse, some controllers can have
different formats and its impossible to tell which one.
The outcome is that we cannot reliably create the metadata of those
formats and be sure the controller BIOS will understand it.
However write support is needed to update/fail/rebuild the arrays
properly so it sits fairly high on the TODO list.
o So far atapicam is not supported with these changes. When/if this
will change is up to the maintainer of atapi-cam so go there for
questions.
HW donated by: Webveveriet AS
HW donated by: Frode Nordahl
HW donated by: Yahoo!
HW donated by: Sentex
Patience by: Vife and my boys (and even the cats)
2005-03-30 12:03:40 +00:00
|
|
|
/* if drive fails status, reselect the drive and try again */
|
2003-08-24 09:22:26 +00:00
|
|
|
if (status == 0xff) {
|
2009-10-31 13:24:14 +00:00
|
|
|
ATA_IDX_OUTB(ch, ATA_DRIVE, ATA_D_IBM | ATA_DEV(unit));
|
This is the much rumoured ATA mkIII update that I've been working on.
o ATA is now fully newbus'd and split into modules.
This means that on a modern system you just load "atapci and ata"
to get the base support, and then one or more of the device
subdrivers "atadisk atapicd atapifd atapist ataraid".
All can be loaded/unloaded anytime, but for obvious reasons you
dont want to unload atadisk when you have mounted filesystems.
o The device identify part of the probe has been rewritten to fix
the problems with odd devices the old had, and to try to remove
so of the long delays some HW could provoke. Also probing is done
without the need for interrupts, making earlier probing possible.
o SATA devices can be hot inserted/removed and devices will be created/
removed in /dev accordingly.
NOTE: only supported on controllers that has this feature:
Promise and Silicon Image for now.
On other controllers the usual atacontrol detach/attach dance is
still needed.
o Support for "atomic" composite ATA requests used for RAID.
o ATA RAID support has been rewritten and and now supports these
metadata formats:
"Adaptec HostRAID"
"Highpoint V2 RocketRAID"
"Highpoint V3 RocketRAID"
"Intel MatrixRAID"
"Integrated Technology Express"
"LSILogic V2 MegaRAID"
"LSILogic V3 MegaRAID"
"Promise FastTrak"
"Silicon Image Medley"
"FreeBSD PseudoRAID"
o Update the ioctl API to match new RAID levels etc.
o Update atacontrol to know about the new RAID levels etc
NOTE: you need to recompile atacontrol with the new sys/ata.h,
make world will take care of that.
NOTE2: that rebuild is done differently from the old system as
the rebuild is now done piggybacked on read requests to the
array, so atacontrol simply starts a background "dd" to rebuild
the array.
o The reinit code has been worked over to be much more robust.
o The timeout code has been overhauled for races.
o Support of new chipsets.
o Lots of fixes for bugs found while doing the modulerization and
reviewing the old code.
Missing or changed features from current ATA:
o atapi-cd no longer has support for ATAPI changers. Todays its
much cheaper and alot faster to copy those CD images to disk
and serve them from there. Besides they dont seem to be made
anymore, maybe for that exact reason.
o ATA RAID can only read metadata from all the above metadata formats,
not write all of them (Promise and Highpoint V2 so far). This means
that arrays can be picked up from the BIOS, but they cannot be
created from FreeBSD. There is more to it than just the missing
write metadata support, those formats are not unique to a given
controller like Promise and Highpoint formats, instead they exist
for several types, and even worse, some controllers can have
different formats and its impossible to tell which one.
The outcome is that we cannot reliably create the metadata of those
formats and be sure the controller BIOS will understand it.
However write support is needed to update/fail/rebuild the arrays
properly so it sits fairly high on the TODO list.
o So far atapicam is not supported with these changes. When/if this
will change is up to the maintainer of atapi-cam so go there for
questions.
HW donated by: Webveveriet AS
HW donated by: Frode Nordahl
HW donated by: Yahoo!
HW donated by: Sentex
Patience by: Vife and my boys (and even the cats)
2005-03-30 12:03:40 +00:00
|
|
|
timeout += 1000;
|
|
|
|
DELAY(1000);
|
|
|
|
continue;
|
2003-08-24 09:22:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* are we done ? */
|
|
|
|
if (!(status & ATA_S_BUSY))
|
This is the much rumoured ATA mkIII update that I've been working on.
o ATA is now fully newbus'd and split into modules.
This means that on a modern system you just load "atapci and ata"
to get the base support, and then one or more of the device
subdrivers "atadisk atapicd atapifd atapist ataraid".
All can be loaded/unloaded anytime, but for obvious reasons you
dont want to unload atadisk when you have mounted filesystems.
o The device identify part of the probe has been rewritten to fix
the problems with odd devices the old had, and to try to remove
so of the long delays some HW could provoke. Also probing is done
without the need for interrupts, making earlier probing possible.
o SATA devices can be hot inserted/removed and devices will be created/
removed in /dev accordingly.
NOTE: only supported on controllers that has this feature:
Promise and Silicon Image for now.
On other controllers the usual atacontrol detach/attach dance is
still needed.
o Support for "atomic" composite ATA requests used for RAID.
o ATA RAID support has been rewritten and and now supports these
metadata formats:
"Adaptec HostRAID"
"Highpoint V2 RocketRAID"
"Highpoint V3 RocketRAID"
"Intel MatrixRAID"
"Integrated Technology Express"
"LSILogic V2 MegaRAID"
"LSILogic V3 MegaRAID"
"Promise FastTrak"
"Silicon Image Medley"
"FreeBSD PseudoRAID"
o Update the ioctl API to match new RAID levels etc.
o Update atacontrol to know about the new RAID levels etc
NOTE: you need to recompile atacontrol with the new sys/ata.h,
make world will take care of that.
NOTE2: that rebuild is done differently from the old system as
the rebuild is now done piggybacked on read requests to the
array, so atacontrol simply starts a background "dd" to rebuild
the array.
o The reinit code has been worked over to be much more robust.
o The timeout code has been overhauled for races.
o Support of new chipsets.
o Lots of fixes for bugs found while doing the modulerization and
reviewing the old code.
Missing or changed features from current ATA:
o atapi-cd no longer has support for ATAPI changers. Todays its
much cheaper and alot faster to copy those CD images to disk
and serve them from there. Besides they dont seem to be made
anymore, maybe for that exact reason.
o ATA RAID can only read metadata from all the above metadata formats,
not write all of them (Promise and Highpoint V2 so far). This means
that arrays can be picked up from the BIOS, but they cannot be
created from FreeBSD. There is more to it than just the missing
write metadata support, those formats are not unique to a given
controller like Promise and Highpoint formats, instead they exist
for several types, and even worse, some controllers can have
different formats and its impossible to tell which one.
The outcome is that we cannot reliably create the metadata of those
formats and be sure the controller BIOS will understand it.
However write support is needed to update/fail/rebuild the arrays
properly so it sits fairly high on the TODO list.
o So far atapicam is not supported with these changes. When/if this
will change is up to the maintainer of atapi-cam so go there for
questions.
HW donated by: Webveveriet AS
HW donated by: Frode Nordahl
HW donated by: Yahoo!
HW donated by: Sentex
Patience by: Vife and my boys (and even the cats)
2005-03-30 12:03:40 +00:00
|
|
|
break;
|
2003-08-24 09:22:26 +00:00
|
|
|
|
|
|
|
if (timeout > 1000) {
|
|
|
|
timeout += 1000;
|
|
|
|
DELAY(1000);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
timeout += 10;
|
|
|
|
DELAY(10);
|
|
|
|
}
|
This is the much rumoured ATA mkIII update that I've been working on.
o ATA is now fully newbus'd and split into modules.
This means that on a modern system you just load "atapci and ata"
to get the base support, and then one or more of the device
subdrivers "atadisk atapicd atapifd atapist ataraid".
All can be loaded/unloaded anytime, but for obvious reasons you
dont want to unload atadisk when you have mounted filesystems.
o The device identify part of the probe has been rewritten to fix
the problems with odd devices the old had, and to try to remove
so of the long delays some HW could provoke. Also probing is done
without the need for interrupts, making earlier probing possible.
o SATA devices can be hot inserted/removed and devices will be created/
removed in /dev accordingly.
NOTE: only supported on controllers that has this feature:
Promise and Silicon Image for now.
On other controllers the usual atacontrol detach/attach dance is
still needed.
o Support for "atomic" composite ATA requests used for RAID.
o ATA RAID support has been rewritten and and now supports these
metadata formats:
"Adaptec HostRAID"
"Highpoint V2 RocketRAID"
"Highpoint V3 RocketRAID"
"Intel MatrixRAID"
"Integrated Technology Express"
"LSILogic V2 MegaRAID"
"LSILogic V3 MegaRAID"
"Promise FastTrak"
"Silicon Image Medley"
"FreeBSD PseudoRAID"
o Update the ioctl API to match new RAID levels etc.
o Update atacontrol to know about the new RAID levels etc
NOTE: you need to recompile atacontrol with the new sys/ata.h,
make world will take care of that.
NOTE2: that rebuild is done differently from the old system as
the rebuild is now done piggybacked on read requests to the
array, so atacontrol simply starts a background "dd" to rebuild
the array.
o The reinit code has been worked over to be much more robust.
o The timeout code has been overhauled for races.
o Support of new chipsets.
o Lots of fixes for bugs found while doing the modulerization and
reviewing the old code.
Missing or changed features from current ATA:
o atapi-cd no longer has support for ATAPI changers. Todays its
much cheaper and alot faster to copy those CD images to disk
and serve them from there. Besides they dont seem to be made
anymore, maybe for that exact reason.
o ATA RAID can only read metadata from all the above metadata formats,
not write all of them (Promise and Highpoint V2 so far). This means
that arrays can be picked up from the BIOS, but they cannot be
created from FreeBSD. There is more to it than just the missing
write metadata support, those formats are not unique to a given
controller like Promise and Highpoint formats, instead they exist
for several types, and even worse, some controllers can have
different formats and its impossible to tell which one.
The outcome is that we cannot reliably create the metadata of those
formats and be sure the controller BIOS will understand it.
However write support is needed to update/fail/rebuild the arrays
properly so it sits fairly high on the TODO list.
o So far atapicam is not supported with these changes. When/if this
will change is up to the maintainer of atapi-cam so go there for
questions.
HW donated by: Webveveriet AS
HW donated by: Frode Nordahl
HW donated by: Yahoo!
HW donated by: Sentex
Patience by: Vife and my boys (and even the cats)
2005-03-30 12:03:40 +00:00
|
|
|
}
|
2005-04-08 09:37:47 +00:00
|
|
|
if (timeout >= 1000000)
|
This is the much rumoured ATA mkIII update that I've been working on.
o ATA is now fully newbus'd and split into modules.
This means that on a modern system you just load "atapci and ata"
to get the base support, and then one or more of the device
subdrivers "atadisk atapicd atapifd atapist ataraid".
All can be loaded/unloaded anytime, but for obvious reasons you
dont want to unload atadisk when you have mounted filesystems.
o The device identify part of the probe has been rewritten to fix
the problems with odd devices the old had, and to try to remove
so of the long delays some HW could provoke. Also probing is done
without the need for interrupts, making earlier probing possible.
o SATA devices can be hot inserted/removed and devices will be created/
removed in /dev accordingly.
NOTE: only supported on controllers that has this feature:
Promise and Silicon Image for now.
On other controllers the usual atacontrol detach/attach dance is
still needed.
o Support for "atomic" composite ATA requests used for RAID.
o ATA RAID support has been rewritten and and now supports these
metadata formats:
"Adaptec HostRAID"
"Highpoint V2 RocketRAID"
"Highpoint V3 RocketRAID"
"Intel MatrixRAID"
"Integrated Technology Express"
"LSILogic V2 MegaRAID"
"LSILogic V3 MegaRAID"
"Promise FastTrak"
"Silicon Image Medley"
"FreeBSD PseudoRAID"
o Update the ioctl API to match new RAID levels etc.
o Update atacontrol to know about the new RAID levels etc
NOTE: you need to recompile atacontrol with the new sys/ata.h,
make world will take care of that.
NOTE2: that rebuild is done differently from the old system as
the rebuild is now done piggybacked on read requests to the
array, so atacontrol simply starts a background "dd" to rebuild
the array.
o The reinit code has been worked over to be much more robust.
o The timeout code has been overhauled for races.
o Support of new chipsets.
o Lots of fixes for bugs found while doing the modulerization and
reviewing the old code.
Missing or changed features from current ATA:
o atapi-cd no longer has support for ATAPI changers. Todays its
much cheaper and alot faster to copy those CD images to disk
and serve them from there. Besides they dont seem to be made
anymore, maybe for that exact reason.
o ATA RAID can only read metadata from all the above metadata formats,
not write all of them (Promise and Highpoint V2 so far). This means
that arrays can be picked up from the BIOS, but they cannot be
created from FreeBSD. There is more to it than just the missing
write metadata support, those formats are not unique to a given
controller like Promise and Highpoint formats, instead they exist
for several types, and even worse, some controllers can have
different formats and its impossible to tell which one.
The outcome is that we cannot reliably create the metadata of those
formats and be sure the controller BIOS will understand it.
However write support is needed to update/fail/rebuild the arrays
properly so it sits fairly high on the TODO list.
o So far atapicam is not supported with these changes. When/if this
will change is up to the maintainer of atapi-cam so go there for
questions.
HW donated by: Webveveriet AS
HW donated by: Frode Nordahl
HW donated by: Yahoo!
HW donated by: Sentex
Patience by: Vife and my boys (and even the cats)
2005-03-30 12:03:40 +00:00
|
|
|
return -2;
|
|
|
|
if (!mask)
|
|
|
|
return (status & ATA_S_ERROR);
|
2003-10-01 09:58:19 +00:00
|
|
|
|
|
|
|
DELAY(1);
|
2003-08-24 09:22:26 +00:00
|
|
|
|
This is the much rumoured ATA mkIII update that I've been working on.
o ATA is now fully newbus'd and split into modules.
This means that on a modern system you just load "atapci and ata"
to get the base support, and then one or more of the device
subdrivers "atadisk atapicd atapifd atapist ataraid".
All can be loaded/unloaded anytime, but for obvious reasons you
dont want to unload atadisk when you have mounted filesystems.
o The device identify part of the probe has been rewritten to fix
the problems with odd devices the old had, and to try to remove
so of the long delays some HW could provoke. Also probing is done
without the need for interrupts, making earlier probing possible.
o SATA devices can be hot inserted/removed and devices will be created/
removed in /dev accordingly.
NOTE: only supported on controllers that has this feature:
Promise and Silicon Image for now.
On other controllers the usual atacontrol detach/attach dance is
still needed.
o Support for "atomic" composite ATA requests used for RAID.
o ATA RAID support has been rewritten and and now supports these
metadata formats:
"Adaptec HostRAID"
"Highpoint V2 RocketRAID"
"Highpoint V3 RocketRAID"
"Intel MatrixRAID"
"Integrated Technology Express"
"LSILogic V2 MegaRAID"
"LSILogic V3 MegaRAID"
"Promise FastTrak"
"Silicon Image Medley"
"FreeBSD PseudoRAID"
o Update the ioctl API to match new RAID levels etc.
o Update atacontrol to know about the new RAID levels etc
NOTE: you need to recompile atacontrol with the new sys/ata.h,
make world will take care of that.
NOTE2: that rebuild is done differently from the old system as
the rebuild is now done piggybacked on read requests to the
array, so atacontrol simply starts a background "dd" to rebuild
the array.
o The reinit code has been worked over to be much more robust.
o The timeout code has been overhauled for races.
o Support of new chipsets.
o Lots of fixes for bugs found while doing the modulerization and
reviewing the old code.
Missing or changed features from current ATA:
o atapi-cd no longer has support for ATAPI changers. Todays its
much cheaper and alot faster to copy those CD images to disk
and serve them from there. Besides they dont seem to be made
anymore, maybe for that exact reason.
o ATA RAID can only read metadata from all the above metadata formats,
not write all of them (Promise and Highpoint V2 so far). This means
that arrays can be picked up from the BIOS, but they cannot be
created from FreeBSD. There is more to it than just the missing
write metadata support, those formats are not unique to a given
controller like Promise and Highpoint formats, instead they exist
for several types, and even worse, some controllers can have
different formats and its impossible to tell which one.
The outcome is that we cannot reliably create the metadata of those
formats and be sure the controller BIOS will understand it.
However write support is needed to update/fail/rebuild the arrays
properly so it sits fairly high on the TODO list.
o So far atapicam is not supported with these changes. When/if this
will change is up to the maintainer of atapi-cam so go there for
questions.
HW donated by: Webveveriet AS
HW donated by: Frode Nordahl
HW donated by: Yahoo!
HW donated by: Sentex
Patience by: Vife and my boys (and even the cats)
2005-03-30 12:03:40 +00:00
|
|
|
/* wait 50 msec for bits wanted */
|
2003-08-24 09:22:26 +00:00
|
|
|
timeout = 5000;
|
This is the much rumoured ATA mkIII update that I've been working on.
o ATA is now fully newbus'd and split into modules.
This means that on a modern system you just load "atapci and ata"
to get the base support, and then one or more of the device
subdrivers "atadisk atapicd atapifd atapist ataraid".
All can be loaded/unloaded anytime, but for obvious reasons you
dont want to unload atadisk when you have mounted filesystems.
o The device identify part of the probe has been rewritten to fix
the problems with odd devices the old had, and to try to remove
so of the long delays some HW could provoke. Also probing is done
without the need for interrupts, making earlier probing possible.
o SATA devices can be hot inserted/removed and devices will be created/
removed in /dev accordingly.
NOTE: only supported on controllers that has this feature:
Promise and Silicon Image for now.
On other controllers the usual atacontrol detach/attach dance is
still needed.
o Support for "atomic" composite ATA requests used for RAID.
o ATA RAID support has been rewritten and and now supports these
metadata formats:
"Adaptec HostRAID"
"Highpoint V2 RocketRAID"
"Highpoint V3 RocketRAID"
"Intel MatrixRAID"
"Integrated Technology Express"
"LSILogic V2 MegaRAID"
"LSILogic V3 MegaRAID"
"Promise FastTrak"
"Silicon Image Medley"
"FreeBSD PseudoRAID"
o Update the ioctl API to match new RAID levels etc.
o Update atacontrol to know about the new RAID levels etc
NOTE: you need to recompile atacontrol with the new sys/ata.h,
make world will take care of that.
NOTE2: that rebuild is done differently from the old system as
the rebuild is now done piggybacked on read requests to the
array, so atacontrol simply starts a background "dd" to rebuild
the array.
o The reinit code has been worked over to be much more robust.
o The timeout code has been overhauled for races.
o Support of new chipsets.
o Lots of fixes for bugs found while doing the modulerization and
reviewing the old code.
Missing or changed features from current ATA:
o atapi-cd no longer has support for ATAPI changers. Todays its
much cheaper and alot faster to copy those CD images to disk
and serve them from there. Besides they dont seem to be made
anymore, maybe for that exact reason.
o ATA RAID can only read metadata from all the above metadata formats,
not write all of them (Promise and Highpoint V2 so far). This means
that arrays can be picked up from the BIOS, but they cannot be
created from FreeBSD. There is more to it than just the missing
write metadata support, those formats are not unique to a given
controller like Promise and Highpoint formats, instead they exist
for several types, and even worse, some controllers can have
different formats and its impossible to tell which one.
The outcome is that we cannot reliably create the metadata of those
formats and be sure the controller BIOS will understand it.
However write support is needed to update/fail/rebuild the arrays
properly so it sits fairly high on the TODO list.
o So far atapicam is not supported with these changes. When/if this
will change is up to the maintainer of atapi-cam so go there for
questions.
HW donated by: Webveveriet AS
HW donated by: Frode Nordahl
HW donated by: Yahoo!
HW donated by: Sentex
Patience by: Vife and my boys (and even the cats)
2005-03-30 12:03:40 +00:00
|
|
|
while (timeout--) {
|
|
|
|
status = ATA_IDX_INB(ch, ATA_ALTSTAT);
|
2003-08-24 09:22:26 +00:00
|
|
|
if ((status & mask) == mask)
|
This is the much rumoured ATA mkIII update that I've been working on.
o ATA is now fully newbus'd and split into modules.
This means that on a modern system you just load "atapci and ata"
to get the base support, and then one or more of the device
subdrivers "atadisk atapicd atapifd atapist ataraid".
All can be loaded/unloaded anytime, but for obvious reasons you
dont want to unload atadisk when you have mounted filesystems.
o The device identify part of the probe has been rewritten to fix
the problems with odd devices the old had, and to try to remove
so of the long delays some HW could provoke. Also probing is done
without the need for interrupts, making earlier probing possible.
o SATA devices can be hot inserted/removed and devices will be created/
removed in /dev accordingly.
NOTE: only supported on controllers that has this feature:
Promise and Silicon Image for now.
On other controllers the usual atacontrol detach/attach dance is
still needed.
o Support for "atomic" composite ATA requests used for RAID.
o ATA RAID support has been rewritten and and now supports these
metadata formats:
"Adaptec HostRAID"
"Highpoint V2 RocketRAID"
"Highpoint V3 RocketRAID"
"Intel MatrixRAID"
"Integrated Technology Express"
"LSILogic V2 MegaRAID"
"LSILogic V3 MegaRAID"
"Promise FastTrak"
"Silicon Image Medley"
"FreeBSD PseudoRAID"
o Update the ioctl API to match new RAID levels etc.
o Update atacontrol to know about the new RAID levels etc
NOTE: you need to recompile atacontrol with the new sys/ata.h,
make world will take care of that.
NOTE2: that rebuild is done differently from the old system as
the rebuild is now done piggybacked on read requests to the
array, so atacontrol simply starts a background "dd" to rebuild
the array.
o The reinit code has been worked over to be much more robust.
o The timeout code has been overhauled for races.
o Support of new chipsets.
o Lots of fixes for bugs found while doing the modulerization and
reviewing the old code.
Missing or changed features from current ATA:
o atapi-cd no longer has support for ATAPI changers. Todays its
much cheaper and alot faster to copy those CD images to disk
and serve them from there. Besides they dont seem to be made
anymore, maybe for that exact reason.
o ATA RAID can only read metadata from all the above metadata formats,
not write all of them (Promise and Highpoint V2 so far). This means
that arrays can be picked up from the BIOS, but they cannot be
created from FreeBSD. There is more to it than just the missing
write metadata support, those formats are not unique to a given
controller like Promise and Highpoint formats, instead they exist
for several types, and even worse, some controllers can have
different formats and its impossible to tell which one.
The outcome is that we cannot reliably create the metadata of those
formats and be sure the controller BIOS will understand it.
However write support is needed to update/fail/rebuild the arrays
properly so it sits fairly high on the TODO list.
o So far atapicam is not supported with these changes. When/if this
will change is up to the maintainer of atapi-cam so go there for
questions.
HW donated by: Webveveriet AS
HW donated by: Frode Nordahl
HW donated by: Yahoo!
HW donated by: Sentex
Patience by: Vife and my boys (and even the cats)
2005-03-30 12:03:40 +00:00
|
|
|
return (status & ATA_S_ERROR);
|
|
|
|
DELAY(10);
|
|
|
|
}
|
|
|
|
return -3;
|
2003-08-24 09:22:26 +00:00
|
|
|
}
|
|
|
|
|
2004-04-13 09:44:20 +00:00
|
|
|
int
|
2005-05-03 07:55:07 +00:00
|
|
|
ata_generic_command(struct ata_request *request)
|
2003-08-24 09:22:26 +00:00
|
|
|
{
|
2008-04-10 13:05:05 +00:00
|
|
|
struct ata_channel *ch = device_get_softc(request->parent);
|
2003-08-24 09:22:26 +00:00
|
|
|
|
|
|
|
/* select device */
|
2009-10-31 13:24:14 +00:00
|
|
|
ATA_IDX_OUTB(ch, ATA_DRIVE, ATA_D_IBM | ATA_D_LBA | ATA_DEV(request->unit));
|
2003-08-24 09:22:26 +00:00
|
|
|
|
|
|
|
/* ready to issue command ? */
|
2009-10-31 13:24:14 +00:00
|
|
|
if (ata_wait(ch, request->unit, 0) < 0) {
|
|
|
|
device_printf(request->parent, "timeout waiting to issue command\n");
|
2010-11-06 19:11:49 +00:00
|
|
|
request->flags |= ATA_R_TIMEOUT;
|
|
|
|
return (-1);
|
2003-08-24 09:22:26 +00:00
|
|
|
}
|
|
|
|
|
2004-02-02 15:49:01 +00:00
|
|
|
/* enable interrupt */
|
2005-04-06 10:22:56 +00:00
|
|
|
ATA_IDX_OUTB(ch, ATA_CONTROL, ATA_A_4BIT);
|
2004-02-02 15:49:01 +00:00
|
|
|
|
2005-05-03 07:55:07 +00:00
|
|
|
if (request->flags & ATA_R_ATAPI) {
|
2005-05-16 13:07:27 +00:00
|
|
|
int timeout = 5000;
|
2009-10-31 13:24:14 +00:00
|
|
|
int res;
|
2005-05-03 07:55:07 +00:00
|
|
|
|
2005-05-16 13:07:27 +00:00
|
|
|
/* issue packet command to controller */
|
2005-05-13 07:58:05 +00:00
|
|
|
if (request->flags & ATA_R_DMA) {
|
2005-05-11 12:41:35 +00:00
|
|
|
ATA_IDX_OUTB(ch, ATA_FEATURE, ATA_F_DMA);
|
2005-05-13 07:58:05 +00:00
|
|
|
ATA_IDX_OUTB(ch, ATA_CYL_LSB, 0);
|
|
|
|
ATA_IDX_OUTB(ch, ATA_CYL_MSB, 0);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ATA_IDX_OUTB(ch, ATA_FEATURE, 0);
|
|
|
|
ATA_IDX_OUTB(ch, ATA_CYL_LSB, request->transfersize);
|
|
|
|
ATA_IDX_OUTB(ch, ATA_CYL_MSB, request->transfersize >> 8);
|
|
|
|
}
|
2005-05-11 12:41:35 +00:00
|
|
|
ATA_IDX_OUTB(ch, ATA_COMMAND, ATA_PACKET_CMD);
|
2005-05-03 07:55:07 +00:00
|
|
|
|
|
|
|
/* command interrupt device ? just return and wait for interrupt */
|
2009-10-31 13:24:14 +00:00
|
|
|
if (request->flags & ATA_R_ATAPI_INTR)
|
2010-11-06 19:11:49 +00:00
|
|
|
return (0);
|
2005-05-03 07:55:07 +00:00
|
|
|
|
2009-10-31 13:24:14 +00:00
|
|
|
/* command processed ? */
|
|
|
|
res = ata_wait(ch, request->unit, 0);
|
|
|
|
if (res != 0) {
|
2010-11-06 19:11:49 +00:00
|
|
|
if (res < 0) {
|
|
|
|
device_printf(request->parent,
|
|
|
|
"timeout waiting for PACKET command\n");
|
|
|
|
request->flags |= ATA_R_TIMEOUT;
|
|
|
|
}
|
2009-10-31 13:24:14 +00:00
|
|
|
return (-1);
|
|
|
|
}
|
2005-05-03 07:55:07 +00:00
|
|
|
/* wait for ready to write ATAPI command block */
|
2005-05-16 13:07:27 +00:00
|
|
|
while (timeout--) {
|
|
|
|
int reason = ATA_IDX_INB(ch, ATA_IREASON);
|
|
|
|
int status = ATA_IDX_INB(ch, ATA_STATUS);
|
|
|
|
|
|
|
|
if (((reason & (ATA_I_CMD | ATA_I_IN)) |
|
|
|
|
(status & (ATA_S_DRQ | ATA_S_BUSY))) == ATAPI_P_CMDOUT)
|
|
|
|
break;
|
|
|
|
DELAY(20);
|
|
|
|
}
|
|
|
|
if (timeout <= 0) {
|
2010-11-06 19:11:49 +00:00
|
|
|
device_printf(request->parent,
|
|
|
|
"timeout waiting for ATAPI ready\n");
|
|
|
|
request->flags |= ATA_R_TIMEOUT;
|
|
|
|
return (-1);
|
2005-05-16 13:07:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* this seems to be needed for some (slow) devices */
|
|
|
|
DELAY(10);
|
|
|
|
|
|
|
|
/* output command block */
|
|
|
|
ATA_IDX_OUTSW_STRM(ch, ATA_DATA, (int16_t *)request->u.atapi.ccb,
|
2009-10-31 13:24:14 +00:00
|
|
|
(request->flags & ATA_R_ATAPI16) ? 8 : 6);
|
2003-08-24 09:22:26 +00:00
|
|
|
}
|
|
|
|
else {
|
2007-12-13 11:47:36 +00:00
|
|
|
ch->hw.tf_write(request);
|
|
|
|
|
|
|
|
/* issue command to controller */
|
|
|
|
ATA_IDX_OUTB(ch, ATA_COMMAND, request->u.ata.command);
|
|
|
|
}
|
2010-11-06 19:11:49 +00:00
|
|
|
return (0);
|
2007-12-13 11:47:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ata_tf_read(struct ata_request *request)
|
|
|
|
{
|
2008-04-10 13:05:05 +00:00
|
|
|
struct ata_channel *ch = device_get_softc(request->parent);
|
2007-12-13 11:47:36 +00:00
|
|
|
|
2009-10-31 13:24:14 +00:00
|
|
|
if (request->flags & ATA_R_48BIT) {
|
2007-12-13 11:47:36 +00:00
|
|
|
ATA_IDX_OUTB(ch, ATA_CONTROL, ATA_A_4BIT | ATA_A_HOB);
|
|
|
|
request->u.ata.count = (ATA_IDX_INB(ch, ATA_COUNT) << 8);
|
|
|
|
request->u.ata.lba =
|
|
|
|
((u_int64_t)(ATA_IDX_INB(ch, ATA_SECTOR)) << 24) |
|
|
|
|
((u_int64_t)(ATA_IDX_INB(ch, ATA_CYL_LSB)) << 32) |
|
|
|
|
((u_int64_t)(ATA_IDX_INB(ch, ATA_CYL_MSB)) << 40);
|
|
|
|
|
|
|
|
ATA_IDX_OUTB(ch, ATA_CONTROL, ATA_A_4BIT);
|
|
|
|
request->u.ata.count |= ATA_IDX_INB(ch, ATA_COUNT);
|
|
|
|
request->u.ata.lba |=
|
|
|
|
(ATA_IDX_INB(ch, ATA_SECTOR) |
|
|
|
|
(ATA_IDX_INB(ch, ATA_CYL_LSB) << 8) |
|
|
|
|
(ATA_IDX_INB(ch, ATA_CYL_MSB) << 16));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
request->u.ata.count = ATA_IDX_INB(ch, ATA_COUNT);
|
|
|
|
request->u.ata.lba = ATA_IDX_INB(ch, ATA_SECTOR) |
|
|
|
|
(ATA_IDX_INB(ch, ATA_CYL_LSB) << 8) |
|
|
|
|
(ATA_IDX_INB(ch, ATA_CYL_MSB) << 16) |
|
|
|
|
((ATA_IDX_INB(ch, ATA_DRIVE) & 0xf) << 24);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ata_tf_write(struct ata_request *request)
|
|
|
|
{
|
2008-04-10 13:05:05 +00:00
|
|
|
struct ata_channel *ch = device_get_softc(request->parent);
|
2007-12-13 11:47:36 +00:00
|
|
|
|
2009-10-31 13:24:14 +00:00
|
|
|
if (request->flags & ATA_R_48BIT) {
|
2007-12-13 11:47:36 +00:00
|
|
|
ATA_IDX_OUTB(ch, ATA_FEATURE, request->u.ata.feature >> 8);
|
|
|
|
ATA_IDX_OUTB(ch, ATA_FEATURE, request->u.ata.feature);
|
|
|
|
ATA_IDX_OUTB(ch, ATA_COUNT, request->u.ata.count >> 8);
|
|
|
|
ATA_IDX_OUTB(ch, ATA_COUNT, request->u.ata.count);
|
|
|
|
ATA_IDX_OUTB(ch, ATA_SECTOR, request->u.ata.lba >> 24);
|
|
|
|
ATA_IDX_OUTB(ch, ATA_SECTOR, request->u.ata.lba);
|
|
|
|
ATA_IDX_OUTB(ch, ATA_CYL_LSB, request->u.ata.lba >> 32);
|
|
|
|
ATA_IDX_OUTB(ch, ATA_CYL_LSB, request->u.ata.lba >> 8);
|
|
|
|
ATA_IDX_OUTB(ch, ATA_CYL_MSB, request->u.ata.lba >> 40);
|
|
|
|
ATA_IDX_OUTB(ch, ATA_CYL_MSB, request->u.ata.lba >> 16);
|
2009-10-31 13:24:14 +00:00
|
|
|
ATA_IDX_OUTB(ch, ATA_DRIVE, ATA_D_LBA | ATA_DEV(request->unit));
|
2007-12-13 11:47:36 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
ATA_IDX_OUTB(ch, ATA_FEATURE, request->u.ata.feature);
|
|
|
|
ATA_IDX_OUTB(ch, ATA_COUNT, request->u.ata.count);
|
|
|
|
ATA_IDX_OUTB(ch, ATA_SECTOR, request->u.ata.lba);
|
|
|
|
ATA_IDX_OUTB(ch, ATA_CYL_LSB, request->u.ata.lba >> 8);
|
|
|
|
ATA_IDX_OUTB(ch, ATA_CYL_MSB, request->u.ata.lba >> 16);
|
|
|
|
ATA_IDX_OUTB(ch, ATA_DRIVE,
|
2009-10-31 13:24:14 +00:00
|
|
|
ATA_D_IBM | ATA_D_LBA | ATA_DEV(request->unit) |
|
2007-12-13 11:47:36 +00:00
|
|
|
((request->u.ata.lba >> 24) & 0x0f));
|
2005-05-03 07:55:07 +00:00
|
|
|
}
|
2003-08-24 09:22:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ata_pio_read(struct ata_request *request, int length)
|
|
|
|
{
|
2015-08-07 14:38:26 +00:00
|
|
|
struct ata_channel *ch = device_get_softc(request->parent);
|
|
|
|
struct bio *bio;
|
|
|
|
uint8_t *addr;
|
|
|
|
vm_offset_t page;
|
|
|
|
int todo, done, off, moff, resid, size, i;
|
|
|
|
uint8_t buf[2] __aligned(2);
|
|
|
|
|
|
|
|
todo = min(request->transfersize, length);
|
|
|
|
page = done = resid = 0;
|
|
|
|
while (done < todo) {
|
|
|
|
size = todo - done;
|
|
|
|
|
|
|
|
/* Prepare data address and limit size (if not sequential). */
|
|
|
|
off = request->donecount + done;
|
|
|
|
if ((request->flags & ATA_R_DATA_IN_CCB) == 0 ||
|
|
|
|
(request->ccb->ccb_h.flags & CAM_DATA_MASK) == CAM_DATA_VADDR) {
|
|
|
|
addr = (uint8_t *)request->data + off;
|
|
|
|
} else if ((request->ccb->ccb_h.flags & CAM_DATA_MASK) == CAM_DATA_BIO) {
|
|
|
|
bio = (struct bio *)request->data;
|
|
|
|
if ((bio->bio_flags & BIO_UNMAPPED) == 0) {
|
|
|
|
addr = (uint8_t *)bio->bio_data + off;
|
|
|
|
} else {
|
|
|
|
moff = bio->bio_ma_offset + off;
|
|
|
|
page = pmap_quick_enter_page(
|
|
|
|
bio->bio_ma[moff / PAGE_SIZE]);
|
|
|
|
moff %= PAGE_SIZE;
|
|
|
|
size = min(size, PAGE_SIZE - moff);
|
|
|
|
addr = (void *)(page + moff);
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
panic("ata_pio_read: Unsupported CAM data type %x\n",
|
|
|
|
(request->ccb->ccb_h.flags & CAM_DATA_MASK));
|
|
|
|
|
|
|
|
/* We may have extra byte already red but not stored. */
|
|
|
|
if (resid) {
|
|
|
|
addr[0] = buf[1];
|
|
|
|
addr++;
|
|
|
|
done++;
|
|
|
|
size--;
|
|
|
|
}
|
2003-08-24 09:22:26 +00:00
|
|
|
|
2015-08-07 14:38:26 +00:00
|
|
|
/* Process main part of data. */
|
|
|
|
resid = size % 2;
|
|
|
|
if (__predict_false((ch->flags & ATA_USE_16BIT) ||
|
|
|
|
(size % 4) != 0 || ((uintptr_t)addr % 4) != 0)) {
|
2013-02-02 21:57:06 +00:00
|
|
|
#ifndef __NO_STRICT_ALIGNMENT
|
2015-08-07 14:38:26 +00:00
|
|
|
if (__predict_false((uintptr_t)addr % 2)) {
|
|
|
|
for (i = 0; i + 1 < size; i += 2) {
|
|
|
|
*(uint16_t *)&buf =
|
|
|
|
ATA_IDX_INW_STRM(ch, ATA_DATA);
|
|
|
|
addr[i] = buf[0];
|
|
|
|
addr[i + 1] = buf[1];
|
|
|
|
}
|
|
|
|
} else
|
2013-02-02 21:57:06 +00:00
|
|
|
#endif
|
2015-08-07 14:38:26 +00:00
|
|
|
ATA_IDX_INSW_STRM(ch, ATA_DATA, (void*)addr,
|
|
|
|
size / 2);
|
|
|
|
|
|
|
|
/* If we have extra byte of data, leave it for later. */
|
|
|
|
if (resid) {
|
|
|
|
*(uint16_t *)&buf =
|
|
|
|
ATA_IDX_INW_STRM(ch, ATA_DATA);
|
|
|
|
addr[size - 1] = buf[0];
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
ATA_IDX_INSL_STRM(ch, ATA_DATA, (void*)addr, size / 4);
|
|
|
|
|
|
|
|
if (page) {
|
|
|
|
pmap_quick_remove_page(page);
|
|
|
|
page = 0;
|
|
|
|
}
|
|
|
|
done += size;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (length > done) {
|
|
|
|
device_printf(request->parent,
|
|
|
|
"WARNING - %s read data overrun %d > %d\n",
|
|
|
|
ata_cmd2str(request), length, done);
|
|
|
|
for (i = done + resid; i < length; i += 2)
|
|
|
|
ATA_IDX_INW(ch, ATA_DATA);
|
|
|
|
}
|
2003-08-24 09:22:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
ata_pio_write(struct ata_request *request, int length)
|
|
|
|
{
|
2015-08-07 14:38:26 +00:00
|
|
|
struct ata_channel *ch = device_get_softc(request->parent);
|
|
|
|
struct bio *bio;
|
|
|
|
uint8_t *addr;
|
|
|
|
vm_offset_t page;
|
|
|
|
int todo, done, off, moff, resid, size, i;
|
|
|
|
uint8_t buf[2] __aligned(2);
|
|
|
|
|
|
|
|
todo = min(request->transfersize, length);
|
|
|
|
page = done = resid = 0;
|
|
|
|
while (done < todo) {
|
|
|
|
size = todo - done;
|
|
|
|
|
|
|
|
/* Prepare data address and limit size (if not sequential). */
|
|
|
|
off = request->donecount + done;
|
|
|
|
if ((request->flags & ATA_R_DATA_IN_CCB) == 0 ||
|
|
|
|
(request->ccb->ccb_h.flags & CAM_DATA_MASK) == CAM_DATA_VADDR) {
|
|
|
|
addr = (uint8_t *)request->data + off;
|
|
|
|
} else if ((request->ccb->ccb_h.flags & CAM_DATA_MASK) == CAM_DATA_BIO) {
|
|
|
|
bio = (struct bio *)request->data;
|
|
|
|
if ((bio->bio_flags & BIO_UNMAPPED) == 0) {
|
|
|
|
addr = (uint8_t *)bio->bio_data + off;
|
|
|
|
} else {
|
|
|
|
moff = bio->bio_ma_offset + off;
|
|
|
|
page = pmap_quick_enter_page(
|
|
|
|
bio->bio_ma[moff / PAGE_SIZE]);
|
|
|
|
moff %= PAGE_SIZE;
|
|
|
|
size = min(size, PAGE_SIZE - moff);
|
|
|
|
addr = (void *)(page + moff);
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
panic("ata_pio_write: Unsupported CAM data type %x\n",
|
|
|
|
(request->ccb->ccb_h.flags & CAM_DATA_MASK));
|
|
|
|
|
|
|
|
/* We may have extra byte to be written first. */
|
|
|
|
if (resid) {
|
|
|
|
buf[1] = addr[0];
|
|
|
|
ATA_IDX_OUTW_STRM(ch, ATA_DATA, *(uint16_t *)&buf);
|
|
|
|
addr++;
|
|
|
|
done++;
|
|
|
|
size--;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Process main part of data. */
|
|
|
|
resid = size % 2;
|
|
|
|
if (__predict_false((ch->flags & ATA_USE_16BIT) ||
|
|
|
|
(size % 4) != 0 || ((uintptr_t)addr % 4) != 0)) {
|
2013-02-02 21:57:06 +00:00
|
|
|
#ifndef __NO_STRICT_ALIGNMENT
|
2015-08-07 14:38:26 +00:00
|
|
|
if (__predict_false((uintptr_t)addr % 2)) {
|
|
|
|
for (i = 0; i + 1 < size; i += 2) {
|
|
|
|
buf[0] = addr[i];
|
|
|
|
buf[1] = addr[i + 1];
|
|
|
|
ATA_IDX_OUTW_STRM(ch, ATA_DATA,
|
|
|
|
*(uint16_t *)&buf);
|
|
|
|
}
|
|
|
|
} else
|
2013-02-02 21:57:06 +00:00
|
|
|
#endif
|
2015-08-07 14:38:26 +00:00
|
|
|
ATA_IDX_OUTSW_STRM(ch, ATA_DATA, (void*)addr,
|
|
|
|
size / 2);
|
|
|
|
|
|
|
|
/* If we have extra byte of data, save it for later. */
|
|
|
|
if (resid)
|
|
|
|
buf[0] = addr[size - 1];
|
|
|
|
} else
|
|
|
|
ATA_IDX_OUTSL_STRM(ch, ATA_DATA,
|
|
|
|
(void*)addr, size / sizeof(int32_t));
|
|
|
|
|
|
|
|
if (page) {
|
|
|
|
pmap_quick_remove_page(page);
|
|
|
|
page = 0;
|
|
|
|
}
|
|
|
|
done += size;
|
|
|
|
}
|
2003-08-24 09:22:26 +00:00
|
|
|
|
2015-08-07 14:38:26 +00:00
|
|
|
/* We may have extra byte of data to be written. Pad it with zero. */
|
|
|
|
if (resid) {
|
|
|
|
buf[1] = 0;
|
2013-02-02 21:57:06 +00:00
|
|
|
ATA_IDX_OUTW_STRM(ch, ATA_DATA, *(uint16_t *)&buf);
|
2015-08-07 14:38:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (length > done) {
|
|
|
|
device_printf(request->parent,
|
|
|
|
"WARNING - %s write data underrun %d > %d\n",
|
|
|
|
ata_cmd2str(request), length, done);
|
|
|
|
for (i = done + resid; i < length; i += 2)
|
|
|
|
ATA_IDX_OUTW(ch, ATA_DATA, 0);
|
|
|
|
}
|
2003-08-24 09:22:26 +00:00
|
|
|
}
|