diff options
| author | Søren Schmidt <sos@FreeBSD.org> | 2001-02-25 21:35:21 +0000 |
|---|---|---|
| committer | Søren Schmidt <sos@FreeBSD.org> | 2001-02-25 21:35:21 +0000 |
| commit | 4e2b6871693bd38bf8f6011939b8362dafe9a0d1 (patch) | |
| tree | 642560b5d3adf38cf6aac47400bab5da1d14045e | |
| parent | fd106a820620b99b55d7ba14057dd34a7af7e3e4 (diff) | |
Notes
| -rw-r--r-- | sys/dev/ata/ata-all.c | 25 | ||||
| -rw-r--r-- | sys/dev/ata/ata-all.h | 2 | ||||
| -rw-r--r-- | sys/dev/ata/ata-disk.c | 31 | ||||
| -rw-r--r-- | sys/dev/ata/ata-disk.h | 2 | ||||
| -rw-r--r-- | sys/dev/ata/ata-dma.c | 48 | ||||
| -rw-r--r-- | sys/dev/ata/ata-raid.c | 2 | ||||
| -rw-r--r-- | sys/dev/ata/ata-raid.h | 2 | ||||
| -rw-r--r-- | sys/dev/ata/atapi-all.c | 39 | ||||
| -rw-r--r-- | sys/dev/ata/atapi-all.h | 7 | ||||
| -rw-r--r-- | sys/dev/ata/atapi-cd.c | 72 | ||||
| -rw-r--r-- | sys/dev/ata/atapi-cd.h | 31 | ||||
| -rw-r--r-- | sys/dev/ata/atapi-fd.c | 7 | ||||
| -rw-r--r-- | sys/dev/ata/atapi-fd.h | 2 | ||||
| -rw-r--r-- | sys/dev/ata/atapi-tape.c | 7 | ||||
| -rw-r--r-- | sys/dev/ata/atapi-tape.h | 2 |
15 files changed, 165 insertions, 114 deletions
diff --git a/sys/dev/ata/ata-all.c b/sys/dev/ata/ata-all.c index d04d87f300a4..437e9d043070 100644 --- a/sys/dev/ata/ata-all.c +++ b/sys/dev/ata/ata-all.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 1998,1999,2000 Søren Schmidt + * Copyright (c) 1998,1999,2000,2001 Søren Schmidt * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -97,7 +97,7 @@ static devclass_t ata_devclass; static devclass_t ata_pci_devclass; static struct intr_config_hook *ata_delayed_attach = NULL; static char ata_conf[256]; -MALLOC_DEFINE(M_ATA, "ATA generic", "ATA driver generic layer"); +static MALLOC_DEFINE(M_ATA, "ATA generic", "ATA driver generic layer"); #if NISA > 0 static struct isa_pnp_id ata_ids[] = { @@ -271,12 +271,16 @@ ata_pci_match(device_t dev) return "AcerLabs Aladdin ATA33 controller"; case 0x05711106: - if (ata_find_dev(dev, 0x05861106, 0)) + if (ata_find_dev(dev, 0x05861106, 0x02)) return "VIA 82C586 ATA33 controller"; + if (ata_find_dev(dev, 0x05861106, 0)) + return "VIA 82C586 ATA controller"; if (ata_find_dev(dev, 0x05961106, 0x12)) return "VIA 82C596 ATA66 controller"; if (ata_find_dev(dev, 0x05961106, 0)) return "VIA 82C596 ATA33 controller"; + if (ata_find_dev(dev, 0x06861106, 0x40)) + return "VIA 82C686 ATA100 controller"; if (ata_find_dev(dev, 0x06861106, 0)) return "VIA 82C686 ATA66 controller"; return "VIA Apollo ATA controller"; @@ -451,6 +455,7 @@ ata_pci_attach(device_t dev) case 0x05711106: case 0x74091022: /* VIA 82C586, 82C596, 82C686 & AMD 756 default setup */ + /* set prefetch, postwrite */ pci_write_config(dev, 0x41, pci_read_config(dev, 0x41, 1) | 0xf0, 1); @@ -736,18 +741,17 @@ static int ata_pcisub_probe(device_t dev) { struct ata_softc *scp = device_get_softc(dev); - device_t *list; + device_t *children; int count, i; /* find channel number on this controller */ - device_get_children(device_get_parent(dev), &list, &count); + device_get_children(device_get_parent(dev), &children, &count); for (i = 0; i < count; i++) { - if (list[i] == dev) + if (children[i] == dev) scp->channel = i; } - + free(children, M_TEMP); scp->chiptype = pci_get_devid(device_get_parent(dev)); - return ata_probe(dev); } @@ -1794,12 +1798,11 @@ ata_init(void) { /* register boot attach to be run when interrupts are enabled */ if (!(ata_delayed_attach = (struct intr_config_hook *) - malloc(sizeof(struct intr_config_hook), - M_TEMP, M_NOWAIT))) { + malloc(sizeof(struct intr_config_hook), + M_TEMP, M_NOWAIT | M_ZERO))) { printf("ata: malloc of delayed attach hook failed\n"); return; } - bzero(ata_delayed_attach, sizeof(struct intr_config_hook)); ata_delayed_attach->ich_func = (void*)ata_boot_attach; if (config_intrhook_establish(ata_delayed_attach) != 0) { diff --git a/sys/dev/ata/ata-all.h b/sys/dev/ata/ata-all.h index 4d2e6c1c30b5..afe1d54224fd 100644 --- a/sys/dev/ata/ata-all.h +++ b/sys/dev/ata/ata-all.h @@ -1,5 +1,5 @@ /*- - * Copyright (c) 1998,1999,2000 Søren Schmidt + * Copyright (c) 1998,1999,2000,2001 Søren Schmidt * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/dev/ata/ata-disk.c b/sys/dev/ata/ata-disk.c index 1fda7dff49a3..964b21e241d4 100644 --- a/sys/dev/ata/ata-disk.c +++ b/sys/dev/ata/ata-disk.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 1998,1999,2000 Søren Schmidt + * Copyright (c) 1998,1999,2000,2001 Søren Schmidt * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -28,7 +28,6 @@ * $FreeBSD$ */ -#include "apm.h" #include "opt_global.h" #include "opt_ata.h" #include <sys/param.h> @@ -41,6 +40,7 @@ #include <sys/disk.h> #include <sys/devicestat.h> #include <sys/cons.h> +#include <sys/syslog.h> #include <vm/vm.h> #include <vm/pmap.h> #include <machine/bus.h> @@ -98,7 +98,7 @@ static int ad_version(u_int16_t); /* internal vars */ static u_int32_t adp_lun_map = 0; -MALLOC_DEFINE(M_AD, "AD driver", "ATA disk driver"); +static MALLOC_DEFINE(M_AD, "AD driver", "ATA disk driver"); /* defines */ #define AD_MAX_RETRIES 3 @@ -115,11 +115,10 @@ ad_attach(struct ata_softc *scp, int device) int secsperint; - if (!(adp = malloc(sizeof(struct ad_softc), M_AD, M_NOWAIT))) { + if (!(adp = malloc(sizeof(struct ad_softc), M_AD, M_NOWAIT | M_ZERO))) { ata_printf(scp, device, "failed to allocate driver storage\n"); return; } - bzero(adp, sizeof(struct ad_softc)); scp->dev_softc[ATA_DEV(device)] = adp; adp->controller = scp; adp->unit = device; @@ -153,10 +152,15 @@ ad_attach(struct ata_softc *scp, int device) 0, 0, 0, 0, ATA_C_F_ENAB_RCACHE, ATA_WAIT_INTR)) printf("ad%d: enabling readahead cache failed\n", adp->lun); +#if defined(ATA_ENABLE_WC) || defined(ATA_ENABLE_TAGS) if (ata_command(adp->controller, adp->unit, ATA_C_SETFEATURES, 0, 0, 0, 0, ATA_C_F_ENAB_WCACHE, ATA_WAIT_INTR)) printf("ad%d: enabling write cache failed\n", adp->lun); - +#else + if (ata_command(adp->controller, adp->unit, ATA_C_SETFEATURES, + 0, 0, 0, 0, ATA_C_F_DIS_WCACHE, ATA_WAIT_INTR)) + printf("ad%d: disabling write cache failed\n", adp->lun); +#endif /* use DMA if drive & controller supports it */ ata_dmainit(adp->controller, adp->unit, ata_pmode(AD_PARAM), ata_wmode(AD_PARAM), ata_umode(AD_PARAM)); @@ -376,13 +380,12 @@ ad_start(struct ad_softc *adp) return; } - if (!(request = malloc(sizeof(struct ad_request), M_AD, M_NOWAIT))) { + if (!(request = malloc(sizeof(struct ad_request), M_AD, M_NOWAIT|M_ZERO))) { printf("ad%d: out of memory in start\n", adp->lun); return; } /* setup request */ - bzero(request, sizeof(struct ad_request)); request->device = adp; request->bp = bp; request->blockaddr = bp->b_pblkno; @@ -592,16 +595,18 @@ ad_interrupt(struct ad_request *request) /* do we have a corrected soft error ? */ if (adp->controller->status & ATA_S_CORR) - printf("ad%d: soft error ECC corrected\n", adp->lun); + diskerr(request->bp, "soft (ECC corrected)", LOG_PRINTF, + request->blockaddr + (request->donecount / DEV_BSIZE), + &adp->disk.d_label); /* did any real errors happen ? */ if ((adp->controller->status & ATA_S_ERROR) || (request->flags & ADR_F_DMA_USED && dma_stat & ATA_BMSTAT_ERROR)) { adp->controller->error = inb(adp->controller->ioaddr + ATA_ERROR); - printf("ad%d: %s %s ERROR blk# %d", adp->lun, - (adp->controller->error & ATA_E_ICRC) ? "UDMA ICRC" : "HARD", - (request->flags & ADR_F_READ) ? "READ" : "WRITE", - request->blockaddr + (request->donecount / DEV_BSIZE)); + diskerr(request->bp, + (adp->controller->error & ATA_E_ICRC) ? "UDMA ICRC" : "hard", + LOG_PRINTF, request->blockaddr + (request->donecount/DEV_BSIZE), + &adp->disk.d_label); /* if this is a UDMA CRC error, reinject request */ if (request->flags & ADR_F_DMA_USED && diff --git a/sys/dev/ata/ata-disk.h b/sys/dev/ata/ata-disk.h index 01e88222517f..2fbe5085cad8 100644 --- a/sys/dev/ata/ata-disk.h +++ b/sys/dev/ata/ata-disk.h @@ -1,5 +1,5 @@ /*- - * Copyright (c) 1998,1999,2000 Søren Schmidt + * Copyright (c) 1998,1999,2000,2001 Søren Schmidt * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/dev/ata/ata-dma.c b/sys/dev/ata/ata-dma.c index afc2bb68a2a8..a7ecb03d49a1 100644 --- a/sys/dev/ata/ata-dma.c +++ b/sys/dev/ata/ata-dma.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 1998,1999,2000 Søren Schmidt + * Copyright (c) 1998,1999,2000,2001 Søren Schmidt * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -353,9 +353,49 @@ ata_dmainit(struct ata_softc *scp, int device, goto via_82c586; case 0x05711106: /* VIA 82C571, 82C586, 82C596, 82C686 */ - if (ata_find_dev(parent, 0x06861106, 0) || /* 82C686a */ - ata_find_dev(parent, 0x05961106, 0x12)) { /* 82C596b */ - + if (ata_find_dev(parent, 0x06861106, 0x40)) { /* 82C686b */ + if (udmamode >= 5) { + error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0, + ATA_UDMA5, ATA_C_F_SETXFER, ATA_WAIT_READY); + if (bootverbose) + ata_printf(scp, device, + "%s setting UDMA5 on VIA chip\n", + (error) ? "failed" : "success"); + if (!error) { + pci_write_config(parent, 0x53 - devno, 0xf0, 1); + scp->mode[ATA_DEV(device)] = ATA_UDMA5; + return; + } + } + if (udmamode >= 4) { + error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0, + ATA_UDMA4, ATA_C_F_SETXFER, ATA_WAIT_READY); + if (bootverbose) + ata_printf(scp, device, + "%s setting UDMA4 on VIA chip\n", + (error) ? "failed" : "success"); + if (!error) { + pci_write_config(parent, 0x53 - devno, 0xf1, 1); + scp->mode[ATA_DEV(device)] = ATA_UDMA4; + return; + } + } + if (udmamode >= 2) { + error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0, + ATA_UDMA2, ATA_C_F_SETXFER, ATA_WAIT_READY); + if (bootverbose) + ata_printf(scp, device, + "%s setting UDMA2 on VIA chip\n", + (error) ? "failed" : "success"); + if (!error) { + pci_write_config(parent, 0x53 - devno, 0xf4, 1); + scp->mode[ATA_DEV(device)] = ATA_UDMA2; + return; + } + } + } + else if (ata_find_dev(parent, 0x06861106, 0) || /* 82C686a */ + ata_find_dev(parent, 0x05961106, 0x12)) { /* 82C596b */ if (udmamode >= 4) { error = ata_command(scp, device, ATA_C_SETFEATURES, 0, 0, 0, ATA_UDMA4, ATA_C_F_SETXFER, ATA_WAIT_READY); diff --git a/sys/dev/ata/ata-raid.c b/sys/dev/ata/ata-raid.c index df295150a5ec..5fdb0eb077e5 100644 --- a/sys/dev/ata/ata-raid.c +++ b/sys/dev/ata/ata-raid.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2000 Søren Schmidt + * Copyright (c) 2000,2001 Søren Schmidt * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/dev/ata/ata-raid.h b/sys/dev/ata/ata-raid.h index 0278642f09b7..2cc7d0128797 100644 --- a/sys/dev/ata/ata-raid.h +++ b/sys/dev/ata/ata-raid.h @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2000 Søren Schmidt + * Copyright (c) 2000,2001 Søren Schmidt * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/dev/ata/atapi-all.c b/sys/dev/ata/atapi-all.c index 5d8e0dd75482..f1d8c57726b6 100644 --- a/sys/dev/ata/atapi-all.c +++ b/sys/dev/ata/atapi-all.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 1998,1999,2000 Søren Schmidt + * Copyright (c) 1998,1999,2000,2001 Søren Schmidt * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -52,7 +52,7 @@ static char *atapi_cmd2str(u_int8_t); static char *atapi_skey2str(u_int8_t); /* internal vars */ -MALLOC_DEFINE(M_ATAPI, "ATAPI generic", "ATAPI driver generic layer"); +static MALLOC_DEFINE(M_ATAPI, "ATAPI generic", "ATAPI driver generic layer"); /* defines */ #define ATAPI_MAX_RETRIES 3 @@ -63,11 +63,10 @@ atapi_attach(struct ata_softc *scp, int device) { struct atapi_softc *atp; - if (!(atp = malloc(sizeof(struct atapi_softc), M_ATAPI, M_NOWAIT))) { + if (!(atp = malloc(sizeof(struct atapi_softc), M_ATAPI, M_NOWAIT|M_ZERO))) { ata_printf(scp, device, "failed to allocate driver storage\n"); return; } - bzero(atp, sizeof(struct atapi_softc)); atp->controller = scp; atp->unit = device; if (bootverbose) @@ -155,10 +154,10 @@ atapi_queue_cmd(struct atapi_softc *atp, int8_t *ccb, caddr_t data, struct atapi_request *request; int error, s; - if (!(request = malloc(sizeof(struct atapi_request), M_ATAPI, M_NOWAIT))) + if (!(request = malloc(sizeof(struct atapi_request), M_ATAPI, + M_NOWAIT | M_ZERO))) return ENOMEM; - bzero(request, sizeof(struct atapi_request)); request->device = atp; request->data = data; request->bytecount = count; @@ -274,7 +273,7 @@ atapi_transfer(struct atapi_request *request) request->timeout_handle = timeout((timeout_t *)atapi_timeout, request, request->timeout); - if (request->ccb[0] != ATAPI_REQUEST_SENSE) + if (!(request->flags & ATPR_F_INTERNAL)) atp->cmd = request->ccb[0]; /* if DMA enabled setup DMA hardware */ @@ -333,12 +332,8 @@ int atapi_interrupt(struct atapi_request *request) { struct atapi_softc *atp = request->device; - int8_t **buffer = (int8_t **)&request->data; int reason, dma_stat = 0; - if (request->ccb[0] == ATAPI_REQUEST_SENSE) - *buffer = (int8_t *)&request->sense; - reason = (inb(atp->controller->ioaddr+ATA_IREASON) & (ATA_I_CMD|ATA_I_IN)) | (atp->controller->status & ATA_S_DRQ); @@ -403,7 +398,7 @@ atapi_interrupt(struct atapi_request *request) if (atp->controller->status & (ATA_S_ERROR | ATA_S_DWF)) request->result = inb(atp->controller->ioaddr + ATA_ERROR); else - if (request->ccb[0] != ATAPI_REQUEST_SENSE) + if (!(request->flags & ATPR_F_INTERNAL)) request->result = 0; break; @@ -422,11 +417,10 @@ op_finished: request->ccb[0] = ATAPI_REQUEST_SENSE; request->ccb[4] = sizeof(struct atapi_reqsense); request->bytecount = sizeof(struct atapi_reqsense); - request->flags = ATPR_F_READ; + request->flags = ATPR_F_READ | ATPR_F_INTERNAL; TAILQ_INSERT_HEAD(&atp->controller->atapi_queue, request, chain); } else { - request->error = 0; if (request->result) { switch ((request->result & ATAPI_SK_MASK)) { case ATAPI_SK_RESERVED: @@ -456,14 +450,21 @@ op_finished: break; default: - printf("%s: %s - %s asc=%02x ascq=%02x error=%02x\n", + printf("%s: %s - %s asc=%02x ascq=%02x ", atp->devname, atapi_cmd2str(atp->cmd), atapi_skey2str(request->sense.sense_key), - request->sense.asc, request->sense.ascq, - request->result & ATAPI_E_MASK); + request->sense.asc, request->sense.ascq); + if (request->sense.sksv) + printf("sks=%02x %02x %02x ", + request->sense.sk_specific, + request->sense.sk_specific1, + request->sense.sk_specific2); + printf("error=%02x\n", request->result & ATAPI_E_MASK); request->error = EIO; } } + else + request->error = 0; if (request->callback) { #ifdef ATAPI_DEBUG printf("%s: finished %s (callback)\n", @@ -542,7 +543,7 @@ atapi_read(struct atapi_request *request, int length) int size = min(request->bytecount, length); int resid; - if (request->ccb[0] == ATAPI_REQUEST_SENSE) + if (request->flags & ATPR_F_INTERNAL) *buffer = (int8_t *)&request->sense; if (request->device->controller->flags & ATA_USE_16BIT || @@ -571,7 +572,7 @@ atapi_write(struct atapi_request *request, int length) int size = min(request->bytecount, length); int resid; - if (request->ccb[0] == ATAPI_REQUEST_SENSE) + if (request->flags & ATPR_F_INTERNAL) *buffer = (int8_t *)&request->sense; if (request->device->controller->flags & ATA_USE_16BIT || diff --git a/sys/dev/ata/atapi-all.h b/sys/dev/ata/atapi-all.h index b81770fa3757..eebc31981de0 100644 --- a/sys/dev/ata/atapi-all.h +++ b/sys/dev/ata/atapi-all.h @@ -1,5 +1,5 @@ /*- - * Copyright (c) 1998,1999,2000 Søren Schmidt + * Copyright (c) 1998,1999,2000,2001 Søren Schmidt * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -136,10 +136,10 @@ struct atapi_reqsense { u_int8_t asc; /* additional sense code */ u_int8_t ascq; /* additional sense code qual */ u_int8_t replaceable_unit_code; /* replaceable unit code */ - u_int8_t sk_specific1 :7; /* sense key specific */ + u_int8_t sk_specific :7; /* sense key specific */ u_int8_t sksv :1; /* sense key specific info OK */ + u_int8_t sk_specific1; /* sense key specific */ u_int8_t sk_specific2; /* sense key specific */ - u_int8_t sk_specific3; /* sense key specific */ }; struct atapi_softc { @@ -171,6 +171,7 @@ struct atapi_request { #define ATPR_F_READ 0x0001 #define ATPR_F_DMA_USED 0x0002 #define ATPR_F_AT_HEAD 0x0004 +#define ATPR_F_INTERNAL 0x0008 caddr_t data; /* pointer to data buf */ atapi_callback_t *callback; /* ptr to callback func */ diff --git a/sys/dev/ata/atapi-cd.c b/sys/dev/ata/atapi-cd.c index a2b9ec969419..5aebda241450 100644 --- a/sys/dev/ata/atapi-cd.c +++ b/sys/dev/ata/atapi-cd.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 1998,1999,2000 Søren Schmidt + * Copyright (c) 1998,1999,2000,2001 Søren Schmidt * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -82,13 +82,13 @@ static int acd_setchan(struct acd_softc *, u_int8_t, u_int8_t, u_int8_t, u_int8_ static void acd_select_slot(struct acd_softc *); static int acd_open_track(struct acd_softc *, struct cdr_track *); static int acd_close_track(struct acd_softc *); -static int acd_close_disk(struct acd_softc *); +static int acd_close_disk(struct acd_softc *, int); static int acd_read_track_info(struct acd_softc *, int32_t, struct acd_track_info*); static int acd_report_key(struct acd_softc *, struct dvd_authinfo *); static int acd_send_key(struct acd_softc *, struct dvd_authinfo *); static int acd_read_structure(struct acd_softc *, struct dvd_struct *); static int acd_eject(struct acd_softc *, int); -static int acd_blank(struct acd_softc *); +static int acd_blank(struct acd_softc *, int); static int acd_prevent_allow(struct acd_softc *, int); static int acd_start_stop(struct acd_softc *, int); static int acd_pause_resume(struct acd_softc *, int); @@ -977,7 +977,7 @@ acdioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct proc *p) break; case CDRIOCBLANK: - error = acd_blank(cdp); + error = acd_blank(cdp, (*(int *)addr)); break; case CDRIOCNEXTWRITEABLEADDR: @@ -1007,7 +1007,7 @@ acdioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct proc *p) break; case CDRIOCCLOSEDISK: - error = acd_close_disk(cdp); + error = acd_close_disk(cdp, (*(int *)addr)); break; case CDRIOCWRITESPEED: @@ -1362,12 +1362,35 @@ acd_select_slot(struct acd_softc *cdp) } static int -acd_close_disk(struct acd_softc *cdp) +acd_close_disk(struct acd_softc *cdp, int multisession) { - int8_t ccb[16] = { ATAPI_CLOSE_TRACK, 0, 0x02, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0 }; + int8_t ccb[16] = { ATAPI_CLOSE_TRACK, 0x01, 0x02, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0 }; + int timeout = 5*60*2; + int error; + struct write_param param; + + if ((error = acd_mode_sense(cdp, ATAPI_CDROM_WRITE_PARAMETERS_PAGE, + (caddr_t)¶m, sizeof(param)))) + return error; - return atapi_queue_cmd(cdp->atp, ccb, NULL, 0, 0, 5*60, NULL, NULL); + if (multisession) + param.session_type = CDR_SESS_MULTI; + else + param.session_type = CDR_SESS_NONE; + + if ((error = acd_mode_select(cdp, (caddr_t)¶m, sizeof(param)))) + return error; + + error = atapi_queue_cmd(cdp->atp, ccb, NULL, 0, 0, 30, NULL, NULL); + if (error) + return error; + while (timeout-- > 0) { + if ((error = atapi_test_ready(cdp->atp)) != EBUSY) + return error; + tsleep(&error, PRIBIO, "acdcld", hz/2); + } + return EIO; } static int @@ -1384,10 +1407,14 @@ acd_open_track(struct acd_softc *cdp, struct cdr_track *track) param.page_length = 0x32; param.test_write = track->test_write ? 1 : 0; param.write_type = CDR_WTYPE_TRACK; + param.session_type = CDR_SESS_MULTI; + param.fp = 0; + param.packet_size = 0; + if (cdp->cap.burnproof) param.burnproof = 1; - switch (track->track_type) { + switch (track->datablock_type) { case CDR_DB_RAW: if (track->preemp) @@ -1395,60 +1422,53 @@ acd_open_track(struct acd_softc *cdp, struct cdr_track *track) else param.track_mode = CDR_TMODE_AUDIO; cdp->block_size = 2352; - param.data_block_type = CDR_DB_RAW; + param.datablock_type = CDR_DB_RAW; param.session_format = CDR_SESS_CDROM; break; case CDR_DB_ROM_MODE1: cdp->block_size = 2048; param.track_mode = CDR_TMODE_DATA; - param.data_block_type = CDR_DB_ROM_MODE1; + param.datablock_type = CDR_DB_ROM_MODE1; param.session_format = CDR_SESS_CDROM; break; case CDR_DB_ROM_MODE2: cdp->block_size = 2336; param.track_mode = CDR_TMODE_DATA; - param.data_block_type = CDR_DB_ROM_MODE2; + param.datablock_type = CDR_DB_ROM_MODE2; param.session_format = CDR_SESS_CDROM; break; case CDR_DB_XA_MODE1: cdp->block_size = 2048; param.track_mode = CDR_TMODE_DATA; - param.data_block_type = CDR_DB_XA_MODE1; + param.datablock_type = CDR_DB_XA_MODE1; param.session_format = CDR_SESS_CDROM_XA; break; case CDR_DB_XA_MODE2_F1: cdp->block_size = 2056; param.track_mode = CDR_TMODE_DATA; - param.data_block_type = CDR_DB_XA_MODE2_F1; + param.datablock_type = CDR_DB_XA_MODE2_F1; param.session_format = CDR_SESS_CDROM_XA; break; case CDR_DB_XA_MODE2_F2: cdp->block_size = 2324; param.track_mode = CDR_TMODE_DATA; - param.data_block_type = CDR_DB_XA_MODE2_F2; + param.datablock_type = CDR_DB_XA_MODE2_F2; param.session_format = CDR_SESS_CDROM_XA; break; case CDR_DB_XA_MODE2_MIX: cdp->block_size = 2332; param.track_mode = CDR_TMODE_DATA; - param.data_block_type = CDR_DB_XA_MODE2_MIX; + param.datablock_type = CDR_DB_XA_MODE2_MIX; param.session_format = CDR_SESS_CDROM_XA; break; } -#if 1 - param.multi_session = CDR_MSES_MULTI; -#else - param.multi_session = CDR_MSES_NONE; -#endif - param.fp = 0; - param.packet_size = 0; return acd_mode_select(cdp, (caddr_t)¶m, sizeof(param)); } @@ -1750,9 +1770,9 @@ acd_eject(struct acd_softc *cdp, int close) } static int -acd_blank(struct acd_softc *cdp) +acd_blank(struct acd_softc *cdp, int blanktype) { - int8_t ccb[16] = { ATAPI_BLANK, 1, 0, 0, 0, 0, 0, 0, + int8_t ccb[16] = { ATAPI_BLANK, (blanktype & 0x7), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; int error; diff --git a/sys/dev/ata/atapi-cd.h b/sys/dev/ata/atapi-cd.h index e6563b09c104..23bb563f350c 100644 --- a/sys/dev/ata/atapi-cd.h +++ b/sys/dev/ata/atapi-cd.h @@ -1,5 +1,5 @@ /*- - * Copyright (c) 1998,1999,2000 Søren Schmidt + * Copyright (c) 1998,1999,2000,2001 Søren Schmidt * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -233,30 +233,13 @@ struct write_param { u_int8_t copy :1; /* generation stamp */ u_int8_t fp :1; /* fixed packet type */ - u_int8_t multi_session :2; /* multi-session type */ -#define CDR_MSES_NONE 0x00 -#define CDR_MSES_FINAL 0x01 -#define CDR_MSES_RESERVED 0x02 -#define CDR_MSES_MULTI 0x03 - - u_int8_t data_block_type :4; /* data block type code */ -#define CDR_DB_RAW 0x0 /* 2352 bytes of raw data */ -#define CDR_DB_RAW_PQ 0x1 /* 2368 bytes raw data + P/Q subchan */ -#define CDR_DB_RAW_PW 0x2 /* 2448 bytes raw data + P-W subchan */ -#define CDR_DB_RAW_PW_R 0x3 /* 2448 bytes raw data + P-W raw sub */ -#define CDR_DB_RES_4 0x4 /* reserved */ -#define CDR_DB_RES_5 0x5 /* reserved */ -#define CDR_DB_RES_6 0x6 /* reserved */ -#define CDR_DB_VS_7 0x7 /* vendor specific */ -#define CDR_DB_ROM_MODE1 0x8 /* 2048 bytes Mode 1 (ISO/IEC 10149) */ -#define CDR_DB_ROM_MODE2 0x9 /* 2336 bytes Mode 2 (ISO/IEC 10149) */ -#define CDR_DB_XA_MODE1 0xa /* 2048 bytes Mode 1 (CD-ROM XA 1) */ -#define CDR_DB_XA_MODE2_F1 0xb /* 2056 bytes Mode 2 (CD-ROM XA 1) */ -#define CDR_DB_XA_MODE2_F2 0xc /* 2324 bytes Mode 2 (CD-ROM XA 2) */ -#define CDR_DB_XA_MODE2_MIX 0xd /* 2332 bytes Mode 2 (CD-ROM XA 1/2) */ -#define CDR_DB_RES_14 0xe /* reserved */ -#define CDR_DB_VS_15 0xf /* vendor specific */ + u_int8_t session_type :2; /* session type */ +#define CDR_SESS_NONE 0x00 +#define CDR_SESS_FINAL 0x01 +#define CDR_SESS_RESERVED 0x02 +#define CDR_SESS_MULTI 0x03 + u_int8_t datablock_type :4; /* data type code (see cdrio.h) */ u_int8_t reserved4_4567 :4; u_int8_t reserved5; u_int8_t reserved6; diff --git a/sys/dev/ata/atapi-fd.c b/sys/dev/ata/atapi-fd.c index a91bfb9ab0ad..0faef754c196 100644 --- a/sys/dev/ata/atapi-fd.c +++ b/sys/dev/ata/atapi-fd.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 1998,1999,2000 Søren Schmidt + * Copyright (c) 1998,1999,2000,2001 Søren Schmidt * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -77,7 +77,7 @@ static int afd_prevent_allow(struct afd_softc *, int); /* internal vars */ static u_int32_t afd_lun_map = 0; -MALLOC_DEFINE(M_AFD, "AFD driver", "ATAPI floppy driver buffers"); +static MALLOC_DEFINE(M_AFD, "AFD driver", "ATAPI floppy driver buffers"); int afdattach(struct atapi_softc *atp) @@ -85,12 +85,11 @@ afdattach(struct atapi_softc *atp) struct afd_softc *fdp; dev_t dev; - fdp = malloc(sizeof(struct afd_softc), M_AFD, M_NOWAIT); + fdp = malloc(sizeof(struct afd_softc), M_AFD, M_NOWAIT | M_ZERO); if (!fdp) { printf("afd: out of memory\n"); return -1; } - bzero(fdp, sizeof(struct afd_softc)); bufq_init(&fdp->bio_queue); fdp->atp = atp; fdp->lun = ata_get_lun(&afd_lun_map); diff --git a/sys/dev/ata/atapi-fd.h b/sys/dev/ata/atapi-fd.h index 22642d00506d..2f68c2b32b59 100644 --- a/sys/dev/ata/atapi-fd.h +++ b/sys/dev/ata/atapi-fd.h @@ -1,5 +1,5 @@ /*- - * Copyright (c) 1998,1999,2000 Søren Schmidt + * Copyright (c) 1998,1999,2000,2001 Søren Schmidt * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/sys/dev/ata/atapi-tape.c b/sys/dev/ata/atapi-tape.c index 3b1688287d3d..b0d4559553f0 100644 --- a/sys/dev/ata/atapi-tape.c +++ b/sys/dev/ata/atapi-tape.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 1998,1999,2000 Søren Schmidt + * Copyright (c) 1998,1999,2000,2001 Søren Schmidt * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -82,7 +82,7 @@ static int 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"); +static MALLOC_DEFINE(M_AST, "AST driver", "ATAPI tape driver buffers"); int astattach(struct atapi_softc *atp) @@ -96,12 +96,11 @@ astattach(struct atapi_softc *atp) cdevsw_add(&ast_cdevsw); ast_cdev_done = 1; } - stp = malloc(sizeof(struct ast_softc), M_AST, M_NOWAIT); + stp = malloc(sizeof(struct ast_softc), M_AST, M_NOWAIT | M_ZERO); if (!stp) { printf("ast: out of memory\n"); return -1; } - bzero(stp, sizeof(struct ast_softc)); bufq_init(&stp->bio_queue); stp->atp = atp; stp->lun = ata_get_lun(&ast_lun_map); diff --git a/sys/dev/ata/atapi-tape.h b/sys/dev/ata/atapi-tape.h index f7c51b41b7e7..004e1bc8483b 100644 --- a/sys/dev/ata/atapi-tape.h +++ b/sys/dev/ata/atapi-tape.h @@ -1,5 +1,5 @@ /*- - * Copyright (c) 1998,1999,2000 Søren Schmidt + * Copyright (c) 1998,1999,2000,2001 Søren Schmidt * All rights reserved. * * Redistribution and use in source and binary forms, with or without |
