2002-12-03 20:20:44 +00:00
|
|
|
/*-
|
2012-01-15 13:23:18 +00:00
|
|
|
* Copyright (c) 2002 - 2008 Søren Schmidt <sos@FreeBSD.org>
|
2002-12-03 20:20:44 +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$");
|
|
|
|
|
2002-12-03 20:20:44 +00:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/kernel.h>
|
2003-02-20 20:02:32 +00:00
|
|
|
#include <sys/ata.h>
|
2002-12-03 20:20:44 +00:00
|
|
|
#include <sys/bus.h>
|
|
|
|
#include <sys/malloc.h>
|
2004-06-03 06:10:02 +00:00
|
|
|
#include <sys/module.h>
|
2004-10-06 19:46:08 +00:00
|
|
|
#include <sys/conf.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>
|
2002-12-03 20:20:44 +00:00
|
|
|
#include <machine/resource.h>
|
|
|
|
#include <machine/bus.h>
|
|
|
|
#include <sys/rman.h>
|
|
|
|
#include <isa/isavar.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 <ata_if.h>
|
2002-12-03 20:20:44 +00:00
|
|
|
|
|
|
|
/* local vars */
|
|
|
|
struct ata_cbus_controller {
|
|
|
|
struct resource *io;
|
2005-04-06 10:22:56 +00:00
|
|
|
struct resource *ctlio;
|
2002-12-03 20:20:44 +00:00
|
|
|
struct resource *bankio;
|
|
|
|
struct resource *irq;
|
2003-02-20 20:02:32 +00:00
|
|
|
void *ih;
|
2013-04-03 18:30:09 +00:00
|
|
|
int channels;
|
2003-02-20 20:02:32 +00:00
|
|
|
struct {
|
2003-03-29 13:37:09 +00:00
|
|
|
void (*function)(void *);
|
|
|
|
void *argument;
|
2003-02-20 20:02:32 +00:00
|
|
|
} interrupt[2];
|
2002-12-03 20:20:44 +00:00
|
|
|
};
|
|
|
|
|
2003-02-20 20:02:32 +00:00
|
|
|
/* local prototypes */
|
|
|
|
static void ata_cbus_intr(void *);
|
|
|
|
|
2002-12-03 20:20:44 +00:00
|
|
|
static int
|
|
|
|
ata_cbus_probe(device_t dev)
|
|
|
|
{
|
|
|
|
struct resource *io;
|
|
|
|
int rid;
|
|
|
|
u_long tmp;
|
|
|
|
|
2003-01-09 14:00:07 +00:00
|
|
|
/* dont probe PnP devices */
|
|
|
|
if (isa_get_vendorid(dev))
|
2003-08-25 09:01:49 +00:00
|
|
|
return (ENXIO);
|
2003-01-09 14:00:07 +00:00
|
|
|
|
2002-12-03 20:20:44 +00:00
|
|
|
/* allocate the ioport range */
|
|
|
|
rid = ATA_IOADDR_RID;
|
2005-04-25 07:57:04 +00:00
|
|
|
if (!(io = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 0, ~0,
|
|
|
|
ATA_PC98_IOSIZE, RF_ACTIVE)))
|
2003-08-25 09:01:49 +00:00
|
|
|
return ENOMEM;
|
2002-12-03 20:20:44 +00:00
|
|
|
|
|
|
|
/* calculate & set the altport range */
|
2005-04-06 10:22:56 +00:00
|
|
|
rid = ATA_PC98_CTLADDR_RID;
|
2002-12-03 20:20:44 +00:00
|
|
|
if (bus_get_resource(dev, SYS_RES_IOPORT, rid, &tmp, &tmp)) {
|
|
|
|
bus_set_resource(dev, SYS_RES_IOPORT, rid,
|
2005-04-06 10:22:56 +00:00
|
|
|
rman_get_start(io)+ATA_PC98_CTLOFFSET, ATA_CTLIOSIZE);
|
2002-12-03 20:20:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* calculate & set the bank range */
|
|
|
|
rid = ATA_PC98_BANKADDR_RID;
|
|
|
|
if (bus_get_resource(dev, SYS_RES_IOPORT, rid, &tmp, &tmp)) {
|
|
|
|
bus_set_resource(dev, SYS_RES_IOPORT, rid,
|
|
|
|
ATA_PC98_BANK, ATA_PC98_BANKIOSIZE);
|
|
|
|
}
|
|
|
|
|
|
|
|
bus_release_resource(dev, SYS_RES_IOPORT, ATA_IOADDR_RID, io);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
ata_cbus_attach(device_t dev)
|
|
|
|
{
|
2003-02-20 20:02:32 +00:00
|
|
|
struct ata_cbus_controller *ctlr = device_get_softc(dev);
|
2009-02-14 21:54:44 +00:00
|
|
|
device_t child;
|
|
|
|
int rid, unit;
|
2002-12-03 20:20:44 +00:00
|
|
|
|
|
|
|
/* allocate resources */
|
|
|
|
rid = ATA_IOADDR_RID;
|
2005-04-25 07:57:04 +00:00
|
|
|
if (!(ctlr->io = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 0, ~0,
|
|
|
|
ATA_PC98_IOSIZE, RF_ACTIVE)))
|
2002-12-03 20:20:44 +00:00
|
|
|
return ENOMEM;
|
|
|
|
|
2005-04-06 10:22:56 +00:00
|
|
|
rid = ATA_PC98_CTLADDR_RID;
|
2005-04-25 07:57:04 +00:00
|
|
|
if (!(ctlr->ctlio =
|
|
|
|
bus_alloc_resource(dev, SYS_RES_IOPORT, &rid,
|
|
|
|
rman_get_start(ctlr->io) + ATA_PC98_CTLOFFSET, ~0,
|
|
|
|
ATA_CTLIOSIZE, RF_ACTIVE))) {
|
2003-03-29 13:37:09 +00:00
|
|
|
bus_release_resource(dev, SYS_RES_IOPORT, ATA_IOADDR_RID, ctlr->io);
|
2002-12-03 20:20:44 +00:00
|
|
|
return ENOMEM;
|
2003-03-29 13:37:09 +00:00
|
|
|
}
|
2002-12-03 20:20:44 +00:00
|
|
|
|
|
|
|
rid = ATA_PC98_BANKADDR_RID;
|
2005-04-25 07:57:04 +00:00
|
|
|
if (!(ctlr->bankio = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid,
|
|
|
|
ATA_PC98_BANK, ~0,
|
|
|
|
ATA_PC98_BANKIOSIZE, RF_ACTIVE))) {
|
2003-03-29 13:37:09 +00:00
|
|
|
bus_release_resource(dev, SYS_RES_IOPORT, ATA_IOADDR_RID, ctlr->io);
|
2005-04-06 10:22:56 +00:00
|
|
|
bus_release_resource(dev, SYS_RES_IOPORT, ATA_CTLADDR_RID, ctlr->ctlio);
|
2002-12-03 20:20:44 +00:00
|
|
|
return ENOMEM;
|
2003-03-29 13:37:09 +00:00
|
|
|
}
|
2002-12-03 20:20:44 +00:00
|
|
|
|
2003-03-29 13:37:09 +00:00
|
|
|
rid = ATA_IRQ_RID;
|
2004-03-17 17:50:55 +00:00
|
|
|
if (!(ctlr->irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid,
|
|
|
|
RF_ACTIVE | RF_SHAREABLE))) {
|
2003-02-20 20:02:32 +00:00
|
|
|
device_printf(dev, "unable to alloc interrupt\n");
|
2003-03-29 13:37:09 +00:00
|
|
|
bus_release_resource(dev, SYS_RES_IOPORT, ATA_IOADDR_RID, ctlr->io);
|
2005-04-06 10:22:56 +00:00
|
|
|
bus_release_resource(dev, SYS_RES_IOPORT, ATA_CTLADDR_RID, ctlr->ctlio);
|
2003-03-29 13:37:09 +00:00
|
|
|
bus_release_resource(dev, SYS_RES_IOPORT,
|
|
|
|
ATA_PC98_BANKADDR_RID, ctlr->bankio);
|
2003-02-20 20:02:32 +00:00
|
|
|
return ENXIO;
|
|
|
|
}
|
|
|
|
|
2004-01-11 22:08:34 +00:00
|
|
|
if ((bus_setup_intr(dev, ctlr->irq, ATA_INTR_FLAGS,
|
2007-02-23 12:19:07 +00:00
|
|
|
NULL, ata_cbus_intr, ctlr, &ctlr->ih))) {
|
2003-02-20 20:02:32 +00:00
|
|
|
device_printf(dev, "unable to setup interrupt\n");
|
2003-03-29 13:37:09 +00:00
|
|
|
bus_release_resource(dev, SYS_RES_IOPORT, ATA_IOADDR_RID, ctlr->io);
|
2005-04-06 10:22:56 +00:00
|
|
|
bus_release_resource(dev, SYS_RES_IOPORT, ATA_CTLADDR_RID, ctlr->ctlio);
|
2003-03-29 13:37:09 +00:00
|
|
|
bus_release_resource(dev, SYS_RES_IOPORT,
|
|
|
|
ATA_PC98_BANKADDR_RID, ctlr->bankio);
|
|
|
|
bus_release_resource(dev, SYS_RES_IOPORT, ATA_IRQ_RID, ctlr->irq);
|
2003-02-20 20:02:32 +00:00
|
|
|
return ENXIO;
|
|
|
|
}
|
|
|
|
|
2013-04-03 18:30:09 +00:00
|
|
|
/* Work around the lack of channel serialization in ATA_CAM. */
|
|
|
|
ctlr->channels = 1;
|
|
|
|
device_printf(dev, "second channel ignored\n");
|
2002-12-03 20:20:44 +00:00
|
|
|
|
2013-04-03 18:30:09 +00:00
|
|
|
for (unit = 0; unit < ctlr->channels; unit++) {
|
2009-02-14 21:54:44 +00:00
|
|
|
child = device_add_child(dev, "ata", unit);
|
|
|
|
if (child == NULL)
|
|
|
|
device_printf(dev, "failed to add ata child device\n");
|
|
|
|
else
|
|
|
|
device_set_ivars(child, (void *)(intptr_t)unit);
|
|
|
|
}
|
2002-12-03 20:20:44 +00:00
|
|
|
|
2009-02-14 21:54:44 +00:00
|
|
|
bus_generic_attach(dev);
|
|
|
|
return (0);
|
2002-12-03 20:20:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct resource *
|
|
|
|
ata_cbus_alloc_resource(device_t dev, device_t child, int type, int *rid,
|
|
|
|
u_long start, u_long end, u_long count, u_int flags)
|
|
|
|
{
|
2003-02-20 20:02:32 +00:00
|
|
|
struct ata_cbus_controller *ctlr = device_get_softc(dev);
|
2002-12-03 20:20:44 +00:00
|
|
|
|
|
|
|
if (type == SYS_RES_IOPORT) {
|
|
|
|
switch (*rid) {
|
|
|
|
case ATA_IOADDR_RID:
|
2003-02-20 20:02:32 +00:00
|
|
|
return ctlr->io;
|
2005-04-06 10:22:56 +00:00
|
|
|
case ATA_CTLADDR_RID:
|
|
|
|
return ctlr->ctlio;
|
2002-12-03 20:20:44 +00:00
|
|
|
}
|
|
|
|
}
|
2003-08-25 09:01:49 +00:00
|
|
|
if (type == SYS_RES_IRQ)
|
2003-02-20 20:02:32 +00:00
|
|
|
return ctlr->irq;
|
2002-12-03 20:20:44 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
ata_cbus_setup_intr(device_t dev, device_t child, struct resource *irq,
|
2007-02-23 12:19:07 +00:00
|
|
|
int flags, driver_filter_t *filter, driver_intr_t *intr,
|
|
|
|
void *arg, void **cookiep)
|
2002-12-03 20:20:44 +00:00
|
|
|
{
|
2003-02-20 20:02:32 +00:00
|
|
|
struct ata_cbus_controller *controller = device_get_softc(dev);
|
|
|
|
int unit = ((struct ata_channel *)device_get_softc(child))->unit;
|
|
|
|
|
2007-02-23 12:19:07 +00:00
|
|
|
if (filter != NULL) {
|
|
|
|
printf("ata-cbus.c: we cannot use a filter here\n");
|
|
|
|
return (EINVAL);
|
|
|
|
}
|
2003-02-20 20:02:32 +00:00
|
|
|
controller->interrupt[unit].function = intr;
|
|
|
|
controller->interrupt[unit].argument = arg;
|
|
|
|
*cookiep = controller;
|
|
|
|
|
|
|
|
return 0;
|
2002-12-03 20:20:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
ata_cbus_print_child(device_t dev, device_t child)
|
|
|
|
{
|
|
|
|
struct ata_channel *ch = device_get_softc(child);
|
|
|
|
int retval = 0;
|
|
|
|
|
|
|
|
retval += bus_print_child_header(dev, child);
|
|
|
|
retval += printf(" at bank %d", ch->unit);
|
|
|
|
retval += bus_print_child_footer(dev, child);
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
2003-02-20 20:02:32 +00:00
|
|
|
static void
|
|
|
|
ata_cbus_intr(void *data)
|
2002-12-03 20:20:44 +00:00
|
|
|
{
|
2003-02-20 20:02:32 +00:00
|
|
|
struct ata_cbus_controller *ctlr = data;
|
2004-10-06 19:46:08 +00:00
|
|
|
struct ata_channel *ch;
|
|
|
|
int unit;
|
|
|
|
|
2013-04-03 18:30:09 +00:00
|
|
|
for (unit = 0; unit < ctlr->channels; 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
|
|
|
if (!(ch = ctlr->interrupt[unit].argument))
|
|
|
|
continue;
|
2013-04-04 07:12:24 +00:00
|
|
|
ctlr->interrupt[unit].function(ch);
|
2004-10-06 19:46:08 +00:00
|
|
|
}
|
2002-12-03 20:20:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static device_method_t ata_cbus_methods[] = {
|
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
|
|
|
/* device interface */
|
|
|
|
DEVMETHOD(device_probe, ata_cbus_probe),
|
|
|
|
DEVMETHOD(device_attach, ata_cbus_attach),
|
|
|
|
// DEVMETHOD(device_detach, ata_cbus_detach),
|
2002-12-03 20:20:44 +00:00
|
|
|
|
|
|
|
/* bus methods */
|
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
|
|
|
DEVMETHOD(bus_alloc_resource, ata_cbus_alloc_resource),
|
|
|
|
DEVMETHOD(bus_setup_intr, ata_cbus_setup_intr),
|
|
|
|
DEVMETHOD(bus_print_child, ata_cbus_print_child),
|
|
|
|
|
2012-03-21 16:59:39 +00:00
|
|
|
DEVMETHOD_END
|
2002-12-03 20:20:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static driver_t ata_cbus_driver = {
|
|
|
|
"atacbus",
|
|
|
|
ata_cbus_methods,
|
|
|
|
sizeof(struct ata_cbus_controller),
|
|
|
|
};
|
|
|
|
|
|
|
|
static devclass_t ata_cbus_devclass;
|
|
|
|
|
2013-04-06 19:12:49 +00:00
|
|
|
DRIVER_MODULE(atacbus, isa, ata_cbus_driver, ata_cbus_devclass, NULL, NULL);
|
2002-12-03 20:20:44 +00:00
|
|
|
|
|
|
|
static int
|
2005-03-31 15:05:40 +00:00
|
|
|
ata_cbuschannel_probe(device_t dev)
|
2009-02-14 21:54:44 +00:00
|
|
|
{
|
|
|
|
char buffer[32];
|
|
|
|
|
|
|
|
sprintf(buffer, "ATA channel %d", (int)(intptr_t)device_get_ivars(dev));
|
|
|
|
device_set_desc_copy(dev, buffer);
|
|
|
|
|
|
|
|
return ata_probe(dev);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
ata_cbuschannel_attach(device_t dev)
|
2002-12-03 20:20:44 +00:00
|
|
|
{
|
2003-02-20 20:02:32 +00:00
|
|
|
struct ata_cbus_controller *ctlr = device_get_softc(device_get_parent(dev));
|
2002-12-03 20:20:44 +00:00
|
|
|
struct ata_channel *ch = device_get_softc(dev);
|
2009-02-14 21:54:44 +00:00
|
|
|
int i;
|
2003-03-29 13:37:09 +00:00
|
|
|
|
2009-02-19 12:47:24 +00:00
|
|
|
if (ch->attached)
|
|
|
|
return (0);
|
|
|
|
ch->attached = 1;
|
|
|
|
|
2009-02-14 21:54:44 +00:00
|
|
|
ch->unit = (intptr_t)device_get_ivars(dev);
|
2003-03-29 13:37:09 +00:00
|
|
|
/* setup the resource vectors */
|
2005-04-06 10:22:56 +00:00
|
|
|
for (i = ATA_DATA; i <= ATA_COMMAND; i ++) {
|
2003-03-29 13:37:09 +00:00
|
|
|
ch->r_io[i].res = ctlr->io;
|
|
|
|
ch->r_io[i].offset = i << 1;
|
|
|
|
}
|
2005-04-06 10:22:56 +00:00
|
|
|
ch->r_io[ATA_CONTROL].res = ctlr->ctlio;
|
|
|
|
ch->r_io[ATA_CONTROL].offset = 0;
|
|
|
|
ch->r_io[ATA_IDX_ADDR].res = ctlr->io;
|
2005-04-30 16:22:07 +00:00
|
|
|
ata_default_registers(dev);
|
2003-03-29 13:37:09 +00:00
|
|
|
|
|
|
|
/* initialize softc for this channel */
|
2004-10-07 17:37:09 +00:00
|
|
|
ch->flags |= ATA_USE_16BIT;
|
2005-04-30 16:22:07 +00:00
|
|
|
ata_generic_hw(dev);
|
2009-02-14 21:54:44 +00:00
|
|
|
|
|
|
|
return ata_attach(dev);
|
2002-12-03 20:20:44 +00:00
|
|
|
}
|
|
|
|
|
2009-02-19 12:47:24 +00:00
|
|
|
static int
|
|
|
|
ata_cbuschannel_detach(device_t dev)
|
|
|
|
{
|
2009-02-20 14:10:23 +00:00
|
|
|
struct ata_channel *ch = device_get_softc(dev);
|
2009-02-19 12:47:24 +00:00
|
|
|
|
|
|
|
if (!ch->attached)
|
|
|
|
return (0);
|
|
|
|
ch->attached = 0;
|
|
|
|
|
|
|
|
return ata_detach(dev);
|
|
|
|
}
|
|
|
|
|
2009-03-09 20:48:57 +00:00
|
|
|
static int
|
|
|
|
ata_cbuschannel_suspend(device_t dev)
|
|
|
|
{
|
|
|
|
struct ata_channel *ch = device_get_softc(dev);
|
|
|
|
|
|
|
|
if (!ch->attached)
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
return ata_suspend(dev);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
ata_cbuschannel_resume(device_t dev)
|
|
|
|
{
|
|
|
|
struct ata_channel *ch = device_get_softc(dev);
|
|
|
|
|
|
|
|
if (!ch->attached)
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
return ata_resume(dev);
|
|
|
|
}
|
|
|
|
|
2005-03-31 15:05:40 +00:00
|
|
|
static device_method_t ata_cbuschannel_methods[] = {
|
2002-12-03 20:20:44 +00:00
|
|
|
/* device interface */
|
2005-03-31 15:05:40 +00:00
|
|
|
DEVMETHOD(device_probe, ata_cbuschannel_probe),
|
2009-02-14 21:54:44 +00:00
|
|
|
DEVMETHOD(device_attach, ata_cbuschannel_attach),
|
2009-02-19 12:47:24 +00:00
|
|
|
DEVMETHOD(device_detach, ata_cbuschannel_detach),
|
2009-03-09 20:48:57 +00:00
|
|
|
DEVMETHOD(device_suspend, ata_cbuschannel_suspend),
|
|
|
|
DEVMETHOD(device_resume, ata_cbuschannel_resume),
|
2012-03-21 16:59:39 +00:00
|
|
|
DEVMETHOD_END
|
2002-12-03 20:20:44 +00:00
|
|
|
};
|
|
|
|
|
2005-03-31 15:05:40 +00:00
|
|
|
static driver_t ata_cbuschannel_driver = {
|
2002-12-03 20:20:44 +00:00
|
|
|
"ata",
|
2005-03-31 15:05:40 +00:00
|
|
|
ata_cbuschannel_methods,
|
2002-12-03 20:20:44 +00:00
|
|
|
sizeof(struct ata_channel),
|
|
|
|
};
|
|
|
|
|
2012-03-21 16:59:39 +00:00
|
|
|
DRIVER_MODULE(ata, atacbus, ata_cbuschannel_driver, ata_devclass, NULL, NULL);
|
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
|
|
|
MODULE_DEPEND(ata, ata, 1, 1, 1);
|