bus_space_write_1(iot, ioh, wd_ctlr, WDCTL_4BIT); delay(1000);
wdc_atapi_send_command_packet(ab_link, acp)	struct bus_link *ab_link;	struct atapi_command_packet *acp;{	struct wdc_softc *wdc = (void*)ab_link->wdc_softc;	bus_space_tag_t iot = wdc->sc_iot;	bus_space_handle_t ioh = wdc->sc_ioh;	struct wdc_xfer *xfer;	u_int8_t flags = acp->flags & 0xff;		if (flags & A_POLLED) {   /* Must use the queue and wdc_atapi_start */		struct wdc_xfer xfer_s;		int i, phase;#ifdef ATAPI_DEBUG_WDC		printf("wdc_atapi_send_cmd: "		    "flags %ld drive %d cmdlen %d datalen %d",		    acp->flags, acp->drive, acp->command_size, acp->data_size);#endif		xfer = &xfer_s;		bzero(xfer, sizeof(xfer_s));		xfer->c_flags = C_INUSE|C_ATAPI|acp->flags;		xfer->d_link = (struct wd_link *)ab_link;		xfer->c_link = ab_link->ctlr_link;		xfer->c_bp = acp->bp;		xfer->atapi_cmd = acp;		xfer->c_blkno = 0;		xfer->databuf = acp->databuf;		xfer->c_bcount = acp->data_size;		if (wait_for_unbusy (wdc) != 0)  {			if ((wdc->sc_status & WDCS_ERR) == 0) {				printf("wdc_atapi_send_command: not ready, "				    "st = %02x\n", wdc->sc_status);				acp->status = ERROR;				return;			}		}		if (wdccommand((struct wd_link*)ab_link,		    ATAPI_PACKET_COMMAND, acp->drive, acp->data_size,		    0, 0, 0) != 0) {			printf("can't send atapi paket command\n");			acp->status = ERROR;			return;		}		/* Wait for cmd i/o phase. */		phase = wait_for_phase(wdc, PHASE_CMDOUT);		if (phase != PHASE_CMDOUT)			printf("wdc_atapi_intr: got wrong phase (0x%x)\n",			    phase);		bus_space_write_raw_multi_2(iot, ioh, wd_data, acp->command,		    acp->command_size);		/* Wait for data i/o phase. */		phase = wait_for_unphase(wdc, PHASE_CMDOUT);		if (phase == PHASE_CMDOUT)			printf("wdc_atapi_intr: got wrong phase (0x%x)\n",			    phase);				while (wdc_atapi_intr(wdc, xfer)) {			for (i = 2000; i > 0; --i)				if ((bus_space_read_1(iot, ioh, wd_status) &				    WDCS_DRQ) == 0)					break;#ifdef ATAPI_DEBUG_WDC			printf("wdc_atapi_intr: i = %d\n", i);#endif		}		wdc->sc_flags &= ~(WDCF_IRQ_WAIT | WDCF_SINGLE | WDCF_ERROR);		wdc->sc_errors = 0;		xfer->c_skip = 0;		return;	} else {	/* POLLED */		xfer = wdc_get_xfer(ab_link->ctlr_link,		    flags & A_NOSLEEP ? IDE_NOSLEEP : 0);		if (xfer == NULL) {			acp->status = ERROR;			return;		}		xfer->c_flags |= C_ATAPI|acp->flags;		xfer->d_link = (struct wd_link*) ab_link;		xfer->c_link = ab_link->ctlr_link;		xfer->c_bp = acp->bp;		xfer->atapi_cmd = acp;		xfer->c_blkno = 0;		xfer->databuf = acp->databuf;		xfer->c_bcount = acp->data_size;		wdc_exec_xfer((struct wd_link*)ab_link,xfer);		return;	}}