diff options
Diffstat (limited to 'sys/dev/ata/ata-all.c')
-rw-r--r-- | sys/dev/ata/ata-all.c | 44 |
1 files changed, 34 insertions, 10 deletions
diff --git a/sys/dev/ata/ata-all.c b/sys/dev/ata/ata-all.c index c6230c7..a7a7628 100644 --- a/sys/dev/ata/ata-all.c +++ b/sys/dev/ata/ata-all.c @@ -92,6 +92,10 @@ devclass_t ata_devclass; static struct intr_config_hook *ata_delayed_attach = NULL; static MALLOC_DEFINE(M_ATA, "ATA generic", "ATA driver generic layer"); +/* misc defines */ +#define DEV_ATAPIALL defined(DEV_ATAPICD) || defined(DEV_ATAPIFD) || \ + defined(DEV_ATAPIST) || defined(DEV_ATAPICAM) + int ata_probe(device_t dev) { @@ -199,12 +203,16 @@ ata_attach(device_t dev) if (ch->devices & ATA_ATA_SLAVE) ad_attach(&ch->device[SLAVE]); #endif -#if defined(DEV_ATAPICD) || defined(DEV_ATAPIFD) || defined(DEV_ATAPIST) +#if DEV_ATAPIALL if (ch->devices & ATA_ATAPI_MASTER) atapi_attach(&ch->device[MASTER]); if (ch->devices & ATA_ATAPI_SLAVE) atapi_attach(&ch->device[SLAVE]); #endif +#ifdef DEV_ATAPICAM + if (ch->devices & (ATA_ATAPI_MASTER | ATA_ATAPI_SLAVE)) + atapi_cam_attach_bus(ch); +#endif } return 0; } @@ -229,12 +237,16 @@ ata_detach(device_t dev) if (ch->devices & ATA_ATA_SLAVE && ch->device[SLAVE].driver) ad_detach(&ch->device[SLAVE], 1); #endif -#if defined(DEV_ATAPICD) || defined(DEV_ATAPIFD) || defined(DEV_ATAPIST) +#if DEV_ATAPIALL if (ch->devices & ATA_ATAPI_MASTER && ch->device[MASTER].driver) atapi_detach(&ch->device[MASTER]); if (ch->devices & ATA_ATAPI_SLAVE && ch->device[SLAVE].driver) atapi_detach(&ch->device[SLAVE]); #endif +#ifdef DEV_ATAPICAM + if (ch->devices & (ATA_ATAPI_SLAVE|ATA_ATAPI_MASTER)) + atapi_cam_detach_bus(ch); +#endif splx(s); if (ch->device[MASTER].param) { @@ -424,7 +436,7 @@ ataioctl(dev_t dev, u_long cmd, caddr_t addr, int32_t flag, struct thread *td) case ATARAIDSTATUS: return ata_raid_status(iocmd->channel, &iocmd->u.raid_status); #endif -#if defined(DEV_ATAPICD) || defined(DEV_ATAPIFD) || defined(DEV_ATAPIST) +#if DEV_ATAPIALL case ATAPICMD: { struct ata_device *atadev; caddr_t buf; @@ -562,17 +574,21 @@ ata_boot_attach(void) } ata_raid_attach(); #endif -#if defined(DEV_ATAPICD) || defined(DEV_ATAPIFD) || defined(DEV_ATAPIST) /* then the atapi devices */ for (ctlr=0; ctlr<devclass_get_maxunit(ata_devclass); ctlr++) { if (!(ch = devclass_get_softc(ata_devclass, ctlr))) continue; +#if DEV_ATAPIALL if (ch->devices & ATA_ATAPI_MASTER) atapi_attach(&ch->device[MASTER]); if (ch->devices & ATA_ATAPI_SLAVE) atapi_attach(&ch->device[SLAVE]); - } #endif +#ifdef DEV_ATAPICAM + if (ch->devices & (ATA_ATAPI_MASTER | ATA_ATAPI_SLAVE)) + atapi_cam_attach_bus(ch); +#endif + } } static void @@ -608,7 +624,7 @@ ata_intr(void *data) return; break; #endif -#if defined(DEV_ATAPICD) || defined(DEV_ATAPIFD) || defined(DEV_ATAPIST) +#if DEV_ATAPIALL case ATA_ACTIVE_ATAPI: if (!ch->running || atapi_interrupt(ch->running) == ATA_OP_CONTINUES) return; @@ -642,7 +658,7 @@ ata_start(struct ata_channel *ch) #ifdef DEV_ATADISK struct ad_request *ad_request; #endif -#if defined(DEV_ATAPICD) || defined(DEV_ATAPIFD) || defined(DEV_ATAPIST) +#if DEV_ATAPIALL struct atapi_request *atapi_request; #endif int s; @@ -670,7 +686,7 @@ ata_start(struct ata_channel *ch) } #endif -#if defined(DEV_ATAPICD) || defined(DEV_ATAPIFD) || defined(DEV_ATAPIST) +#if DEV_ATAPIALL /* find & call the responsible driver if anything on the ATAPI queue */ if (TAILQ_EMPTY(&ch->atapi_queue)) { if (ch->devices & (ATA_ATAPI_MASTER) && ch->device[MASTER].driver) @@ -834,6 +850,10 @@ ata_reinit(struct ata_channel *ch) ata_printf(ch, -1, "resetting devices ..\n"); ata_reset(ch); +#ifdef DEV_ATAPICAM + if (devices & (ATA_ATAPI_SLAVE|ATA_ATAPI_MASTER)) + atapi_cam_detach_bus(ch); +#endif if ((misdev = devices & ~ch->devices)) { #ifdef DEV_ATADISK if (misdev & ATA_ATA_MASTER && ch->device[MASTER].driver) @@ -841,7 +861,7 @@ ata_reinit(struct ata_channel *ch) if (misdev & ATA_ATA_SLAVE && ch->device[SLAVE].driver) ad_detach(&ch->device[SLAVE], 0); #endif -#if defined(DEV_ATAPICD) || defined(DEV_ATAPIFD) || defined(DEV_ATAPIST) +#if DEV_ATAPIALL if (misdev & ATA_ATAPI_MASTER && ch->device[MASTER].driver) atapi_detach(&ch->device[MASTER]); if (misdev & ATA_ATAPI_SLAVE && ch->device[SLAVE].driver) @@ -886,7 +906,7 @@ ata_reinit(struct ata_channel *ch) ad_reinit(&ch->device[SLAVE]); } #endif -#if defined(DEV_ATAPICD) || defined(DEV_ATAPIFD) || defined(DEV_ATAPIST) +#if DEV_ATAPIALL if (newdev & ATA_ATAPI_MASTER && !ch->device[MASTER].driver) atapi_attach(&ch->device[MASTER]); else if (ch->devices & (ATA_ATAPI_MASTER) && ch->device[MASTER].driver) { @@ -900,6 +920,10 @@ ata_reinit(struct ata_channel *ch) atapi_reinit(&ch->device[SLAVE]); } #endif +#ifdef DEV_ATAPICAM + if (ch->devices & (ATA_ATAPI_MASTER | ATA_ATAPI_SLAVE)) + atapi_cam_attach_bus(ch); +#endif printf("done\n"); ATA_UNLOCK_CH(ch); ata_start(ch); |