2 * Bus independent FreeBSD shim for the aic79xx based Adaptec SCSI controllers
4 * Copyright (c) 1994-2002, 2004 Justin T. Gibbs.
5 * Copyright (c) 2001-2002 Adaptec Inc.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions, and the following disclaimer,
13 * without modification.
14 * 2. The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
17 * Alternatively, this software may be distributed under the terms of the
18 * GNU Public License ("GPL").
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
24 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * $Id: //depot/aic7xxx/freebsd/dev/aic7xxx/aic79xx_osm.c#35 $
35 #include <sys/cdefs.h>
36 __FBSDID("$FreeBSD$");
38 #include <dev/aic7xxx/aic79xx_osm.h>
39 #include <dev/aic7xxx/aic79xx_inline.h>
41 #include <sys/kthread.h>
48 #ifndef AHD_TMODE_ENABLE
49 #define AHD_TMODE_ENABLE 0
52 #include <dev/aic7xxx/aic_osm_lib.c>
54 #define ccb_scb_ptr spriv_ptr0
57 static void ahd_dump_targcmd(struct target_cmd *cmd);
59 static int ahd_modevent(module_t mod, int type, void *data);
60 static void ahd_action(struct cam_sim *sim, union ccb *ccb);
61 static void ahd_set_tran_settings(struct ahd_softc *ahd,
62 int our_id, char channel,
63 struct ccb_trans_settings *cts);
64 static void ahd_get_tran_settings(struct ahd_softc *ahd,
65 int our_id, char channel,
66 struct ccb_trans_settings *cts);
67 static void ahd_async(void *callback_arg, uint32_t code,
68 struct cam_path *path, void *arg);
69 static void ahd_execute_scb(void *arg, bus_dma_segment_t *dm_segs,
70 int nsegments, int error);
71 static void ahd_poll(struct cam_sim *sim);
72 static void ahd_setup_data(struct ahd_softc *ahd, struct cam_sim *sim,
73 struct ccb_scsiio *csio, struct scb *scb);
74 static void ahd_abort_ccb(struct ahd_softc *ahd, struct cam_sim *sim,
76 static int ahd_create_path(struct ahd_softc *ahd,
77 char channel, u_int target, u_int lun,
78 struct cam_path **path);
80 static const char *ahd_sysctl_node_elements[] = {
86 #ifndef NO_SYSCTL_DESCR
87 static const char *ahd_sysctl_node_descriptions[] = {
88 "root error collection for aic79xx controllers",
89 "summary collection for aic79xx controllers",
90 "debug collection for aic79xx controllers"
94 static const char *ahd_sysctl_errors_elements[] = {
100 #ifndef NO_SYSCTL_DESCR
101 static const char *ahd_sysctl_errors_descriptions[] = {
102 "Correctable errors",
103 "Uncorrectable errors",
109 ahd_set_debugcounters(SYSCTL_HANDLER_ARGS)
111 struct ahd_softc *sc;
116 error = sysctl_handle_int(oidp, &tmpv, 0, req);
117 if (error != 0 || req->newptr == NULL)
119 if (tmpv < 0 || tmpv >= AHD_ERRORS_NUMBER)
121 sc->summerr[arg2] = tmpv;
126 ahd_clear_allcounters(SYSCTL_HANDLER_ARGS)
128 struct ahd_softc *sc;
133 error = sysctl_handle_int(oidp, &tmpv, 0, req);
134 if (error != 0 || req->newptr == NULL)
137 bzero(sc->summerr, sizeof(sc->summerr));
142 ahd_create_path(struct ahd_softc *ahd, char channel, u_int target,
143 u_int lun, struct cam_path **path)
147 path_id = cam_sim_path(ahd->platform_data->sim);
148 return (xpt_create_path(path, /*periph*/NULL,
149 path_id, target, lun));
153 ahd_sysctl(struct ahd_softc *ahd)
157 for (i = 0; i < AHD_SYSCTL_NUMBER; i++)
158 sysctl_ctx_init(&ahd->sysctl_ctx[i]);
160 ahd->sysctl_tree[AHD_SYSCTL_ROOT] =
161 SYSCTL_ADD_NODE(&ahd->sysctl_ctx[AHD_SYSCTL_ROOT],
162 SYSCTL_STATIC_CHILDREN(_hw), OID_AUTO,
163 device_get_nameunit(ahd->dev_softc), CTLFLAG_RD, 0,
164 ahd_sysctl_node_descriptions[AHD_SYSCTL_ROOT]);
165 SYSCTL_ADD_PROC(&ahd->sysctl_ctx[AHD_SYSCTL_ROOT],
166 SYSCTL_CHILDREN(ahd->sysctl_tree[AHD_SYSCTL_ROOT]),
167 OID_AUTO, "clear", CTLTYPE_UINT | CTLFLAG_RW, ahd,
168 0, ahd_clear_allcounters, "IU",
169 "Clear all counters");
171 for (i = AHD_SYSCTL_SUMMARY; i < AHD_SYSCTL_NUMBER; i++)
172 ahd->sysctl_tree[i] =
173 SYSCTL_ADD_NODE(&ahd->sysctl_ctx[i],
174 SYSCTL_CHILDREN(ahd->sysctl_tree[AHD_SYSCTL_ROOT]),
175 OID_AUTO, ahd_sysctl_node_elements[i],
177 ahd_sysctl_node_descriptions[i]);
179 for (i = AHD_ERRORS_CORRECTABLE; i < AHD_ERRORS_NUMBER; i++) {
180 SYSCTL_ADD_UINT(&ahd->sysctl_ctx[AHD_SYSCTL_SUMMARY],
181 SYSCTL_CHILDREN(ahd->sysctl_tree[AHD_SYSCTL_SUMMARY]),
182 OID_AUTO, ahd_sysctl_errors_elements[i],
183 CTLFLAG_RD, &ahd->summerr[i], i,
184 ahd_sysctl_errors_descriptions[i]);
185 SYSCTL_ADD_PROC(&ahd->sysctl_ctx[AHD_SYSCTL_DEBUG],
186 SYSCTL_CHILDREN(ahd->sysctl_tree[AHD_SYSCTL_DEBUG]),
187 OID_AUTO, ahd_sysctl_errors_elements[i],
188 CTLFLAG_RW | CTLTYPE_UINT, ahd, i,
189 ahd_set_debugcounters, "IU",
190 ahd_sysctl_errors_descriptions[i]);
195 ahd_map_int(struct ahd_softc *ahd)
199 /* Hook up our interrupt handler */
200 error = bus_setup_intr(ahd->dev_softc, ahd->platform_data->irq,
201 INTR_TYPE_CAM|INTR_MPSAFE, NULL,
202 ahd_platform_intr, ahd, &ahd->platform_data->ih);
204 device_printf(ahd->dev_softc, "bus_setup_intr() failed: %d\n",
210 * Attach all the sub-devices we can find
213 ahd_attach(struct ahd_softc *ahd)
216 struct ccb_setasync csa;
217 struct cam_devq *devq;
219 struct cam_path *path;
227 * Create a thread to perform all recovery.
229 if (ahd_spawn_recovery_thread(ahd) != 0)
232 ahd_controller_info(ahd, ahd_info);
233 printf("%s\n", ahd_info);
237 * Create the device queue for our SIM(s).
239 devq = cam_simq_alloc(AHD_MAX_QUEUE);
244 * Construct our SIM entry
246 sim = cam_sim_alloc(ahd_action, ahd_poll, "ahd", ahd,
247 device_get_unit(ahd->dev_softc),
248 &ahd->platform_data->mtx, 1, /*XXX*/256, devq);
254 if (xpt_bus_register(sim, ahd->dev_softc, /*bus_id*/0) != CAM_SUCCESS) {
255 cam_sim_free(sim, /*free_devq*/TRUE);
260 if (xpt_create_path(&path, /*periph*/NULL,
261 cam_sim_path(sim), CAM_TARGET_WILDCARD,
262 CAM_LUN_WILDCARD) != CAM_REQ_CMP) {
263 xpt_bus_deregister(cam_sim_path(sim));
264 cam_sim_free(sim, /*free_devq*/TRUE);
269 xpt_setup_ccb(&csa.ccb_h, path, /*priority*/5);
270 csa.ccb_h.func_code = XPT_SASYNC_CB;
271 csa.event_enable = AC_LOST_DEVICE;
272 csa.callback = ahd_async;
273 csa.callback_arg = sim;
274 xpt_action((union ccb *)&csa);
278 ahd->platform_data->sim = sim;
279 ahd->platform_data->path = path;
282 /* We have to wait until after any system dumps... */
283 ahd->platform_data->eh =
284 EVENTHANDLER_REGISTER(shutdown_final, ahd_shutdown,
285 ahd, SHUTDOWN_PRI_DEFAULT);
286 ahd_intr_enable(ahd, TRUE);
294 * Catch an interrupt from the adapter
297 ahd_platform_intr(void *arg)
299 struct ahd_softc *ahd;
301 ahd = (struct ahd_softc *)arg;
308 * We have an scb which has been processed by the
309 * adaptor, now we look to see how the operation
313 ahd_done(struct ahd_softc *ahd, struct scb *scb)
317 CAM_DEBUG(scb->io_ctx->ccb_h.path, CAM_DEBUG_TRACE,
318 ("ahd_done - scb %d\n", SCB_GET_TAG(scb)));
321 LIST_REMOVE(scb, pending_links);
322 if ((scb->flags & SCB_TIMEDOUT) != 0)
323 LIST_REMOVE(scb, timedout_links);
325 callout_stop(&scb->io_timer);
327 if ((ccb->ccb_h.flags & CAM_DIR_MASK) != CAM_DIR_NONE) {
330 if ((ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN)
331 op = BUS_DMASYNC_POSTREAD;
333 op = BUS_DMASYNC_POSTWRITE;
334 bus_dmamap_sync(ahd->buffer_dmat, scb->dmamap, op);
335 bus_dmamap_unload(ahd->buffer_dmat, scb->dmamap);
338 #ifdef AHD_TARGET_MODE
339 if (ccb->ccb_h.func_code == XPT_CONT_TARGET_IO) {
340 struct cam_path *ccb_path;
343 * If we have finally disconnected, clean up our
344 * pending device state.
345 * XXX - There may be error states that cause where
346 * we will remain connected.
348 ccb_path = ccb->ccb_h.path;
349 if (ahd->pending_device != NULL
350 && xpt_path_comp(ahd->pending_device->path, ccb_path) == 0) {
352 if ((ccb->ccb_h.flags & CAM_SEND_STATUS) != 0) {
353 ahd->pending_device = NULL;
355 xpt_print_path(ccb->ccb_h.path);
356 printf("Still disconnected\n");
361 if (aic_get_transaction_status(scb) == CAM_REQ_INPROG)
362 ccb->ccb_h.status |= CAM_REQ_CMP;
363 ccb->ccb_h.status &= ~CAM_SIM_QUEUED;
364 ahd_free_scb(ahd, scb);
370 if ((scb->flags & SCB_RECOVERY_SCB) != 0) {
371 struct scb *list_scb;
373 ahd->scb_data.recovery_scbs--;
375 if (aic_get_transaction_status(scb) == CAM_BDR_SENT
376 || aic_get_transaction_status(scb) == CAM_REQ_ABORTED)
377 aic_set_transaction_status(scb, CAM_CMD_TIMEOUT);
379 if (ahd->scb_data.recovery_scbs == 0) {
381 * All recovery actions have completed successfully,
382 * so reinstate the timeouts for all other pending
385 LIST_FOREACH(list_scb,
386 &ahd->pending_scbs, pending_links) {
388 aic_scb_timer_reset(list_scb,
389 aic_get_timeout(scb));
392 ahd_print_path(ahd, scb);
393 printf("no longer in timeout, status = %x\n",
398 /* Don't clobber any existing error state */
399 if (aic_get_transaction_status(scb) == CAM_REQ_INPROG) {
400 ccb->ccb_h.status |= CAM_REQ_CMP;
401 } else if ((scb->flags & SCB_SENSE) != 0) {
403 * We performed autosense retrieval.
405 * Zero any sense not transferred by the
406 * device. The SCSI spec mandates that any
407 * untransfered data should be assumed to be
408 * zero. Complete the 'bounce' of sense information
409 * through buffers accessible via bus-space by
410 * copying it into the clients csio.
412 memset(&ccb->csio.sense_data, 0, sizeof(ccb->csio.sense_data));
413 memcpy(&ccb->csio.sense_data,
414 ahd_get_sense_buf(ahd, scb),
415 /* XXX What size do we want to use??? */
416 sizeof(ccb->csio.sense_data)
417 - ccb->csio.sense_resid);
418 scb->io_ctx->ccb_h.status |= CAM_AUTOSNS_VALID;
419 } else if ((scb->flags & SCB_PKT_SENSE) != 0) {
420 struct scsi_status_iu_header *siu;
424 * Copy only the sense data into the provided buffer.
426 siu = (struct scsi_status_iu_header *)scb->sense_data;
427 sense_len = MIN(scsi_4btoul(siu->sense_length),
428 sizeof(ccb->csio.sense_data));
429 memset(&ccb->csio.sense_data, 0, sizeof(ccb->csio.sense_data));
430 memcpy(&ccb->csio.sense_data,
431 ahd_get_sense_buf(ahd, scb) + SIU_SENSE_OFFSET(siu),
434 if ((ahd_debug & AHD_SHOW_SENSE) != 0) {
435 uint8_t *sense_data = (uint8_t *)&ccb->csio.sense_data;
438 printf("Copied %d bytes of sense data offset %d:",
439 sense_len, SIU_SENSE_OFFSET(siu));
440 for (i = 0; i < sense_len; i++)
441 printf(" 0x%x", *sense_data++);
445 scb->io_ctx->ccb_h.status |= CAM_AUTOSNS_VALID;
447 ccb->ccb_h.status &= ~CAM_SIM_QUEUED;
448 ahd_free_scb(ahd, scb);
453 ahd_action(struct cam_sim *sim, union ccb *ccb)
455 struct ahd_softc *ahd;
456 #ifdef AHD_TARGET_MODE
457 struct ahd_tmode_lstate *lstate;
462 CAM_DEBUG(ccb->ccb_h.path, CAM_DEBUG_TRACE, ("ahd_action\n"));
464 ahd = (struct ahd_softc *)cam_sim_softc(sim);
466 target_id = ccb->ccb_h.target_id;
467 our_id = SIM_SCSI_ID(ahd, sim);
469 switch (ccb->ccb_h.func_code) {
470 /* Common cases first */
471 #ifdef AHD_TARGET_MODE
472 case XPT_ACCEPT_TARGET_IO: /* Accept Host Target Mode CDB */
473 case XPT_CONT_TARGET_IO:/* Continue Host Target I/O Connection*/
475 struct ahd_tmode_tstate *tstate;
478 status = ahd_find_tmode_devs(ahd, sim, ccb, &tstate,
481 if (status != CAM_REQ_CMP) {
482 if (ccb->ccb_h.func_code == XPT_CONT_TARGET_IO) {
483 /* Response from the black hole device */
485 lstate = ahd->black_hole;
487 ccb->ccb_h.status = status;
492 if (ccb->ccb_h.func_code == XPT_ACCEPT_TARGET_IO) {
494 SLIST_INSERT_HEAD(&lstate->accept_tios, &ccb->ccb_h,
496 ccb->ccb_h.status = CAM_REQ_INPROG;
497 if ((ahd->flags & AHD_TQINFIFO_BLOCKED) != 0)
498 ahd_run_tqinfifo(ahd, /*paused*/FALSE);
503 * The target_id represents the target we attempt to
504 * select. In target mode, this is the initiator of
505 * the original command.
508 target_id = ccb->csio.init_id;
512 case XPT_SCSI_IO: /* Execute the requested I/O operation */
513 case XPT_RESET_DEV: /* Bus Device Reset the specified SCSI device */
516 struct hardware_scb *hscb;
517 struct ahd_initiator_tinfo *tinfo;
518 struct ahd_tmode_tstate *tstate;
521 if ((ahd->flags & AHD_INITIATORROLE) == 0
522 && (ccb->ccb_h.func_code == XPT_SCSI_IO
523 || ccb->ccb_h.func_code == XPT_RESET_DEV)) {
524 ccb->ccb_h.status = CAM_PROVIDE_FAIL;
532 tinfo = ahd_fetch_transinfo(ahd, 'A', our_id,
534 if ((ccb->ccb_h.flags & CAM_TAG_ACTION_VALID) == 0
535 || (tinfo->curr.ppr_options & MSG_EXT_PPR_IU_REQ) != 0
536 || ccb->ccb_h.func_code == XPT_CONT_TARGET_IO) {
537 col_idx = AHD_NEVER_COL_IDX;
539 col_idx = AHD_BUILD_COL_IDX(target_id,
540 ccb->ccb_h.target_lun);
542 if ((scb = ahd_get_scb(ahd, col_idx)) == NULL) {
544 xpt_freeze_simq(sim, /*count*/1);
545 ahd->flags |= AHD_RESOURCE_SHORTAGE;
546 ccb->ccb_h.status = CAM_REQUEUE_REQ;
553 CAM_DEBUG(ccb->ccb_h.path, CAM_DEBUG_SUBTRACE,
554 ("start scb(%p)\n", scb));
557 * So we can find the SCB when an abort is requested
559 ccb->ccb_h.ccb_scb_ptr = scb;
562 * Put all the arguments for the xfer in the scb
565 hscb->scsiid = BUILD_SCSIID(ahd, sim, target_id, our_id);
566 hscb->lun = ccb->ccb_h.target_lun;
567 if (ccb->ccb_h.func_code == XPT_RESET_DEV) {
569 scb->flags |= SCB_DEVICE_RESET;
570 hscb->control |= MK_MESSAGE;
571 hscb->task_management = SIU_TASKMGMT_LUN_RESET;
572 ahd_execute_scb(scb, NULL, 0, 0);
574 #ifdef AHD_TARGET_MODE
575 if (ccb->ccb_h.func_code == XPT_CONT_TARGET_IO) {
576 struct target_data *tdata;
578 tdata = &hscb->shared_data.tdata;
579 if (ahd->pending_device == lstate)
580 scb->flags |= SCB_TARGET_IMMEDIATE;
581 hscb->control |= TARGET_SCB;
582 tdata->target_phases = 0;
583 if ((ccb->ccb_h.flags & CAM_SEND_STATUS) != 0) {
584 tdata->target_phases |= SPHASE_PENDING;
586 ccb->csio.scsi_status;
588 if (ccb->ccb_h.flags & CAM_DIS_DISCONNECT)
589 tdata->target_phases |= NO_DISCONNECT;
591 tdata->initiator_tag =
592 ahd_htole16(ccb->csio.tag_id);
595 hscb->task_management = 0;
596 if (ccb->ccb_h.flags & CAM_TAG_ACTION_VALID)
597 hscb->control |= ccb->csio.tag_action;
599 ahd_setup_data(ahd, sim, &ccb->csio, scb);
603 #ifdef AHD_TARGET_MODE
605 case XPT_IMMED_NOTIFY:
607 struct ahd_tmode_tstate *tstate;
608 struct ahd_tmode_lstate *lstate;
611 status = ahd_find_tmode_devs(ahd, sim, ccb, &tstate,
614 if (status != CAM_REQ_CMP) {
615 ccb->ccb_h.status = status;
619 SLIST_INSERT_HEAD(&lstate->immed_notifies, &ccb->ccb_h,
621 ccb->ccb_h.status = CAM_REQ_INPROG;
622 ahd_send_lstate_events(ahd, lstate);
625 case XPT_EN_LUN: /* Enable LUN as a target */
626 ahd_handle_en_lun(ahd, sim, ccb);
630 case XPT_ABORT: /* Abort the specified CCB */
632 ahd_abort_ccb(ahd, sim, ccb);
635 case XPT_SET_TRAN_SETTINGS:
637 ahd_set_tran_settings(ahd, SIM_SCSI_ID(ahd, sim),
638 SIM_CHANNEL(ahd, sim), &ccb->cts);
642 case XPT_GET_TRAN_SETTINGS:
643 /* Get default/user set transfer settings for the target */
645 ahd_get_tran_settings(ahd, SIM_SCSI_ID(ahd, sim),
646 SIM_CHANNEL(ahd, sim), &ccb->cts);
650 case XPT_CALC_GEOMETRY:
652 aic_calc_geometry(&ccb->ccg, ahd->flags & AHD_EXTENDED_TRANS_A);
656 case XPT_RESET_BUS: /* Reset the specified SCSI bus */
660 found = ahd_reset_channel(ahd, SIM_CHANNEL(ahd, sim),
661 /*initiate reset*/TRUE);
663 xpt_print_path(SIM_PATH(ahd, sim));
664 printf("SCSI bus reset delivered. "
665 "%d SCBs aborted.\n", found);
667 ccb->ccb_h.status = CAM_REQ_CMP;
671 case XPT_TERM_IO: /* Terminate the I/O process */
673 ccb->ccb_h.status = CAM_REQ_INVALID;
676 case XPT_PATH_INQ: /* Path routing inquiry */
678 struct ccb_pathinq *cpi = &ccb->cpi;
680 cpi->version_num = 1; /* XXX??? */
681 cpi->hba_inquiry = PI_SDTR_ABLE|PI_TAG_ABLE;
682 if ((ahd->features & AHD_WIDE) != 0)
683 cpi->hba_inquiry |= PI_WIDE_16;
684 if ((ahd->features & AHD_TARGETMODE) != 0) {
685 cpi->target_sprt = PIT_PROCESSOR
689 cpi->target_sprt = 0;
692 cpi->hba_eng_cnt = 0;
693 cpi->max_target = (ahd->features & AHD_WIDE) ? 15 : 7;
694 cpi->max_lun = AHD_NUM_LUNS_NONPKT - 1;
695 cpi->initiator_id = ahd->our_id;
696 if ((ahd->flags & AHD_RESET_BUS_A) == 0) {
697 cpi->hba_misc |= PIM_NOBUSRESET;
699 cpi->bus_id = cam_sim_bus(sim);
700 cpi->base_transfer_speed = 3300;
701 strncpy(cpi->sim_vid, "FreeBSD", SIM_IDLEN);
702 strncpy(cpi->hba_vid, "Adaptec", HBA_IDLEN);
703 strncpy(cpi->dev_name, cam_sim_name(sim), DEV_IDLEN);
704 cpi->unit_number = cam_sim_unit(sim);
705 cpi->protocol = PROTO_SCSI;
706 cpi->protocol_version = SCSI_REV_2;
707 cpi->transport = XPORT_SPI;
708 cpi->transport_version = 4;
709 cpi->xport_specific.spi.ppr_options = SID_SPI_CLOCK_DT_ST
712 cpi->ccb_h.status = CAM_REQ_CMP;
717 ccb->ccb_h.status = CAM_PROVIDE_FAIL;
725 ahd_set_tran_settings(struct ahd_softc *ahd, int our_id, char channel,
726 struct ccb_trans_settings *cts)
728 struct ahd_devinfo devinfo;
729 struct ccb_trans_settings_scsi *scsi;
730 struct ccb_trans_settings_spi *spi;
731 struct ahd_initiator_tinfo *tinfo;
732 struct ahd_tmode_tstate *tstate;
733 uint16_t *discenable;
737 scsi = &cts->proto_specific.scsi;
738 spi = &cts->xport_specific.spi;
739 ahd_compile_devinfo(&devinfo, SIM_SCSI_ID(ahd, sim),
740 cts->ccb_h.target_id,
741 cts->ccb_h.target_lun,
742 SIM_CHANNEL(ahd, sim),
744 tinfo = ahd_fetch_transinfo(ahd, devinfo.channel,
746 devinfo.target, &tstate);
748 if (cts->type == CTS_TYPE_CURRENT_SETTINGS) {
749 update_type |= AHD_TRANS_GOAL;
750 discenable = &tstate->discenable;
751 tagenable = &tstate->tagenable;
752 tinfo->curr.protocol_version = cts->protocol_version;
753 tinfo->curr.transport_version = cts->transport_version;
754 tinfo->goal.protocol_version = cts->protocol_version;
755 tinfo->goal.transport_version = cts->transport_version;
756 } else if (cts->type == CTS_TYPE_USER_SETTINGS) {
757 update_type |= AHD_TRANS_USER;
758 discenable = &ahd->user_discenable;
759 tagenable = &ahd->user_tagenable;
760 tinfo->user.protocol_version = cts->protocol_version;
761 tinfo->user.transport_version = cts->transport_version;
763 cts->ccb_h.status = CAM_REQ_INVALID;
767 if ((spi->valid & CTS_SPI_VALID_DISC) != 0) {
768 if ((spi->flags & CTS_SPI_FLAGS_DISC_ENB) != 0)
769 *discenable |= devinfo.target_mask;
771 *discenable &= ~devinfo.target_mask;
774 if ((scsi->valid & CTS_SCSI_VALID_TQ) != 0) {
775 if ((scsi->flags & CTS_SCSI_FLAGS_TAG_ENB) != 0)
776 *tagenable |= devinfo.target_mask;
778 *tagenable &= ~devinfo.target_mask;
781 if ((spi->valid & CTS_SPI_VALID_BUS_WIDTH) != 0) {
782 ahd_validate_width(ahd, /*tinfo limit*/NULL,
783 &spi->bus_width, ROLE_UNKNOWN);
784 ahd_set_width(ahd, &devinfo, spi->bus_width,
785 update_type, /*paused*/FALSE);
788 if ((spi->valid & CTS_SPI_VALID_PPR_OPTIONS) == 0) {
789 if (update_type == AHD_TRANS_USER)
790 spi->ppr_options = tinfo->user.ppr_options;
792 spi->ppr_options = tinfo->goal.ppr_options;
795 if ((spi->valid & CTS_SPI_VALID_SYNC_OFFSET) == 0) {
796 if (update_type == AHD_TRANS_USER)
797 spi->sync_offset = tinfo->user.offset;
799 spi->sync_offset = tinfo->goal.offset;
802 if ((spi->valid & CTS_SPI_VALID_SYNC_RATE) == 0) {
803 if (update_type == AHD_TRANS_USER)
804 spi->sync_period = tinfo->user.period;
806 spi->sync_period = tinfo->goal.period;
809 if (((spi->valid & CTS_SPI_VALID_SYNC_RATE) != 0)
810 || ((spi->valid & CTS_SPI_VALID_SYNC_OFFSET) != 0)) {
813 maxsync = AHD_SYNCRATE_MAX;
815 if (spi->bus_width != MSG_EXT_WDTR_BUS_16_BIT)
816 spi->ppr_options &= ~MSG_EXT_PPR_DT_REQ;
818 if ((*discenable & devinfo.target_mask) == 0)
819 spi->ppr_options &= ~MSG_EXT_PPR_IU_REQ;
821 ahd_find_syncrate(ahd, &spi->sync_period,
822 &spi->ppr_options, maxsync);
823 ahd_validate_offset(ahd, /*tinfo limit*/NULL,
824 spi->sync_period, &spi->sync_offset,
825 spi->bus_width, ROLE_UNKNOWN);
827 /* We use a period of 0 to represent async */
828 if (spi->sync_offset == 0) {
829 spi->sync_period = 0;
830 spi->ppr_options = 0;
833 ahd_set_syncrate(ahd, &devinfo, spi->sync_period,
834 spi->sync_offset, spi->ppr_options,
835 update_type, /*paused*/FALSE);
837 cts->ccb_h.status = CAM_REQ_CMP;
841 ahd_get_tran_settings(struct ahd_softc *ahd, int our_id, char channel,
842 struct ccb_trans_settings *cts)
844 struct ahd_devinfo devinfo;
845 struct ccb_trans_settings_scsi *scsi;
846 struct ccb_trans_settings_spi *spi;
847 struct ahd_initiator_tinfo *targ_info;
848 struct ahd_tmode_tstate *tstate;
849 struct ahd_transinfo *tinfo;
851 scsi = &cts->proto_specific.scsi;
852 spi = &cts->xport_specific.spi;
853 ahd_compile_devinfo(&devinfo, our_id,
854 cts->ccb_h.target_id,
855 cts->ccb_h.target_lun,
856 channel, ROLE_UNKNOWN);
857 targ_info = ahd_fetch_transinfo(ahd, devinfo.channel,
859 devinfo.target, &tstate);
861 if (cts->type == CTS_TYPE_CURRENT_SETTINGS)
862 tinfo = &targ_info->curr;
864 tinfo = &targ_info->user;
866 scsi->flags &= ~CTS_SCSI_FLAGS_TAG_ENB;
867 spi->flags &= ~CTS_SPI_FLAGS_DISC_ENB;
868 if (cts->type == CTS_TYPE_USER_SETTINGS) {
869 if ((ahd->user_discenable & devinfo.target_mask) != 0)
870 spi->flags |= CTS_SPI_FLAGS_DISC_ENB;
872 if ((ahd->user_tagenable & devinfo.target_mask) != 0)
873 scsi->flags |= CTS_SCSI_FLAGS_TAG_ENB;
875 if ((tstate->discenable & devinfo.target_mask) != 0)
876 spi->flags |= CTS_SPI_FLAGS_DISC_ENB;
878 if ((tstate->tagenable & devinfo.target_mask) != 0)
879 scsi->flags |= CTS_SCSI_FLAGS_TAG_ENB;
881 cts->protocol_version = tinfo->protocol_version;
882 cts->transport_version = tinfo->transport_version;
884 spi->sync_period = tinfo->period;
885 spi->sync_offset = tinfo->offset;
886 spi->bus_width = tinfo->width;
887 spi->ppr_options = tinfo->ppr_options;
889 cts->protocol = PROTO_SCSI;
890 cts->transport = XPORT_SPI;
891 spi->valid = CTS_SPI_VALID_SYNC_RATE
892 | CTS_SPI_VALID_SYNC_OFFSET
893 | CTS_SPI_VALID_BUS_WIDTH
894 | CTS_SPI_VALID_PPR_OPTIONS;
896 if (cts->ccb_h.target_lun != CAM_LUN_WILDCARD) {
897 scsi->valid = CTS_SCSI_VALID_TQ;
898 spi->valid |= CTS_SPI_VALID_DISC;
903 cts->ccb_h.status = CAM_REQ_CMP;
907 ahd_async(void *callback_arg, uint32_t code, struct cam_path *path, void *arg)
909 struct ahd_softc *ahd;
912 sim = (struct cam_sim *)callback_arg;
913 ahd = (struct ahd_softc *)cam_sim_softc(sim);
917 struct ahd_devinfo devinfo;
919 ahd_compile_devinfo(&devinfo, SIM_SCSI_ID(ahd, sim),
920 xpt_path_target_id(path),
921 xpt_path_lun_id(path),
922 SIM_CHANNEL(ahd, sim),
926 * Revert to async/narrow transfers
927 * for the next device.
929 ahd_set_width(ahd, &devinfo, MSG_EXT_WDTR_BUS_8_BIT,
930 AHD_TRANS_GOAL|AHD_TRANS_CUR, /*paused*/FALSE);
931 ahd_set_syncrate(ahd, &devinfo, /*period*/0, /*offset*/0,
932 /*ppr_options*/0, AHD_TRANS_GOAL|AHD_TRANS_CUR,
942 ahd_execute_scb(void *arg, bus_dma_segment_t *dm_segs, int nsegments,
947 struct ahd_softc *ahd;
948 struct ahd_initiator_tinfo *tinfo;
949 struct ahd_tmode_tstate *tstate;
952 scb = (struct scb *)arg;
954 ahd = scb->ahd_softc;
958 aic_set_transaction_status(scb, CAM_REQ_TOO_BIG);
960 aic_set_transaction_status(scb, CAM_REQ_CMP_ERR);
962 bus_dmamap_unload(ahd->buffer_dmat, scb->dmamap);
963 ahd_free_scb(ahd, scb);
968 if (nsegments != 0) {
973 /* Copy the segments into our SG list */
974 for (i = nsegments, sg = scb->sg_list; i > 0; i--) {
976 sg = ahd_sg_setup(ahd, scb, sg, dm_segs->ds_addr,
982 if ((ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN)
983 op = BUS_DMASYNC_PREREAD;
985 op = BUS_DMASYNC_PREWRITE;
987 bus_dmamap_sync(ahd->buffer_dmat, scb->dmamap, op);
989 if (ccb->ccb_h.func_code == XPT_CONT_TARGET_IO) {
990 struct target_data *tdata;
992 tdata = &scb->hscb->shared_data.tdata;
993 tdata->target_phases |= DPHASE_PENDING;
994 if ((ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_OUT)
995 tdata->data_phase = P_DATAOUT;
997 tdata->data_phase = P_DATAIN;
1002 * Last time we need to check if this SCB needs to
1005 if (aic_get_transaction_status(scb) != CAM_REQ_INPROG) {
1007 bus_dmamap_unload(ahd->buffer_dmat,
1009 ahd_free_scb(ahd, scb);
1014 tinfo = ahd_fetch_transinfo(ahd, SCSIID_CHANNEL(ahd, scb->hscb->scsiid),
1015 SCSIID_OUR_ID(scb->hscb->scsiid),
1016 SCSIID_TARGET(ahd, scb->hscb->scsiid),
1019 mask = SCB_GET_TARGET_MASK(ahd, scb);
1021 if ((tstate->discenable & mask) != 0
1022 && (ccb->ccb_h.flags & CAM_DIS_DISCONNECT) == 0)
1023 scb->hscb->control |= DISCENB;
1025 if ((tinfo->curr.ppr_options & MSG_EXT_PPR_IU_REQ) != 0) {
1026 scb->flags |= SCB_PACKETIZED;
1027 if (scb->hscb->task_management != 0)
1028 scb->hscb->control &= ~MK_MESSAGE;
1031 if ((ccb->ccb_h.flags & CAM_NEGOTIATE) != 0
1032 && (tinfo->goal.width != 0
1033 || tinfo->goal.period != 0
1034 || tinfo->goal.ppr_options != 0)) {
1035 scb->flags |= SCB_NEGOTIATE;
1036 scb->hscb->control |= MK_MESSAGE;
1037 } else if ((tstate->auto_negotiate & mask) != 0) {
1038 scb->flags |= SCB_AUTO_NEGOTIATE;
1039 scb->hscb->control |= MK_MESSAGE;
1042 LIST_INSERT_HEAD(&ahd->pending_scbs, scb, pending_links);
1044 ccb->ccb_h.status |= CAM_SIM_QUEUED;
1046 aic_scb_timer_start(scb);
1048 if ((scb->flags & SCB_TARGET_IMMEDIATE) != 0) {
1049 /* Define a mapping from our tag to the SCB. */
1050 ahd->scb_data.scbindex[SCB_GET_TAG(scb)] = scb;
1052 ahd_set_scbptr(ahd, SCB_GET_TAG(scb));
1053 ahd_outb(ahd, RETURN_1, CONT_MSG_LOOP_TARG);
1056 ahd_queue_scb(ahd, scb);
1062 ahd_poll(struct cam_sim *sim)
1064 ahd_intr(cam_sim_softc(sim));
1068 ahd_setup_data(struct ahd_softc *ahd, struct cam_sim *sim,
1069 struct ccb_scsiio *csio, struct scb *scb)
1071 struct hardware_scb *hscb;
1072 struct ccb_hdr *ccb_h;
1075 ccb_h = &csio->ccb_h;
1078 csio->sense_resid = 0;
1079 if (ccb_h->func_code == XPT_SCSI_IO) {
1080 hscb->cdb_len = csio->cdb_len;
1081 if ((ccb_h->flags & CAM_CDB_POINTER) != 0) {
1083 if (hscb->cdb_len > MAX_CDB_LEN
1084 && (ccb_h->flags & CAM_CDB_PHYS) == 0) {
1087 * Should CAM start to support CDB sizes
1088 * greater than 16 bytes, we could use
1089 * the sense buffer to store the CDB.
1091 aic_set_transaction_status(scb,
1093 ahd_free_scb(ahd, scb);
1094 xpt_done((union ccb *)csio);
1097 if ((ccb_h->flags & CAM_CDB_PHYS) != 0) {
1098 hscb->shared_data.idata.cdb_from_host.cdbptr =
1099 aic_htole64((uintptr_t)csio->cdb_io.cdb_ptr);
1100 hscb->shared_data.idata.cdb_from_host.cdblen =
1102 hscb->cdb_len |= SCB_CDB_LEN_PTR;
1104 memcpy(hscb->shared_data.idata.cdb,
1105 csio->cdb_io.cdb_ptr,
1109 if (hscb->cdb_len > MAX_CDB_LEN) {
1111 aic_set_transaction_status(scb,
1113 ahd_free_scb(ahd, scb);
1114 xpt_done((union ccb *)csio);
1117 memcpy(hscb->shared_data.idata.cdb,
1118 csio->cdb_io.cdb_bytes, hscb->cdb_len);
1122 /* Only use S/G if there is a transfer */
1123 if ((ccb_h->flags & CAM_DIR_MASK) != CAM_DIR_NONE) {
1124 if ((ccb_h->flags & CAM_SCATTER_VALID) == 0) {
1125 /* We've been given a pointer to a single buffer */
1126 if ((ccb_h->flags & CAM_DATA_PHYS) == 0) {
1131 error = bus_dmamap_load(ahd->buffer_dmat,
1137 if (error == EINPROGRESS) {
1139 * So as to maintain ordering,
1140 * freeze the controller queue
1141 * until our mapping is
1144 xpt_freeze_simq(sim,
1146 scb->io_ctx->ccb_h.status |=
1151 struct bus_dma_segment seg;
1153 /* Pointer to physical buffer */
1154 if (csio->dxfer_len > AHD_MAXTRANSFER_SIZE)
1155 panic("ahd_setup_data - Transfer size "
1156 "larger than can device max");
1159 (bus_addr_t)(vm_offset_t)csio->data_ptr;
1160 seg.ds_len = csio->dxfer_len;
1161 ahd_execute_scb(scb, &seg, 1, 0);
1164 struct bus_dma_segment *segs;
1166 if ((ccb_h->flags & CAM_DATA_PHYS) != 0)
1167 panic("ahd_setup_data - Physical segment "
1168 "pointers unsupported");
1170 if ((ccb_h->flags & CAM_SG_LIST_PHYS) == 0)
1171 panic("ahd_setup_data - Virtual segment "
1172 "addresses unsupported");
1174 /* Just use the segments provided */
1175 segs = (struct bus_dma_segment *)csio->data_ptr;
1176 ahd_execute_scb(scb, segs, csio->sglist_cnt, 0);
1179 ahd_execute_scb(scb, NULL, 0, 0);
1184 ahd_abort_ccb(struct ahd_softc *ahd, struct cam_sim *sim, union ccb *ccb)
1186 union ccb *abort_ccb;
1188 abort_ccb = ccb->cab.abort_ccb;
1189 switch (abort_ccb->ccb_h.func_code) {
1190 #ifdef AHD_TARGET_MODE
1191 case XPT_ACCEPT_TARGET_IO:
1192 case XPT_IMMED_NOTIFY:
1193 case XPT_CONT_TARGET_IO:
1195 struct ahd_tmode_tstate *tstate;
1196 struct ahd_tmode_lstate *lstate;
1197 struct ccb_hdr_slist *list;
1200 status = ahd_find_tmode_devs(ahd, sim, abort_ccb, &tstate,
1203 if (status != CAM_REQ_CMP) {
1204 ccb->ccb_h.status = status;
1208 if (abort_ccb->ccb_h.func_code == XPT_ACCEPT_TARGET_IO)
1209 list = &lstate->accept_tios;
1210 else if (abort_ccb->ccb_h.func_code == XPT_IMMED_NOTIFY)
1211 list = &lstate->immed_notifies;
1216 struct ccb_hdr *curelm;
1219 curelm = SLIST_FIRST(list);
1221 if (curelm == &abort_ccb->ccb_h) {
1223 SLIST_REMOVE_HEAD(list, sim_links.sle);
1225 while(curelm != NULL) {
1226 struct ccb_hdr *nextelm;
1229 SLIST_NEXT(curelm, sim_links.sle);
1231 if (nextelm == &abort_ccb->ccb_h) {
1244 abort_ccb->ccb_h.status = CAM_REQ_ABORTED;
1245 xpt_done(abort_ccb);
1246 ccb->ccb_h.status = CAM_REQ_CMP;
1248 xpt_print_path(abort_ccb->ccb_h.path);
1249 printf("Not found\n");
1250 ccb->ccb_h.status = CAM_PATH_INVALID;
1258 /* XXX Fully implement the hard ones */
1259 ccb->ccb_h.status = CAM_UA_ABORT;
1262 ccb->ccb_h.status = CAM_REQ_INVALID;
1269 ahd_send_async(struct ahd_softc *ahd, char channel, u_int target,
1270 u_int lun, ac_code code, void *opt_arg)
1272 struct ccb_trans_settings cts;
1273 struct cam_path *path;
1278 error = ahd_create_path(ahd, channel, target, lun, &path);
1280 if (error != CAM_REQ_CMP)
1284 case AC_TRANSFER_NEG:
1286 struct ccb_trans_settings_scsi *scsi;
1288 cts.type = CTS_TYPE_CURRENT_SETTINGS;
1289 scsi = &cts.proto_specific.scsi;
1290 cts.ccb_h.path = path;
1291 cts.ccb_h.target_id = target;
1292 cts.ccb_h.target_lun = lun;
1293 ahd_get_tran_settings(ahd, ahd->our_id, channel, &cts);
1295 scsi->valid &= ~CTS_SCSI_VALID_TQ;
1296 scsi->flags &= ~CTS_SCSI_FLAGS_TAG_ENB;
1297 if (opt_arg == NULL)
1299 if (*((ahd_queue_alg *)opt_arg) == AHD_QUEUE_TAGGED)
1300 scsi->flags |= ~CTS_SCSI_FLAGS_TAG_ENB;
1301 scsi->valid |= CTS_SCSI_VALID_TQ;
1308 panic("ahd_send_async: Unexpected async event");
1310 xpt_async(code, path, arg);
1311 xpt_free_path(path);
1315 ahd_platform_set_tags(struct ahd_softc *ahd,
1316 struct ahd_devinfo *devinfo, int enable)
1321 ahd_platform_alloc(struct ahd_softc *ahd, void *platform_arg)
1323 ahd->platform_data = malloc(sizeof(struct ahd_platform_data), M_DEVBUF,
1325 if (ahd->platform_data == NULL)
1331 ahd_platform_free(struct ahd_softc *ahd)
1333 struct ahd_platform_data *pdata;
1335 pdata = ahd->platform_data;
1336 if (pdata != NULL) {
1337 if (pdata->regs[0] != NULL)
1338 bus_release_resource(ahd->dev_softc,
1339 pdata->regs_res_type[0],
1340 pdata->regs_res_id[0],
1343 if (pdata->regs[1] != NULL)
1344 bus_release_resource(ahd->dev_softc,
1345 pdata->regs_res_type[1],
1346 pdata->regs_res_id[1],
1349 if (pdata->irq != NULL)
1350 bus_release_resource(ahd->dev_softc,
1351 pdata->irq_res_type,
1354 if (pdata->sim != NULL) {
1355 xpt_async(AC_LOST_DEVICE, pdata->path, NULL);
1356 xpt_free_path(pdata->path);
1357 xpt_bus_deregister(cam_sim_path(pdata->sim));
1358 cam_sim_free(pdata->sim, /*free_devq*/TRUE);
1360 if (pdata->eh != NULL)
1361 EVENTHANDLER_DEREGISTER(shutdown_final, pdata->eh);
1362 free(ahd->platform_data, M_DEVBUF);
1367 ahd_softc_comp(struct ahd_softc *lahd, struct ahd_softc *rahd)
1369 /* We don't sort softcs under FreeBSD so report equal always */
1374 ahd_detach(device_t dev)
1376 struct ahd_softc *ahd;
1378 device_printf(dev, "detaching device\n");
1379 ahd = device_get_softc(dev);
1381 TAILQ_REMOVE(&ahd_tailq, ahd, links);
1382 ahd_intr_enable(ahd, FALSE);
1383 bus_teardown_intr(dev, ahd->platform_data->irq, ahd->platform_data->ih);
1391 ahd_dump_targcmd(struct target_cmd *cmd)
1397 byte = &cmd->initiator_channel;
1398 /* Debugging info for received commands */
1399 last_byte = &cmd[1].initiator_channel;
1402 while (byte < last_byte) {
1405 printf("%#x", *byte++);
1418 ahd_modevent(module_t mod, int type, void *data)
1420 /* XXX Deal with busy status on unload. */
1421 /* XXX Deal with unknown events */
1425 static moduledata_t ahd_mod = {
1431 /********************************** DDB Hooks *********************************/
1433 static struct ahd_softc *ahd_ddb_softc;
1434 static int ahd_ddb_paused;
1435 static int ahd_ddb_paused_on_entry;
1436 DB_COMMAND(ahd_sunit, ahd_ddb_sunit)
1438 struct ahd_softc *list_ahd;
1440 ahd_ddb_softc = NULL;
1441 TAILQ_FOREACH(list_ahd, &ahd_tailq, links) {
1442 if (list_ahd->unit == addr)
1443 ahd_ddb_softc = list_ahd;
1445 if (ahd_ddb_softc == NULL)
1446 db_error("No matching softc found!\n");
1449 DB_COMMAND(ahd_pause, ahd_ddb_pause)
1451 if (ahd_ddb_softc == NULL) {
1452 db_error("Must set unit with ahd_sunit first!\n");
1455 if (ahd_ddb_paused == 0) {
1457 if (ahd_is_paused(ahd_ddb_softc)) {
1458 ahd_ddb_paused_on_entry++;
1461 ahd_pause(ahd_ddb_softc);
1465 DB_COMMAND(ahd_unpause, ahd_ddb_unpause)
1467 if (ahd_ddb_softc == NULL) {
1468 db_error("Must set unit with ahd_sunit first!\n");
1471 if (ahd_ddb_paused != 0) {
1473 if (ahd_ddb_paused_on_entry)
1475 ahd_unpause(ahd_ddb_softc);
1476 } else if (ahd_ddb_paused_on_entry != 0) {
1477 /* Two unpauses to clear a paused on entry. */
1478 ahd_ddb_paused_on_entry = 0;
1479 ahd_unpause(ahd_ddb_softc);
1483 DB_COMMAND(ahd_in, ahd_ddb_in)
1488 if (ahd_ddb_softc == NULL) {
1489 db_error("Must set unit with ahd_sunit first!\n");
1496 while ((c = *modif++) != '\0') {
1512 while (--count >= 0) {
1513 db_printf("%04lx (M)%x: \t", (u_long)addr,
1514 ahd_inb(ahd_ddb_softc, MODE_PTR));
1517 db_printf("%02x\n", ahd_inb(ahd_ddb_softc, addr));
1520 db_printf("%04x\n", ahd_inw(ahd_ddb_softc, addr));
1523 db_printf("%08x\n", ahd_inl(ahd_ddb_softc, addr));
1529 DB_FUNC(ahd_out, ahd_ddb_out, db_cmd_table, CS_MORE, NULL)
1531 db_expr_t old_value;
1532 db_expr_t new_value;
1535 if (ahd_ddb_softc == NULL) {
1536 db_error("Must set unit with ahd_sunit first!\n");
1552 db_error("Unknown size\n");
1556 while (db_expression(&new_value)) {
1560 old_value = ahd_inb(ahd_ddb_softc, addr);
1561 ahd_outb(ahd_ddb_softc, addr, new_value);
1564 old_value = ahd_inw(ahd_ddb_softc, addr);
1565 ahd_outw(ahd_ddb_softc, addr, new_value);
1568 old_value = ahd_inl(ahd_ddb_softc, addr);
1569 ahd_outl(ahd_ddb_softc, addr, new_value);
1572 db_printf("%04lx (M)%x: \t0x%lx\t=\t0x%lx",
1573 (u_long)addr, ahd_inb(ahd_ddb_softc, MODE_PTR),
1574 (u_long)old_value, (u_long)new_value);
1580 DB_COMMAND(ahd_dump, ahd_ddb_dump)
1582 if (ahd_ddb_softc == NULL) {
1583 db_error("Must set unit with ahd_sunit first!\n");
1586 ahd_dump_card_state(ahd_ddb_softc);
1592 DECLARE_MODULE(ahd, ahd_mod, SI_SUB_DRIVERS, SI_ORDER_MIDDLE);
1593 MODULE_DEPEND(ahd, cam, 1, 1, 1);
1594 MODULE_VERSION(ahd, 1);