1999-03-03 21:10:29 +00:00
|
|
|
|
/*-
|
|
|
|
|
* Copyright (c) 1998,1999 S<EFBFBD>ren Schmidt
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
|
* are met:
|
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
|
* notice, this list of conditions and the following disclaimer,
|
|
|
|
|
* 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.
|
|
|
|
|
*
|
Nine'th update to the new ATA/ATAPI driver:
The atapi subsystem has gotten better error handeling and timeouts,
it also tries a REQUEST SENSE command when devices returns errors,
to give a little more info as to what went wrong. It might be a
little verbose for now, but I'm interested in as much feedback on
errors as possible, especially timeouts, as I'm a bit in doubt if
I've chosen resonable default values everywhere.
The disk driver has been changed a bit to prepare for tagged queing,
which is next on my list.
The disk driver has grown a dump routine, I got one implementation
from Darrell Anderson <anderson@cs.duke.edu> which also did
partial dumps (usefull on big memory machines) I left out the
partial stuff for now, and changed the rest alot to fit into the new
ad_request framework.
Some minor cleanups and rearrangements as well.
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, again you have been warned :)
Notebook owners should be carefull that their machines dont suspend
as this might cause trouble...
But please tell me how it works for you!
Enjoy!
-Søren
1999-06-25 09:03:07 +00:00
|
|
|
|
* $Id: atapi-fd.c,v 1.10 1999/05/31 11:24:29 phk Exp $
|
1999-03-03 21:10:29 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "ata.h"
|
|
|
|
|
#include "atapifd.h"
|
|
|
|
|
#include "opt_devfs.h"
|
|
|
|
|
|
|
|
|
|
#if NATA > 0 && NATAPIFD > 0
|
|
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
|
#include <sys/systm.h>
|
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
|
#include <sys/proc.h>
|
|
|
|
|
#include <sys/device.h>
|
|
|
|
|
#include <sys/malloc.h>
|
|
|
|
|
#include <sys/buf.h>
|
|
|
|
|
#include <sys/disklabel.h>
|
|
|
|
|
#include <sys/diskslice.h>
|
|
|
|
|
#include <sys/devicestat.h>
|
|
|
|
|
#include <sys/cdio.h>
|
|
|
|
|
#include <sys/fcntl.h>
|
|
|
|
|
#include <sys/conf.h>
|
|
|
|
|
#include <sys/stat.h>
|
|
|
|
|
#ifdef DEVFS
|
|
|
|
|
#include <sys/devfsext.h>
|
|
|
|
|
#endif
|
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 <pci/pcivar.h>
|
1999-03-03 21:10:29 +00:00
|
|
|
|
#include <dev/ata/ata-all.h>
|
|
|
|
|
#include <dev/ata/atapi-all.h>
|
|
|
|
|
#include <dev/ata/atapi-fd.h>
|
|
|
|
|
|
|
|
|
|
static d_open_t afdopen;
|
|
|
|
|
static d_close_t afdclose;
|
|
|
|
|
static d_ioctl_t afdioctl;
|
|
|
|
|
static d_strategy_t afdstrategy;
|
|
|
|
|
|
|
|
|
|
static struct cdevsw afd_cdevsw = {
|
1999-05-30 16:53:49 +00:00
|
|
|
|
/* open */ afdopen,
|
|
|
|
|
/* close */ afdclose,
|
|
|
|
|
/* read */ physread,
|
|
|
|
|
/* write */ physwrite,
|
|
|
|
|
/* ioctl */ afdioctl,
|
|
|
|
|
/* stop */ nostop,
|
|
|
|
|
/* reset */ noreset,
|
|
|
|
|
/* devtotty */ nodevtotty,
|
|
|
|
|
/* poll */ nopoll,
|
|
|
|
|
/* mmap */ nommap,
|
|
|
|
|
/* strategy */ afdstrategy,
|
|
|
|
|
/* name */ "afd",
|
|
|
|
|
/* parms */ noparms,
|
Nine'th update to the new ATA/ATAPI driver:
The atapi subsystem has gotten better error handeling and timeouts,
it also tries a REQUEST SENSE command when devices returns errors,
to give a little more info as to what went wrong. It might be a
little verbose for now, but I'm interested in as much feedback on
errors as possible, especially timeouts, as I'm a bit in doubt if
I've chosen resonable default values everywhere.
The disk driver has been changed a bit to prepare for tagged queing,
which is next on my list.
The disk driver has grown a dump routine, I got one implementation
from Darrell Anderson <anderson@cs.duke.edu> which also did
partial dumps (usefull on big memory machines) I left out the
partial stuff for now, and changed the rest alot to fit into the new
ad_request framework.
Some minor cleanups and rearrangements as well.
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, again you have been warned :)
Notebook owners should be carefull that their machines dont suspend
as this might cause trouble...
But please tell me how it works for you!
Enjoy!
-Søren
1999-06-25 09:03:07 +00:00
|
|
|
|
/* maj */ 118,
|
1999-05-30 16:53:49 +00:00
|
|
|
|
/* dump */ nodump,
|
|
|
|
|
/* psize */ nopsize,
|
|
|
|
|
/* flags */ D_DISK,
|
|
|
|
|
/* maxio */ 0,
|
Nine'th update to the new ATA/ATAPI driver:
The atapi subsystem has gotten better error handeling and timeouts,
it also tries a REQUEST SENSE command when devices returns errors,
to give a little more info as to what went wrong. It might be a
little verbose for now, but I'm interested in as much feedback on
errors as possible, especially timeouts, as I'm a bit in doubt if
I've chosen resonable default values everywhere.
The disk driver has been changed a bit to prepare for tagged queing,
which is next on my list.
The disk driver has grown a dump routine, I got one implementation
from Darrell Anderson <anderson@cs.duke.edu> which also did
partial dumps (usefull on big memory machines) I left out the
partial stuff for now, and changed the rest alot to fit into the new
ad_request framework.
Some minor cleanups and rearrangements as well.
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, again you have been warned :)
Notebook owners should be carefull that their machines dont suspend
as this might cause trouble...
But please tell me how it works for you!
Enjoy!
-Søren
1999-06-25 09:03:07 +00:00
|
|
|
|
/* bmaj */ 32,
|
1999-03-07 21:49:14 +00:00
|
|
|
|
};
|
1999-03-03 21:10:29 +00:00
|
|
|
|
|
|
|
|
|
#define NUNIT 8
|
|
|
|
|
#define UNIT(d) ((minor(d) >> 3) & 3)
|
|
|
|
|
|
Nine'th update to the new ATA/ATAPI driver:
The atapi subsystem has gotten better error handeling and timeouts,
it also tries a REQUEST SENSE command when devices returns errors,
to give a little more info as to what went wrong. It might be a
little verbose for now, but I'm interested in as much feedback on
errors as possible, especially timeouts, as I'm a bit in doubt if
I've chosen resonable default values everywhere.
The disk driver has been changed a bit to prepare for tagged queing,
which is next on my list.
The disk driver has grown a dump routine, I got one implementation
from Darrell Anderson <anderson@cs.duke.edu> which also did
partial dumps (usefull on big memory machines) I left out the
partial stuff for now, and changed the rest alot to fit into the new
ad_request framework.
Some minor cleanups and rearrangements as well.
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, again you have been warned :)
Notebook owners should be carefull that their machines dont suspend
as this might cause trouble...
But please tell me how it works for you!
Enjoy!
-Søren
1999-06-25 09:03:07 +00:00
|
|
|
|
#define F_OPEN 0x0001 /* the device is opened */
|
|
|
|
|
#define F_MEDIA_CHANGED 0x0002 /* the media have changed */
|
1999-03-03 21:10:29 +00:00
|
|
|
|
|
Nine'th update to the new ATA/ATAPI driver:
The atapi subsystem has gotten better error handeling and timeouts,
it also tries a REQUEST SENSE command when devices returns errors,
to give a little more info as to what went wrong. It might be a
little verbose for now, but I'm interested in as much feedback on
errors as possible, especially timeouts, as I'm a bit in doubt if
I've chosen resonable default values everywhere.
The disk driver has been changed a bit to prepare for tagged queing,
which is next on my list.
The disk driver has grown a dump routine, I got one implementation
from Darrell Anderson <anderson@cs.duke.edu> which also did
partial dumps (usefull on big memory machines) I left out the
partial stuff for now, and changed the rest alot to fit into the new
ad_request framework.
Some minor cleanups and rearrangements as well.
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, again you have been warned :)
Notebook owners should be carefull that their machines dont suspend
as this might cause trouble...
But please tell me how it works for you!
Enjoy!
-Søren
1999-06-25 09:03:07 +00:00
|
|
|
|
static struct afd_softc *afdtab[NUNIT]; /* drive info by unit number */
|
|
|
|
|
static int32_t afdnlun = 0; /* number of config'd drives */
|
1999-03-03 21:10:29 +00:00
|
|
|
|
|
|
|
|
|
int32_t afdattach(struct atapi_softc *);
|
|
|
|
|
static int32_t afd_sense(struct afd_softc *);
|
|
|
|
|
static void afd_describe(struct afd_softc *);
|
|
|
|
|
static void afd_strategy(struct buf *);
|
|
|
|
|
static void afd_start(struct afd_softc *);
|
1999-05-20 09:12:06 +00:00
|
|
|
|
static void afd_partial_done(struct atapi_request *);
|
1999-03-03 21:10:29 +00:00
|
|
|
|
static void afd_done(struct atapi_request *);
|
|
|
|
|
static int32_t afd_start_device(struct afd_softc *, int32_t);
|
|
|
|
|
static int32_t afd_lock_device(struct afd_softc *, int32_t);
|
|
|
|
|
static int32_t afd_eject(struct afd_softc *, int32_t);
|
|
|
|
|
static void afd_drvinit(void *);
|
|
|
|
|
|
|
|
|
|
int32_t
|
|
|
|
|
afdattach(struct atapi_softc *atp)
|
|
|
|
|
{
|
|
|
|
|
struct afd_softc *fdp;
|
|
|
|
|
|
|
|
|
|
if (afdnlun >= NUNIT) {
|
|
|
|
|
printf("afd: too many units\n");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
fdp = malloc(sizeof(struct afd_softc), M_TEMP, M_NOWAIT);
|
|
|
|
|
if (!fdp) {
|
|
|
|
|
printf("afd: out of memory\n");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
bzero(fdp, sizeof(struct afd_softc));
|
|
|
|
|
bufq_init(&fdp->buf_queue);
|
|
|
|
|
fdp->atp = atp;
|
|
|
|
|
fdp->lun = afdnlun;
|
|
|
|
|
fdp->flags = F_MEDIA_CHANGED;
|
|
|
|
|
|
|
|
|
|
if (afd_sense(fdp)) {
|
|
|
|
|
free(fdp, M_TEMP);
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
1999-05-20 09:12:06 +00:00
|
|
|
|
if (!strncmp(atp->atapi_parm->model, "IOMEGA ZIP", 11))
|
|
|
|
|
fdp->transfersize = 64;
|
|
|
|
|
|
1999-03-03 21:10:29 +00:00
|
|
|
|
afd_describe(fdp);
|
|
|
|
|
afdtab[afdnlun++] = fdp;
|
|
|
|
|
devstat_add_entry(&fdp->stats, "afd", fdp->lun, DEV_BSIZE,
|
|
|
|
|
DEVSTAT_NO_ORDERED_TAGS,
|
|
|
|
|
DEVSTAT_TYPE_DIRECT | DEVSTAT_TYPE_IF_IDE,
|
Nine'th update to the new ATA/ATAPI driver:
The atapi subsystem has gotten better error handeling and timeouts,
it also tries a REQUEST SENSE command when devices returns errors,
to give a little more info as to what went wrong. It might be a
little verbose for now, but I'm interested in as much feedback on
errors as possible, especially timeouts, as I'm a bit in doubt if
I've chosen resonable default values everywhere.
The disk driver has been changed a bit to prepare for tagged queing,
which is next on my list.
The disk driver has grown a dump routine, I got one implementation
from Darrell Anderson <anderson@cs.duke.edu> which also did
partial dumps (usefull on big memory machines) I left out the
partial stuff for now, and changed the rest alot to fit into the new
ad_request framework.
Some minor cleanups and rearrangements as well.
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, again you have been warned :)
Notebook owners should be carefull that their machines dont suspend
as this might cause trouble...
But please tell me how it works for you!
Enjoy!
-Søren
1999-06-25 09:03:07 +00:00
|
|
|
|
0x174);
|
1999-03-03 21:10:29 +00:00
|
|
|
|
#ifdef DEVFS
|
|
|
|
|
fdp->cdevs_token = devfs_add_devswf(&afd_cdevsw, dkmakeminor(fdp->lun, 0,0),
|
|
|
|
|
DV_CHR, UID_ROOT, GID_OPERATOR,
|
|
|
|
|
0640, "rafd%d", fdp->lun);
|
|
|
|
|
fdp->bdevs_token = devfs_add_devswf(&afd_cdevsw, dkmakeminor(fdp->lun, 0,0),
|
|
|
|
|
DV_BLK, UID_ROOT, GID_OPERATOR,
|
|
|
|
|
0640, "afd%d", fdp->lun);
|
|
|
|
|
#endif
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int32_t
|
|
|
|
|
afd_sense(struct afd_softc *fdp)
|
|
|
|
|
{
|
|
|
|
|
int32_t error, count;
|
|
|
|
|
int8_t buffer[256];
|
|
|
|
|
int8_t ccb[16] = { ATAPI_MODE_SENSE, 0, ATAPI_REWRITEABLE_CAP_PAGE,
|
|
|
|
|
0, 0, 0, 0, sizeof(buffer)>>8, sizeof(buffer) & 0xff,
|
|
|
|
|
0, 0, 0, 0, 0, 0, 0 };
|
|
|
|
|
|
|
|
|
|
bzero(buffer, sizeof(buffer));
|
Nine'th update to the new ATA/ATAPI driver:
The atapi subsystem has gotten better error handeling and timeouts,
it also tries a REQUEST SENSE command when devices returns errors,
to give a little more info as to what went wrong. It might be a
little verbose for now, but I'm interested in as much feedback on
errors as possible, especially timeouts, as I'm a bit in doubt if
I've chosen resonable default values everywhere.
The disk driver has been changed a bit to prepare for tagged queing,
which is next on my list.
The disk driver has grown a dump routine, I got one implementation
from Darrell Anderson <anderson@cs.duke.edu> which also did
partial dumps (usefull on big memory machines) I left out the
partial stuff for now, and changed the rest alot to fit into the new
ad_request framework.
Some minor cleanups and rearrangements as well.
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, again you have been warned :)
Notebook owners should be carefull that their machines dont suspend
as this might cause trouble...
But please tell me how it works for you!
Enjoy!
-Søren
1999-06-25 09:03:07 +00:00
|
|
|
|
/* get drive capabilities, some drives needs this repeated */
|
1999-03-03 21:10:29 +00:00
|
|
|
|
for (count = 0 ; count < 5 ; count++) {
|
|
|
|
|
if (!(error = atapi_queue_cmd(fdp->atp, ccb, buffer, sizeof(buffer),
|
Nine'th update to the new ATA/ATAPI driver:
The atapi subsystem has gotten better error handeling and timeouts,
it also tries a REQUEST SENSE command when devices returns errors,
to give a little more info as to what went wrong. It might be a
little verbose for now, but I'm interested in as much feedback on
errors as possible, especially timeouts, as I'm a bit in doubt if
I've chosen resonable default values everywhere.
The disk driver has been changed a bit to prepare for tagged queing,
which is next on my list.
The disk driver has grown a dump routine, I got one implementation
from Darrell Anderson <anderson@cs.duke.edu> which also did
partial dumps (usefull on big memory machines) I left out the
partial stuff for now, and changed the rest alot to fit into the new
ad_request framework.
Some minor cleanups and rearrangements as well.
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, again you have been warned :)
Notebook owners should be carefull that their machines dont suspend
as this might cause trouble...
But please tell me how it works for you!
Enjoy!
-Søren
1999-06-25 09:03:07 +00:00
|
|
|
|
A_READ, 30, NULL, NULL, NULL)))
|
1999-03-03 21:10:29 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
#ifdef AFD_DEBUG
|
|
|
|
|
atapi_dump("afd: sense", buffer, sizeof(buffer));
|
|
|
|
|
#endif
|
|
|
|
|
if (error)
|
|
|
|
|
return error;
|
|
|
|
|
bcopy(buffer, &fdp->header, sizeof(struct afd_header));
|
|
|
|
|
bcopy(buffer+sizeof(struct afd_header), &fdp->cap,
|
|
|
|
|
sizeof(struct afd_cappage));
|
|
|
|
|
if (fdp->cap.page_code != ATAPI_REWRITEABLE_CAP_PAGE)
|
|
|
|
|
return 1;
|
|
|
|
|
fdp->cap.cylinders = ntohs(fdp->cap.cylinders);
|
|
|
|
|
fdp->cap.sector_size = ntohs(fdp->cap.sector_size);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
afd_describe(struct afd_softc *fdp)
|
|
|
|
|
{
|
|
|
|
|
int8_t model_buf[40+1];
|
|
|
|
|
int8_t revision_buf[8+1];
|
|
|
|
|
|
|
|
|
|
bpack(fdp->atp->atapi_parm->model, model_buf, sizeof(model_buf));
|
|
|
|
|
bpack(fdp->atp->atapi_parm->revision, revision_buf, sizeof(revision_buf));
|
|
|
|
|
printf("afd%d: <%s/%s> rewriteable drive at ata%d as %s\n",
|
|
|
|
|
fdp->lun, model_buf, revision_buf,
|
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
|
|
|
|
fdp->atp->controller->lun,
|
1999-03-03 21:10:29 +00:00
|
|
|
|
(fdp->atp->unit == ATA_MASTER) ? "master" : "slave ");
|
|
|
|
|
printf("afd%d: %luMB (%u sectors), %u cyls, %u heads, %u S/T, %u B/S\n",
|
|
|
|
|
afdnlun,
|
|
|
|
|
(fdp->cap.cylinders * fdp->cap.heads * fdp->cap.sectors) /
|
1999-05-20 09:12:06 +00:00
|
|
|
|
((1024L * 1024L) / fdp->cap.sector_size),
|
1999-03-03 21:10:29 +00:00
|
|
|
|
fdp->cap.cylinders * fdp->cap.heads * fdp->cap.sectors,
|
|
|
|
|
fdp->cap.cylinders, fdp->cap.heads, fdp->cap.sectors,
|
|
|
|
|
fdp->cap.sector_size);
|
1999-05-20 09:12:06 +00:00
|
|
|
|
printf("afd%d: Medium: ", fdp->lun);
|
1999-03-03 21:10:29 +00:00
|
|
|
|
switch (fdp->header.medium_type) {
|
1999-05-20 09:12:06 +00:00
|
|
|
|
case MFD_2DD:
|
|
|
|
|
printf("720KB DD disk"); break;
|
|
|
|
|
|
|
|
|
|
case MFD_HD_12:
|
|
|
|
|
printf("1.2MB HD disk"); break;
|
|
|
|
|
|
|
|
|
|
case MFD_HD_144:
|
|
|
|
|
printf("1.44MB HD disk"); break;
|
|
|
|
|
|
|
|
|
|
case MFD_UHD:
|
|
|
|
|
printf("120MB UHD disk"); break;
|
|
|
|
|
|
1999-03-03 21:10:29 +00:00
|
|
|
|
default: printf("Unknown media (0x%x)", fdp->header.medium_type);
|
|
|
|
|
}
|
|
|
|
|
if (fdp->header.wp) printf(", writeprotected");
|
|
|
|
|
printf("\n");
|
|
|
|
|
}
|
|
|
|
|
|
1999-03-05 09:43:30 +00:00
|
|
|
|
static int
|
1999-03-03 21:10:29 +00:00
|
|
|
|
afdopen(dev_t dev, int32_t flags, int32_t fmt, struct proc *p)
|
|
|
|
|
{
|
|
|
|
|
struct afd_softc *fdp;
|
|
|
|
|
struct disklabel label;
|
|
|
|
|
int32_t lun = UNIT(dev);
|
|
|
|
|
|
|
|
|
|
if (lun >= afdnlun || !(fdp = afdtab[lun]))
|
|
|
|
|
return ENXIO;
|
|
|
|
|
|
|
|
|
|
fdp->flags &= ~F_MEDIA_CHANGED;
|
|
|
|
|
afd_lock_device(fdp, 1);
|
|
|
|
|
if (afd_sense(fdp))
|
|
|
|
|
printf("afd%d: sense media type failed\n", fdp->lun);
|
|
|
|
|
|
|
|
|
|
/* build disklabel and initilize slice tables */
|
|
|
|
|
bzero(&label, sizeof label);
|
|
|
|
|
label.d_secsize = fdp->cap.sector_size;
|
|
|
|
|
label.d_nsectors = fdp->cap.sectors;
|
|
|
|
|
label.d_ntracks = fdp->cap.heads;
|
|
|
|
|
label.d_ncylinders = fdp->cap.cylinders;
|
|
|
|
|
label.d_secpercyl = fdp->cap.heads * fdp->cap.sectors;
|
|
|
|
|
label.d_secperunit = fdp->cap.heads * fdp->cap.sectors * fdp->cap.cylinders;
|
|
|
|
|
|
Nine'th update to the new ATA/ATAPI driver:
The atapi subsystem has gotten better error handeling and timeouts,
it also tries a REQUEST SENSE command when devices returns errors,
to give a little more info as to what went wrong. It might be a
little verbose for now, but I'm interested in as much feedback on
errors as possible, especially timeouts, as I'm a bit in doubt if
I've chosen resonable default values everywhere.
The disk driver has been changed a bit to prepare for tagged queing,
which is next on my list.
The disk driver has grown a dump routine, I got one implementation
from Darrell Anderson <anderson@cs.duke.edu> which also did
partial dumps (usefull on big memory machines) I left out the
partial stuff for now, and changed the rest alot to fit into the new
ad_request framework.
Some minor cleanups and rearrangements as well.
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, again you have been warned :)
Notebook owners should be carefull that their machines dont suspend
as this might cause trouble...
But please tell me how it works for you!
Enjoy!
-Søren
1999-06-25 09:03:07 +00:00
|
|
|
|
/* initialize slice tables. */
|
1999-03-03 21:10:29 +00:00
|
|
|
|
return dsopen("afd", dev, fmt, 0, &fdp->slices, &label, afd_strategy,
|
|
|
|
|
(ds_setgeom_t *)NULL, &afd_cdevsw);
|
|
|
|
|
}
|
|
|
|
|
|
1999-03-05 09:43:30 +00:00
|
|
|
|
static int
|
1999-03-03 21:10:29 +00:00
|
|
|
|
afdclose(dev_t dev, int32_t flags, int32_t fmt, struct proc *p)
|
|
|
|
|
{
|
|
|
|
|
int32_t lun = UNIT(dev);
|
|
|
|
|
struct afd_softc *fdp;
|
|
|
|
|
|
|
|
|
|
if (lun >= afdnlun || !(fdp = afdtab[lun]))
|
|
|
|
|
return ENXIO;
|
|
|
|
|
|
|
|
|
|
dsclose(dev, fmt, fdp->slices);
|
|
|
|
|
if(!dsisopen(fdp->slices))
|
|
|
|
|
afd_lock_device(fdp, 0);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
1999-03-05 09:43:30 +00:00
|
|
|
|
static int
|
1999-03-03 21:10:29 +00:00
|
|
|
|
afdioctl(dev_t dev, u_long cmd, caddr_t addr, int32_t flag, struct proc *p)
|
|
|
|
|
{
|
|
|
|
|
int32_t lun = UNIT(dev);
|
|
|
|
|
int32_t error = 0;
|
|
|
|
|
struct afd_softc *fdp;
|
|
|
|
|
|
|
|
|
|
if (lun >= afdnlun || !(fdp = afdtab[lun]))
|
|
|
|
|
return ENXIO;
|
|
|
|
|
|
1999-03-07 21:49:14 +00:00
|
|
|
|
error = dsioctl("sd", dev, cmd, addr, flag, &fdp->slices,
|
|
|
|
|
afd_strategy, (ds_setgeom_t *)NULL);
|
|
|
|
|
|
|
|
|
|
if (error != ENOIOCTL)
|
|
|
|
|
return error;
|
1999-03-03 21:10:29 +00:00
|
|
|
|
|
1999-03-07 21:49:14 +00:00
|
|
|
|
switch (cmd) {
|
1999-03-03 21:10:29 +00:00
|
|
|
|
case CDIOCEJECT:
|
|
|
|
|
if ((fdp->flags & F_OPEN) && fdp->refcnt)
|
|
|
|
|
return EBUSY;
|
|
|
|
|
return afd_eject(fdp, 0);
|
|
|
|
|
|
|
|
|
|
case CDIOCCLOSE:
|
|
|
|
|
if ((fdp->flags & F_OPEN) && fdp->refcnt)
|
|
|
|
|
return 0;
|
|
|
|
|
return afd_eject(fdp, 1);
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
return ENOTTY;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
afdstrategy(struct buf *bp)
|
|
|
|
|
{
|
|
|
|
|
int32_t lun = UNIT(bp->b_dev);
|
|
|
|
|
struct afd_softc *fdp = afdtab[lun];
|
|
|
|
|
int32_t x;
|
|
|
|
|
|
|
|
|
|
if (bp->b_bcount == 0) {
|
|
|
|
|
bp->b_resid = 0;
|
|
|
|
|
biodone(bp);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (dscheck(bp, fdp->slices) <= 0) {
|
|
|
|
|
biodone(bp);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
x = splbio();
|
|
|
|
|
bufq_insert_tail(&fdp->buf_queue, bp);
|
|
|
|
|
afd_start(fdp);
|
|
|
|
|
splx(x);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
afd_strategy(struct buf *bp)
|
|
|
|
|
{
|
|
|
|
|
afdstrategy(bp);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
afd_start(struct afd_softc *fdp)
|
|
|
|
|
{
|
|
|
|
|
struct buf *bp = bufq_first(&fdp->buf_queue);
|
|
|
|
|
u_int32_t lba, count;
|
|
|
|
|
int8_t ccb[16];
|
1999-05-20 09:12:06 +00:00
|
|
|
|
int8_t *data_ptr;
|
1999-03-03 21:10:29 +00:00
|
|
|
|
|
|
|
|
|
if (!bp)
|
|
|
|
|
return;
|
1999-05-17 15:58:47 +00:00
|
|
|
|
|
1999-03-03 21:10:29 +00:00
|
|
|
|
bufq_remove(&fdp->buf_queue, bp);
|
|
|
|
|
|
Nine'th update to the new ATA/ATAPI driver:
The atapi subsystem has gotten better error handeling and timeouts,
it also tries a REQUEST SENSE command when devices returns errors,
to give a little more info as to what went wrong. It might be a
little verbose for now, but I'm interested in as much feedback on
errors as possible, especially timeouts, as I'm a bit in doubt if
I've chosen resonable default values everywhere.
The disk driver has been changed a bit to prepare for tagged queing,
which is next on my list.
The disk driver has grown a dump routine, I got one implementation
from Darrell Anderson <anderson@cs.duke.edu> which also did
partial dumps (usefull on big memory machines) I left out the
partial stuff for now, and changed the rest alot to fit into the new
ad_request framework.
Some minor cleanups and rearrangements as well.
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, again you have been warned :)
Notebook owners should be carefull that their machines dont suspend
as this might cause trouble...
But please tell me how it works for you!
Enjoy!
-Søren
1999-06-25 09:03:07 +00:00
|
|
|
|
/* should reject all queued entries if media have changed. */
|
1999-03-03 21:10:29 +00:00
|
|
|
|
if (fdp->flags & F_MEDIA_CHANGED) {
|
|
|
|
|
bp->b_error = EIO;
|
|
|
|
|
bp->b_flags |= B_ERROR;
|
|
|
|
|
biodone(bp);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lba = bp->b_blkno / (fdp->cap.sector_size / DEV_BSIZE);
|
|
|
|
|
count = (bp->b_bcount + (fdp->cap.sector_size - 1)) / fdp->cap.sector_size;
|
1999-05-20 09:12:06 +00:00
|
|
|
|
data_ptr = bp->b_data;
|
|
|
|
|
bp->b_resid = 0;
|
1999-03-07 21:49:14 +00:00
|
|
|
|
|
1999-05-17 15:58:47 +00:00
|
|
|
|
bzero(ccb, sizeof(ccb));
|
|
|
|
|
|
1999-03-03 21:10:29 +00:00
|
|
|
|
if (bp->b_flags & B_READ)
|
|
|
|
|
ccb[0] = ATAPI_READ_BIG;
|
|
|
|
|
else
|
|
|
|
|
ccb[0] = ATAPI_WRITE_BIG;
|
|
|
|
|
|
1999-05-20 09:12:06 +00:00
|
|
|
|
devstat_start_transaction(&fdp->stats);
|
|
|
|
|
|
|
|
|
|
while (fdp->transfersize && (count > fdp->transfersize)) {
|
|
|
|
|
ccb[2] = lba>>24;
|
|
|
|
|
ccb[3] = lba>>16;
|
|
|
|
|
ccb[4] = lba>>8;
|
|
|
|
|
ccb[5] = lba;
|
|
|
|
|
ccb[7] = fdp->transfersize>>8;
|
|
|
|
|
ccb[8] = fdp->transfersize;
|
|
|
|
|
|
|
|
|
|
atapi_queue_cmd(fdp->atp, ccb, data_ptr,
|
|
|
|
|
fdp->transfersize * fdp->cap.sector_size,
|
Nine'th update to the new ATA/ATAPI driver:
The atapi subsystem has gotten better error handeling and timeouts,
it also tries a REQUEST SENSE command when devices returns errors,
to give a little more info as to what went wrong. It might be a
little verbose for now, but I'm interested in as much feedback on
errors as possible, especially timeouts, as I'm a bit in doubt if
I've chosen resonable default values everywhere.
The disk driver has been changed a bit to prepare for tagged queing,
which is next on my list.
The disk driver has grown a dump routine, I got one implementation
from Darrell Anderson <anderson@cs.duke.edu> which also did
partial dumps (usefull on big memory machines) I left out the
partial stuff for now, and changed the rest alot to fit into the new
ad_request framework.
Some minor cleanups and rearrangements as well.
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, again you have been warned :)
Notebook owners should be carefull that their machines dont suspend
as this might cause trouble...
But please tell me how it works for you!
Enjoy!
-Søren
1999-06-25 09:03:07 +00:00
|
|
|
|
(bp->b_flags & B_READ) ? A_READ : 0, 30,
|
1999-05-20 09:12:06 +00:00
|
|
|
|
afd_partial_done, fdp, bp);
|
|
|
|
|
|
|
|
|
|
count -= fdp->transfersize;
|
|
|
|
|
lba += fdp->transfersize;
|
|
|
|
|
data_ptr += fdp->transfersize * fdp->cap.sector_size;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ccb[2] = lba>>24;
|
1999-03-03 21:10:29 +00:00
|
|
|
|
ccb[3] = lba>>16;
|
|
|
|
|
ccb[4] = lba>>8;
|
1999-05-20 09:12:06 +00:00
|
|
|
|
ccb[5] = lba;
|
1999-03-03 21:10:29 +00:00
|
|
|
|
ccb[7] = count>>8;
|
|
|
|
|
ccb[8] = count;
|
|
|
|
|
|
1999-05-20 09:12:06 +00:00
|
|
|
|
atapi_queue_cmd(fdp->atp, ccb, data_ptr, count * fdp->cap.sector_size,
|
Nine'th update to the new ATA/ATAPI driver:
The atapi subsystem has gotten better error handeling and timeouts,
it also tries a REQUEST SENSE command when devices returns errors,
to give a little more info as to what went wrong. It might be a
little verbose for now, but I'm interested in as much feedback on
errors as possible, especially timeouts, as I'm a bit in doubt if
I've chosen resonable default values everywhere.
The disk driver has been changed a bit to prepare for tagged queing,
which is next on my list.
The disk driver has grown a dump routine, I got one implementation
from Darrell Anderson <anderson@cs.duke.edu> which also did
partial dumps (usefull on big memory machines) I left out the
partial stuff for now, and changed the rest alot to fit into the new
ad_request framework.
Some minor cleanups and rearrangements as well.
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, again you have been warned :)
Notebook owners should be carefull that their machines dont suspend
as this might cause trouble...
But please tell me how it works for you!
Enjoy!
-Søren
1999-06-25 09:03:07 +00:00
|
|
|
|
(bp->b_flags & B_READ) ? A_READ : 0, 30, afd_done, fdp, bp);
|
1999-05-20 09:12:06 +00:00
|
|
|
|
}
|
1999-03-03 21:10:29 +00:00
|
|
|
|
|
1999-05-20 09:12:06 +00:00
|
|
|
|
static void
|
|
|
|
|
afd_partial_done(struct atapi_request *request)
|
|
|
|
|
{
|
|
|
|
|
struct buf *bp = request->bp;
|
|
|
|
|
|
|
|
|
|
if (request->result) {
|
Nine'th update to the new ATA/ATAPI driver:
The atapi subsystem has gotten better error handeling and timeouts,
it also tries a REQUEST SENSE command when devices returns errors,
to give a little more info as to what went wrong. It might be a
little verbose for now, but I'm interested in as much feedback on
errors as possible, especially timeouts, as I'm a bit in doubt if
I've chosen resonable default values everywhere.
The disk driver has been changed a bit to prepare for tagged queing,
which is next on my list.
The disk driver has grown a dump routine, I got one implementation
from Darrell Anderson <anderson@cs.duke.edu> which also did
partial dumps (usefull on big memory machines) I left out the
partial stuff for now, and changed the rest alot to fit into the new
ad_request framework.
Some minor cleanups and rearrangements as well.
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, again you have been warned :)
Notebook owners should be carefull that their machines dont suspend
as this might cause trouble...
But please tell me how it works for you!
Enjoy!
-Søren
1999-06-25 09:03:07 +00:00
|
|
|
|
bp->b_error = atapi_error(request->device, request->result);
|
1999-05-20 09:12:06 +00:00
|
|
|
|
bp->b_flags |= B_ERROR;
|
|
|
|
|
}
|
|
|
|
|
bp->b_resid += request->bytecount;
|
1999-03-03 21:10:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
afd_done(struct atapi_request *request)
|
|
|
|
|
{
|
|
|
|
|
struct buf *bp = request->bp;
|
|
|
|
|
struct afd_softc *fdp = request->driver;
|
|
|
|
|
|
1999-05-20 09:12:06 +00:00
|
|
|
|
if (request->result || (bp->b_flags & B_ERROR)) {
|
Nine'th update to the new ATA/ATAPI driver:
The atapi subsystem has gotten better error handeling and timeouts,
it also tries a REQUEST SENSE command when devices returns errors,
to give a little more info as to what went wrong. It might be a
little verbose for now, but I'm interested in as much feedback on
errors as possible, especially timeouts, as I'm a bit in doubt if
I've chosen resonable default values everywhere.
The disk driver has been changed a bit to prepare for tagged queing,
which is next on my list.
The disk driver has grown a dump routine, I got one implementation
from Darrell Anderson <anderson@cs.duke.edu> which also did
partial dumps (usefull on big memory machines) I left out the
partial stuff for now, and changed the rest alot to fit into the new
ad_request framework.
Some minor cleanups and rearrangements as well.
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, again you have been warned :)
Notebook owners should be carefull that their machines dont suspend
as this might cause trouble...
But please tell me how it works for you!
Enjoy!
-Søren
1999-06-25 09:03:07 +00:00
|
|
|
|
bp->b_error = atapi_error(request->device, request->result);
|
1999-03-03 21:10:29 +00:00
|
|
|
|
bp->b_flags |= B_ERROR;
|
|
|
|
|
}
|
|
|
|
|
else
|
1999-05-20 09:12:06 +00:00
|
|
|
|
bp->b_resid += request->bytecount;
|
|
|
|
|
|
|
|
|
|
devstat_end_transaction(&fdp->stats, bp->b_bcount - bp->b_resid,
|
|
|
|
|
DEVSTAT_TAG_NONE,
|
|
|
|
|
(bp->b_flags&B_READ) ? DEVSTAT_READ:DEVSTAT_WRITE);
|
|
|
|
|
|
1999-03-03 21:10:29 +00:00
|
|
|
|
biodone(bp);
|
|
|
|
|
afd_start(fdp);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int32_t
|
|
|
|
|
afd_start_device(struct afd_softc *fdp, int32_t start)
|
|
|
|
|
{
|
|
|
|
|
int8_t ccb[16] = { ATAPI_START_STOP, 0, 0, 0, start,
|
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
|
|
|
|
|
Nine'th update to the new ATA/ATAPI driver:
The atapi subsystem has gotten better error handeling and timeouts,
it also tries a REQUEST SENSE command when devices returns errors,
to give a little more info as to what went wrong. It might be a
little verbose for now, but I'm interested in as much feedback on
errors as possible, especially timeouts, as I'm a bit in doubt if
I've chosen resonable default values everywhere.
The disk driver has been changed a bit to prepare for tagged queing,
which is next on my list.
The disk driver has grown a dump routine, I got one implementation
from Darrell Anderson <anderson@cs.duke.edu> which also did
partial dumps (usefull on big memory machines) I left out the
partial stuff for now, and changed the rest alot to fit into the new
ad_request framework.
Some minor cleanups and rearrangements as well.
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, again you have been warned :)
Notebook owners should be carefull that their machines dont suspend
as this might cause trouble...
But please tell me how it works for you!
Enjoy!
-Søren
1999-06-25 09:03:07 +00:00
|
|
|
|
return atapi_queue_cmd(fdp->atp, ccb, NULL, 0, 0, 30, NULL, NULL, NULL);
|
1999-03-03 21:10:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int32_t
|
|
|
|
|
afd_lock_device(struct afd_softc *fdp, int32_t lock)
|
|
|
|
|
{
|
|
|
|
|
int8_t ccb[16] = { ATAPI_PREVENT_ALLOW, 0, 0, 0, lock,
|
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
|
|
|
|
|
Nine'th update to the new ATA/ATAPI driver:
The atapi subsystem has gotten better error handeling and timeouts,
it also tries a REQUEST SENSE command when devices returns errors,
to give a little more info as to what went wrong. It might be a
little verbose for now, but I'm interested in as much feedback on
errors as possible, especially timeouts, as I'm a bit in doubt if
I've chosen resonable default values everywhere.
The disk driver has been changed a bit to prepare for tagged queing,
which is next on my list.
The disk driver has grown a dump routine, I got one implementation
from Darrell Anderson <anderson@cs.duke.edu> which also did
partial dumps (usefull on big memory machines) I left out the
partial stuff for now, and changed the rest alot to fit into the new
ad_request framework.
Some minor cleanups and rearrangements as well.
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, again you have been warned :)
Notebook owners should be carefull that their machines dont suspend
as this might cause trouble...
But please tell me how it works for you!
Enjoy!
-Søren
1999-06-25 09:03:07 +00:00
|
|
|
|
return atapi_queue_cmd(fdp->atp, ccb, NULL, 0, 0, 30, NULL, NULL, NULL);
|
1999-03-03 21:10:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int32_t
|
|
|
|
|
afd_eject(struct afd_softc *fdp, int32_t close)
|
|
|
|
|
{
|
|
|
|
|
int32_t error;
|
|
|
|
|
|
|
|
|
|
error = afd_start_device(fdp, 0);
|
Nine'th update to the new ATA/ATAPI driver:
The atapi subsystem has gotten better error handeling and timeouts,
it also tries a REQUEST SENSE command when devices returns errors,
to give a little more info as to what went wrong. It might be a
little verbose for now, but I'm interested in as much feedback on
errors as possible, especially timeouts, as I'm a bit in doubt if
I've chosen resonable default values everywhere.
The disk driver has been changed a bit to prepare for tagged queing,
which is next on my list.
The disk driver has grown a dump routine, I got one implementation
from Darrell Anderson <anderson@cs.duke.edu> which also did
partial dumps (usefull on big memory machines) I left out the
partial stuff for now, and changed the rest alot to fit into the new
ad_request framework.
Some minor cleanups and rearrangements as well.
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, again you have been warned :)
Notebook owners should be carefull that their machines dont suspend
as this might cause trouble...
But please tell me how it works for you!
Enjoy!
-Søren
1999-06-25 09:03:07 +00:00
|
|
|
|
if (error == EBUSY || error == EAGAIN) {
|
1999-03-03 21:10:29 +00:00
|
|
|
|
if (!close)
|
|
|
|
|
return 0;
|
|
|
|
|
if ((error = afd_start_device(fdp, 3)))
|
|
|
|
|
return error;
|
Nine'th update to the new ATA/ATAPI driver:
The atapi subsystem has gotten better error handeling and timeouts,
it also tries a REQUEST SENSE command when devices returns errors,
to give a little more info as to what went wrong. It might be a
little verbose for now, but I'm interested in as much feedback on
errors as possible, especially timeouts, as I'm a bit in doubt if
I've chosen resonable default values everywhere.
The disk driver has been changed a bit to prepare for tagged queing,
which is next on my list.
The disk driver has grown a dump routine, I got one implementation
from Darrell Anderson <anderson@cs.duke.edu> which also did
partial dumps (usefull on big memory machines) I left out the
partial stuff for now, and changed the rest alot to fit into the new
ad_request framework.
Some minor cleanups and rearrangements as well.
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, again you have been warned :)
Notebook owners should be carefull that their machines dont suspend
as this might cause trouble...
But please tell me how it works for you!
Enjoy!
-Søren
1999-06-25 09:03:07 +00:00
|
|
|
|
return afd_lock_device(fdp, 1);
|
1999-03-03 21:10:29 +00:00
|
|
|
|
}
|
Nine'th update to the new ATA/ATAPI driver:
The atapi subsystem has gotten better error handeling and timeouts,
it also tries a REQUEST SENSE command when devices returns errors,
to give a little more info as to what went wrong. It might be a
little verbose for now, but I'm interested in as much feedback on
errors as possible, especially timeouts, as I'm a bit in doubt if
I've chosen resonable default values everywhere.
The disk driver has been changed a bit to prepare for tagged queing,
which is next on my list.
The disk driver has grown a dump routine, I got one implementation
from Darrell Anderson <anderson@cs.duke.edu> which also did
partial dumps (usefull on big memory machines) I left out the
partial stuff for now, and changed the rest alot to fit into the new
ad_request framework.
Some minor cleanups and rearrangements as well.
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, again you have been warned :)
Notebook owners should be carefull that their machines dont suspend
as this might cause trouble...
But please tell me how it works for you!
Enjoy!
-Søren
1999-06-25 09:03:07 +00:00
|
|
|
|
if (error)
|
|
|
|
|
return error;
|
|
|
|
|
|
1999-03-03 21:10:29 +00:00
|
|
|
|
if (close)
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
tsleep((caddr_t) &lbolt, PRIBIO, "afdej1", 0);
|
|
|
|
|
tsleep((caddr_t) &lbolt, PRIBIO, "afdej2", 0);
|
Nine'th update to the new ATA/ATAPI driver:
The atapi subsystem has gotten better error handeling and timeouts,
it also tries a REQUEST SENSE command when devices returns errors,
to give a little more info as to what went wrong. It might be a
little verbose for now, but I'm interested in as much feedback on
errors as possible, especially timeouts, as I'm a bit in doubt if
I've chosen resonable default values everywhere.
The disk driver has been changed a bit to prepare for tagged queing,
which is next on my list.
The disk driver has grown a dump routine, I got one implementation
from Darrell Anderson <anderson@cs.duke.edu> which also did
partial dumps (usefull on big memory machines) I left out the
partial stuff for now, and changed the rest alot to fit into the new
ad_request framework.
Some minor cleanups and rearrangements as well.
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, again you have been warned :)
Notebook owners should be carefull that their machines dont suspend
as this might cause trouble...
But please tell me how it works for you!
Enjoy!
-Søren
1999-06-25 09:03:07 +00:00
|
|
|
|
if ((error = afd_lock_device(fdp, 0)))
|
|
|
|
|
return error;
|
1999-03-03 21:10:29 +00:00
|
|
|
|
fdp->flags |= F_MEDIA_CHANGED;
|
|
|
|
|
return afd_start_device(fdp, 2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
afd_drvinit(void *unused)
|
|
|
|
|
{
|
1999-04-10 18:53:35 +00:00
|
|
|
|
static int32_t afd_devsw_installed = 0;
|
1999-03-03 21:10:29 +00:00
|
|
|
|
|
|
|
|
|
if (!afd_devsw_installed) {
|
Nine'th update to the new ATA/ATAPI driver:
The atapi subsystem has gotten better error handeling and timeouts,
it also tries a REQUEST SENSE command when devices returns errors,
to give a little more info as to what went wrong. It might be a
little verbose for now, but I'm interested in as much feedback on
errors as possible, especially timeouts, as I'm a bit in doubt if
I've chosen resonable default values everywhere.
The disk driver has been changed a bit to prepare for tagged queing,
which is next on my list.
The disk driver has grown a dump routine, I got one implementation
from Darrell Anderson <anderson@cs.duke.edu> which also did
partial dumps (usefull on big memory machines) I left out the
partial stuff for now, and changed the rest alot to fit into the new
ad_request framework.
Some minor cleanups and rearrangements as well.
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, again you have been warned :)
Notebook owners should be carefull that their machines dont suspend
as this might cause trouble...
But please tell me how it works for you!
Enjoy!
-Søren
1999-06-25 09:03:07 +00:00
|
|
|
|
if (!afd_cdevsw.d_maxio)
|
|
|
|
|
afd_cdevsw.d_maxio = 254 * DEV_BSIZE;
|
1999-05-31 11:29:30 +00:00
|
|
|
|
cdevsw_add(&afd_cdevsw);
|
1999-03-03 21:10:29 +00:00
|
|
|
|
afd_devsw_installed = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SYSINIT(afddev, SI_SUB_DRIVERS, SI_ORDER_MIDDLE, afd_drvinit, NULL)
|
|
|
|
|
#endif /* NATA & NATAPIFD */
|