ATAPI_DEBUG_PRINT(("acdstart: waking up\n"));
acdstart(acd)	struct acd_softc *acd;{	struct at_dev_link *ad_link;	struct buf *bp = 0;	struct buf *dp;	struct read cmd;	u_int32_t blkno, nblks;	struct partition *p;	ACD_DEBUG_PRINT(("acd: acdstart\n"));#ifdef DIAGNOSTIC	if (acd == NULL) {		printf("acdstart: null acd\n");		return;	}#endif			ad_link = acd->ad_link;#ifdef DIAGNOSTIC	if (ad_link == NULL) {		printf("acdstart: null ad_link\n");		return;	}#endif	/*	 * Check if the device has room for another command	 */	while (ad_link->openings > 0) {		/*		 * there is excess capacity, but a special waits		 * It'll need the adapter as soon as we clear out of the		 * way and let it run (user level wait).		 */		if (ad_link->flags & ADEV_WAITING) {#ifdef ATAPI_DEBUG			printf("acdstart: waking up\n");#endif			ad_link->flags &= ~ADEV_WAITING;			wakeup((caddr_t)ad_link);			return;		}				/*		 * See if there is a buf with work for us to do..		 */		dp = &acd->buf_queue;#ifdef ACD_DEBUG		if (dp == NULL) {			printf("acdstart: null dp\n");			return;		}#endif		if ((bp = dp->b_actf) == NULL)	/* yes, an assign */			return;		ACD_DEBUG_PRINT(("acdstart: a buf\n"));		dp->b_actf = bp->b_actf;		/*		 * If the device has become invalid, abort all the		 * reads and writes until all files have been closed and		 * re-opened		 */		if ((ad_link->flags & ADEV_MEDIA_LOADED) == 0) {			bp->b_error = EIO;			bp->b_flags |= B_ERROR;			biodone(bp);			continue;		}		/*		 *		 * First, translate the block to absolute and put it in terms		 * of the logical blocksize of the device.		 */		blkno =		    bp->b_blkno / (acd->sc_dk.dk_label->d_secsize / DEV_BSIZE);		if (CDPART(bp->b_dev) != RAW_PART) {			p =			  &acd->sc_dk.dk_label->d_partitions[CDPART(bp->b_dev)];			blkno += p->p_offset;		}		nblks = howmany(bp->b_bcount, acd->sc_dk.dk_label->d_secsize);		ACD_DEBUG_PRINT(("acdstart: blkno %d nblk %d\n",		    blkno, nblks));		/*		 *  Fill out the atapi command		 */		bzero(&cmd, sizeof(cmd));		cmd.operation_code = ATAPI_READ;		_lto4b(blkno, cmd.lba);		_lto2b(nblks, cmd.length);		/* Instrumentation. */		disk_busy(&acd->sc_dk);		/*		 * Call the routine that chats with the adapter.		 * Note: we cannot sleep as we may be an interrupt		 */		 if (atapi_exec_io(ad_link, &cmd, sizeof(cmd), bp, A_NOSLEEP))			printf("%s: not queued", acd->sc_dev.dv_xname);	}}