summaryrefslogtreecommitdiffstats
path: root/sys/dev/ata/atapi-tape.c
diff options
context:
space:
mode:
authorsos <sos@FreeBSD.org>2000-02-18 20:57:33 +0000
committersos <sos@FreeBSD.org>2000-02-18 20:57:33 +0000
commit6feaaed878ea54ff19a32fb1fa9e961f31156bf9 (patch)
treedf6b1c424ce11d10280d0e2830b96a3eb27b5673 /sys/dev/ata/atapi-tape.c
parenteeff6080d3810c5a858215f55e4a05d7a095f464 (diff)
downloadFreeBSD-src-6feaaed878ea54ff19a32fb1fa9e961f31156bf9.zip
FreeBSD-src-6feaaed878ea54ff19a32fb1fa9e961f31156bf9.tar.gz
Update the ata driver to take more advantage of newbus, this
was needed to make attach/detach of devices work, which is needed for the PCCARD support. (PCCARD support is still not working though, more to come on that) Support the CMD646 chip which is used on many alphas, sadly only in WDMA2 mode, as the silicon is broken beyond belief for UDMA modes. Lots of cosmetic fixes here and there. Sorry for the size of this megapatchfromhell but it was not possible otherwise... newbus patches based on work from: dfr (Doug Rabson)
Diffstat (limited to 'sys/dev/ata/atapi-tape.c')
-rw-r--r--sys/dev/ata/atapi-tape.c37
1 files changed, 26 insertions, 11 deletions
diff --git a/sys/dev/ata/atapi-tape.c b/sys/dev/ata/atapi-tape.c
index 71c69ca..9d41648 100644
--- a/sys/dev/ata/atapi-tape.c
+++ b/sys/dev/ata/atapi-tape.c
@@ -28,7 +28,6 @@
* $FreeBSD$
*/
-#include "apm.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
@@ -39,18 +38,15 @@
#include <sys/mtio.h>
#include <sys/disklabel.h>
#include <sys/devicestat.h>
-#if NAPM > 0
-#include <machine/apm_bios.h>
-#endif
#include <dev/ata/ata-all.h>
#include <dev/ata/atapi-all.h>
#include <dev/ata/atapi-tape.h>
+/* device structures */
static d_open_t astopen;
static d_close_t astclose;
static d_ioctl_t astioctl;
static d_strategy_t aststrategy;
-
static struct cdevsw ast_cdevsw = {
/* open */ astopen,
/* close */ astclose,
@@ -70,6 +66,7 @@ static struct cdevsw ast_cdevsw = {
/* prototypes */
int32_t astattach(struct atapi_softc *);
+void astdetach(struct atapi_softc *);
static int32_t ast_sense(struct ast_softc *);
static void ast_describe(struct ast_softc *);
static void ast_start(struct ast_softc *);
@@ -86,6 +83,7 @@ static int32_t ast_rewind(struct ast_softc *);
static int32_t ast_erase(struct ast_softc *);
/* internal vars */
+static u_int32_t ast_lun_map = 0;
static u_int64_t ast_total = 0;
MALLOC_DEFINE(M_AST, "AST driver", "ATAPI tape driver buffers");
@@ -95,7 +93,7 @@ astattach(struct atapi_softc *atp)
struct ast_softc *stp;
struct ast_readposition position;
dev_t dev;
- static int32_t ast_cdev_done = 0, astnlun = 0;
+ static int32_t ast_cdev_done = 0;
if (!ast_cdev_done) {
cdevsw_add(&ast_cdevsw);
@@ -109,12 +107,14 @@ astattach(struct atapi_softc *atp)
bzero(stp, sizeof(struct ast_softc));
bufq_init(&stp->buf_queue);
stp->atp = atp;
- stp->lun = astnlun++;
- stp->atp->flags |= ATAPI_F_MEDIA_CHANGED;
+ stp->lun = ata_get_lun(&ast_lun_map);
if (ast_sense(stp)) {
free(stp, M_AST);
return -1;
}
+ stp->atp->flags |= ATAPI_F_MEDIA_CHANGED;
+ stp->atp->driver = stp;
+
if (!strcmp(ATA_PARAM(stp->atp->controller, stp->atp->unit)->model,
"OnStream DI-30")) {
struct ast_transferpage transfer;
@@ -139,16 +139,31 @@ astattach(struct atapi_softc *atp)
UID_ROOT, GID_OPERATOR, 0640, "ast%d", stp->lun);
dev->si_drv1 = stp;
dev->si_iosize_max = 252 * DEV_BSIZE;
+ stp->dev1 = dev;
dev = make_dev(&ast_cdevsw, dkmakeminor(stp->lun, 0, 1),
UID_ROOT, GID_OPERATOR, 0640, "nast%d", stp->lun);
dev->si_drv1 = stp;
dev->si_iosize_max = 252 * DEV_BSIZE;
+ stp->dev2 = dev;
if ((stp->atp->devname = malloc(8, M_AST, M_NOWAIT)))
sprintf(stp->atp->devname, "ast%d", stp->lun);
ast_describe(stp);
return 0;
}
+void
+astdetach(struct atapi_softc *atp)
+{
+ struct ast_softc *stp = atp->driver;
+
+ destroy_dev(stp->dev1);
+ destroy_dev(stp->dev2);
+ devstat_remove_entry(&stp->stats);
+ free(stp->atp->devname, M_AST);
+ ata_free_lun(&ast_lun_map, stp->lun);
+ free(stp, M_AST);
+}
+
static int32_t
ast_sense(struct ast_softc *stp)
{
@@ -184,7 +199,7 @@ ast_describe(struct ast_softc *stp)
printf("ast%d: <%.40s/%.8s> tape drive at ata%d as %s\n",
stp->lun, ATA_PARAM(stp->atp->controller, stp->atp->unit)->model,
ATA_PARAM(stp->atp->controller, stp->atp->unit)->revision,
- stp->atp->controller->lun,
+ device_get_unit(stp->atp->controller->dev),
(stp->atp->unit == ATA_MASTER) ? "master" : "slave");
printf("ast%d: ", stp->lun);
printf("%dKB/s, ", stp->cap.max_speed);
@@ -225,7 +240,7 @@ ast_describe(struct ast_softc *stp)
else {
printf("ast%d: TAPE <%.40s> at ata%d-%s using %s\n",
stp->lun, ATA_PARAM(stp->atp->controller, stp->atp->unit)->model,
- stp->atp->controller->lun,
+ device_get_unit(stp->atp->controller->dev),
(stp->atp->unit == ATA_MASTER) ? "master" : "slave",
ata_mode2str(stp->atp->controller->mode[ATA_DEV(stp->atp->unit)])
);
@@ -482,7 +497,7 @@ static int32_t
ast_done(struct atapi_request *request)
{
struct buf *bp = request->bp;
- struct ast_softc *stp = request->driver;
+ struct ast_softc *stp = request->device->driver;
if (request->error) {
bp->b_error = request->error;
OpenPOWER on IntegriCloud