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
|
|
|
|
/*-
|
2004-01-11 22:08:34 +00:00
|
|
|
|
* Copyright (c) 1998 - 2004 S<EFBFBD>ren Schmidt <sos@FreeBSD.org>
|
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
|
|
|
|
* 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$");
|
|
|
|
|
|
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
|
|
|
|
#include <sys/param.h>
|
|
|
|
|
#include <sys/systm.h>
|
2001-03-15 15:36:25 +00:00
|
|
|
|
#include <sys/ata.h>
|
2003-02-20 20:02:32 +00:00
|
|
|
|
#include <sys/kernel.h>
|
2002-04-26 22:48:23 +00:00
|
|
|
|
#include <sys/endian.h>
|
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
|
|
|
|
#include <sys/malloc.h>
|
2003-07-01 15:52:06 +00:00
|
|
|
|
#include <sys/lock.h>
|
2004-01-11 22:08:34 +00:00
|
|
|
|
#include <sys/sema.h>
|
2003-08-24 09:22:26 +00:00
|
|
|
|
#include <sys/taskqueue.h>
|
2004-01-14 21:26:35 +00:00
|
|
|
|
#include <vm/uma.h>
|
1999-04-18 20:48:15 +00:00
|
|
|
|
#include <sys/bus.h>
|
2000-08-28 21:48:13 +00:00
|
|
|
|
#include <machine/bus.h>
|
2001-02-06 16:44:25 +00:00
|
|
|
|
#include <sys/rman.h>
|
2003-08-24 09:22:26 +00:00
|
|
|
|
#include <dev/pci/pcivar.h>
|
2000-09-20 07:00:24 +00:00
|
|
|
|
#include <dev/ata/ata-all.h>
|
2003-02-20 20:02:32 +00:00
|
|
|
|
#include <dev/ata/ata-pci.h>
|
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
|
|
|
|
|
1999-10-09 19:57:13 +00:00
|
|
|
|
/* prototypes */
|
2003-08-25 11:13:04 +00:00
|
|
|
|
static void ata_dmaalloc(struct ata_channel *);
|
2003-03-29 13:37:09 +00:00
|
|
|
|
static void ata_dmafree(struct ata_channel *);
|
2004-08-13 08:14:27 +00:00
|
|
|
|
static void ata_dmasetprd(void *, bus_dma_segment_t *, int, int);
|
2003-10-21 19:20:37 +00:00
|
|
|
|
static int ata_dmaload(struct ata_device *, caddr_t, int32_t, int);
|
|
|
|
|
static int ata_dmaunload(struct ata_channel *);
|
1999-10-09 19:57:13 +00:00
|
|
|
|
|
2003-02-20 20:02:32 +00:00
|
|
|
|
/* local vars */
|
|
|
|
|
static MALLOC_DEFINE(M_ATADMA, "ATA DMA", "ATA driver DMA");
|
2002-04-05 13:13:56 +00:00
|
|
|
|
|
2003-02-20 20:02:32 +00:00
|
|
|
|
/* misc defines */
|
|
|
|
|
#define MAXTABSZ PAGE_SIZE
|
2004-08-12 08:20:36 +00:00
|
|
|
|
#define MAXWSPCSZ PAGE_SIZE
|
2002-04-05 13:13:56 +00:00
|
|
|
|
|
|
|
|
|
struct ata_dc_cb_args {
|
|
|
|
|
bus_addr_t maddr;
|
|
|
|
|
int error;
|
|
|
|
|
};
|
|
|
|
|
|
2003-08-25 11:13:04 +00:00
|
|
|
|
void
|
2003-02-20 20:02:32 +00:00
|
|
|
|
ata_dmainit(struct ata_channel *ch)
|
|
|
|
|
{
|
2003-08-25 11:13:04 +00:00
|
|
|
|
if ((ch->dma = malloc(sizeof(struct ata_dma), M_ATADMA, M_NOWAIT|M_ZERO))) {
|
|
|
|
|
ch->dma->alloc = ata_dmaalloc;
|
|
|
|
|
ch->dma->free = ata_dmafree;
|
2004-08-13 08:14:27 +00:00
|
|
|
|
ch->dma->setprd = ata_dmasetprd;
|
2003-10-21 19:20:37 +00:00
|
|
|
|
ch->dma->load = ata_dmaload;
|
|
|
|
|
ch->dma->unload = ata_dmaunload;
|
2003-08-25 11:13:04 +00:00
|
|
|
|
ch->dma->alignment = 2;
|
2003-11-28 19:01:28 +00:00
|
|
|
|
ch->dma->max_iosize = 64 * 1024;
|
|
|
|
|
ch->dma->boundary = 64 * 1024;
|
2003-08-25 11:13:04 +00:00
|
|
|
|
}
|
2003-02-20 20:02:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-04-05 13:13:56 +00:00
|
|
|
|
static void
|
|
|
|
|
ata_dmasetupc_cb(void *xsc, bus_dma_segment_t *segs, int nsegs, int error)
|
|
|
|
|
{
|
|
|
|
|
struct ata_dc_cb_args *cba = (struct ata_dc_cb_args *)xsc;
|
|
|
|
|
|
|
|
|
|
if (!(cba->error = error))
|
|
|
|
|
cba->maddr = segs[0].ds_addr;
|
|
|
|
|
}
|
1999-04-16 21:22:55 +00:00
|
|
|
|
|
2003-08-25 11:13:04 +00:00
|
|
|
|
static void
|
2003-03-29 13:37:09 +00:00
|
|
|
|
ata_dmaalloc(struct ata_channel *ch)
|
2000-09-19 11:08:39 +00:00
|
|
|
|
{
|
2002-04-05 13:13:56 +00:00
|
|
|
|
struct ata_dc_cb_args ccba;
|
|
|
|
|
|
2004-08-20 19:05:22 +00:00
|
|
|
|
if (bus_dma_tag_create(NULL, ch->dma->alignment, 0,
|
2003-10-07 13:48:55 +00:00
|
|
|
|
BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR,
|
2004-08-20 19:05:22 +00:00
|
|
|
|
NULL, NULL, 16*1024*1024,
|
|
|
|
|
ATA_DMA_ENTRIES, ch->dma->max_iosize,
|
2003-10-07 13:48:55 +00:00
|
|
|
|
BUS_DMA_ALLOCNOW, NULL, NULL, &ch->dma->dmatag))
|
2003-08-25 11:13:04 +00:00
|
|
|
|
goto error;
|
|
|
|
|
|
2003-10-07 13:48:55 +00:00
|
|
|
|
if (bus_dma_tag_create(ch->dma->dmatag, PAGE_SIZE, PAGE_SIZE,
|
2003-08-25 11:13:04 +00:00
|
|
|
|
BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR,
|
2003-10-07 13:48:55 +00:00
|
|
|
|
NULL, NULL, MAXTABSZ, 1, MAXTABSZ,
|
|
|
|
|
BUS_DMA_ALLOCNOW, NULL, NULL, &ch->dma->cdmatag))
|
2003-08-25 11:13:04 +00:00
|
|
|
|
goto error;
|
|
|
|
|
|
2003-11-28 19:01:28 +00:00
|
|
|
|
if (bus_dma_tag_create(ch->dma->dmatag,ch->dma->alignment,ch->dma->boundary,
|
2003-08-25 11:13:04 +00:00
|
|
|
|
BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR,
|
2004-08-20 19:05:22 +00:00
|
|
|
|
NULL, NULL, 16*1024*1024,
|
|
|
|
|
ATA_DMA_ENTRIES, ch->dma->max_iosize,
|
2003-08-25 11:13:04 +00:00
|
|
|
|
BUS_DMA_ALLOCNOW, NULL, NULL, &ch->dma->ddmatag))
|
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
|
|
if (bus_dmamem_alloc(ch->dma->cdmatag, (void **)&ch->dma->dmatab, 0,
|
|
|
|
|
&ch->dma->cdmamap))
|
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
|
|
if (bus_dmamap_load(ch->dma->cdmatag, ch->dma->cdmamap, ch->dma->dmatab,
|
|
|
|
|
MAXTABSZ, ata_dmasetupc_cb, &ccba, 0) || ccba.error) {
|
2004-04-13 09:44:20 +00:00
|
|
|
|
bus_dmamem_free(ch->dma->cdmatag, ch->dma->dmatab, ch->dma->cdmamap);
|
2003-08-25 11:13:04 +00:00
|
|
|
|
goto error;
|
2002-04-05 13:13:56 +00:00
|
|
|
|
}
|
2003-08-25 11:13:04 +00:00
|
|
|
|
ch->dma->mdmatab = ccba.maddr;
|
2004-04-13 09:44:20 +00:00
|
|
|
|
|
2003-08-25 11:13:04 +00:00
|
|
|
|
if (bus_dmamap_create(ch->dma->ddmatag, 0, &ch->dma->ddmamap))
|
|
|
|
|
goto error;
|
2004-04-13 09:44:20 +00:00
|
|
|
|
|
|
|
|
|
if (bus_dma_tag_create(ch->dma->dmatag, PAGE_SIZE, PAGE_SIZE,
|
|
|
|
|
BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR,
|
|
|
|
|
NULL, NULL, MAXWSPCSZ, 1, MAXWSPCSZ,
|
|
|
|
|
BUS_DMA_ALLOCNOW, NULL, NULL, &ch->dma->wdmatag))
|
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
|
|
if (bus_dmamem_alloc(ch->dma->wdmatag, (void **)&ch->dma->workspace, 0,
|
|
|
|
|
&ch->dma->wdmamap))
|
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
|
|
if (bus_dmamap_load(ch->dma->wdmatag, ch->dma->wdmamap, ch->dma->workspace,
|
|
|
|
|
MAXWSPCSZ, ata_dmasetupc_cb, &ccba, 0) || ccba.error) {
|
|
|
|
|
bus_dmamem_free(ch->dma->wdmatag, ch->dma->workspace, ch->dma->wdmamap);
|
|
|
|
|
goto error;
|
|
|
|
|
}
|
|
|
|
|
ch->dma->wdmatab = ccba.maddr;
|
|
|
|
|
|
2003-08-25 11:13:04 +00:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
error:
|
2004-04-13 09:44:20 +00:00
|
|
|
|
ata_printf(ch, -1, "WARNING - DMA allocation failed, disabling DMA\n");
|
2003-08-25 11:13:04 +00:00
|
|
|
|
ata_dmafree(ch);
|
|
|
|
|
free(ch->dma, M_ATADMA);
|
|
|
|
|
ch->dma = NULL;
|
2002-04-05 13:13:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-02-20 20:02:32 +00:00
|
|
|
|
static void
|
2003-03-29 13:37:09 +00:00
|
|
|
|
ata_dmafree(struct ata_channel *ch)
|
2002-04-05 13:13:56 +00:00
|
|
|
|
{
|
2004-04-13 09:44:20 +00:00
|
|
|
|
if (ch->dma->wdmatab) {
|
|
|
|
|
bus_dmamap_unload(ch->dma->wdmatag, ch->dma->wdmamap);
|
|
|
|
|
bus_dmamem_free(ch->dma->wdmatag, ch->dma->workspace, ch->dma->wdmamap);
|
|
|
|
|
ch->dma->wdmatab = 0;
|
|
|
|
|
ch->dma->wdmamap = NULL;
|
|
|
|
|
ch->dma->workspace = NULL;
|
|
|
|
|
}
|
|
|
|
|
if (ch->dma->wdmatag) {
|
|
|
|
|
bus_dma_tag_destroy(ch->dma->wdmatag);
|
|
|
|
|
ch->dma->wdmatag = NULL;
|
|
|
|
|
}
|
2003-03-29 13:37:09 +00:00
|
|
|
|
if (ch->dma->mdmatab) {
|
|
|
|
|
bus_dmamap_unload(ch->dma->cdmatag, ch->dma->cdmamap);
|
|
|
|
|
bus_dmamem_free(ch->dma->cdmatag, ch->dma->dmatab, ch->dma->cdmamap);
|
|
|
|
|
ch->dma->mdmatab = 0;
|
|
|
|
|
ch->dma->cdmamap = NULL;
|
|
|
|
|
ch->dma->dmatab = NULL;
|
2002-04-05 13:13:56 +00:00
|
|
|
|
}
|
2003-03-29 13:37:09 +00:00
|
|
|
|
if (ch->dma->ddmamap) {
|
|
|
|
|
bus_dmamap_destroy(ch->dma->ddmatag, ch->dma->ddmamap);
|
|
|
|
|
ch->dma->ddmamap = NULL;
|
2002-04-05 13:13:56 +00:00
|
|
|
|
}
|
2003-03-29 13:37:09 +00:00
|
|
|
|
if (ch->dma->cdmatag) {
|
|
|
|
|
bus_dma_tag_destroy(ch->dma->cdmatag);
|
|
|
|
|
ch->dma->cdmatag = NULL;
|
2002-04-05 13:13:56 +00:00
|
|
|
|
}
|
2003-03-29 13:37:09 +00:00
|
|
|
|
if (ch->dma->ddmatag) {
|
|
|
|
|
bus_dma_tag_destroy(ch->dma->ddmatag);
|
|
|
|
|
ch->dma->ddmatag = NULL;
|
2000-09-19 11:08:39 +00:00
|
|
|
|
}
|
2003-03-29 13:37:09 +00:00
|
|
|
|
if (ch->dma->dmatag) {
|
|
|
|
|
bus_dma_tag_destroy(ch->dma->dmatag);
|
|
|
|
|
ch->dma->dmatag = NULL;
|
2000-03-05 16:52:26 +00:00
|
|
|
|
}
|
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
|
|
|
|
}
|
|
|
|
|
|
2002-04-05 13:13:56 +00:00
|
|
|
|
static void
|
2004-08-13 08:14:27 +00:00
|
|
|
|
ata_dmasetprd(void *xsc, bus_dma_segment_t *segs, int nsegs, int error)
|
2002-04-05 13:13:56 +00:00
|
|
|
|
{
|
2004-08-13 08:14:27 +00:00
|
|
|
|
struct ata_dmasetprd_args *args = xsc;
|
|
|
|
|
struct ata_dma_prdentry *prd = args->dmatab;
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
if ((args->error = error))
|
2002-04-05 13:13:56 +00:00
|
|
|
|
return;
|
2004-08-13 08:14:27 +00:00
|
|
|
|
|
2002-04-05 13:13:56 +00:00
|
|
|
|
for (i = 0; i < nsegs; i++) {
|
2004-08-13 08:14:27 +00:00
|
|
|
|
prd[i].addr = htole32(segs[i].ds_addr);
|
|
|
|
|
prd[i].count = htole32(segs[i].ds_len);
|
2002-04-05 13:13:56 +00:00
|
|
|
|
}
|
2004-08-13 08:14:27 +00:00
|
|
|
|
prd[i - 1].count |= htole32(ATA_DMA_EOT);
|
2002-04-05 13:13:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-02-20 20:02:32 +00:00
|
|
|
|
static int
|
2003-10-21 19:20:37 +00:00
|
|
|
|
ata_dmaload(struct ata_device *atadev, caddr_t data, int32_t count, int dir)
|
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
|
|
|
|
{
|
2002-04-05 13:13:56 +00:00
|
|
|
|
struct ata_channel *ch = atadev->channel;
|
2004-08-13 08:14:27 +00:00
|
|
|
|
struct ata_dmasetprd_args cba;
|
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
|
|
|
|
|
2004-08-13 08:14:27 +00:00
|
|
|
|
if (ch->dma->flags & ATA_DMA_LOADED) {
|
2003-10-21 19:20:37 +00:00
|
|
|
|
ata_prtdev(atadev, "FAILURE - already active DMA on this device\n");
|
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
|
|
|
|
return -1;
|
2000-09-19 11:08:39 +00:00
|
|
|
|
}
|
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
|
|
|
|
if (!count) {
|
2003-08-24 09:22:26 +00:00
|
|
|
|
ata_prtdev(atadev, "FAILURE - zero length DMA transfer attempted\n");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
2003-10-21 19:20:37 +00:00
|
|
|
|
if (((uintptr_t)data & (ch->dma->alignment - 1)) ||
|
|
|
|
|
(count & (ch->dma->alignment - 1))) {
|
|
|
|
|
ata_prtdev(atadev, "FAILURE - non aligned DMA transfer attempted\n");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
2003-08-24 09:22:26 +00:00
|
|
|
|
if (count > ch->dma->max_iosize) {
|
|
|
|
|
ata_prtdev(atadev,
|
|
|
|
|
"FAILURE - oversized DMA transfer attempted %d > %d\n",
|
|
|
|
|
count, ch->dma->max_iosize);
|
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
|
|
|
|
return -1;
|
|
|
|
|
}
|
2002-04-18 19:11:45 +00:00
|
|
|
|
|
2003-03-29 13:37:09 +00:00
|
|
|
|
cba.dmatab = ch->dma->dmatab;
|
2003-10-21 19:20:37 +00:00
|
|
|
|
|
2003-03-29 13:37:09 +00:00
|
|
|
|
bus_dmamap_sync(ch->dma->cdmatag, ch->dma->cdmamap, BUS_DMASYNC_PREWRITE);
|
2003-10-21 19:20:37 +00:00
|
|
|
|
|
2003-03-29 13:37:09 +00:00
|
|
|
|
if (bus_dmamap_load(ch->dma->ddmatag, ch->dma->ddmamap, data, count,
|
2004-08-13 08:14:27 +00:00
|
|
|
|
ch->dma->setprd, &cba, 0) || cba.error)
|
2002-04-18 19:11:45 +00:00
|
|
|
|
return -1;
|
|
|
|
|
|
2003-03-29 13:37:09 +00:00
|
|
|
|
bus_dmamap_sync(ch->dma->ddmatag, ch->dma->ddmamap,
|
|
|
|
|
dir ? BUS_DMASYNC_PREREAD : BUS_DMASYNC_PREWRITE);
|
2002-04-18 19:11:45 +00:00
|
|
|
|
|
2003-10-21 19:20:37 +00:00
|
|
|
|
ch->dma->cur_iosize = count;
|
2004-08-05 21:13:41 +00:00
|
|
|
|
ch->dma->flags = dir ? (ATA_DMA_LOADED | ATA_DMA_READ) : ATA_DMA_LOADED;
|
2002-04-18 19:11:45 +00:00
|
|
|
|
return 0;
|
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
|
|
|
|
}
|
|
|
|
|
|
2000-09-19 11:08:39 +00:00
|
|
|
|
int
|
2003-10-21 19:20:37 +00:00
|
|
|
|
ata_dmaunload(struct ata_channel *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
|
|
|
|
{
|
2003-08-24 09:22:26 +00:00
|
|
|
|
bus_dmamap_sync(ch->dma->cdmatag, ch->dma->cdmamap, BUS_DMASYNC_POSTWRITE);
|
|
|
|
|
|
2003-03-29 13:37:09 +00:00
|
|
|
|
bus_dmamap_sync(ch->dma->ddmatag, ch->dma->ddmamap,
|
|
|
|
|
(ch->dma->flags & ATA_DMA_READ) != 0 ?
|
2002-04-05 13:13:56 +00:00
|
|
|
|
BUS_DMASYNC_POSTREAD : BUS_DMASYNC_POSTWRITE);
|
2003-03-29 13:37:09 +00:00
|
|
|
|
bus_dmamap_unload(ch->dma->ddmatag, ch->dma->ddmamap);
|
2003-08-24 09:22:26 +00:00
|
|
|
|
|
2003-10-21 19:20:37 +00:00
|
|
|
|
ch->dma->cur_iosize = 0;
|
2004-08-05 21:13:41 +00:00
|
|
|
|
ch->dma->flags &= ~ATA_DMA_LOADED;
|
2003-03-29 13:37:09 +00:00
|
|
|
|
return 0;
|
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
|
|
|
|
}
|