Finally!!
The much roumored replacement for our current IDE/ATA/ATAPI is
materialising in the CVS repositories around the globe.
So what does this bring us:
A new reengineered ATA/ATAPI subsystem, that tries to overcome
most of the deficiencies with the current drivers.
It supports PCI as well as ISA devices without all the hackery
in ide_pci.c to make PCI devices look like ISA counterparts.
It doesn't have the excessive wait problem on probe, in fact you
shouldn't notice any delay when your devices are getting probed.
Probing and attaching of devices are postponed until interrupts
are enabled (well almost, not finished yet for disks), making
things alot cleaner.
Improved performance, although DMA support is still WIP and not
in this pre alpha release, worldstone is faster with the new
driver compared to the old even with DMA.
So what does it take away:
There is NO support for old MFM/RLL/ESDI disks.
There is NO support for bad144, if your disk is bad, ditch it, it has
already outgrown its internal spare sectors, and is dying.
For you to try this out, you will have to modify your kernel config
file to use the "ata" controller instead of all wdc? entries.
example:
# for a PCI only system (most modern machines)
controller ata0
device atadisk0 # ATA disks
device atapicd0 # ATAPI CDROM's
device atapist0 # ATAPI tapes
#You should add the following on ISA systems:
controller ata1 at isa? port "IO_WD1" bio irq 14
controller ata2 at isa? port "IO_WD2" bio irq 15
You can leave it all in there, the system knows how to manage.
For now this driver reuses the device entries from the old system
(that will probably change later), but remember that disks are
now numbered in the sequence they are found (like the SCSI system)
not as absolute positions as the old system.
Although I have tested this on all the systems I can get my hands on,
there might very well be gremlins in there, so use AT YOU OWN RISK!!
This is still WIP, so there are lots of rough edges and unfinished
things in there, and what I have in my lab might look very different
from whats in CVS at any given time. So please have all eventual
changes go through me, or chances are they just dissapears...
I would very much like to hear from you, both good and bad news
are very welcome.
Enjoy!!
-Søren
1999-03-01 21:19:19 +00:00
|
|
|
|
/*-
|
2004-01-11 22:08:34 +00:00
|
|
|
|
* Copyright (c) 1998 - 2004 S<EFBFBD>ren Schmidt <sos@FreeBSD.org>
|
Finally!!
The much roumored replacement for our current IDE/ATA/ATAPI is
materialising in the CVS repositories around the globe.
So what does this bring us:
A new reengineered ATA/ATAPI subsystem, that tries to overcome
most of the deficiencies with the current drivers.
It supports PCI as well as ISA devices without all the hackery
in ide_pci.c to make PCI devices look like ISA counterparts.
It doesn't have the excessive wait problem on probe, in fact you
shouldn't notice any delay when your devices are getting probed.
Probing and attaching of devices are postponed until interrupts
are enabled (well almost, not finished yet for disks), making
things alot cleaner.
Improved performance, although DMA support is still WIP and not
in this pre alpha release, worldstone is faster with the new
driver compared to the old even with DMA.
So what does it take away:
There is NO support for old MFM/RLL/ESDI disks.
There is NO support for bad144, if your disk is bad, ditch it, it has
already outgrown its internal spare sectors, and is dying.
For you to try this out, you will have to modify your kernel config
file to use the "ata" controller instead of all wdc? entries.
example:
# for a PCI only system (most modern machines)
controller ata0
device atadisk0 # ATA disks
device atapicd0 # ATAPI CDROM's
device atapist0 # ATAPI tapes
#You should add the following on ISA systems:
controller ata1 at isa? port "IO_WD1" bio irq 14
controller ata2 at isa? port "IO_WD2" bio irq 15
You can leave it all in there, the system knows how to manage.
For now this driver reuses the device entries from the old system
(that will probably change later), but remember that disks are
now numbered in the sequence they are found (like the SCSI system)
not as absolute positions as the old system.
Although I have tested this on all the systems I can get my hands on,
there might very well be gremlins in there, so use AT YOU OWN RISK!!
This is still WIP, so there are lots of rough edges and unfinished
things in there, and what I have in my lab might look very different
from whats in CVS at any given time. So please have all eventual
changes go through me, or chances are they just dissapears...
I would very much like to hear from you, both good and bad news
are very welcome.
Enjoy!!
-Søren
1999-03-01 21:19:19 +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.
|
|
|
|
|
* 3. The name of the author may not be used to endorse or promote products
|
|
|
|
|
* derived from this software without specific prior written permission.
|
|
|
|
|
*
|
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
*/
|
|
|
|
|
|
2003-08-24 17:55:58 +00:00
|
|
|
|
#include <sys/cdefs.h>
|
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
|
1999-10-09 19:57:13 +00:00
|
|
|
|
#include "opt_ata.h"
|
Finally!!
The much roumored replacement for our current IDE/ATA/ATAPI is
materialising in the CVS repositories around the globe.
So what does this bring us:
A new reengineered ATA/ATAPI subsystem, that tries to overcome
most of the deficiencies with the current drivers.
It supports PCI as well as ISA devices without all the hackery
in ide_pci.c to make PCI devices look like ISA counterparts.
It doesn't have the excessive wait problem on probe, in fact you
shouldn't notice any delay when your devices are getting probed.
Probing and attaching of devices are postponed until interrupts
are enabled (well almost, not finished yet for disks), making
things alot cleaner.
Improved performance, although DMA support is still WIP and not
in this pre alpha release, worldstone is faster with the new
driver compared to the old even with DMA.
So what does it take away:
There is NO support for old MFM/RLL/ESDI disks.
There is NO support for bad144, if your disk is bad, ditch it, it has
already outgrown its internal spare sectors, and is dying.
For you to try this out, you will have to modify your kernel config
file to use the "ata" controller instead of all wdc? entries.
example:
# for a PCI only system (most modern machines)
controller ata0
device atadisk0 # ATA disks
device atapicd0 # ATAPI CDROM's
device atapist0 # ATAPI tapes
#You should add the following on ISA systems:
controller ata1 at isa? port "IO_WD1" bio irq 14
controller ata2 at isa? port "IO_WD2" bio irq 15
You can leave it all in there, the system knows how to manage.
For now this driver reuses the device entries from the old system
(that will probably change later), but remember that disks are
now numbered in the sequence they are found (like the SCSI system)
not as absolute positions as the old system.
Although I have tested this on all the systems I can get my hands on,
there might very well be gremlins in there, so use AT YOU OWN RISK!!
This is still WIP, so there are lots of rough edges and unfinished
things in there, and what I have in my lab might look very different
from whats in CVS at any given time. So please have all eventual
changes go through me, or chances are they just dissapears...
I would very much like to hear from you, both good and bad news
are very welcome.
Enjoy!!
-Søren
1999-03-01 21:19:19 +00:00
|
|
|
|
#include <sys/param.h>
|
|
|
|
|
#include <sys/systm.h>
|
2001-03-15 15:36:25 +00:00
|
|
|
|
#include <sys/ata.h>
|
Finally!!
The much roumored replacement for our current IDE/ATA/ATAPI is
materialising in the CVS repositories around the globe.
So what does this bring us:
A new reengineered ATA/ATAPI subsystem, that tries to overcome
most of the deficiencies with the current drivers.
It supports PCI as well as ISA devices without all the hackery
in ide_pci.c to make PCI devices look like ISA counterparts.
It doesn't have the excessive wait problem on probe, in fact you
shouldn't notice any delay when your devices are getting probed.
Probing and attaching of devices are postponed until interrupts
are enabled (well almost, not finished yet for disks), making
things alot cleaner.
Improved performance, although DMA support is still WIP and not
in this pre alpha release, worldstone is faster with the new
driver compared to the old even with DMA.
So what does it take away:
There is NO support for old MFM/RLL/ESDI disks.
There is NO support for bad144, if your disk is bad, ditch it, it has
already outgrown its internal spare sectors, and is dying.
For you to try this out, you will have to modify your kernel config
file to use the "ata" controller instead of all wdc? entries.
example:
# for a PCI only system (most modern machines)
controller ata0
device atadisk0 # ATA disks
device atapicd0 # ATAPI CDROM's
device atapist0 # ATAPI tapes
#You should add the following on ISA systems:
controller ata1 at isa? port "IO_WD1" bio irq 14
controller ata2 at isa? port "IO_WD2" bio irq 15
You can leave it all in there, the system knows how to manage.
For now this driver reuses the device entries from the old system
(that will probably change later), but remember that disks are
now numbered in the sequence they are found (like the SCSI system)
not as absolute positions as the old system.
Although I have tested this on all the systems I can get my hands on,
there might very well be gremlins in there, so use AT YOU OWN RISK!!
This is still WIP, so there are lots of rough edges and unfinished
things in there, and what I have in my lab might look very different
from whats in CVS at any given time. So please have all eventual
changes go through me, or chances are they just dissapears...
I would very much like to hear from you, both good and bad news
are very welcome.
Enjoy!!
-Søren
1999-03-01 21:19:19 +00:00
|
|
|
|
#include <sys/kernel.h>
|
2003-08-24 09:22:26 +00:00
|
|
|
|
#include <sys/endian.h>
|
2003-10-10 11:00:06 +00:00
|
|
|
|
#include <sys/ctype.h>
|
2001-03-15 15:36:25 +00:00
|
|
|
|
#include <sys/conf.h>
|
1999-04-18 20:48:15 +00:00
|
|
|
|
#include <sys/bus.h>
|
2000-05-05 09:59:14 +00:00
|
|
|
|
#include <sys/bio.h>
|
Finally!!
The much roumored replacement for our current IDE/ATA/ATAPI is
materialising in the CVS repositories around the globe.
So what does this bring us:
A new reengineered ATA/ATAPI subsystem, that tries to overcome
most of the deficiencies with the current drivers.
It supports PCI as well as ISA devices without all the hackery
in ide_pci.c to make PCI devices look like ISA counterparts.
It doesn't have the excessive wait problem on probe, in fact you
shouldn't notice any delay when your devices are getting probed.
Probing and attaching of devices are postponed until interrupts
are enabled (well almost, not finished yet for disks), making
things alot cleaner.
Improved performance, although DMA support is still WIP and not
in this pre alpha release, worldstone is faster with the new
driver compared to the old even with DMA.
So what does it take away:
There is NO support for old MFM/RLL/ESDI disks.
There is NO support for bad144, if your disk is bad, ditch it, it has
already outgrown its internal spare sectors, and is dying.
For you to try this out, you will have to modify your kernel config
file to use the "ata" controller instead of all wdc? entries.
example:
# for a PCI only system (most modern machines)
controller ata0
device atadisk0 # ATA disks
device atapicd0 # ATAPI CDROM's
device atapist0 # ATAPI tapes
#You should add the following on ISA systems:
controller ata1 at isa? port "IO_WD1" bio irq 14
controller ata2 at isa? port "IO_WD2" bio irq 15
You can leave it all in there, the system knows how to manage.
For now this driver reuses the device entries from the old system
(that will probably change later), but remember that disks are
now numbered in the sequence they are found (like the SCSI system)
not as absolute positions as the old system.
Although I have tested this on all the systems I can get my hands on,
there might very well be gremlins in there, so use AT YOU OWN RISK!!
This is still WIP, so there are lots of rough edges and unfinished
things in there, and what I have in my lab might look very different
from whats in CVS at any given time. So please have all eventual
changes go through me, or chances are they just dissapears...
I would very much like to hear from you, both good and bad news
are very welcome.
Enjoy!!
-Søren
1999-03-01 21:19:19 +00:00
|
|
|
|
#include <sys/malloc.h>
|
2000-01-27 19:00:51 +00:00
|
|
|
|
#include <sys/sysctl.h>
|
2004-01-14 21:26:35 +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>
|
2000-01-24 20:45:24 +00:00
|
|
|
|
#include <machine/stdarg.h>
|
1999-04-18 20:48:15 +00:00
|
|
|
|
#include <machine/resource.h>
|
|
|
|
|
#include <machine/bus.h>
|
|
|
|
|
#include <sys/rman.h>
|
2000-02-18 20:57:33 +00:00
|
|
|
|
#ifdef __alpha__
|
|
|
|
|
#include <machine/md_var.h>
|
Ten'th update to the new ATA/ATAPI driver:
It been awhile since the last major update, as a benefit there
are some cool things in this one (and new bugs probably :) )...
The ATA driver has grown "real" timeout support for all devices.
This means that it should be possible to get in contact with
(especially) lost ATAPI devices. It also means that the ATA
driver is now usable on notebooks as it will DTRT on resume.
An experimental hack at utilizing the Promise66's at UDMA66 is
in there, but I cant test it. If someone feels like sending
me one, give me a ping.
The ATAPI DMA enableling scheme has been changed, also better DMA
support for the Aladdin chipset has been implemented for ATAPI
devices. Note that the Aladdin apparently only can do DMA reads
on ATAPI devices, and the Promise cant do ATAPI DMA at all.
I have seen problems on some ATAPI devices that should be able
to run in DMA mode, so if you encounter problems with hanging
atapi devices during the probe, or during access, disable DMA
in atapi-all.c, and let me know. It might be nessesary to do this
via a "white list" for known good devices...
The ATAPI CDROM driver can now use eject/close without hanging and
the bug that caused reading beyond the end of a CD has been fixed.
Media change is also handled proberly. DVD drives are identified
and are usable as CDROM devices at least, I dont have the HW to
test this further, see above :).
The ATAPI tape driver has gotten some support for using the DSC
method for not blocking the IDE channel during read/write when
the device has full buffers. It knows about the OnStream DI-30
device, support is not completed yet, but it can function as a
primitive backup medium, without filemarks, and without bad media
handeling. This is because the OnStream device doesn't handle this
(like everybody else) in HW. It also now supports getting/setting
the record position on devices that supports it.
Some rather major cleanups and rearrangements as well (cvs -b diff
is your freind). I'm closing in on declaring this for beta code,
most of the infrastruture is in place by now.
As usual USE AT YOUR OWN RISK!!, this is still alpha level code.
This driver can hose your disk real bad if anything goes wrong, but
now you have been warned :)
But please tell me how it works for you!
Enjoy!
-Søren
1999-09-21 19:50:40 +00:00
|
|
|
|
#endif
|
2003-04-01 15:06:26 +00:00
|
|
|
|
#include <geom/geom_disk.h>
|
Finally!!
The much roumored replacement for our current IDE/ATA/ATAPI is
materialising in the CVS repositories around the globe.
So what does this bring us:
A new reengineered ATA/ATAPI subsystem, that tries to overcome
most of the deficiencies with the current drivers.
It supports PCI as well as ISA devices without all the hackery
in ide_pci.c to make PCI devices look like ISA counterparts.
It doesn't have the excessive wait problem on probe, in fact you
shouldn't notice any delay when your devices are getting probed.
Probing and attaching of devices are postponed until interrupts
are enabled (well almost, not finished yet for disks), making
things alot cleaner.
Improved performance, although DMA support is still WIP and not
in this pre alpha release, worldstone is faster with the new
driver compared to the old even with DMA.
So what does it take away:
There is NO support for old MFM/RLL/ESDI disks.
There is NO support for bad144, if your disk is bad, ditch it, it has
already outgrown its internal spare sectors, and is dying.
For you to try this out, you will have to modify your kernel config
file to use the "ata" controller instead of all wdc? entries.
example:
# for a PCI only system (most modern machines)
controller ata0
device atadisk0 # ATA disks
device atapicd0 # ATAPI CDROM's
device atapist0 # ATAPI tapes
#You should add the following on ISA systems:
controller ata1 at isa? port "IO_WD1" bio irq 14
controller ata2 at isa? port "IO_WD2" bio irq 15
You can leave it all in there, the system knows how to manage.
For now this driver reuses the device entries from the old system
(that will probably change later), but remember that disks are
now numbered in the sequence they are found (like the SCSI system)
not as absolute positions as the old system.
Although I have tested this on all the systems I can get my hands on,
there might very well be gremlins in there, so use AT YOU OWN RISK!!
This is still WIP, so there are lots of rough edges and unfinished
things in there, and what I have in my lab might look very different
from whats in CVS at any given time. So please have all eventual
changes go through me, or chances are they just dissapears...
I would very much like to hear from you, both good and bad news
are very welcome.
Enjoy!!
-Søren
1999-03-01 21:19:19 +00:00
|
|
|
|
#include <dev/ata/ata-all.h>
|
Ten'th update to the new ATA/ATAPI driver:
It been awhile since the last major update, as a benefit there
are some cool things in this one (and new bugs probably :) )...
The ATA driver has grown "real" timeout support for all devices.
This means that it should be possible to get in contact with
(especially) lost ATAPI devices. It also means that the ATA
driver is now usable on notebooks as it will DTRT on resume.
An experimental hack at utilizing the Promise66's at UDMA66 is
in there, but I cant test it. If someone feels like sending
me one, give me a ping.
The ATAPI DMA enableling scheme has been changed, also better DMA
support for the Aladdin chipset has been implemented for ATAPI
devices. Note that the Aladdin apparently only can do DMA reads
on ATAPI devices, and the Promise cant do ATAPI DMA at all.
I have seen problems on some ATAPI devices that should be able
to run in DMA mode, so if you encounter problems with hanging
atapi devices during the probe, or during access, disable DMA
in atapi-all.c, and let me know. It might be nessesary to do this
via a "white list" for known good devices...
The ATAPI CDROM driver can now use eject/close without hanging and
the bug that caused reading beyond the end of a CD has been fixed.
Media change is also handled proberly. DVD drives are identified
and are usable as CDROM devices at least, I dont have the HW to
test this further, see above :).
The ATAPI tape driver has gotten some support for using the DSC
method for not blocking the IDE channel during read/write when
the device has full buffers. It knows about the OnStream DI-30
device, support is not completed yet, but it can function as a
primitive backup medium, without filemarks, and without bad media
handeling. This is because the OnStream device doesn't handle this
(like everybody else) in HW. It also now supports getting/setting
the record position on devices that supports it.
Some rather major cleanups and rearrangements as well (cvs -b diff
is your freind). I'm closing in on declaring this for beta code,
most of the infrastruture is in place by now.
As usual USE AT YOUR OWN RISK!!, this is still alpha level code.
This driver can hose your disk real bad if anything goes wrong, but
now you have been warned :)
But please tell me how it works for you!
Enjoy!
-Søren
1999-09-21 19:50:40 +00:00
|
|
|
|
#include <dev/ata/ata-disk.h>
|
Major update of the ATA RAID code, part 1:
Overhaul of the attach/detach code and structures, there were some nasty
bugs in the old implementation. This made it possible to collapse the
ATA/ATAPI device control structures into one generic structure.
A note here, the kernel is NOT ready for detach of active devices,
it fails all over in random places, but for inactive devices it works.
However for ATA RAID this works, since the RAID abstration layer
insulates the buggy^H^H^H^H^H^Hfragile device subsystem from the
physical disks.
Proberly detect the RAID's from the BIOS, and mark critical RAID1
arrays as such, but continue if there is enough of the mirror left
to do so.
Properly fail arrays on a live system. For RAID0 that means return EIO,
and for RAID1 it means continue on the still working part of the mirror
if possible, else return EIO.
If the state changes, log this to the console.
Allow for Promise & Highpoint controllers/arrays to coexist on the
same machine. It is not possible to distribute arrays over different
makes of controllers though.
If Promise SuperSwap enclosures are used, signal disk state on the
status LED on the front.
Misc fixes that I had lying around for various minor bugs.
Sponsored by: Advanis Inc.
2002-02-04 19:23:40 +00:00
|
|
|
|
#include <dev/ata/ata-raid.h>
|
Finally!!
The much roumored replacement for our current IDE/ATA/ATAPI is
materialising in the CVS repositories around the globe.
So what does this bring us:
A new reengineered ATA/ATAPI subsystem, that tries to overcome
most of the deficiencies with the current drivers.
It supports PCI as well as ISA devices without all the hackery
in ide_pci.c to make PCI devices look like ISA counterparts.
It doesn't have the excessive wait problem on probe, in fact you
shouldn't notice any delay when your devices are getting probed.
Probing and attaching of devices are postponed until interrupts
are enabled (well almost, not finished yet for disks), making
things alot cleaner.
Improved performance, although DMA support is still WIP and not
in this pre alpha release, worldstone is faster with the new
driver compared to the old even with DMA.
So what does it take away:
There is NO support for old MFM/RLL/ESDI disks.
There is NO support for bad144, if your disk is bad, ditch it, it has
already outgrown its internal spare sectors, and is dying.
For you to try this out, you will have to modify your kernel config
file to use the "ata" controller instead of all wdc? entries.
example:
# for a PCI only system (most modern machines)
controller ata0
device atadisk0 # ATA disks
device atapicd0 # ATAPI CDROM's
device atapist0 # ATAPI tapes
#You should add the following on ISA systems:
controller ata1 at isa? port "IO_WD1" bio irq 14
controller ata2 at isa? port "IO_WD2" bio irq 15
You can leave it all in there, the system knows how to manage.
For now this driver reuses the device entries from the old system
(that will probably change later), but remember that disks are
now numbered in the sequence they are found (like the SCSI system)
not as absolute positions as the old system.
Although I have tested this on all the systems I can get my hands on,
there might very well be gremlins in there, so use AT YOU OWN RISK!!
This is still WIP, so there are lots of rough edges and unfinished
things in there, and what I have in my lab might look very different
from whats in CVS at any given time. So please have all eventual
changes go through me, or chances are they just dissapears...
I would very much like to hear from you, both good and bad news
are very welcome.
Enjoy!!
-Søren
1999-03-01 21:19:19 +00:00
|
|
|
|
|
2001-03-15 15:36:25 +00:00
|
|
|
|
/* device structures */
|
2003-08-24 09:22:26 +00:00
|
|
|
|
static d_ioctl_t ata_ioctl;
|
2004-05-20 14:49:12 +00:00
|
|
|
|
static struct cdevsw ata_cdevsw = {
|
2004-02-21 21:10:55 +00:00
|
|
|
|
.d_version = D_VERSION,
|
|
|
|
|
.d_flags = D_NEEDGIANT,
|
2003-08-24 09:22:26 +00:00
|
|
|
|
.d_ioctl = ata_ioctl,
|
2003-03-03 12:15:54 +00:00
|
|
|
|
.d_name = "ata",
|
2001-03-15 15:36:25 +00:00
|
|
|
|
};
|
|
|
|
|
|
Finally!!
The much roumored replacement for our current IDE/ATA/ATAPI is
materialising in the CVS repositories around the globe.
So what does this bring us:
A new reengineered ATA/ATAPI subsystem, that tries to overcome
most of the deficiencies with the current drivers.
It supports PCI as well as ISA devices without all the hackery
in ide_pci.c to make PCI devices look like ISA counterparts.
It doesn't have the excessive wait problem on probe, in fact you
shouldn't notice any delay when your devices are getting probed.
Probing and attaching of devices are postponed until interrupts
are enabled (well almost, not finished yet for disks), making
things alot cleaner.
Improved performance, although DMA support is still WIP and not
in this pre alpha release, worldstone is faster with the new
driver compared to the old even with DMA.
So what does it take away:
There is NO support for old MFM/RLL/ESDI disks.
There is NO support for bad144, if your disk is bad, ditch it, it has
already outgrown its internal spare sectors, and is dying.
For you to try this out, you will have to modify your kernel config
file to use the "ata" controller instead of all wdc? entries.
example:
# for a PCI only system (most modern machines)
controller ata0
device atadisk0 # ATA disks
device atapicd0 # ATAPI CDROM's
device atapist0 # ATAPI tapes
#You should add the following on ISA systems:
controller ata1 at isa? port "IO_WD1" bio irq 14
controller ata2 at isa? port "IO_WD2" bio irq 15
You can leave it all in there, the system knows how to manage.
For now this driver reuses the device entries from the old system
(that will probably change later), but remember that disks are
now numbered in the sequence they are found (like the SCSI system)
not as absolute positions as the old system.
Although I have tested this on all the systems I can get my hands on,
there might very well be gremlins in there, so use AT YOU OWN RISK!!
This is still WIP, so there are lots of rough edges and unfinished
things in there, and what I have in my lab might look very different
from whats in CVS at any given time. So please have all eventual
changes go through me, or chances are they just dissapears...
I would very much like to hear from you, both good and bad news
are very welcome.
Enjoy!!
-Søren
1999-03-01 21:19:19 +00:00
|
|
|
|
/* prototypes */
|
2003-08-25 09:01:49 +00:00
|
|
|
|
static void ata_shutdown(void *, int);
|
|
|
|
|
static int ata_getparam(struct ata_device *, u_int8_t);
|
|
|
|
|
static void ata_identify_devices(struct ata_channel *);
|
2000-02-18 20:57:33 +00:00
|
|
|
|
static void ata_boot_attach(void);
|
2003-08-25 09:01:49 +00:00
|
|
|
|
static void bswap(int8_t *, int);
|
|
|
|
|
static void btrim(int8_t *, int);
|
|
|
|
|
static void bpack(int8_t *, int8_t *, int);
|
2003-08-24 09:22:26 +00:00
|
|
|
|
static void ata_init(void);
|
Finally!!
The much roumored replacement for our current IDE/ATA/ATAPI is
materialising in the CVS repositories around the globe.
So what does this bring us:
A new reengineered ATA/ATAPI subsystem, that tries to overcome
most of the deficiencies with the current drivers.
It supports PCI as well as ISA devices without all the hackery
in ide_pci.c to make PCI devices look like ISA counterparts.
It doesn't have the excessive wait problem on probe, in fact you
shouldn't notice any delay when your devices are getting probed.
Probing and attaching of devices are postponed until interrupts
are enabled (well almost, not finished yet for disks), making
things alot cleaner.
Improved performance, although DMA support is still WIP and not
in this pre alpha release, worldstone is faster with the new
driver compared to the old even with DMA.
So what does it take away:
There is NO support for old MFM/RLL/ESDI disks.
There is NO support for bad144, if your disk is bad, ditch it, it has
already outgrown its internal spare sectors, and is dying.
For you to try this out, you will have to modify your kernel config
file to use the "ata" controller instead of all wdc? entries.
example:
# for a PCI only system (most modern machines)
controller ata0
device atadisk0 # ATA disks
device atapicd0 # ATAPI CDROM's
device atapist0 # ATAPI tapes
#You should add the following on ISA systems:
controller ata1 at isa? port "IO_WD1" bio irq 14
controller ata2 at isa? port "IO_WD2" bio irq 15
You can leave it all in there, the system knows how to manage.
For now this driver reuses the device entries from the old system
(that will probably change later), but remember that disks are
now numbered in the sequence they are found (like the SCSI system)
not as absolute positions as the old system.
Although I have tested this on all the systems I can get my hands on,
there might very well be gremlins in there, so use AT YOU OWN RISK!!
This is still WIP, so there are lots of rough edges and unfinished
things in there, and what I have in my lab might look very different
from whats in CVS at any given time. So please have all eventual
changes go through me, or chances are they just dissapears...
I would very much like to hear from you, both good and bad news
are very welcome.
Enjoy!!
-Søren
1999-03-01 21:19:19 +00:00
|
|
|
|
|
2003-11-11 14:55:36 +00:00
|
|
|
|
/* global vars */
|
2003-11-30 16:27:59 +00:00
|
|
|
|
MALLOC_DEFINE(M_ATA, "ATA generic", "ATA driver generic layer");
|
2003-11-11 14:55:36 +00:00
|
|
|
|
struct intr_config_hook *ata_delayed_attach = NULL;
|
|
|
|
|
devclass_t ata_devclass;
|
2004-01-14 21:26:35 +00:00
|
|
|
|
uma_zone_t ata_zone;
|
2004-05-20 14:49:12 +00:00
|
|
|
|
int ata_wc = 1;
|
2003-11-11 14:55:36 +00:00
|
|
|
|
|
|
|
|
|
/* local vars */
|
|
|
|
|
static int ata_dma = 1;
|
|
|
|
|
static int atapi_dma = 0;
|
|
|
|
|
|
2001-03-19 08:04:54 +00:00
|
|
|
|
/* sysctl vars */
|
|
|
|
|
SYSCTL_NODE(_hw, OID_AUTO, ata, CTLFLAG_RD, 0, "ATA driver parameters");
|
2003-08-24 09:22:26 +00:00
|
|
|
|
TUNABLE_INT("hw.ata.ata_dma", &ata_dma);
|
2003-11-03 09:25:02 +00:00
|
|
|
|
SYSCTL_INT(_hw_ata, OID_AUTO, ata_dma, CTLFLAG_RDTUN, &ata_dma, 0,
|
|
|
|
|
"ATA disk DMA mode control");
|
2003-08-24 09:22:26 +00:00
|
|
|
|
TUNABLE_INT("hw.ata.wc", &ata_wc);
|
2003-11-03 09:25:02 +00:00
|
|
|
|
SYSCTL_INT(_hw_ata, OID_AUTO, wc, CTLFLAG_RDTUN, &ata_wc, 0,
|
|
|
|
|
"ATA disk write caching");
|
2003-08-24 09:22:26 +00:00
|
|
|
|
TUNABLE_INT("hw.ata.atapi_dma", &atapi_dma);
|
2003-11-03 09:25:02 +00:00
|
|
|
|
SYSCTL_INT(_hw_ata, OID_AUTO, atapi_dma, CTLFLAG_RDTUN, &atapi_dma, 0,
|
|
|
|
|
"ATAPI device DMA mode control");
|
Finally!!
The much roumored replacement for our current IDE/ATA/ATAPI is
materialising in the CVS repositories around the globe.
So what does this bring us:
A new reengineered ATA/ATAPI subsystem, that tries to overcome
most of the deficiencies with the current drivers.
It supports PCI as well as ISA devices without all the hackery
in ide_pci.c to make PCI devices look like ISA counterparts.
It doesn't have the excessive wait problem on probe, in fact you
shouldn't notice any delay when your devices are getting probed.
Probing and attaching of devices are postponed until interrupts
are enabled (well almost, not finished yet for disks), making
things alot cleaner.
Improved performance, although DMA support is still WIP and not
in this pre alpha release, worldstone is faster with the new
driver compared to the old even with DMA.
So what does it take away:
There is NO support for old MFM/RLL/ESDI disks.
There is NO support for bad144, if your disk is bad, ditch it, it has
already outgrown its internal spare sectors, and is dying.
For you to try this out, you will have to modify your kernel config
file to use the "ata" controller instead of all wdc? entries.
example:
# for a PCI only system (most modern machines)
controller ata0
device atadisk0 # ATA disks
device atapicd0 # ATAPI CDROM's
device atapist0 # ATAPI tapes
#You should add the following on ISA systems:
controller ata1 at isa? port "IO_WD1" bio irq 14
controller ata2 at isa? port "IO_WD2" bio irq 15
You can leave it all in there, the system knows how to manage.
For now this driver reuses the device entries from the old system
(that will probably change later), but remember that disks are
now numbered in the sequence they are found (like the SCSI system)
not as absolute positions as the old system.
Although I have tested this on all the systems I can get my hands on,
there might very well be gremlins in there, so use AT YOU OWN RISK!!
This is still WIP, so there are lots of rough edges and unfinished
things in there, and what I have in my lab might look very different
from whats in CVS at any given time. So please have all eventual
changes go through me, or chances are they just dissapears...
I would very much like to hear from you, both good and bad news
are very welcome.
Enjoy!!
-Søren
1999-03-01 21:19:19 +00:00
|
|
|
|
|
2003-08-24 09:22:26 +00:00
|
|
|
|
/*
|
|
|
|
|
* newbus device interface related functions
|
|
|
|
|
*/
|
2000-09-19 11:08:39 +00:00
|
|
|
|
int
|
2000-02-18 20:57:33 +00:00
|
|
|
|
ata_probe(device_t dev)
|
|
|
|
|
{
|
Major update of the ATA RAID code, part 1:
Overhaul of the attach/detach code and structures, there were some nasty
bugs in the old implementation. This made it possible to collapse the
ATA/ATAPI device control structures into one generic structure.
A note here, the kernel is NOT ready for detach of active devices,
it fails all over in random places, but for inactive devices it works.
However for ATA RAID this works, since the RAID abstration layer
insulates the buggy^H^H^H^H^H^Hfragile device subsystem from the
physical disks.
Proberly detect the RAID's from the BIOS, and mark critical RAID1
arrays as such, but continue if there is enough of the mirror left
to do so.
Properly fail arrays on a live system. For RAID0 that means return EIO,
and for RAID1 it means continue on the still working part of the mirror
if possible, else return EIO.
If the state changes, log this to the console.
Allow for Promise & Highpoint controllers/arrays to coexist on the
same machine. It is not possible to distribute arrays over different
makes of controllers though.
If Promise SuperSwap enclosures are used, signal disk state on the
status LED on the front.
Misc fixes that I had lying around for various minor bugs.
Sponsored by: Advanis Inc.
2002-02-04 19:23:40 +00:00
|
|
|
|
struct ata_channel *ch;
|
2000-02-18 20:57:33 +00:00
|
|
|
|
|
Major update of the ATA RAID code, part 1:
Overhaul of the attach/detach code and structures, there were some nasty
bugs in the old implementation. This made it possible to collapse the
ATA/ATAPI device control structures into one generic structure.
A note here, the kernel is NOT ready for detach of active devices,
it fails all over in random places, but for inactive devices it works.
However for ATA RAID this works, since the RAID abstration layer
insulates the buggy^H^H^H^H^H^Hfragile device subsystem from the
physical disks.
Proberly detect the RAID's from the BIOS, and mark critical RAID1
arrays as such, but continue if there is enough of the mirror left
to do so.
Properly fail arrays on a live system. For RAID0 that means return EIO,
and for RAID1 it means continue on the still working part of the mirror
if possible, else return EIO.
If the state changes, log this to the console.
Allow for Promise & Highpoint controllers/arrays to coexist on the
same machine. It is not possible to distribute arrays over different
makes of controllers though.
If Promise SuperSwap enclosures are used, signal disk state on the
status LED on the front.
Misc fixes that I had lying around for various minor bugs.
Sponsored by: Advanis Inc.
2002-02-04 19:23:40 +00:00
|
|
|
|
if (!dev || !(ch = device_get_softc(dev)))
|
2000-02-18 20:57:33 +00:00
|
|
|
|
return ENXIO;
|
Major update of the ATA RAID code, part 1:
Overhaul of the attach/detach code and structures, there were some nasty
bugs in the old implementation. This made it possible to collapse the
ATA/ATAPI device control structures into one generic structure.
A note here, the kernel is NOT ready for detach of active devices,
it fails all over in random places, but for inactive devices it works.
However for ATA RAID this works, since the RAID abstration layer
insulates the buggy^H^H^H^H^H^Hfragile device subsystem from the
physical disks.
Proberly detect the RAID's from the BIOS, and mark critical RAID1
arrays as such, but continue if there is enough of the mirror left
to do so.
Properly fail arrays on a live system. For RAID0 that means return EIO,
and for RAID1 it means continue on the still working part of the mirror
if possible, else return EIO.
If the state changes, log this to the console.
Allow for Promise & Highpoint controllers/arrays to coexist on the
same machine. It is not possible to distribute arrays over different
makes of controllers though.
If Promise SuperSwap enclosures are used, signal disk state on the
status LED on the front.
Misc fixes that I had lying around for various minor bugs.
Sponsored by: Advanis Inc.
2002-02-04 19:23:40 +00:00
|
|
|
|
|
2003-03-29 13:37:09 +00:00
|
|
|
|
if (ch->r_irq)
|
2001-03-19 08:04:54 +00:00
|
|
|
|
return EEXIST;
|
Finally!!
The much roumored replacement for our current IDE/ATA/ATAPI is
materialising in the CVS repositories around the globe.
So what does this bring us:
A new reengineered ATA/ATAPI subsystem, that tries to overcome
most of the deficiencies with the current drivers.
It supports PCI as well as ISA devices without all the hackery
in ide_pci.c to make PCI devices look like ISA counterparts.
It doesn't have the excessive wait problem on probe, in fact you
shouldn't notice any delay when your devices are getting probed.
Probing and attaching of devices are postponed until interrupts
are enabled (well almost, not finished yet for disks), making
things alot cleaner.
Improved performance, although DMA support is still WIP and not
in this pre alpha release, worldstone is faster with the new
driver compared to the old even with DMA.
So what does it take away:
There is NO support for old MFM/RLL/ESDI disks.
There is NO support for bad144, if your disk is bad, ditch it, it has
already outgrown its internal spare sectors, and is dying.
For you to try this out, you will have to modify your kernel config
file to use the "ata" controller instead of all wdc? entries.
example:
# for a PCI only system (most modern machines)
controller ata0
device atadisk0 # ATA disks
device atapicd0 # ATAPI CDROM's
device atapist0 # ATAPI tapes
#You should add the following on ISA systems:
controller ata1 at isa? port "IO_WD1" bio irq 14
controller ata2 at isa? port "IO_WD2" bio irq 15
You can leave it all in there, the system knows how to manage.
For now this driver reuses the device entries from the old system
(that will probably change later), but remember that disks are
now numbered in the sequence they are found (like the SCSI system)
not as absolute positions as the old system.
Although I have tested this on all the systems I can get my hands on,
there might very well be gremlins in there, so use AT YOU OWN RISK!!
This is still WIP, so there are lots of rough edges and unfinished
things in there, and what I have in my lab might look very different
from whats in CVS at any given time. So please have all eventual
changes go through me, or chances are they just dissapears...
I would very much like to hear from you, both good and bad news
are very welcome.
Enjoy!!
-Søren
1999-03-01 21:19:19 +00:00
|
|
|
|
|
2000-02-18 20:57:33 +00:00
|
|
|
|
/* initialize the softc basics */
|
Major update of the ATA RAID code, part 1:
Overhaul of the attach/detach code and structures, there were some nasty
bugs in the old implementation. This made it possible to collapse the
ATA/ATAPI device control structures into one generic structure.
A note here, the kernel is NOT ready for detach of active devices,
it fails all over in random places, but for inactive devices it works.
However for ATA RAID this works, since the RAID abstration layer
insulates the buggy^H^H^H^H^H^Hfragile device subsystem from the
physical disks.
Proberly detect the RAID's from the BIOS, and mark critical RAID1
arrays as such, but continue if there is enough of the mirror left
to do so.
Properly fail arrays on a live system. For RAID0 that means return EIO,
and for RAID1 it means continue on the still working part of the mirror
if possible, else return EIO.
If the state changes, log this to the console.
Allow for Promise & Highpoint controllers/arrays to coexist on the
same machine. It is not possible to distribute arrays over different
makes of controllers though.
If Promise SuperSwap enclosures are used, signal disk state on the
status LED on the front.
Misc fixes that I had lying around for various minor bugs.
Sponsored by: Advanis Inc.
2002-02-04 19:23:40 +00:00
|
|
|
|
ch->device[MASTER].channel = ch;
|
|
|
|
|
ch->device[MASTER].unit = ATA_MASTER;
|
|
|
|
|
ch->device[MASTER].mode = ATA_PIO;
|
|
|
|
|
ch->device[SLAVE].channel = ch;
|
|
|
|
|
ch->device[SLAVE].unit = ATA_SLAVE;
|
|
|
|
|
ch->device[SLAVE].mode = ATA_PIO;
|
2003-08-24 09:22:26 +00:00
|
|
|
|
ch->dev = dev;
|
2004-04-30 16:21:34 +00:00
|
|
|
|
ch->lock = ATA_IDLE;
|
2003-03-29 13:37:09 +00:00
|
|
|
|
|
|
|
|
|
/* initialise device(s) on this channel */
|
|
|
|
|
ch->locking(ch, ATA_LF_LOCK);
|
2003-08-24 09:22:26 +00:00
|
|
|
|
ch->hw.reset(ch);
|
2003-03-29 13:37:09 +00:00
|
|
|
|
ch->locking(ch, ATA_LF_UNLOCK);
|
2000-02-18 20:57:33 +00:00
|
|
|
|
return 0;
|
Finally!!
The much roumored replacement for our current IDE/ATA/ATAPI is
materialising in the CVS repositories around the globe.
So what does this bring us:
A new reengineered ATA/ATAPI subsystem, that tries to overcome
most of the deficiencies with the current drivers.
It supports PCI as well as ISA devices without all the hackery
in ide_pci.c to make PCI devices look like ISA counterparts.
It doesn't have the excessive wait problem on probe, in fact you
shouldn't notice any delay when your devices are getting probed.
Probing and attaching of devices are postponed until interrupts
are enabled (well almost, not finished yet for disks), making
things alot cleaner.
Improved performance, although DMA support is still WIP and not
in this pre alpha release, worldstone is faster with the new
driver compared to the old even with DMA.
So what does it take away:
There is NO support for old MFM/RLL/ESDI disks.
There is NO support for bad144, if your disk is bad, ditch it, it has
already outgrown its internal spare sectors, and is dying.
For you to try this out, you will have to modify your kernel config
file to use the "ata" controller instead of all wdc? entries.
example:
# for a PCI only system (most modern machines)
controller ata0
device atadisk0 # ATA disks
device atapicd0 # ATAPI CDROM's
device atapist0 # ATAPI tapes
#You should add the following on ISA systems:
controller ata1 at isa? port "IO_WD1" bio irq 14
controller ata2 at isa? port "IO_WD2" bio irq 15
You can leave it all in there, the system knows how to manage.
For now this driver reuses the device entries from the old system
(that will probably change later), but remember that disks are
now numbered in the sequence they are found (like the SCSI system)
not as absolute positions as the old system.
Although I have tested this on all the systems I can get my hands on,
there might very well be gremlins in there, so use AT YOU OWN RISK!!
This is still WIP, so there are lots of rough edges and unfinished
things in there, and what I have in my lab might look very different
from whats in CVS at any given time. So please have all eventual
changes go through me, or chances are they just dissapears...
I would very much like to hear from you, both good and bad news
are very welcome.
Enjoy!!
-Søren
1999-03-01 21:19:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-03-06 21:43:46 +00:00
|
|
|
|
int
|
2000-02-18 20:57:33 +00:00
|
|
|
|
ata_attach(device_t dev)
|
2000-01-18 21:02:59 +00:00
|
|
|
|
{
|
Major update of the ATA RAID code, part 1:
Overhaul of the attach/detach code and structures, there were some nasty
bugs in the old implementation. This made it possible to collapse the
ATA/ATAPI device control structures into one generic structure.
A note here, the kernel is NOT ready for detach of active devices,
it fails all over in random places, but for inactive devices it works.
However for ATA RAID this works, since the RAID abstration layer
insulates the buggy^H^H^H^H^H^Hfragile device subsystem from the
physical disks.
Proberly detect the RAID's from the BIOS, and mark critical RAID1
arrays as such, but continue if there is enough of the mirror left
to do so.
Properly fail arrays on a live system. For RAID0 that means return EIO,
and for RAID1 it means continue on the still working part of the mirror
if possible, else return EIO.
If the state changes, log this to the console.
Allow for Promise & Highpoint controllers/arrays to coexist on the
same machine. It is not possible to distribute arrays over different
makes of controllers though.
If Promise SuperSwap enclosures are used, signal disk state on the
status LED on the front.
Misc fixes that I had lying around for various minor bugs.
Sponsored by: Advanis Inc.
2002-02-04 19:23:40 +00:00
|
|
|
|
struct ata_channel *ch;
|
2001-02-06 16:44:25 +00:00
|
|
|
|
int error, rid;
|
2000-02-18 20:57:33 +00:00
|
|
|
|
|
Major update of the ATA RAID code, part 1:
Overhaul of the attach/detach code and structures, there were some nasty
bugs in the old implementation. This made it possible to collapse the
ATA/ATAPI device control structures into one generic structure.
A note here, the kernel is NOT ready for detach of active devices,
it fails all over in random places, but for inactive devices it works.
However for ATA RAID this works, since the RAID abstration layer
insulates the buggy^H^H^H^H^H^Hfragile device subsystem from the
physical disks.
Proberly detect the RAID's from the BIOS, and mark critical RAID1
arrays as such, but continue if there is enough of the mirror left
to do so.
Properly fail arrays on a live system. For RAID0 that means return EIO,
and for RAID1 it means continue on the still working part of the mirror
if possible, else return EIO.
If the state changes, log this to the console.
Allow for Promise & Highpoint controllers/arrays to coexist on the
same machine. It is not possible to distribute arrays over different
makes of controllers though.
If Promise SuperSwap enclosures are used, signal disk state on the
status LED on the front.
Misc fixes that I had lying around for various minor bugs.
Sponsored by: Advanis Inc.
2002-02-04 19:23:40 +00:00
|
|
|
|
if (!dev || !(ch = device_get_softc(dev)))
|
2000-02-18 20:57:33 +00:00
|
|
|
|
return ENXIO;
|
|
|
|
|
|
2001-02-06 16:44:25 +00:00
|
|
|
|
rid = ATA_IRQ_RID;
|
2004-03-17 17:50:55 +00:00
|
|
|
|
ch->r_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid,
|
|
|
|
|
RF_SHAREABLE | RF_ACTIVE);
|
Major update of the ATA RAID code, part 1:
Overhaul of the attach/detach code and structures, there were some nasty
bugs in the old implementation. This made it possible to collapse the
ATA/ATAPI device control structures into one generic structure.
A note here, the kernel is NOT ready for detach of active devices,
it fails all over in random places, but for inactive devices it works.
However for ATA RAID this works, since the RAID abstration layer
insulates the buggy^H^H^H^H^H^Hfragile device subsystem from the
physical disks.
Proberly detect the RAID's from the BIOS, and mark critical RAID1
arrays as such, but continue if there is enough of the mirror left
to do so.
Properly fail arrays on a live system. For RAID0 that means return EIO,
and for RAID1 it means continue on the still working part of the mirror
if possible, else return EIO.
If the state changes, log this to the console.
Allow for Promise & Highpoint controllers/arrays to coexist on the
same machine. It is not possible to distribute arrays over different
makes of controllers though.
If Promise SuperSwap enclosures are used, signal disk state on the
status LED on the front.
Misc fixes that I had lying around for various minor bugs.
Sponsored by: Advanis Inc.
2002-02-04 19:23:40 +00:00
|
|
|
|
if (!ch->r_irq) {
|
|
|
|
|
ata_printf(ch, -1, "unable to allocate interrupt\n");
|
2000-02-18 20:57:33 +00:00
|
|
|
|
return ENXIO;
|
|
|
|
|
}
|
2003-08-24 09:22:26 +00:00
|
|
|
|
if ((error = bus_setup_intr(dev, ch->r_irq, ATA_INTR_FLAGS,
|
|
|
|
|
ch->hw.interrupt, ch, &ch->ih))) {
|
2002-03-03 15:36:21 +00:00
|
|
|
|
ata_printf(ch, -1, "unable to setup interrupt\n");
|
2000-02-25 09:48:23 +00:00
|
|
|
|
return error;
|
2002-03-03 15:36:21 +00:00
|
|
|
|
}
|
2000-01-18 21:02:59 +00:00
|
|
|
|
|
2003-02-20 20:02:32 +00:00
|
|
|
|
if (ch->dma)
|
2003-03-29 13:37:09 +00:00
|
|
|
|
ch->dma->alloc(ch);
|
2003-02-20 20:02:32 +00:00
|
|
|
|
|
2004-03-01 13:17:07 +00:00
|
|
|
|
/* initialize queue and associated lock */
|
|
|
|
|
bzero(&ch->queue_mtx, sizeof(struct mtx));
|
2004-06-22 11:18:25 +00:00
|
|
|
|
mtx_init(&ch->queue_mtx, "ATA queue lock", NULL, MTX_DEF);
|
2004-03-01 13:17:07 +00:00
|
|
|
|
TAILQ_INIT(&ch->ata_queue);
|
|
|
|
|
|
2003-08-24 09:22:26 +00:00
|
|
|
|
/* do not attach devices if we are in early boot */
|
|
|
|
|
if (ata_delayed_attach)
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
ata_identify_devices(ch);
|
|
|
|
|
|
|
|
|
|
if (ch->device[MASTER].attach)
|
|
|
|
|
ch->device[MASTER].attach(&ch->device[MASTER]);
|
|
|
|
|
if (ch->device[SLAVE].attach)
|
|
|
|
|
ch->device[SLAVE].attach(&ch->device[SLAVE]);
|
2002-08-09 20:54:06 +00:00
|
|
|
|
#ifdef DEV_ATAPICAM
|
2003-08-24 09:22:26 +00:00
|
|
|
|
atapi_cam_attach_bus(ch);
|
2000-02-18 20:57:33 +00:00
|
|
|
|
#endif
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2001-03-06 21:43:46 +00:00
|
|
|
|
int
|
2000-02-18 20:57:33 +00:00
|
|
|
|
ata_detach(device_t dev)
|
|
|
|
|
{
|
Major update of the ATA RAID code, part 1:
Overhaul of the attach/detach code and structures, there were some nasty
bugs in the old implementation. This made it possible to collapse the
ATA/ATAPI device control structures into one generic structure.
A note here, the kernel is NOT ready for detach of active devices,
it fails all over in random places, but for inactive devices it works.
However for ATA RAID this works, since the RAID abstration layer
insulates the buggy^H^H^H^H^H^Hfragile device subsystem from the
physical disks.
Proberly detect the RAID's from the BIOS, and mark critical RAID1
arrays as such, but continue if there is enough of the mirror left
to do so.
Properly fail arrays on a live system. For RAID0 that means return EIO,
and for RAID1 it means continue on the still working part of the mirror
if possible, else return EIO.
If the state changes, log this to the console.
Allow for Promise & Highpoint controllers/arrays to coexist on the
same machine. It is not possible to distribute arrays over different
makes of controllers though.
If Promise SuperSwap enclosures are used, signal disk state on the
status LED on the front.
Misc fixes that I had lying around for various minor bugs.
Sponsored by: Advanis Inc.
2002-02-04 19:23:40 +00:00
|
|
|
|
struct ata_channel *ch;
|
2004-05-20 14:49:12 +00:00
|
|
|
|
|
2003-03-29 13:37:09 +00:00
|
|
|
|
if (!dev || !(ch = device_get_softc(dev)) || !ch->r_irq)
|
2000-02-18 20:57:33 +00:00
|
|
|
|
return ENXIO;
|
2000-01-18 21:02:59 +00:00
|
|
|
|
|
2003-08-24 09:22:26 +00:00
|
|
|
|
/* detach devices on this channel */
|
|
|
|
|
if (ch->device[MASTER].detach)
|
|
|
|
|
ch->device[MASTER].detach(&ch->device[MASTER]);
|
|
|
|
|
if (ch->device[SLAVE].detach)
|
|
|
|
|
ch->device[SLAVE].detach(&ch->device[SLAVE]);
|
2002-08-09 20:54:06 +00:00
|
|
|
|
#ifdef DEV_ATAPICAM
|
2002-10-22 20:18:51 +00:00
|
|
|
|
atapi_cam_detach_bus(ch);
|
2000-01-19 07:25:46 +00:00
|
|
|
|
#endif
|
2003-08-24 09:22:26 +00:00
|
|
|
|
|
|
|
|
|
/* fail outstanding requests on this channel */
|
2004-01-11 22:08:34 +00:00
|
|
|
|
ata_fail_requests(ch, NULL);
|
2001-02-06 16:44:25 +00:00
|
|
|
|
|
2004-01-11 22:08:34 +00:00
|
|
|
|
/* flush cache and powerdown device */
|
Major update of the ATA RAID code, part 1:
Overhaul of the attach/detach code and structures, there were some nasty
bugs in the old implementation. This made it possible to collapse the
ATA/ATAPI device control structures into one generic structure.
A note here, the kernel is NOT ready for detach of active devices,
it fails all over in random places, but for inactive devices it works.
However for ATA RAID this works, since the RAID abstration layer
insulates the buggy^H^H^H^H^H^Hfragile device subsystem from the
physical disks.
Proberly detect the RAID's from the BIOS, and mark critical RAID1
arrays as such, but continue if there is enough of the mirror left
to do so.
Properly fail arrays on a live system. For RAID0 that means return EIO,
and for RAID1 it means continue on the still working part of the mirror
if possible, else return EIO.
If the state changes, log this to the console.
Allow for Promise & Highpoint controllers/arrays to coexist on the
same machine. It is not possible to distribute arrays over different
makes of controllers though.
If Promise SuperSwap enclosures are used, signal disk state on the
status LED on the front.
Misc fixes that I had lying around for various minor bugs.
Sponsored by: Advanis Inc.
2002-02-04 19:23:40 +00:00
|
|
|
|
if (ch->device[MASTER].param) {
|
2003-08-25 07:59:50 +00:00
|
|
|
|
if (ch->device[MASTER].param->support.command2 & ATA_SUPPORT_FLUSHCACHE)
|
|
|
|
|
ata_controlcmd(&ch->device[MASTER], ATA_FLUSHCACHE, 0, 0, 0);
|
2003-10-12 12:37:11 +00:00
|
|
|
|
ata_controlcmd(&ch->device[MASTER], ATA_SLEEP, 0, 0, 0);
|
Major update of the ATA RAID code, part 1:
Overhaul of the attach/detach code and structures, there were some nasty
bugs in the old implementation. This made it possible to collapse the
ATA/ATAPI device control structures into one generic structure.
A note here, the kernel is NOT ready for detach of active devices,
it fails all over in random places, but for inactive devices it works.
However for ATA RAID this works, since the RAID abstration layer
insulates the buggy^H^H^H^H^H^Hfragile device subsystem from the
physical disks.
Proberly detect the RAID's from the BIOS, and mark critical RAID1
arrays as such, but continue if there is enough of the mirror left
to do so.
Properly fail arrays on a live system. For RAID0 that means return EIO,
and for RAID1 it means continue on the still working part of the mirror
if possible, else return EIO.
If the state changes, log this to the console.
Allow for Promise & Highpoint controllers/arrays to coexist on the
same machine. It is not possible to distribute arrays over different
makes of controllers though.
If Promise SuperSwap enclosures are used, signal disk state on the
status LED on the front.
Misc fixes that I had lying around for various minor bugs.
Sponsored by: Advanis Inc.
2002-02-04 19:23:40 +00:00
|
|
|
|
free(ch->device[MASTER].param, M_ATA);
|
|
|
|
|
ch->device[MASTER].param = NULL;
|
2000-01-18 21:02:59 +00:00
|
|
|
|
}
|
Major update of the ATA RAID code, part 1:
Overhaul of the attach/detach code and structures, there were some nasty
bugs in the old implementation. This made it possible to collapse the
ATA/ATAPI device control structures into one generic structure.
A note here, the kernel is NOT ready for detach of active devices,
it fails all over in random places, but for inactive devices it works.
However for ATA RAID this works, since the RAID abstration layer
insulates the buggy^H^H^H^H^H^Hfragile device subsystem from the
physical disks.
Proberly detect the RAID's from the BIOS, and mark critical RAID1
arrays as such, but continue if there is enough of the mirror left
to do so.
Properly fail arrays on a live system. For RAID0 that means return EIO,
and for RAID1 it means continue on the still working part of the mirror
if possible, else return EIO.
If the state changes, log this to the console.
Allow for Promise & Highpoint controllers/arrays to coexist on the
same machine. It is not possible to distribute arrays over different
makes of controllers though.
If Promise SuperSwap enclosures are used, signal disk state on the
status LED on the front.
Misc fixes that I had lying around for various minor bugs.
Sponsored by: Advanis Inc.
2002-02-04 19:23:40 +00:00
|
|
|
|
if (ch->device[SLAVE].param) {
|
2003-08-25 07:59:50 +00:00
|
|
|
|
if (ch->device[SLAVE].param->support.command2 & ATA_SUPPORT_FLUSHCACHE)
|
|
|
|
|
ata_controlcmd(&ch->device[SLAVE], ATA_FLUSHCACHE, 0, 0, 0);
|
2003-10-12 12:37:11 +00:00
|
|
|
|
ata_controlcmd(&ch->device[SLAVE], ATA_SLEEP, 0, 0, 0);
|
Major update of the ATA RAID code, part 1:
Overhaul of the attach/detach code and structures, there were some nasty
bugs in the old implementation. This made it possible to collapse the
ATA/ATAPI device control structures into one generic structure.
A note here, the kernel is NOT ready for detach of active devices,
it fails all over in random places, but for inactive devices it works.
However for ATA RAID this works, since the RAID abstration layer
insulates the buggy^H^H^H^H^H^Hfragile device subsystem from the
physical disks.
Proberly detect the RAID's from the BIOS, and mark critical RAID1
arrays as such, but continue if there is enough of the mirror left
to do so.
Properly fail arrays on a live system. For RAID0 that means return EIO,
and for RAID1 it means continue on the still working part of the mirror
if possible, else return EIO.
If the state changes, log this to the console.
Allow for Promise & Highpoint controllers/arrays to coexist on the
same machine. It is not possible to distribute arrays over different
makes of controllers though.
If Promise SuperSwap enclosures are used, signal disk state on the
status LED on the front.
Misc fixes that I had lying around for various minor bugs.
Sponsored by: Advanis Inc.
2002-02-04 19:23:40 +00:00
|
|
|
|
free(ch->device[SLAVE].param, M_ATA);
|
|
|
|
|
ch->device[SLAVE].param = NULL;
|
2000-02-18 20:57:33 +00:00
|
|
|
|
}
|
Major update of the ATA RAID code, part 1:
Overhaul of the attach/detach code and structures, there were some nasty
bugs in the old implementation. This made it possible to collapse the
ATA/ATAPI device control structures into one generic structure.
A note here, the kernel is NOT ready for detach of active devices,
it fails all over in random places, but for inactive devices it works.
However for ATA RAID this works, since the RAID abstration layer
insulates the buggy^H^H^H^H^H^Hfragile device subsystem from the
physical disks.
Proberly detect the RAID's from the BIOS, and mark critical RAID1
arrays as such, but continue if there is enough of the mirror left
to do so.
Properly fail arrays on a live system. For RAID0 that means return EIO,
and for RAID1 it means continue on the still working part of the mirror
if possible, else return EIO.
If the state changes, log this to the console.
Allow for Promise & Highpoint controllers/arrays to coexist on the
same machine. It is not possible to distribute arrays over different
makes of controllers though.
If Promise SuperSwap enclosures are used, signal disk state on the
status LED on the front.
Misc fixes that I had lying around for various minor bugs.
Sponsored by: Advanis Inc.
2002-02-04 19:23:40 +00:00
|
|
|
|
ch->device[MASTER].mode = ATA_PIO;
|
|
|
|
|
ch->device[SLAVE].mode = ATA_PIO;
|
|
|
|
|
ch->devices = 0;
|
2003-08-24 09:22:26 +00:00
|
|
|
|
|
2003-02-20 20:02:32 +00:00
|
|
|
|
if (ch->dma)
|
2003-03-29 13:37:09 +00:00
|
|
|
|
ch->dma->free(ch);
|
Major update of the ATA RAID code, part 1:
Overhaul of the attach/detach code and structures, there were some nasty
bugs in the old implementation. This made it possible to collapse the
ATA/ATAPI device control structures into one generic structure.
A note here, the kernel is NOT ready for detach of active devices,
it fails all over in random places, but for inactive devices it works.
However for ATA RAID this works, since the RAID abstration layer
insulates the buggy^H^H^H^H^H^Hfragile device subsystem from the
physical disks.
Proberly detect the RAID's from the BIOS, and mark critical RAID1
arrays as such, but continue if there is enough of the mirror left
to do so.
Properly fail arrays on a live system. For RAID0 that means return EIO,
and for RAID1 it means continue on the still working part of the mirror
if possible, else return EIO.
If the state changes, log this to the console.
Allow for Promise & Highpoint controllers/arrays to coexist on the
same machine. It is not possible to distribute arrays over different
makes of controllers though.
If Promise SuperSwap enclosures are used, signal disk state on the
status LED on the front.
Misc fixes that I had lying around for various minor bugs.
Sponsored by: Advanis Inc.
2002-02-04 19:23:40 +00:00
|
|
|
|
|
|
|
|
|
bus_teardown_intr(dev, ch->r_irq, ch->ih);
|
|
|
|
|
bus_release_resource(dev, SYS_RES_IRQ, ATA_IRQ_RID, ch->r_irq);
|
|
|
|
|
ch->r_irq = NULL;
|
2004-03-01 13:17:07 +00:00
|
|
|
|
mtx_destroy(&ch->queue_mtx);
|
2003-08-24 09:22:26 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
ata_reinit(struct ata_channel *ch)
|
|
|
|
|
{
|
2003-10-07 13:44:15 +00:00
|
|
|
|
struct ata_request *request = ch->running;
|
2003-08-24 09:22:26 +00:00
|
|
|
|
int devices, misdev, newdev;
|
2004-05-20 14:49:12 +00:00
|
|
|
|
|
2003-08-24 09:22:26 +00:00
|
|
|
|
if (!ch->r_irq)
|
|
|
|
|
return ENXIO;
|
|
|
|
|
|
|
|
|
|
/* reset the HW */
|
2004-01-11 22:08:34 +00:00
|
|
|
|
if (bootverbose)
|
|
|
|
|
ata_printf(ch, -1, "reiniting channel ..\n");
|
2004-04-30 16:21:34 +00:00
|
|
|
|
ATA_FORCELOCK_CH(ch);
|
2004-01-11 22:08:34 +00:00
|
|
|
|
ch->flags |= ATA_IMMEDIATE_MODE;
|
2003-08-24 09:22:26 +00:00
|
|
|
|
ch->running = NULL;
|
|
|
|
|
devices = ch->devices;
|
|
|
|
|
ch->hw.reset(ch);
|
2002-03-11 21:04:32 +00:00
|
|
|
|
ATA_UNLOCK_CH(ch);
|
2003-08-24 09:22:26 +00:00
|
|
|
|
|
2004-01-11 22:08:34 +00:00
|
|
|
|
if (bootverbose)
|
|
|
|
|
ata_printf(ch, -1, "resetting done ..\n");
|
|
|
|
|
|
2003-08-24 09:22:26 +00:00
|
|
|
|
/* detach what left the channel during reset */
|
|
|
|
|
if ((misdev = devices & ~ch->devices)) {
|
|
|
|
|
if ((misdev & (ATA_ATA_MASTER | ATA_ATAPI_MASTER)) &&
|
2003-10-07 13:44:15 +00:00
|
|
|
|
ch->device[MASTER].detach) {
|
|
|
|
|
if (request && (request->device == &ch->device[MASTER])) {
|
|
|
|
|
request->result = ENXIO;
|
2004-04-13 09:44:20 +00:00
|
|
|
|
request->retries = 0;
|
2003-10-07 13:44:15 +00:00
|
|
|
|
}
|
2003-08-24 09:22:26 +00:00
|
|
|
|
ch->device[MASTER].detach(&ch->device[MASTER]);
|
2004-01-11 22:08:34 +00:00
|
|
|
|
ata_fail_requests(ch, &ch->device[MASTER]);
|
|
|
|
|
free(ch->device[MASTER].param, M_ATA);
|
|
|
|
|
ch->device[MASTER].param = NULL;
|
2003-10-07 13:44:15 +00:00
|
|
|
|
}
|
2003-08-24 09:22:26 +00:00
|
|
|
|
if ((misdev & (ATA_ATA_SLAVE | ATA_ATAPI_SLAVE)) &&
|
2003-10-07 13:44:15 +00:00
|
|
|
|
ch->device[SLAVE].detach) {
|
|
|
|
|
if (request && (request->device == &ch->device[SLAVE])) {
|
|
|
|
|
request->result = ENXIO;
|
2004-04-13 09:44:20 +00:00
|
|
|
|
request->retries = 0;
|
2003-10-07 13:44:15 +00:00
|
|
|
|
}
|
2003-08-24 09:22:26 +00:00
|
|
|
|
ch->device[SLAVE].detach(&ch->device[SLAVE]);
|
2004-01-11 22:08:34 +00:00
|
|
|
|
ata_fail_requests(ch, &ch->device[SLAVE]);
|
|
|
|
|
free(ch->device[SLAVE].param, M_ATA);
|
|
|
|
|
ch->device[SLAVE].param = NULL;
|
2003-10-07 13:44:15 +00:00
|
|
|
|
}
|
2003-08-24 09:22:26 +00:00
|
|
|
|
}
|
2004-05-20 14:49:12 +00:00
|
|
|
|
|
2004-01-11 22:08:34 +00:00
|
|
|
|
/* identify what is present on the channel now */
|
2003-08-24 09:22:26 +00:00
|
|
|
|
ata_identify_devices(ch);
|
|
|
|
|
|
|
|
|
|
/* attach new devices that appeared during reset */
|
|
|
|
|
if ((newdev = ~devices & ch->devices)) {
|
|
|
|
|
if ((newdev & (ATA_ATA_MASTER | ATA_ATAPI_MASTER)) &&
|
|
|
|
|
ch->device[MASTER].attach)
|
|
|
|
|
ch->device[MASTER].attach(&ch->device[MASTER]);
|
|
|
|
|
if ((newdev & (ATA_ATA_SLAVE | ATA_ATAPI_SLAVE)) &&
|
|
|
|
|
ch->device[SLAVE].attach)
|
|
|
|
|
ch->device[SLAVE].attach(&ch->device[SLAVE]);
|
|
|
|
|
}
|
2003-10-10 11:03:27 +00:00
|
|
|
|
|
2004-01-11 22:08:34 +00:00
|
|
|
|
/* restore device config and transfermode on devices */
|
|
|
|
|
if (ch->devices & (ATA_ATA_MASTER | ATA_ATAPI_MASTER)) {
|
|
|
|
|
if (ch->device[MASTER].config)
|
|
|
|
|
ch->device[MASTER].config(&ch->device[MASTER]);
|
2003-10-10 11:03:27 +00:00
|
|
|
|
ch->device[MASTER].setmode(&ch->device[MASTER],ch->device[MASTER].mode);
|
2004-01-11 22:08:34 +00:00
|
|
|
|
}
|
|
|
|
|
if (ch->devices & (ATA_ATA_SLAVE | ATA_ATAPI_SLAVE)) {
|
|
|
|
|
if (ch->device[SLAVE].config)
|
|
|
|
|
ch->device[SLAVE].config(&ch->device[SLAVE]);
|
2003-10-10 11:03:27 +00:00
|
|
|
|
ch->device[SLAVE].setmode(&ch->device[SLAVE], ch->device[SLAVE].mode);
|
2004-01-11 22:08:34 +00:00
|
|
|
|
}
|
2003-10-10 11:03:27 +00:00
|
|
|
|
|
2003-08-24 09:22:26 +00:00
|
|
|
|
#ifdef DEV_ATAPICAM
|
|
|
|
|
atapi_cam_reinit_bus(ch);
|
|
|
|
|
#endif
|
|
|
|
|
|
2004-01-11 22:08:34 +00:00
|
|
|
|
if (bootverbose)
|
|
|
|
|
ata_printf(ch, -1, "device config done ..\n");
|
|
|
|
|
ch->flags &= ~ATA_IMMEDIATE_MODE;
|
|
|
|
|
ata_start(ch);
|
2000-02-18 20:57:33 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-04 09:34:14 +00:00
|
|
|
|
int
|
|
|
|
|
ata_suspend(device_t dev)
|
|
|
|
|
{
|
|
|
|
|
struct ata_channel *ch;
|
|
|
|
|
|
|
|
|
|
if (!dev || !(ch = device_get_softc(dev)))
|
|
|
|
|
return ENXIO;
|
|
|
|
|
ch->locking(ch, ATA_LF_LOCK);
|
2004-04-30 16:21:34 +00:00
|
|
|
|
ATA_SLEEPLOCK_CH(ch);
|
2003-05-04 09:34:14 +00:00
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2001-03-06 21:43:46 +00:00
|
|
|
|
int
|
2000-02-18 20:57:33 +00:00
|
|
|
|
ata_resume(device_t dev)
|
|
|
|
|
{
|
2002-12-03 20:20:44 +00:00
|
|
|
|
struct ata_channel *ch;
|
|
|
|
|
int error;
|
|
|
|
|
|
|
|
|
|
if (!dev || !(ch = device_get_softc(dev)))
|
|
|
|
|
return ENXIO;
|
|
|
|
|
|
2003-02-20 20:02:32 +00:00
|
|
|
|
ch->locking(ch, ATA_LF_LOCK);
|
2002-12-03 20:20:44 +00:00
|
|
|
|
error = ata_reinit(ch);
|
2003-02-20 20:02:32 +00:00
|
|
|
|
ch->locking(ch, ATA_LF_UNLOCK);
|
2003-08-24 09:22:26 +00:00
|
|
|
|
ata_start(ch);
|
2002-12-03 20:20:44 +00:00
|
|
|
|
return error;
|
2000-01-18 21:02:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-08-24 09:22:26 +00:00
|
|
|
|
static void
|
|
|
|
|
ata_shutdown(void *arg, int howto)
|
2001-03-15 15:36:25 +00:00
|
|
|
|
{
|
Major update of the ATA RAID code, part 1:
Overhaul of the attach/detach code and structures, there were some nasty
bugs in the old implementation. This made it possible to collapse the
ATA/ATAPI device control structures into one generic structure.
A note here, the kernel is NOT ready for detach of active devices,
it fails all over in random places, but for inactive devices it works.
However for ATA RAID this works, since the RAID abstration layer
insulates the buggy^H^H^H^H^H^Hfragile device subsystem from the
physical disks.
Proberly detect the RAID's from the BIOS, and mark critical RAID1
arrays as such, but continue if there is enough of the mirror left
to do so.
Properly fail arrays on a live system. For RAID0 that means return EIO,
and for RAID1 it means continue on the still working part of the mirror
if possible, else return EIO.
If the state changes, log this to the console.
Allow for Promise & Highpoint controllers/arrays to coexist on the
same machine. It is not possible to distribute arrays over different
makes of controllers though.
If Promise SuperSwap enclosures are used, signal disk state on the
status LED on the front.
Misc fixes that I had lying around for various minor bugs.
Sponsored by: Advanis Inc.
2002-02-04 19:23:40 +00:00
|
|
|
|
struct ata_channel *ch;
|
2003-08-24 09:22:26 +00:00
|
|
|
|
int ctlr;
|
2001-03-15 15:36:25 +00:00
|
|
|
|
|
2003-08-24 09:22:26 +00:00
|
|
|
|
/* flush cache on all devices */
|
|
|
|
|
for (ctlr = 0; ctlr < devclass_get_maxunit(ata_devclass); ctlr++) {
|
|
|
|
|
if (!(ch = devclass_get_softc(ata_devclass, ctlr)))
|
|
|
|
|
continue;
|
2003-08-25 07:59:50 +00:00
|
|
|
|
if (ch->device[MASTER].param &&
|
|
|
|
|
ch->device[MASTER].param->support.command2 & ATA_SUPPORT_FLUSHCACHE)
|
2003-08-24 09:22:26 +00:00
|
|
|
|
ata_controlcmd(&ch->device[MASTER], ATA_FLUSHCACHE, 0, 0, 0);
|
2003-08-25 07:59:50 +00:00
|
|
|
|
if (ch->device[SLAVE].param &&
|
|
|
|
|
ch->device[SLAVE].param->support.command2 & ATA_SUPPORT_FLUSHCACHE)
|
2003-08-24 09:22:26 +00:00
|
|
|
|
ata_controlcmd(&ch->device[SLAVE], ATA_FLUSHCACHE, 0, 0, 0);
|
2003-03-22 12:18:20 +00:00
|
|
|
|
}
|
2003-08-24 09:22:26 +00:00
|
|
|
|
}
|
2003-03-22 12:18:20 +00:00
|
|
|
|
|
2003-08-24 09:22:26 +00:00
|
|
|
|
/*
|
|
|
|
|
* device related interfaces
|
|
|
|
|
*/
|
|
|
|
|
static int
|
2004-06-16 09:47:26 +00:00
|
|
|
|
ata_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int32_t flag, struct thread *td)
|
2003-08-24 09:22:26 +00:00
|
|
|
|
{
|
|
|
|
|
struct ata_cmd *iocmd = (struct ata_cmd *)addr;
|
|
|
|
|
device_t device = devclass_get_device(ata_devclass, iocmd->channel);
|
|
|
|
|
struct ata_channel *ch;
|
|
|
|
|
struct ata_device *atadev;
|
|
|
|
|
struct ata_request *request;
|
|
|
|
|
caddr_t buf;
|
|
|
|
|
int error = ENOTTY;
|
2001-05-17 10:29:30 +00:00
|
|
|
|
|
2003-08-24 09:22:26 +00:00
|
|
|
|
DROP_GIANT();
|
2001-05-17 10:29:30 +00:00
|
|
|
|
switch (iocmd->cmd) {
|
2003-08-24 09:22:26 +00:00
|
|
|
|
case ATAGMAXCHANNEL:
|
|
|
|
|
iocmd->u.maxchan = devclass_get_maxunit(ata_devclass);
|
|
|
|
|
error = 0;
|
|
|
|
|
break;
|
2002-03-30 16:36:41 +00:00
|
|
|
|
|
2003-08-24 09:22:26 +00:00
|
|
|
|
case ATAGPARM:
|
|
|
|
|
if (!device || !(ch = device_get_softc(device))) {
|
|
|
|
|
error = ENXIO;
|
|
|
|
|
break;
|
2002-03-30 16:36:41 +00:00
|
|
|
|
}
|
2004-05-20 14:49:12 +00:00
|
|
|
|
iocmd->u.param.type[MASTER] =
|
2003-08-24 09:22:26 +00:00
|
|
|
|
ch->devices & (ATA_ATA_MASTER | ATA_ATAPI_MASTER);
|
|
|
|
|
iocmd->u.param.type[SLAVE] =
|
|
|
|
|
ch->devices & (ATA_ATA_SLAVE | ATA_ATAPI_SLAVE);
|
|
|
|
|
if (ch->device[MASTER].name)
|
|
|
|
|
strcpy(iocmd->u.param.name[MASTER], ch->device[MASTER].name);
|
|
|
|
|
if (ch->device[SLAVE].name)
|
|
|
|
|
strcpy(iocmd->u.param.name[SLAVE], ch->device[SLAVE].name);
|
|
|
|
|
if (ch->device[MASTER].param)
|
|
|
|
|
bcopy(ch->device[MASTER].param, &iocmd->u.param.params[MASTER],
|
|
|
|
|
sizeof(struct ata_params));
|
|
|
|
|
if (ch->device[SLAVE].param)
|
|
|
|
|
bcopy(ch->device[SLAVE].param, &iocmd->u.param.params[SLAVE],
|
|
|
|
|
sizeof(struct ata_params));
|
|
|
|
|
error = 0;
|
|
|
|
|
break;
|
2002-03-30 16:36:41 +00:00
|
|
|
|
|
2003-08-24 09:22:26 +00:00
|
|
|
|
case ATAGMODE:
|
|
|
|
|
if (!device || !(ch = device_get_softc(device))) {
|
|
|
|
|
error = ENXIO;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
iocmd->u.mode.mode[MASTER] = ch->device[MASTER].mode;
|
|
|
|
|
iocmd->u.mode.mode[SLAVE] = ch->device[SLAVE].mode;
|
|
|
|
|
error = 0;
|
|
|
|
|
break;
|
2002-04-02 13:48:17 +00:00
|
|
|
|
|
2003-08-24 09:22:26 +00:00
|
|
|
|
case ATASMODE:
|
|
|
|
|
if (!device || !(ch = device_get_softc(device))) {
|
|
|
|
|
error = ENXIO;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (iocmd->u.mode.mode[MASTER] >= 0 && ch->device[MASTER].param)
|
|
|
|
|
ch->device[MASTER].setmode(&ch->device[MASTER],
|
|
|
|
|
iocmd->u.mode.mode[MASTER]);
|
|
|
|
|
iocmd->u.mode.mode[MASTER] = ch->device[MASTER].mode;
|
2004-05-20 14:49:12 +00:00
|
|
|
|
if (iocmd->u.mode.mode[SLAVE] >= 0 && ch->device[SLAVE].param)
|
2003-08-24 09:22:26 +00:00
|
|
|
|
ch->device[SLAVE].setmode(&ch->device[SLAVE],
|
|
|
|
|
iocmd->u.mode.mode[SLAVE]);
|
|
|
|
|
iocmd->u.mode.mode[SLAVE] = ch->device[SLAVE].mode;
|
|
|
|
|
error = 0;
|
|
|
|
|
break;
|
2003-05-02 12:41:44 +00:00
|
|
|
|
|
2003-08-24 09:22:26 +00:00
|
|
|
|
case ATAREQUEST:
|
|
|
|
|
if (!device || !(ch = device_get_softc(device))) {
|
|
|
|
|
error = ENXIO;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (!(atadev = &ch->device[iocmd->device])) {
|
|
|
|
|
error = ENODEV;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (!(buf = malloc(iocmd->u.request.count, M_ATA, M_NOWAIT))) {
|
|
|
|
|
error = ENOMEM;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (!(request = ata_alloc_request())) {
|
|
|
|
|
error = ENOMEM;
|
|
|
|
|
free(buf, M_ATA);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (iocmd->u.request.flags & ATA_CMD_WRITE) {
|
|
|
|
|
error = copyin(iocmd->u.request.data, buf, iocmd->u.request.count);
|
2001-08-30 09:47:17 +00:00
|
|
|
|
if (error) {
|
2003-08-24 09:22:26 +00:00
|
|
|
|
free(buf, M_ATA);
|
|
|
|
|
ata_free_request(request);
|
|
|
|
|
break;
|
2001-08-30 09:47:17 +00:00
|
|
|
|
}
|
2002-03-10 21:03:04 +00:00
|
|
|
|
}
|
2004-05-20 14:49:12 +00:00
|
|
|
|
|
2003-08-24 09:22:26 +00:00
|
|
|
|
request->device = atadev;
|
2002-03-26 09:31:22 +00:00
|
|
|
|
|
2003-08-24 09:22:26 +00:00
|
|
|
|
if (iocmd->u.request.flags & ATA_CMD_ATAPI) {
|
|
|
|
|
request->flags = ATA_R_ATAPI;
|
|
|
|
|
bcopy(iocmd->u.request.u.atapi.ccb, request->u.atapi.ccb, 16);
|
2000-01-24 20:45:24 +00:00
|
|
|
|
}
|
2003-08-24 09:22:26 +00:00
|
|
|
|
else {
|
|
|
|
|
request->u.ata.command = iocmd->u.request.u.ata.command;
|
|
|
|
|
request->u.ata.feature = iocmd->u.request.u.ata.feature;
|
|
|
|
|
request->u.ata.lba = iocmd->u.request.u.ata.lba;
|
|
|
|
|
request->u.ata.count = iocmd->u.request.u.ata.count;
|
2000-01-24 20:45:24 +00:00
|
|
|
|
}
|
2000-01-18 21:02:59 +00:00
|
|
|
|
|
2003-08-24 09:22:26 +00:00
|
|
|
|
request->timeout = iocmd->u.request.timeout;
|
|
|
|
|
request->data = buf;
|
|
|
|
|
request->bytecount = iocmd->u.request.count;
|
|
|
|
|
request->transfersize = request->bytecount;
|
2000-02-18 20:57:33 +00:00
|
|
|
|
|
2003-08-24 09:22:26 +00:00
|
|
|
|
if (iocmd->u.request.flags & ATA_CMD_CONTROL)
|
|
|
|
|
request->flags |= ATA_R_CONTROL;
|
|
|
|
|
if (iocmd->u.request.flags & ATA_CMD_READ)
|
|
|
|
|
request->flags |= ATA_R_READ;
|
|
|
|
|
if (iocmd->u.request.flags & ATA_CMD_WRITE)
|
|
|
|
|
request->flags |= ATA_R_WRITE;
|
2000-02-18 20:57:33 +00:00
|
|
|
|
|
2003-08-24 09:22:26 +00:00
|
|
|
|
ata_queue_request(request);
|
2000-01-03 10:26:59 +00:00
|
|
|
|
|
2003-08-27 15:27:56 +00:00
|
|
|
|
if (request->result)
|
|
|
|
|
iocmd->u.request.error = request->result;
|
2003-08-24 09:22:26 +00:00
|
|
|
|
else {
|
|
|
|
|
if (iocmd->u.request.flags & ATA_CMD_READ)
|
|
|
|
|
error = copyout(buf,
|
|
|
|
|
iocmd->u.request.data, iocmd->u.request.count);
|
|
|
|
|
else
|
|
|
|
|
error = 0;
|
|
|
|
|
}
|
|
|
|
|
free(buf, M_ATA);
|
|
|
|
|
ata_free_request(request);
|
|
|
|
|
break;
|
Finally!!
The much roumored replacement for our current IDE/ATA/ATAPI is
materialising in the CVS repositories around the globe.
So what does this bring us:
A new reengineered ATA/ATAPI subsystem, that tries to overcome
most of the deficiencies with the current drivers.
It supports PCI as well as ISA devices without all the hackery
in ide_pci.c to make PCI devices look like ISA counterparts.
It doesn't have the excessive wait problem on probe, in fact you
shouldn't notice any delay when your devices are getting probed.
Probing and attaching of devices are postponed until interrupts
are enabled (well almost, not finished yet for disks), making
things alot cleaner.
Improved performance, although DMA support is still WIP and not
in this pre alpha release, worldstone is faster with the new
driver compared to the old even with DMA.
So what does it take away:
There is NO support for old MFM/RLL/ESDI disks.
There is NO support for bad144, if your disk is bad, ditch it, it has
already outgrown its internal spare sectors, and is dying.
For you to try this out, you will have to modify your kernel config
file to use the "ata" controller instead of all wdc? entries.
example:
# for a PCI only system (most modern machines)
controller ata0
device atadisk0 # ATA disks
device atapicd0 # ATAPI CDROM's
device atapist0 # ATAPI tapes
#You should add the following on ISA systems:
controller ata1 at isa? port "IO_WD1" bio irq 14
controller ata2 at isa? port "IO_WD2" bio irq 15
You can leave it all in there, the system knows how to manage.
For now this driver reuses the device entries from the old system
(that will probably change later), but remember that disks are
now numbered in the sequence they are found (like the SCSI system)
not as absolute positions as the old system.
Although I have tested this on all the systems I can get my hands on,
there might very well be gremlins in there, so use AT YOU OWN RISK!!
This is still WIP, so there are lots of rough edges and unfinished
things in there, and what I have in my lab might look very different
from whats in CVS at any given time. So please have all eventual
changes go through me, or chances are they just dissapears...
I would very much like to hear from you, both good and bad news
are very welcome.
Enjoy!!
-Søren
1999-03-01 21:19:19 +00:00
|
|
|
|
|
2003-08-24 09:22:26 +00:00
|
|
|
|
case ATAREINIT:
|
|
|
|
|
if (!device || !(ch = device_get_softc(device)))
|
|
|
|
|
return ENXIO;
|
|
|
|
|
error = ata_reinit(ch);
|
|
|
|
|
ata_start(ch);
|
|
|
|
|
break;
|
2000-09-19 11:08:39 +00:00
|
|
|
|
|
2003-08-24 09:22:26 +00:00
|
|
|
|
case ATAATTACH:
|
|
|
|
|
if (!device) {
|
|
|
|
|
error = ENXIO;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
/* SOS should enable channel HW on controller XXX */
|
|
|
|
|
error = ata_probe(device);
|
|
|
|
|
if (!error)
|
|
|
|
|
error = ata_attach(device);
|
|
|
|
|
break;
|
2000-09-19 11:08:39 +00:00
|
|
|
|
|
2003-08-24 09:22:26 +00:00
|
|
|
|
case ATADETACH:
|
|
|
|
|
if (!device) {
|
|
|
|
|
error = ENXIO;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
error = ata_detach(device);
|
|
|
|
|
/* SOS should disable channel HW on controller XXX */
|
Finally!!
The much roumored replacement for our current IDE/ATA/ATAPI is
materialising in the CVS repositories around the globe.
So what does this bring us:
A new reengineered ATA/ATAPI subsystem, that tries to overcome
most of the deficiencies with the current drivers.
It supports PCI as well as ISA devices without all the hackery
in ide_pci.c to make PCI devices look like ISA counterparts.
It doesn't have the excessive wait problem on probe, in fact you
shouldn't notice any delay when your devices are getting probed.
Probing and attaching of devices are postponed until interrupts
are enabled (well almost, not finished yet for disks), making
things alot cleaner.
Improved performance, although DMA support is still WIP and not
in this pre alpha release, worldstone is faster with the new
driver compared to the old even with DMA.
So what does it take away:
There is NO support for old MFM/RLL/ESDI disks.
There is NO support for bad144, if your disk is bad, ditch it, it has
already outgrown its internal spare sectors, and is dying.
For you to try this out, you will have to modify your kernel config
file to use the "ata" controller instead of all wdc? entries.
example:
# for a PCI only system (most modern machines)
controller ata0
device atadisk0 # ATA disks
device atapicd0 # ATAPI CDROM's
device atapist0 # ATAPI tapes
#You should add the following on ISA systems:
controller ata1 at isa? port "IO_WD1" bio irq 14
controller ata2 at isa? port "IO_WD2" bio irq 15
You can leave it all in there, the system knows how to manage.
For now this driver reuses the device entries from the old system
(that will probably change later), but remember that disks are
now numbered in the sequence they are found (like the SCSI system)
not as absolute positions as the old system.
Although I have tested this on all the systems I can get my hands on,
there might very well be gremlins in there, so use AT YOU OWN RISK!!
This is still WIP, so there are lots of rough edges and unfinished
things in there, and what I have in my lab might look very different
from whats in CVS at any given time. So please have all eventual
changes go through me, or chances are they just dissapears...
I would very much like to hear from you, both good and bad news
are very welcome.
Enjoy!!
-Søren
1999-03-01 21:19:19 +00:00
|
|
|
|
break;
|
2004-05-20 14:49:12 +00:00
|
|
|
|
|
2003-08-24 09:22:26 +00:00
|
|
|
|
|
|
|
|
|
#ifdef DEV_ATARAID
|
|
|
|
|
case ATARAIDCREATE:
|
|
|
|
|
error = ata_raid_create(&iocmd->u.raid_setup);
|
|
|
|
|
break;
|
2004-05-20 14:49:12 +00:00
|
|
|
|
|
2003-08-24 09:22:26 +00:00
|
|
|
|
case ATARAIDDELETE:
|
|
|
|
|
error = ata_raid_delete(iocmd->channel);
|
|
|
|
|
break;
|
2004-05-20 14:49:12 +00:00
|
|
|
|
|
2003-08-24 09:22:26 +00:00
|
|
|
|
case ATARAIDSTATUS:
|
|
|
|
|
error = ata_raid_status(iocmd->channel, &iocmd->u.raid_status);
|
|
|
|
|
break;
|
2004-05-20 14:49:12 +00:00
|
|
|
|
|
2003-08-24 09:22:26 +00:00
|
|
|
|
case ATARAIDADDSPARE:
|
|
|
|
|
error = ata_raid_addspare(iocmd->channel, iocmd->u.raid_spare.disk);
|
|
|
|
|
break;
|
2004-05-20 14:49:12 +00:00
|
|
|
|
|
2003-08-24 09:22:26 +00:00
|
|
|
|
case ATARAIDREBUILD:
|
|
|
|
|
error = ata_raid_rebuild(iocmd->channel);
|
Finally!!
The much roumored replacement for our current IDE/ATA/ATAPI is
materialising in the CVS repositories around the globe.
So what does this bring us:
A new reengineered ATA/ATAPI subsystem, that tries to overcome
most of the deficiencies with the current drivers.
It supports PCI as well as ISA devices without all the hackery
in ide_pci.c to make PCI devices look like ISA counterparts.
It doesn't have the excessive wait problem on probe, in fact you
shouldn't notice any delay when your devices are getting probed.
Probing and attaching of devices are postponed until interrupts
are enabled (well almost, not finished yet for disks), making
things alot cleaner.
Improved performance, although DMA support is still WIP and not
in this pre alpha release, worldstone is faster with the new
driver compared to the old even with DMA.
So what does it take away:
There is NO support for old MFM/RLL/ESDI disks.
There is NO support for bad144, if your disk is bad, ditch it, it has
already outgrown its internal spare sectors, and is dying.
For you to try this out, you will have to modify your kernel config
file to use the "ata" controller instead of all wdc? entries.
example:
# for a PCI only system (most modern machines)
controller ata0
device atadisk0 # ATA disks
device atapicd0 # ATAPI CDROM's
device atapist0 # ATAPI tapes
#You should add the following on ISA systems:
controller ata1 at isa? port "IO_WD1" bio irq 14
controller ata2 at isa? port "IO_WD2" bio irq 15
You can leave it all in there, the system knows how to manage.
For now this driver reuses the device entries from the old system
(that will probably change later), but remember that disks are
now numbered in the sequence they are found (like the SCSI system)
not as absolute positions as the old system.
Although I have tested this on all the systems I can get my hands on,
there might very well be gremlins in there, so use AT YOU OWN RISK!!
This is still WIP, so there are lots of rough edges and unfinished
things in there, and what I have in my lab might look very different
from whats in CVS at any given time. So please have all eventual
changes go through me, or chances are they just dissapears...
I would very much like to hear from you, both good and bad news
are very welcome.
Enjoy!!
-Søren
1999-03-01 21:19:19 +00:00
|
|
|
|
break;
|
Ten'th update to the new ATA/ATAPI driver:
It been awhile since the last major update, as a benefit there
are some cool things in this one (and new bugs probably :) )...
The ATA driver has grown "real" timeout support for all devices.
This means that it should be possible to get in contact with
(especially) lost ATAPI devices. It also means that the ATA
driver is now usable on notebooks as it will DTRT on resume.
An experimental hack at utilizing the Promise66's at UDMA66 is
in there, but I cant test it. If someone feels like sending
me one, give me a ping.
The ATAPI DMA enableling scheme has been changed, also better DMA
support for the Aladdin chipset has been implemented for ATAPI
devices. Note that the Aladdin apparently only can do DMA reads
on ATAPI devices, and the Promise cant do ATAPI DMA at all.
I have seen problems on some ATAPI devices that should be able
to run in DMA mode, so if you encounter problems with hanging
atapi devices during the probe, or during access, disable DMA
in atapi-all.c, and let me know. It might be nessesary to do this
via a "white list" for known good devices...
The ATAPI CDROM driver can now use eject/close without hanging and
the bug that caused reading beyond the end of a CD has been fixed.
Media change is also handled proberly. DVD drives are identified
and are usable as CDROM devices at least, I dont have the HW to
test this further, see above :).
The ATAPI tape driver has gotten some support for using the DSC
method for not blocking the IDE channel during read/write when
the device has full buffers. It knows about the OnStream DI-30
device, support is not completed yet, but it can function as a
primitive backup medium, without filemarks, and without bad media
handeling. This is because the OnStream device doesn't handle this
(like everybody else) in HW. It also now supports getting/setting
the record position on devices that supports it.
Some rather major cleanups and rearrangements as well (cvs -b diff
is your freind). I'm closing in on declaring this for beta code,
most of the infrastruture is in place by now.
As usual USE AT YOUR OWN RISK!!, this is still alpha level code.
This driver can hose your disk real bad if anything goes wrong, but
now you have been warned :)
But please tell me how it works for you!
Enjoy!
-Søren
1999-09-21 19:50:40 +00:00
|
|
|
|
#endif
|
2002-07-22 18:35:01 +00:00
|
|
|
|
}
|
2003-08-24 09:22:26 +00:00
|
|
|
|
PICKUP_GIANT();
|
|
|
|
|
return error;
|
Finally!!
The much roumored replacement for our current IDE/ATA/ATAPI is
materialising in the CVS repositories around the globe.
So what does this bring us:
A new reengineered ATA/ATAPI subsystem, that tries to overcome
most of the deficiencies with the current drivers.
It supports PCI as well as ISA devices without all the hackery
in ide_pci.c to make PCI devices look like ISA counterparts.
It doesn't have the excessive wait problem on probe, in fact you
shouldn't notice any delay when your devices are getting probed.
Probing and attaching of devices are postponed until interrupts
are enabled (well almost, not finished yet for disks), making
things alot cleaner.
Improved performance, although DMA support is still WIP and not
in this pre alpha release, worldstone is faster with the new
driver compared to the old even with DMA.
So what does it take away:
There is NO support for old MFM/RLL/ESDI disks.
There is NO support for bad144, if your disk is bad, ditch it, it has
already outgrown its internal spare sectors, and is dying.
For you to try this out, you will have to modify your kernel config
file to use the "ata" controller instead of all wdc? entries.
example:
# for a PCI only system (most modern machines)
controller ata0
device atadisk0 # ATA disks
device atapicd0 # ATAPI CDROM's
device atapist0 # ATAPI tapes
#You should add the following on ISA systems:
controller ata1 at isa? port "IO_WD1" bio irq 14
controller ata2 at isa? port "IO_WD2" bio irq 15
You can leave it all in there, the system knows how to manage.
For now this driver reuses the device entries from the old system
(that will probably change later), but remember that disks are
now numbered in the sequence they are found (like the SCSI system)
not as absolute positions as the old system.
Although I have tested this on all the systems I can get my hands on,
there might very well be gremlins in there, so use AT YOU OWN RISK!!
This is still WIP, so there are lots of rough edges and unfinished
things in there, and what I have in my lab might look very different
from whats in CVS at any given time. So please have all eventual
changes go through me, or chances are they just dissapears...
I would very much like to hear from you, both good and bad news
are very welcome.
Enjoy!!
-Søren
1999-03-01 21:19:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-08-24 09:22:26 +00:00
|
|
|
|
/*
|
|
|
|
|
* device probe functions
|
|
|
|
|
*/
|
2004-05-20 14:49:12 +00:00
|
|
|
|
static int
|
2003-08-24 09:22:26 +00:00
|
|
|
|
ata_getparam(struct ata_device *atadev, u_int8_t command)
|
Finally!!
The much roumored replacement for our current IDE/ATA/ATAPI is
materialising in the CVS repositories around the globe.
So what does this bring us:
A new reengineered ATA/ATAPI subsystem, that tries to overcome
most of the deficiencies with the current drivers.
It supports PCI as well as ISA devices without all the hackery
in ide_pci.c to make PCI devices look like ISA counterparts.
It doesn't have the excessive wait problem on probe, in fact you
shouldn't notice any delay when your devices are getting probed.
Probing and attaching of devices are postponed until interrupts
are enabled (well almost, not finished yet for disks), making
things alot cleaner.
Improved performance, although DMA support is still WIP and not
in this pre alpha release, worldstone is faster with the new
driver compared to the old even with DMA.
So what does it take away:
There is NO support for old MFM/RLL/ESDI disks.
There is NO support for bad144, if your disk is bad, ditch it, it has
already outgrown its internal spare sectors, and is dying.
For you to try this out, you will have to modify your kernel config
file to use the "ata" controller instead of all wdc? entries.
example:
# for a PCI only system (most modern machines)
controller ata0
device atadisk0 # ATA disks
device atapicd0 # ATAPI CDROM's
device atapist0 # ATAPI tapes
#You should add the following on ISA systems:
controller ata1 at isa? port "IO_WD1" bio irq 14
controller ata2 at isa? port "IO_WD2" bio irq 15
You can leave it all in there, the system knows how to manage.
For now this driver reuses the device entries from the old system
(that will probably change later), but remember that disks are
now numbered in the sequence they are found (like the SCSI system)
not as absolute positions as the old system.
Although I have tested this on all the systems I can get my hands on,
there might very well be gremlins in there, so use AT YOU OWN RISK!!
This is still WIP, so there are lots of rough edges and unfinished
things in there, and what I have in my lab might look very different
from whats in CVS at any given time. So please have all eventual
changes go through me, or chances are they just dissapears...
I would very much like to hear from you, both good and bad news
are very welcome.
Enjoy!!
-Søren
1999-03-01 21:19:19 +00:00
|
|
|
|
{
|
2003-08-24 09:22:26 +00:00
|
|
|
|
struct ata_request *request;
|
|
|
|
|
int error = ENOMEM;
|
Finally!!
The much roumored replacement for our current IDE/ATA/ATAPI is
materialising in the CVS repositories around the globe.
So what does this bring us:
A new reengineered ATA/ATAPI subsystem, that tries to overcome
most of the deficiencies with the current drivers.
It supports PCI as well as ISA devices without all the hackery
in ide_pci.c to make PCI devices look like ISA counterparts.
It doesn't have the excessive wait problem on probe, in fact you
shouldn't notice any delay when your devices are getting probed.
Probing and attaching of devices are postponed until interrupts
are enabled (well almost, not finished yet for disks), making
things alot cleaner.
Improved performance, although DMA support is still WIP and not
in this pre alpha release, worldstone is faster with the new
driver compared to the old even with DMA.
So what does it take away:
There is NO support for old MFM/RLL/ESDI disks.
There is NO support for bad144, if your disk is bad, ditch it, it has
already outgrown its internal spare sectors, and is dying.
For you to try this out, you will have to modify your kernel config
file to use the "ata" controller instead of all wdc? entries.
example:
# for a PCI only system (most modern machines)
controller ata0
device atadisk0 # ATA disks
device atapicd0 # ATAPI CDROM's
device atapist0 # ATAPI tapes
#You should add the following on ISA systems:
controller ata1 at isa? port "IO_WD1" bio irq 14
controller ata2 at isa? port "IO_WD2" bio irq 15
You can leave it all in there, the system knows how to manage.
For now this driver reuses the device entries from the old system
(that will probably change later), but remember that disks are
now numbered in the sequence they are found (like the SCSI system)
not as absolute positions as the old system.
Although I have tested this on all the systems I can get my hands on,
there might very well be gremlins in there, so use AT YOU OWN RISK!!
This is still WIP, so there are lots of rough edges and unfinished
things in there, and what I have in my lab might look very different
from whats in CVS at any given time. So please have all eventual
changes go through me, or chances are they just dissapears...
I would very much like to hear from you, both good and bad news
are very welcome.
Enjoy!!
-Søren
1999-03-01 21:19:19 +00:00
|
|
|
|
|
2004-01-11 22:08:34 +00:00
|
|
|
|
if (!atadev->param)
|
|
|
|
|
atadev->param = malloc(sizeof(struct ata_params), M_ATA, M_NOWAIT);
|
|
|
|
|
if (atadev->param) {
|
2004-05-20 14:49:12 +00:00
|
|
|
|
request = ata_alloc_request();
|
2003-08-24 09:22:26 +00:00
|
|
|
|
if (request) {
|
2004-01-30 19:16:08 +00:00
|
|
|
|
int retries = 2;
|
|
|
|
|
while (retries-- > 0) {
|
|
|
|
|
request->device = atadev;
|
|
|
|
|
request->timeout = 5;
|
|
|
|
|
request->retries = -1;
|
|
|
|
|
request->u.ata.command = command;
|
|
|
|
|
request->flags = (ATA_R_READ | ATA_R_IMMEDIATE);
|
|
|
|
|
request->data = (caddr_t)atadev->param;
|
|
|
|
|
request->bytecount = sizeof(struct ata_params);
|
|
|
|
|
request->transfersize = DEV_BSIZE;
|
2003-09-01 11:13:21 +00:00
|
|
|
|
ata_queue_request(request);
|
|
|
|
|
if (!(error = request->result))
|
|
|
|
|
break;
|
|
|
|
|
}
|
2003-08-24 09:22:26 +00:00
|
|
|
|
ata_free_request(request);
|
2002-03-11 21:04:32 +00:00
|
|
|
|
}
|
2004-01-13 21:35:39 +00:00
|
|
|
|
if (!error && (isprint(atadev->param->model[0]) ||
|
|
|
|
|
isprint(atadev->param->model[1]))) {
|
2004-01-11 22:08:34 +00:00
|
|
|
|
struct ata_params *atacap = atadev->param;
|
2003-08-24 09:22:26 +00:00
|
|
|
|
#if BYTE_ORDER == BIG_ENDIAN
|
|
|
|
|
int16_t *ptr;
|
2000-09-19 11:08:39 +00:00
|
|
|
|
|
2003-08-24 09:22:26 +00:00
|
|
|
|
for (ptr = (int16_t *)atacap;
|
|
|
|
|
ptr < (int16_t *)atacap + sizeof(struct ata_params)/2; ptr++) {
|
|
|
|
|
*ptr = bswap16(*ptr);
|
|
|
|
|
}
|
Fourth update to the new ATA/ATAPI driver:
Well, better late than newer, but things has been hectic
around here, sorry for the long delay.
DMA support has been added to the ATA disk driver.
This only works on Intel PIIX3/4, Acer Aladdin and Promise controllers.
The promise support works without the BIOS on the board,
and timing modes are set to support up to UDMA speed. This
solves the problems with having more than one promise controller
in the same system.
There is support for "generic" DMA, that might work on other
controllers, but now you have been warned :)
More chipset specific code will come soon, I have to find testers
with the approbiate HW, more on that when I have it ready.
The system now uses its own major numbers, please run MAKEDEV
with the devices you need (ad?, acd?, afd?, ast?).
For now the disk driver will also attach to the old wd major
so one can at least boot without this step, but be warned, this
will eventually go away. The bootblocks will have to be changed
before one can boot directly from an "ad" device though.
Fixed problems:
All known hang problems should be solved
The probe code has been sligthly changed, this should solve
the reports I have lying around (I hope).
Hangs when accessing ata & atapi device on the same channel simultaniously.
A real braino in ata_start caused this, fixed.
As usual USE AT YOUR OWN RISK!!, this is still pre alpha level code.
Especially the DMA support can hose your disk real bad if anything
goes wrong, agaiin you have been warned :)
But please tell me how it works for you!
Enjoy!
-Søren
1999-03-28 18:57:20 +00:00
|
|
|
|
#endif
|
2003-08-24 09:22:26 +00:00
|
|
|
|
if (!((atacap->model[0] == 'N' && atacap->model[1] == 'E') ||
|
|
|
|
|
(atacap->model[0] == 'F' && atacap->model[1] == 'X') ||
|
|
|
|
|
(atacap->model[0] == 'P' && atacap->model[1] == 'i')))
|
|
|
|
|
bswap(atacap->model, sizeof(atacap->model));
|
|
|
|
|
btrim(atacap->model, sizeof(atacap->model));
|
|
|
|
|
bpack(atacap->model, atacap->model, sizeof(atacap->model));
|
|
|
|
|
bswap(atacap->revision, sizeof(atacap->revision));
|
|
|
|
|
btrim(atacap->revision, sizeof(atacap->revision));
|
|
|
|
|
bpack(atacap->revision, atacap->revision, sizeof(atacap->revision));
|
|
|
|
|
bswap(atacap->serial, sizeof(atacap->serial));
|
|
|
|
|
btrim(atacap->serial, sizeof(atacap->serial));
|
|
|
|
|
bpack(atacap->serial, atacap->serial, sizeof(atacap->serial));
|
|
|
|
|
if (bootverbose)
|
|
|
|
|
ata_prtdev(atadev,
|
|
|
|
|
"pio=0x%02x wdma=0x%02x udma=0x%02x cable=%spin\n",
|
|
|
|
|
ata_pmode(atacap), ata_wmode(atacap),
|
|
|
|
|
ata_umode(atacap),
|
|
|
|
|
(atacap->hwres & ATA_CABLE_ID) ? "80":"40");
|
2002-03-11 21:04:32 +00:00
|
|
|
|
}
|
2004-01-13 21:35:39 +00:00
|
|
|
|
else {
|
|
|
|
|
if (!error)
|
|
|
|
|
error = ENXIO;
|
|
|
|
|
if (atadev->param) {
|
|
|
|
|
free(atadev->param, M_ATA);
|
|
|
|
|
atadev->param = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
Finally!!
The much roumored replacement for our current IDE/ATA/ATAPI is
materialising in the CVS repositories around the globe.
So what does this bring us:
A new reengineered ATA/ATAPI subsystem, that tries to overcome
most of the deficiencies with the current drivers.
It supports PCI as well as ISA devices without all the hackery
in ide_pci.c to make PCI devices look like ISA counterparts.
It doesn't have the excessive wait problem on probe, in fact you
shouldn't notice any delay when your devices are getting probed.
Probing and attaching of devices are postponed until interrupts
are enabled (well almost, not finished yet for disks), making
things alot cleaner.
Improved performance, although DMA support is still WIP and not
in this pre alpha release, worldstone is faster with the new
driver compared to the old even with DMA.
So what does it take away:
There is NO support for old MFM/RLL/ESDI disks.
There is NO support for bad144, if your disk is bad, ditch it, it has
already outgrown its internal spare sectors, and is dying.
For you to try this out, you will have to modify your kernel config
file to use the "ata" controller instead of all wdc? entries.
example:
# for a PCI only system (most modern machines)
controller ata0
device atadisk0 # ATA disks
device atapicd0 # ATAPI CDROM's
device atapist0 # ATAPI tapes
#You should add the following on ISA systems:
controller ata1 at isa? port "IO_WD1" bio irq 14
controller ata2 at isa? port "IO_WD2" bio irq 15
You can leave it all in there, the system knows how to manage.
For now this driver reuses the device entries from the old system
(that will probably change later), but remember that disks are
now numbered in the sequence they are found (like the SCSI system)
not as absolute positions as the old system.
Although I have tested this on all the systems I can get my hands on,
there might very well be gremlins in there, so use AT YOU OWN RISK!!
This is still WIP, so there are lots of rough edges and unfinished
things in there, and what I have in my lab might look very different
from whats in CVS at any given time. So please have all eventual
changes go through me, or chances are they just dissapears...
I would very much like to hear from you, both good and bad news
are very welcome.
Enjoy!!
-Søren
1999-03-01 21:19:19 +00:00
|
|
|
|
}
|
2003-08-24 09:22:26 +00:00
|
|
|
|
return error;
|
Ten'th update to the new ATA/ATAPI driver:
It been awhile since the last major update, as a benefit there
are some cool things in this one (and new bugs probably :) )...
The ATA driver has grown "real" timeout support for all devices.
This means that it should be possible to get in contact with
(especially) lost ATAPI devices. It also means that the ATA
driver is now usable on notebooks as it will DTRT on resume.
An experimental hack at utilizing the Promise66's at UDMA66 is
in there, but I cant test it. If someone feels like sending
me one, give me a ping.
The ATAPI DMA enableling scheme has been changed, also better DMA
support for the Aladdin chipset has been implemented for ATAPI
devices. Note that the Aladdin apparently only can do DMA reads
on ATAPI devices, and the Promise cant do ATAPI DMA at all.
I have seen problems on some ATAPI devices that should be able
to run in DMA mode, so if you encounter problems with hanging
atapi devices during the probe, or during access, disable DMA
in atapi-all.c, and let me know. It might be nessesary to do this
via a "white list" for known good devices...
The ATAPI CDROM driver can now use eject/close without hanging and
the bug that caused reading beyond the end of a CD has been fixed.
Media change is also handled proberly. DVD drives are identified
and are usable as CDROM devices at least, I dont have the HW to
test this further, see above :).
The ATAPI tape driver has gotten some support for using the DSC
method for not blocking the IDE channel during read/write when
the device has full buffers. It knows about the OnStream DI-30
device, support is not completed yet, but it can function as a
primitive backup medium, without filemarks, and without bad media
handeling. This is because the OnStream device doesn't handle this
(like everybody else) in HW. It also now supports getting/setting
the record position on devices that supports it.
Some rather major cleanups and rearrangements as well (cvs -b diff
is your freind). I'm closing in on declaring this for beta code,
most of the infrastruture is in place by now.
As usual USE AT YOUR OWN RISK!!, this is still alpha level code.
This driver can hose your disk real bad if anything goes wrong, but
now you have been warned :)
But please tell me how it works for you!
Enjoy!
-Søren
1999-09-21 19:50:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-08-24 09:22:26 +00:00
|
|
|
|
static void
|
|
|
|
|
ata_identify_devices(struct ata_channel *ch)
|
Ten'th update to the new ATA/ATAPI driver:
It been awhile since the last major update, as a benefit there
are some cool things in this one (and new bugs probably :) )...
The ATA driver has grown "real" timeout support for all devices.
This means that it should be possible to get in contact with
(especially) lost ATAPI devices. It also means that the ATA
driver is now usable on notebooks as it will DTRT on resume.
An experimental hack at utilizing the Promise66's at UDMA66 is
in there, but I cant test it. If someone feels like sending
me one, give me a ping.
The ATAPI DMA enableling scheme has been changed, also better DMA
support for the Aladdin chipset has been implemented for ATAPI
devices. Note that the Aladdin apparently only can do DMA reads
on ATAPI devices, and the Promise cant do ATAPI DMA at all.
I have seen problems on some ATAPI devices that should be able
to run in DMA mode, so if you encounter problems with hanging
atapi devices during the probe, or during access, disable DMA
in atapi-all.c, and let me know. It might be nessesary to do this
via a "white list" for known good devices...
The ATAPI CDROM driver can now use eject/close without hanging and
the bug that caused reading beyond the end of a CD has been fixed.
Media change is also handled proberly. DVD drives are identified
and are usable as CDROM devices at least, I dont have the HW to
test this further, see above :).
The ATAPI tape driver has gotten some support for using the DSC
method for not blocking the IDE channel during read/write when
the device has full buffers. It knows about the OnStream DI-30
device, support is not completed yet, but it can function as a
primitive backup medium, without filemarks, and without bad media
handeling. This is because the OnStream device doesn't handle this
(like everybody else) in HW. It also now supports getting/setting
the record position on devices that supports it.
Some rather major cleanups and rearrangements as well (cvs -b diff
is your freind). I'm closing in on declaring this for beta code,
most of the infrastruture is in place by now.
As usual USE AT YOUR OWN RISK!!, this is still alpha level code.
This driver can hose your disk real bad if anything goes wrong, but
now you have been warned :)
But please tell me how it works for you!
Enjoy!
-Søren
1999-09-21 19:50:40 +00:00
|
|
|
|
{
|
2003-08-24 09:22:26 +00:00
|
|
|
|
if (ch->devices & ATA_ATA_SLAVE) {
|
|
|
|
|
if (ata_getparam(&ch->device[SLAVE], ATA_ATA_IDENTIFY))
|
|
|
|
|
ch->devices &= ~ATA_ATA_SLAVE;
|
|
|
|
|
#ifdef DEV_ATADISK
|
|
|
|
|
else
|
|
|
|
|
ch->device[SLAVE].attach = ad_attach;
|
|
|
|
|
#endif
|
2001-12-25 14:43:08 +00:00
|
|
|
|
}
|
2003-08-24 09:22:26 +00:00
|
|
|
|
if (ch->devices & ATA_ATAPI_SLAVE) {
|
|
|
|
|
if (ata_getparam(&ch->device[SLAVE], ATA_ATAPI_IDENTIFY))
|
|
|
|
|
ch->devices &= ~ATA_ATAPI_SLAVE;
|
|
|
|
|
else {
|
|
|
|
|
switch (ch->device[SLAVE].param->config & ATA_ATAPI_TYPE_MASK) {
|
|
|
|
|
#ifdef DEV_ATAPICD
|
|
|
|
|
case ATA_ATAPI_TYPE_CDROM:
|
|
|
|
|
ch->device[SLAVE].attach = acd_attach;
|
Ten'th update to the new ATA/ATAPI driver:
It been awhile since the last major update, as a benefit there
are some cool things in this one (and new bugs probably :) )...
The ATA driver has grown "real" timeout support for all devices.
This means that it should be possible to get in contact with
(especially) lost ATAPI devices. It also means that the ATA
driver is now usable on notebooks as it will DTRT on resume.
An experimental hack at utilizing the Promise66's at UDMA66 is
in there, but I cant test it. If someone feels like sending
me one, give me a ping.
The ATAPI DMA enableling scheme has been changed, also better DMA
support for the Aladdin chipset has been implemented for ATAPI
devices. Note that the Aladdin apparently only can do DMA reads
on ATAPI devices, and the Promise cant do ATAPI DMA at all.
I have seen problems on some ATAPI devices that should be able
to run in DMA mode, so if you encounter problems with hanging
atapi devices during the probe, or during access, disable DMA
in atapi-all.c, and let me know. It might be nessesary to do this
via a "white list" for known good devices...
The ATAPI CDROM driver can now use eject/close without hanging and
the bug that caused reading beyond the end of a CD has been fixed.
Media change is also handled proberly. DVD drives are identified
and are usable as CDROM devices at least, I dont have the HW to
test this further, see above :).
The ATAPI tape driver has gotten some support for using the DSC
method for not blocking the IDE channel during read/write when
the device has full buffers. It knows about the OnStream DI-30
device, support is not completed yet, but it can function as a
primitive backup medium, without filemarks, and without bad media
handeling. This is because the OnStream device doesn't handle this
(like everybody else) in HW. It also now supports getting/setting
the record position on devices that supports it.
Some rather major cleanups and rearrangements as well (cvs -b diff
is your freind). I'm closing in on declaring this for beta code,
most of the infrastruture is in place by now.
As usual USE AT YOUR OWN RISK!!, this is still alpha level code.
This driver can hose your disk real bad if anything goes wrong, but
now you have been warned :)
But please tell me how it works for you!
Enjoy!
-Søren
1999-09-21 19:50:40 +00:00
|
|
|
|
break;
|
2003-08-24 09:22:26 +00:00
|
|
|
|
#endif
|
|
|
|
|
#ifdef DEV_ATAPIFD
|
|
|
|
|
case ATA_ATAPI_TYPE_DIRECT:
|
|
|
|
|
ch->device[SLAVE].attach = afd_attach;
|
Ten'th update to the new ATA/ATAPI driver:
It been awhile since the last major update, as a benefit there
are some cool things in this one (and new bugs probably :) )...
The ATA driver has grown "real" timeout support for all devices.
This means that it should be possible to get in contact with
(especially) lost ATAPI devices. It also means that the ATA
driver is now usable on notebooks as it will DTRT on resume.
An experimental hack at utilizing the Promise66's at UDMA66 is
in there, but I cant test it. If someone feels like sending
me one, give me a ping.
The ATAPI DMA enableling scheme has been changed, also better DMA
support for the Aladdin chipset has been implemented for ATAPI
devices. Note that the Aladdin apparently only can do DMA reads
on ATAPI devices, and the Promise cant do ATAPI DMA at all.
I have seen problems on some ATAPI devices that should be able
to run in DMA mode, so if you encounter problems with hanging
atapi devices during the probe, or during access, disable DMA
in atapi-all.c, and let me know. It might be nessesary to do this
via a "white list" for known good devices...
The ATAPI CDROM driver can now use eject/close without hanging and
the bug that caused reading beyond the end of a CD has been fixed.
Media change is also handled proberly. DVD drives are identified
and are usable as CDROM devices at least, I dont have the HW to
test this further, see above :).
The ATAPI tape driver has gotten some support for using the DSC
method for not blocking the IDE channel during read/write when
the device has full buffers. It knows about the OnStream DI-30
device, support is not completed yet, but it can function as a
primitive backup medium, without filemarks, and without bad media
handeling. This is because the OnStream device doesn't handle this
(like everybody else) in HW. It also now supports getting/setting
the record position on devices that supports it.
Some rather major cleanups and rearrangements as well (cvs -b diff
is your freind). I'm closing in on declaring this for beta code,
most of the infrastruture is in place by now.
As usual USE AT YOUR OWN RISK!!, this is still alpha level code.
This driver can hose your disk real bad if anything goes wrong, but
now you have been warned :)
But please tell me how it works for you!
Enjoy!
-Søren
1999-09-21 19:50:40 +00:00
|
|
|
|
break;
|
|
|
|
|
#endif
|
2003-08-24 09:22:26 +00:00
|
|
|
|
#ifdef DEV_ATAPIST
|
|
|
|
|
case ATA_ATAPI_TYPE_TAPE:
|
|
|
|
|
ch->device[SLAVE].attach = ast_attach;
|
|
|
|
|
break;
|
Ten'th update to the new ATA/ATAPI driver:
It been awhile since the last major update, as a benefit there
are some cool things in this one (and new bugs probably :) )...
The ATA driver has grown "real" timeout support for all devices.
This means that it should be possible to get in contact with
(especially) lost ATAPI devices. It also means that the ATA
driver is now usable on notebooks as it will DTRT on resume.
An experimental hack at utilizing the Promise66's at UDMA66 is
in there, but I cant test it. If someone feels like sending
me one, give me a ping.
The ATAPI DMA enableling scheme has been changed, also better DMA
support for the Aladdin chipset has been implemented for ATAPI
devices. Note that the Aladdin apparently only can do DMA reads
on ATAPI devices, and the Promise cant do ATAPI DMA at all.
I have seen problems on some ATAPI devices that should be able
to run in DMA mode, so if you encounter problems with hanging
atapi devices during the probe, or during access, disable DMA
in atapi-all.c, and let me know. It might be nessesary to do this
via a "white list" for known good devices...
The ATAPI CDROM driver can now use eject/close without hanging and
the bug that caused reading beyond the end of a CD has been fixed.
Media change is also handled proberly. DVD drives are identified
and are usable as CDROM devices at least, I dont have the HW to
test this further, see above :).
The ATAPI tape driver has gotten some support for using the DSC
method for not blocking the IDE channel during read/write when
the device has full buffers. It knows about the OnStream DI-30
device, support is not completed yet, but it can function as a
primitive backup medium, without filemarks, and without bad media
handeling. This is because the OnStream device doesn't handle this
(like everybody else) in HW. It also now supports getting/setting
the record position on devices that supports it.
Some rather major cleanups and rearrangements as well (cvs -b diff
is your freind). I'm closing in on declaring this for beta code,
most of the infrastruture is in place by now.
As usual USE AT YOUR OWN RISK!!, this is still alpha level code.
This driver can hose your disk real bad if anything goes wrong, but
now you have been warned :)
But please tell me how it works for you!
Enjoy!
-Søren
1999-09-21 19:50:40 +00:00
|
|
|
|
#endif
|
2003-08-24 09:22:26 +00:00
|
|
|
|
}
|
2001-03-14 12:05:44 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2003-08-24 09:22:26 +00:00
|
|
|
|
if (ch->devices & ATA_ATA_MASTER) {
|
|
|
|
|
if (ata_getparam(&ch->device[MASTER], ATA_ATA_IDENTIFY))
|
|
|
|
|
ch->devices &= ~ATA_ATA_MASTER;
|
2001-03-14 12:05:44 +00:00
|
|
|
|
#ifdef DEV_ATADISK
|
2003-08-24 09:22:26 +00:00
|
|
|
|
else
|
|
|
|
|
ch->device[MASTER].attach = ad_attach;
|
2001-03-14 12:05:44 +00:00
|
|
|
|
#endif
|
2003-02-20 20:02:32 +00:00
|
|
|
|
}
|
2003-08-24 09:22:26 +00:00
|
|
|
|
if (ch->devices & ATA_ATAPI_MASTER) {
|
|
|
|
|
if (ata_getparam(&ch->device[MASTER], ATA_ATAPI_IDENTIFY))
|
|
|
|
|
ch->devices &= ~ATA_ATAPI_MASTER;
|
|
|
|
|
else {
|
|
|
|
|
switch (ch->device[MASTER].param->config & ATA_ATAPI_TYPE_MASK) {
|
|
|
|
|
#ifdef DEV_ATAPICD
|
|
|
|
|
case ATA_ATAPI_TYPE_CDROM:
|
|
|
|
|
ch->device[MASTER].attach = acd_attach;
|
|
|
|
|
break;
|
2001-03-14 12:05:44 +00:00
|
|
|
|
#endif
|
2003-08-24 09:22:26 +00:00
|
|
|
|
#ifdef DEV_ATAPIFD
|
|
|
|
|
case ATA_ATAPI_TYPE_DIRECT:
|
|
|
|
|
ch->device[MASTER].attach = afd_attach;
|
|
|
|
|
break;
|
2002-08-09 20:54:06 +00:00
|
|
|
|
#endif
|
2003-08-24 09:22:26 +00:00
|
|
|
|
#ifdef DEV_ATAPIST
|
|
|
|
|
case ATA_ATAPI_TYPE_TAPE:
|
|
|
|
|
ch->device[MASTER].attach = ast_attach;
|
|
|
|
|
break;
|
2003-02-20 20:02:32 +00:00
|
|
|
|
#endif
|
2003-08-24 09:22:26 +00:00
|
|
|
|
}
|
2000-09-19 11:08:39 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2003-11-11 14:55:36 +00:00
|
|
|
|
|
|
|
|
|
/* setup basic transfer mode by setting PIO mode and DMA if supported */
|
2004-04-13 09:44:20 +00:00
|
|
|
|
if (ch->device[MASTER].param) {
|
2003-11-11 14:55:36 +00:00
|
|
|
|
ch->device[MASTER].setmode(&ch->device[MASTER], ATA_PIO_MAX);
|
|
|
|
|
if ((((ch->devices & ATA_ATAPI_MASTER) && atapi_dma &&
|
|
|
|
|
(ch->device[MASTER].param->config&ATA_DRQ_MASK) != ATA_DRQ_INTR)||
|
2004-05-20 14:49:12 +00:00
|
|
|
|
((ch->devices & ATA_ATA_MASTER) && ata_dma)) && ch->dma)
|
2003-11-11 14:55:36 +00:00
|
|
|
|
ch->device[MASTER].setmode(&ch->device[MASTER], ATA_DMA_MAX);
|
|
|
|
|
|
|
|
|
|
}
|
2004-04-13 09:44:20 +00:00
|
|
|
|
if (ch->device[SLAVE].param) {
|
2003-11-11 14:55:36 +00:00
|
|
|
|
ch->device[SLAVE].setmode(&ch->device[SLAVE], ATA_PIO_MAX);
|
|
|
|
|
if ((((ch->devices & ATA_ATAPI_SLAVE) && atapi_dma &&
|
|
|
|
|
(ch->device[SLAVE].param->config&ATA_DRQ_MASK) != ATA_DRQ_INTR) ||
|
2004-05-20 14:49:12 +00:00
|
|
|
|
((ch->devices & ATA_ATA_SLAVE) && ata_dma)) && ch->dma)
|
2003-11-11 14:55:36 +00:00
|
|
|
|
ch->device[SLAVE].setmode(&ch->device[SLAVE], ATA_DMA_MAX);
|
|
|
|
|
}
|
2000-09-19 11:08:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
2004-05-20 14:49:12 +00:00
|
|
|
|
static void
|
2003-08-24 09:22:26 +00:00
|
|
|
|
ata_boot_attach(void)
|
2003-05-02 13:47:44 +00:00
|
|
|
|
{
|
|
|
|
|
struct ata_channel *ch;
|
|
|
|
|
int ctlr;
|
|
|
|
|
|
2003-08-24 09:22:26 +00:00
|
|
|
|
/*
|
|
|
|
|
* run through all ata devices and look for real ATA & ATAPI devices
|
|
|
|
|
* using the hints we found in the early probe, this avoids some of
|
|
|
|
|
* the delays probing of non-exsistent devices can cause.
|
|
|
|
|
*/
|
|
|
|
|
for (ctlr=0; ctlr<devclass_get_maxunit(ata_devclass); ctlr++) {
|
2003-05-02 13:47:44 +00:00
|
|
|
|
if (!(ch = devclass_get_softc(ata_devclass, ctlr)))
|
|
|
|
|
continue;
|
2003-08-24 09:22:26 +00:00
|
|
|
|
ata_identify_devices(ch);
|
|
|
|
|
if (ch->device[MASTER].attach)
|
|
|
|
|
ch->device[MASTER].attach(&ch->device[MASTER]);
|
|
|
|
|
if (ch->device[SLAVE].attach)
|
|
|
|
|
ch->device[SLAVE].attach(&ch->device[SLAVE]);
|
|
|
|
|
#ifdef DEV_ATAPICAM
|
|
|
|
|
atapi_cam_attach_bus(ch);
|
Fourth update to the new ATA/ATAPI driver:
Well, better late than newer, but things has been hectic
around here, sorry for the long delay.
DMA support has been added to the ATA disk driver.
This only works on Intel PIIX3/4, Acer Aladdin and Promise controllers.
The promise support works without the BIOS on the board,
and timing modes are set to support up to UDMA speed. This
solves the problems with having more than one promise controller
in the same system.
There is support for "generic" DMA, that might work on other
controllers, but now you have been warned :)
More chipset specific code will come soon, I have to find testers
with the approbiate HW, more on that when I have it ready.
The system now uses its own major numbers, please run MAKEDEV
with the devices you need (ad?, acd?, afd?, ast?).
For now the disk driver will also attach to the old wd major
so one can at least boot without this step, but be warned, this
will eventually go away. The bootblocks will have to be changed
before one can boot directly from an "ad" device though.
Fixed problems:
All known hang problems should be solved
The probe code has been sligthly changed, this should solve
the reports I have lying around (I hope).
Hangs when accessing ata & atapi device on the same channel simultaniously.
A real braino in ata_start caused this, fixed.
As usual USE AT YOUR OWN RISK!!, this is still pre alpha level code.
Especially the DMA support can hose your disk real bad if anything
goes wrong, agaiin you have been warned :)
But please tell me how it works for you!
Enjoy!
-Søren
1999-03-28 18:57:20 +00:00
|
|
|
|
#endif
|
1999-03-05 09:43:30 +00:00
|
|
|
|
}
|
2003-08-24 09:22:26 +00:00
|
|
|
|
#ifdef DEV_ATARAID
|
|
|
|
|
ata_raid_attach();
|
|
|
|
|
#endif
|
|
|
|
|
if (ata_delayed_attach) {
|
|
|
|
|
config_intrhook_disestablish(ata_delayed_attach);
|
|
|
|
|
free(ata_delayed_attach, M_TEMP);
|
|
|
|
|
ata_delayed_attach = NULL;
|
1999-03-05 09:43:30 +00:00
|
|
|
|
}
|
Major update of the ATA RAID code, part 1:
Overhaul of the attach/detach code and structures, there were some nasty
bugs in the old implementation. This made it possible to collapse the
ATA/ATAPI device control structures into one generic structure.
A note here, the kernel is NOT ready for detach of active devices,
it fails all over in random places, but for inactive devices it works.
However for ATA RAID this works, since the RAID abstration layer
insulates the buggy^H^H^H^H^H^Hfragile device subsystem from the
physical disks.
Proberly detect the RAID's from the BIOS, and mark critical RAID1
arrays as such, but continue if there is enough of the mirror left
to do so.
Properly fail arrays on a live system. For RAID0 that means return EIO,
and for RAID1 it means continue on the still working part of the mirror
if possible, else return EIO.
If the state changes, log this to the console.
Allow for Promise & Highpoint controllers/arrays to coexist on the
same machine. It is not possible to distribute arrays over different
makes of controllers though.
If Promise SuperSwap enclosures are used, signal disk state on the
status LED on the front.
Misc fixes that I had lying around for various minor bugs.
Sponsored by: Advanis Inc.
2002-02-04 19:23:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-08-24 09:22:26 +00:00
|
|
|
|
/*
|
|
|
|
|
* misc support functions
|
|
|
|
|
*/
|
2002-03-30 16:36:41 +00:00
|
|
|
|
static void
|
2003-08-24 09:22:26 +00:00
|
|
|
|
bswap(int8_t *buf, int len)
|
2002-03-30 16:36:41 +00:00
|
|
|
|
{
|
2003-08-24 09:22:26 +00:00
|
|
|
|
u_int16_t *ptr = (u_int16_t*)(buf + len);
|
2004-05-20 14:49:12 +00:00
|
|
|
|
|
2003-08-24 09:22:26 +00:00
|
|
|
|
while (--ptr >= (u_int16_t*)buf)
|
|
|
|
|
*ptr = ntohs(*ptr);
|
2002-03-30 16:36:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2003-08-24 09:22:26 +00:00
|
|
|
|
btrim(int8_t *buf, int len)
|
2004-05-20 14:49:12 +00:00
|
|
|
|
{
|
2003-08-24 09:22:26 +00:00
|
|
|
|
int8_t *ptr;
|
2002-03-30 16:36:41 +00:00
|
|
|
|
|
2004-05-20 14:49:12 +00:00
|
|
|
|
for (ptr = buf; ptr < buf+len; ++ptr)
|
2003-08-24 09:22:26 +00:00
|
|
|
|
if (!*ptr)
|
|
|
|
|
*ptr = ' ';
|
|
|
|
|
for (ptr = buf + len - 1; ptr >= buf && *ptr == ' '; --ptr)
|
|
|
|
|
*ptr = 0;
|
2002-03-30 16:36:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2003-08-24 09:22:26 +00:00
|
|
|
|
bpack(int8_t *src, int8_t *dst, int len)
|
2002-03-30 16:36:41 +00:00
|
|
|
|
{
|
2003-08-24 09:22:26 +00:00
|
|
|
|
int i, j, blank;
|
2002-03-30 16:36:41 +00:00
|
|
|
|
|
2003-08-24 09:22:26 +00:00
|
|
|
|
for (i = j = blank = 0 ; i < len; i++) {
|
|
|
|
|
if (blank && src[i] == ' ') continue;
|
|
|
|
|
if (blank && src[i] != ' ') {
|
|
|
|
|
dst[j++] = src[i];
|
|
|
|
|
blank = 0;
|
|
|
|
|
continue;
|
2003-03-12 10:59:35 +00:00
|
|
|
|
}
|
2003-08-24 09:22:26 +00:00
|
|
|
|
if (src[i] == ' ') {
|
|
|
|
|
blank = 1;
|
|
|
|
|
if (i == 0)
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
dst[j++] = src[i];
|
2003-01-27 09:04:29 +00:00
|
|
|
|
}
|
2004-05-20 14:49:12 +00:00
|
|
|
|
if (j < len)
|
2003-08-24 09:22:26 +00:00
|
|
|
|
dst[j] = 0x00;
|
Major update of the ATA RAID code, part 1:
Overhaul of the attach/detach code and structures, there were some nasty
bugs in the old implementation. This made it possible to collapse the
ATA/ATAPI device control structures into one generic structure.
A note here, the kernel is NOT ready for detach of active devices,
it fails all over in random places, but for inactive devices it works.
However for ATA RAID this works, since the RAID abstration layer
insulates the buggy^H^H^H^H^H^Hfragile device subsystem from the
physical disks.
Proberly detect the RAID's from the BIOS, and mark critical RAID1
arrays as such, but continue if there is enough of the mirror left
to do so.
Properly fail arrays on a live system. For RAID0 that means return EIO,
and for RAID1 it means continue on the still working part of the mirror
if possible, else return EIO.
If the state changes, log this to the console.
Allow for Promise & Highpoint controllers/arrays to coexist on the
same machine. It is not possible to distribute arrays over different
makes of controllers though.
If Promise SuperSwap enclosures are used, signal disk state on the
status LED on the front.
Misc fixes that I had lying around for various minor bugs.
Sponsored by: Advanis Inc.
2002-02-04 19:23:40 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
ata_printf(struct ata_channel *ch, int device, const char * fmt, ...)
|
|
|
|
|
{
|
|
|
|
|
va_list ap;
|
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
|
|
if (device == -1)
|
|
|
|
|
ret = printf("ata%d: ", device_get_unit(ch->dev));
|
|
|
|
|
else {
|
|
|
|
|
if (ch->device[ATA_DEV(device)].name)
|
|
|
|
|
ret = printf("%s: ", ch->device[ATA_DEV(device)].name);
|
|
|
|
|
else
|
|
|
|
|
ret = printf("ata%d-%s: ", device_get_unit(ch->dev),
|
|
|
|
|
(device == ATA_MASTER) ? "master" : "slave");
|
|
|
|
|
}
|
|
|
|
|
va_start(ap, fmt);
|
|
|
|
|
ret += vprintf(fmt, ap);
|
|
|
|
|
va_end(ap);
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
ata_prtdev(struct ata_device *atadev, const char * fmt, ...)
|
|
|
|
|
{
|
|
|
|
|
va_list ap;
|
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
|
|
if (atadev->name)
|
|
|
|
|
ret = printf("%s: ", atadev->name);
|
|
|
|
|
else
|
|
|
|
|
ret = printf("ata%d-%s: ", device_get_unit(atadev->channel->dev),
|
|
|
|
|
(atadev->unit == ATA_MASTER) ? "master" : "slave");
|
|
|
|
|
va_start(ap, fmt);
|
|
|
|
|
ret += vprintf(fmt, ap);
|
|
|
|
|
va_end(ap);
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
ata_set_name(struct ata_device *atadev, char *name, int lun)
|
2001-03-15 15:36:25 +00:00
|
|
|
|
{
|
Major update of the ATA RAID code, part 1:
Overhaul of the attach/detach code and structures, there were some nasty
bugs in the old implementation. This made it possible to collapse the
ATA/ATAPI device control structures into one generic structure.
A note here, the kernel is NOT ready for detach of active devices,
it fails all over in random places, but for inactive devices it works.
However for ATA RAID this works, since the RAID abstration layer
insulates the buggy^H^H^H^H^H^Hfragile device subsystem from the
physical disks.
Proberly detect the RAID's from the BIOS, and mark critical RAID1
arrays as such, but continue if there is enough of the mirror left
to do so.
Properly fail arrays on a live system. For RAID0 that means return EIO,
and for RAID1 it means continue on the still working part of the mirror
if possible, else return EIO.
If the state changes, log this to the console.
Allow for Promise & Highpoint controllers/arrays to coexist on the
same machine. It is not possible to distribute arrays over different
makes of controllers though.
If Promise SuperSwap enclosures are used, signal disk state on the
status LED on the front.
Misc fixes that I had lying around for various minor bugs.
Sponsored by: Advanis Inc.
2002-02-04 19:23:40 +00:00
|
|
|
|
atadev->name = malloc(strlen(name) + 4, M_ATA, M_NOWAIT);
|
|
|
|
|
if (atadev->name)
|
|
|
|
|
sprintf(atadev->name, "%s%d", name, lun);
|
2001-03-15 15:36:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
Major update of the ATA RAID code, part 1:
Overhaul of the attach/detach code and structures, there were some nasty
bugs in the old implementation. This made it possible to collapse the
ATA/ATAPI device control structures into one generic structure.
A note here, the kernel is NOT ready for detach of active devices,
it fails all over in random places, but for inactive devices it works.
However for ATA RAID this works, since the RAID abstration layer
insulates the buggy^H^H^H^H^H^Hfragile device subsystem from the
physical disks.
Proberly detect the RAID's from the BIOS, and mark critical RAID1
arrays as such, but continue if there is enough of the mirror left
to do so.
Properly fail arrays on a live system. For RAID0 that means return EIO,
and for RAID1 it means continue on the still working part of the mirror
if possible, else return EIO.
If the state changes, log this to the console.
Allow for Promise & Highpoint controllers/arrays to coexist on the
same machine. It is not possible to distribute arrays over different
makes of controllers though.
If Promise SuperSwap enclosures are used, signal disk state on the
status LED on the front.
Misc fixes that I had lying around for various minor bugs.
Sponsored by: Advanis Inc.
2002-02-04 19:23:40 +00:00
|
|
|
|
ata_free_name(struct ata_device *atadev)
|
2001-03-15 15:36:25 +00:00
|
|
|
|
{
|
Major update of the ATA RAID code, part 1:
Overhaul of the attach/detach code and structures, there were some nasty
bugs in the old implementation. This made it possible to collapse the
ATA/ATAPI device control structures into one generic structure.
A note here, the kernel is NOT ready for detach of active devices,
it fails all over in random places, but for inactive devices it works.
However for ATA RAID this works, since the RAID abstration layer
insulates the buggy^H^H^H^H^H^Hfragile device subsystem from the
physical disks.
Proberly detect the RAID's from the BIOS, and mark critical RAID1
arrays as such, but continue if there is enough of the mirror left
to do so.
Properly fail arrays on a live system. For RAID0 that means return EIO,
and for RAID1 it means continue on the still working part of the mirror
if possible, else return EIO.
If the state changes, log this to the console.
Allow for Promise & Highpoint controllers/arrays to coexist on the
same machine. It is not possible to distribute arrays over different
makes of controllers though.
If Promise SuperSwap enclosures are used, signal disk state on the
status LED on the front.
Misc fixes that I had lying around for various minor bugs.
Sponsored by: Advanis Inc.
2002-02-04 19:23:40 +00:00
|
|
|
|
if (atadev->name)
|
|
|
|
|
free(atadev->name, M_ATA);
|
|
|
|
|
atadev->name = NULL;
|
2001-03-15 15:36:25 +00:00
|
|
|
|
}
|
2004-05-20 14:49:12 +00:00
|
|
|
|
|
2000-02-18 20:57:33 +00:00
|
|
|
|
int
|
2000-09-19 11:08:39 +00:00
|
|
|
|
ata_get_lun(u_int32_t *map)
|
|
|
|
|
{
|
|
|
|
|
int lun = ffs(~*map) - 1;
|
|
|
|
|
|
|
|
|
|
*map |= (1 << lun);
|
|
|
|
|
return lun;
|
|
|
|
|
}
|
|
|
|
|
|
2001-02-06 12:41:53 +00:00
|
|
|
|
int
|
|
|
|
|
ata_test_lun(u_int32_t *map, int lun)
|
|
|
|
|
{
|
2001-02-06 12:49:33 +00:00
|
|
|
|
return (*map & (1 << lun));
|
2001-02-06 12:41:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-09-19 11:08:39 +00:00
|
|
|
|
void
|
|
|
|
|
ata_free_lun(u_int32_t *map, int lun)
|
|
|
|
|
{
|
|
|
|
|
*map &= ~(1 << lun);
|
|
|
|
|
}
|
2004-05-20 14:49:12 +00:00
|
|
|
|
|
2000-09-19 11:08:39 +00:00
|
|
|
|
char *
|
|
|
|
|
ata_mode2str(int mode)
|
Ten'th update to the new ATA/ATAPI driver:
It been awhile since the last major update, as a benefit there
are some cool things in this one (and new bugs probably :) )...
The ATA driver has grown "real" timeout support for all devices.
This means that it should be possible to get in contact with
(especially) lost ATAPI devices. It also means that the ATA
driver is now usable on notebooks as it will DTRT on resume.
An experimental hack at utilizing the Promise66's at UDMA66 is
in there, but I cant test it. If someone feels like sending
me one, give me a ping.
The ATAPI DMA enableling scheme has been changed, also better DMA
support for the Aladdin chipset has been implemented for ATAPI
devices. Note that the Aladdin apparently only can do DMA reads
on ATAPI devices, and the Promise cant do ATAPI DMA at all.
I have seen problems on some ATAPI devices that should be able
to run in DMA mode, so if you encounter problems with hanging
atapi devices during the probe, or during access, disable DMA
in atapi-all.c, and let me know. It might be nessesary to do this
via a "white list" for known good devices...
The ATAPI CDROM driver can now use eject/close without hanging and
the bug that caused reading beyond the end of a CD has been fixed.
Media change is also handled proberly. DVD drives are identified
and are usable as CDROM devices at least, I dont have the HW to
test this further, see above :).
The ATAPI tape driver has gotten some support for using the DSC
method for not blocking the IDE channel during read/write when
the device has full buffers. It knows about the OnStream DI-30
device, support is not completed yet, but it can function as a
primitive backup medium, without filemarks, and without bad media
handeling. This is because the OnStream device doesn't handle this
(like everybody else) in HW. It also now supports getting/setting
the record position on devices that supports it.
Some rather major cleanups and rearrangements as well (cvs -b diff
is your freind). I'm closing in on declaring this for beta code,
most of the infrastruture is in place by now.
As usual USE AT YOUR OWN RISK!!, this is still alpha level code.
This driver can hose your disk real bad if anything goes wrong, but
now you have been warned :)
But please tell me how it works for you!
Enjoy!
-Søren
1999-09-21 19:50:40 +00:00
|
|
|
|
{
|
|
|
|
|
switch (mode) {
|
2000-01-27 19:00:51 +00:00
|
|
|
|
case ATA_PIO: return "BIOSPIO";
|
2000-01-03 10:26:59 +00:00
|
|
|
|
case ATA_PIO0: return "PIO0";
|
|
|
|
|
case ATA_PIO1: return "PIO1";
|
|
|
|
|
case ATA_PIO2: return "PIO2";
|
|
|
|
|
case ATA_PIO3: return "PIO3";
|
|
|
|
|
case ATA_PIO4: return "PIO4";
|
Major update of the ATA RAID code, part 1:
Overhaul of the attach/detach code and structures, there were some nasty
bugs in the old implementation. This made it possible to collapse the
ATA/ATAPI device control structures into one generic structure.
A note here, the kernel is NOT ready for detach of active devices,
it fails all over in random places, but for inactive devices it works.
However for ATA RAID this works, since the RAID abstration layer
insulates the buggy^H^H^H^H^H^Hfragile device subsystem from the
physical disks.
Proberly detect the RAID's from the BIOS, and mark critical RAID1
arrays as such, but continue if there is enough of the mirror left
to do so.
Properly fail arrays on a live system. For RAID0 that means return EIO,
and for RAID1 it means continue on the still working part of the mirror
if possible, else return EIO.
If the state changes, log this to the console.
Allow for Promise & Highpoint controllers/arrays to coexist on the
same machine. It is not possible to distribute arrays over different
makes of controllers though.
If Promise SuperSwap enclosures are used, signal disk state on the
status LED on the front.
Misc fixes that I had lying around for various minor bugs.
Sponsored by: Advanis Inc.
2002-02-04 19:23:40 +00:00
|
|
|
|
case ATA_DMA: return "BIOSDMA";
|
2003-02-20 20:02:32 +00:00
|
|
|
|
case ATA_WDMA0: return "WDMA0";
|
|
|
|
|
case ATA_WDMA1: return "WDMA1";
|
2000-01-03 10:26:59 +00:00
|
|
|
|
case ATA_WDMA2: return "WDMA2";
|
2003-02-20 20:02:32 +00:00
|
|
|
|
case ATA_UDMA0: return "UDMA16";
|
|
|
|
|
case ATA_UDMA1: return "UDMA25";
|
2000-01-03 10:26:59 +00:00
|
|
|
|
case ATA_UDMA2: return "UDMA33";
|
2003-02-20 20:02:32 +00:00
|
|
|
|
case ATA_UDMA3: return "UDMA40";
|
2000-01-03 10:26:59 +00:00
|
|
|
|
case ATA_UDMA4: return "UDMA66";
|
2000-08-06 19:51:58 +00:00
|
|
|
|
case ATA_UDMA5: return "UDMA100";
|
2001-10-06 11:07:04 +00:00
|
|
|
|
case ATA_UDMA6: return "UDMA133";
|
2003-05-18 16:43:08 +00:00
|
|
|
|
case ATA_SA150: return "SATA150";
|
2000-01-03 10:26:59 +00:00
|
|
|
|
default: return "???";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2000-02-18 20:57:33 +00:00
|
|
|
|
int
|
|
|
|
|
ata_pmode(struct ata_params *ap)
|
|
|
|
|
{
|
|
|
|
|
if (ap->atavalid & ATA_FLAG_64_70) {
|
2003-02-20 20:02:32 +00:00
|
|
|
|
if (ap->apiomodes & 0x02)
|
|
|
|
|
return ATA_PIO4;
|
2004-05-20 14:49:12 +00:00
|
|
|
|
if (ap->apiomodes & 0x01)
|
2003-02-20 20:02:32 +00:00
|
|
|
|
return ATA_PIO3;
|
2004-05-20 14:49:12 +00:00
|
|
|
|
}
|
2003-09-08 08:30:43 +00:00
|
|
|
|
if (ap->mwdmamodes & 0x04)
|
|
|
|
|
return ATA_PIO4;
|
|
|
|
|
if (ap->mwdmamodes & 0x02)
|
|
|
|
|
return ATA_PIO3;
|
|
|
|
|
if (ap->mwdmamodes & 0x01)
|
2003-02-20 20:02:32 +00:00
|
|
|
|
return ATA_PIO2;
|
2003-09-08 08:30:43 +00:00
|
|
|
|
if ((ap->retired_piomode & ATA_RETIRED_PIO_MASK) == 0x200)
|
|
|
|
|
return ATA_PIO2;
|
|
|
|
|
if ((ap->retired_piomode & ATA_RETIRED_PIO_MASK) == 0x100)
|
2003-02-20 20:02:32 +00:00
|
|
|
|
return ATA_PIO1;
|
2003-09-08 08:30:43 +00:00
|
|
|
|
if ((ap->retired_piomode & ATA_RETIRED_PIO_MASK) == 0x000)
|
2003-02-20 20:02:32 +00:00
|
|
|
|
return ATA_PIO0;
|
2004-05-20 14:49:12 +00:00
|
|
|
|
return ATA_PIO0;
|
|
|
|
|
}
|
2000-02-18 20:57:33 +00:00
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
ata_wmode(struct ata_params *ap)
|
|
|
|
|
{
|
2001-10-06 11:07:04 +00:00
|
|
|
|
if (ap->mwdmamodes & 0x04)
|
2003-02-20 20:02:32 +00:00
|
|
|
|
return ATA_WDMA2;
|
2001-10-06 11:07:04 +00:00
|
|
|
|
if (ap->mwdmamodes & 0x02)
|
2003-02-20 20:02:32 +00:00
|
|
|
|
return ATA_WDMA1;
|
2001-10-06 11:07:04 +00:00
|
|
|
|
if (ap->mwdmamodes & 0x01)
|
2003-02-20 20:02:32 +00:00
|
|
|
|
return ATA_WDMA0;
|
2000-02-18 20:57:33 +00:00
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
|
ata_umode(struct ata_params *ap)
|
|
|
|
|
{
|
|
|
|
|
if (ap->atavalid & ATA_FLAG_88) {
|
2001-10-06 11:07:04 +00:00
|
|
|
|
if (ap->udmamodes & 0x40)
|
2003-02-20 20:02:32 +00:00
|
|
|
|
return ATA_UDMA6;
|
2000-08-06 19:51:58 +00:00
|
|
|
|
if (ap->udmamodes & 0x20)
|
2003-02-20 20:02:32 +00:00
|
|
|
|
return ATA_UDMA5;
|
2000-02-18 20:57:33 +00:00
|
|
|
|
if (ap->udmamodes & 0x10)
|
2003-02-20 20:02:32 +00:00
|
|
|
|
return ATA_UDMA4;
|
2000-02-18 20:57:33 +00:00
|
|
|
|
if (ap->udmamodes & 0x08)
|
2003-02-20 20:02:32 +00:00
|
|
|
|
return ATA_UDMA3;
|
2000-02-18 20:57:33 +00:00
|
|
|
|
if (ap->udmamodes & 0x04)
|
2003-02-20 20:02:32 +00:00
|
|
|
|
return ATA_UDMA2;
|
2000-02-18 20:57:33 +00:00
|
|
|
|
if (ap->udmamodes & 0x02)
|
2003-02-20 20:02:32 +00:00
|
|
|
|
return ATA_UDMA1;
|
2000-02-18 20:57:33 +00:00
|
|
|
|
if (ap->udmamodes & 0x01)
|
2003-02-20 20:02:32 +00:00
|
|
|
|
return ATA_UDMA0;
|
2000-02-18 20:57:33 +00:00
|
|
|
|
}
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
2003-02-20 20:02:32 +00:00
|
|
|
|
int
|
|
|
|
|
ata_limit_mode(struct ata_device *atadev, int mode, int maxmode)
|
|
|
|
|
{
|
|
|
|
|
if (maxmode && mode > maxmode)
|
|
|
|
|
mode = maxmode;
|
|
|
|
|
|
|
|
|
|
if (mode >= ATA_UDMA0 && ata_umode(atadev->param) > 0)
|
|
|
|
|
return min(mode, ata_umode(atadev->param));
|
|
|
|
|
|
|
|
|
|
if (mode >= ATA_WDMA0 && ata_wmode(atadev->param) > 0)
|
|
|
|
|
return min(mode, ata_wmode(atadev->param));
|
|
|
|
|
|
2004-05-20 14:49:12 +00:00
|
|
|
|
if (mode > ata_pmode(atadev->param))
|
2003-02-20 20:02:32 +00:00
|
|
|
|
return min(mode, ata_pmode(atadev->param));
|
|
|
|
|
|
|
|
|
|
return mode;
|
|
|
|
|
}
|
|
|
|
|
|
2000-02-18 20:57:33 +00:00
|
|
|
|
static void
|
|
|
|
|
ata_init(void)
|
|
|
|
|
{
|
2001-03-15 15:36:25 +00:00
|
|
|
|
/* register controlling device */
|
2001-03-19 11:55:13 +00:00
|
|
|
|
make_dev(&ata_cdevsw, 0, UID_ROOT, GID_OPERATOR, 0600, "ata");
|
2001-03-15 15:36:25 +00:00
|
|
|
|
|
2000-02-18 20:57:33 +00:00
|
|
|
|
/* register boot attach to be run when interrupts are enabled */
|
|
|
|
|
if (!(ata_delayed_attach = (struct intr_config_hook *)
|
2000-12-26 12:05:49 +00:00
|
|
|
|
malloc(sizeof(struct intr_config_hook),
|
|
|
|
|
M_TEMP, M_NOWAIT | M_ZERO))) {
|
2000-02-18 20:57:33 +00:00
|
|
|
|
printf("ata: malloc of delayed attach hook failed\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
ata_delayed_attach->ich_func = (void*)ata_boot_attach;
|
|
|
|
|
if (config_intrhook_establish(ata_delayed_attach) != 0) {
|
|
|
|
|
printf("ata: config_intrhook_establish failed\n");
|
|
|
|
|
free(ata_delayed_attach, M_TEMP);
|
|
|
|
|
}
|
2004-01-11 22:08:34 +00:00
|
|
|
|
|
2004-01-14 21:26:35 +00:00
|
|
|
|
/* register handler to flush write caches on shutdown */
|
2003-05-02 13:47:44 +00:00
|
|
|
|
if ((EVENTHANDLER_REGISTER(shutdown_post_sync, ata_shutdown,
|
|
|
|
|
NULL, SHUTDOWN_PRI_DEFAULT)) == NULL)
|
|
|
|
|
printf("ata: shutdown event registration failed!\n");
|
|
|
|
|
|
2004-01-14 21:26:35 +00:00
|
|
|
|
/* init our UMA zone for ATA requests */
|
|
|
|
|
ata_zone = uma_zcreate("ata_request", sizeof(struct ata_request),
|
|
|
|
|
NULL, NULL, NULL, NULL, 0, 0);
|
2000-02-18 20:57:33 +00:00
|
|
|
|
}
|
|
|
|
|
SYSINIT(atadev, SI_SUB_DRIVERS, SI_ORDER_SECOND, ata_init, NULL)
|