From d0993d75845c08d86123c532c506dfadb6ed5493 Mon Sep 17 00:00:00 2001 From: "Justin T. Gibbs" Date: Tue, 10 Nov 1998 06:44:42 +0000 Subject: [PATCH] Fix probes when a port address is specified. Convert from BT'isms to AHA'isms Don't fail the probe if the illegal command bit is set in the status register. If the BusLogic MultiMaster probe preceeded us, it may well have determined that the card we are attaching to was not a true MultiMaster by sending us a command that fails on the 154X. Reset the adapter before doing the inquiry. This provides extra sanity and will also clear the illegal command status bit that my be left over from the MultiMaster probe. --- sys/dev/aha/aha.c | 384 ++++++++++++++++++++++++++----------------- sys/dev/aha/ahareg.h | 109 ++++++------ 2 files changed, 294 insertions(+), 199 deletions(-) diff --git a/sys/dev/aha/aha.c b/sys/dev/aha/aha.c index 9109c6d4cfe3..46fa098fe370 100644 --- a/sys/dev/aha/aha.c +++ b/sys/dev/aha/aha.c @@ -55,7 +55,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: aha.c,v 1.9 1998/10/15 19:53:30 imp Exp $ + * $Id: aha.c,v 1.10 1998/10/15 23:46:33 gibbs Exp $ */ #include @@ -125,15 +125,15 @@ ahanextoutbox(struct aha_softc *aha) /* CCB Mangement functions */ static __inline u_int32_t ahaccbvtop(struct aha_softc *aha, - struct aha_ccb *bccb); + struct aha_ccb *accb); static __inline struct aha_ccb* ahaccbptov(struct aha_softc *aha, u_int32_t ccb_addr); static __inline u_int32_t -ahaccbvtop(struct aha_softc *aha, struct aha_ccb *bccb) +ahaccbvtop(struct aha_softc *aha, struct aha_ccb *accb) { return (aha->aha_ccb_physbase - + (u_int32_t)((caddr_t)bccb - (caddr_t)aha->aha_ccb_array)); + + (u_int32_t)((caddr_t)accb - (caddr_t)aha->aha_ccb_array)); } static __inline struct aha_ccb * ahaccbptov(struct aha_softc *aha, u_int32_t ccb_addr) @@ -143,10 +143,10 @@ ahaccbptov(struct aha_softc *aha, u_int32_t ccb_addr) } static struct aha_ccb* ahagetccb(struct aha_softc *aha); -static __inline void ahafreeccb(struct aha_softc *aha, struct aha_ccb *bccb); +static __inline void ahafreeccb(struct aha_softc *aha, struct aha_ccb *accb); static void ahaallocccbs(struct aha_softc *aha); static bus_dmamap_callback_t ahaexecuteccb; -static void ahadone(struct aha_softc *aha, struct aha_ccb *bccb, +static void ahadone(struct aha_softc *aha, struct aha_ccb *accb, aha_mbi_comp_code_t comp_code); /* Host adapter command functions */ @@ -163,7 +163,7 @@ static void ahafetchtransinfo(struct aha_softc *aha, struct ccb_trans_settings *cts); /* CAM SIM entry points */ -#define ccb_bccb_ptr spriv_ptr0 +#define ccb_accb_ptr spriv_ptr0 #define ccb_aha_ptr spriv_ptr1 static void ahaaction(struct cam_sim *sim, union ccb *ccb); static void ahapoll(struct cam_sim *sim); @@ -180,12 +180,26 @@ u_long aha_unit = 0; */ struct aha_isa_port aha_isa_ports[] = { - { 0x330, 0 }, - { 0x334, 0 }, - { 0x230, 0 }, - { 0x234, 0 }, - { 0x130, 0 }, - { 0x134, 0 } + { 0x130, 0, 4 }, + { 0x134, 0, 5 }, + { 0x230, 0, 2 }, + { 0x234, 0, 3 }, + { 0x330, 0, 0 }, + { 0x334, 0, 1 } +}; + +/* + * I/O ports listed in the order enumerated by the + * card for certain op codes. + */ +u_int16_t aha_board_ports[] = +{ + 0x330, + 0x334, + 0x230, + 0x234, + 0x130, + 0x134 }; /* Exported functions */ @@ -292,13 +306,26 @@ aha_probe(struct aha_softc* aha) status = aha_inb(aha, STATUS_REG); if ((status == 0) || (status & (DIAG_ACTIVE|CMD_REG_BUSY| - STATUS_REG_RSVD|CMD_INVALID)) != 0) { + STATUS_REG_RSVD)) != 0) { + PRVERB(("%s: status reg test failed %x\n", aha_name(aha), + status)); return (ENXIO); } intstat = aha_inb(aha, INTSTAT_REG); if ((intstat & INTSTAT_REG_RSVD) != 0) { - printf("%s: Failed Intstat Reg Test\n", aha_name(aha)); + PRVERB(("%s: Failed Intstat Reg Test\n", aha_name(aha))); + return (ENXIO); + } + + /* + * Looking good so far. Final test is to reset the + * adapter and fetch the board ID and ensure we aren't + * looking at a BusLogic. + */ + if ((error = ahareset(aha, /*hard_reset*/TRUE)) != 0) { + if (bootverbose) + printf("%s: Failed Reset\n", aha_name(aha)); return (ENXIO); } @@ -306,7 +333,7 @@ aha_probe(struct aha_softc* aha) * Get the board ID. We use this to see if we're dealing with * a buslogic card or a aha card (or clone). */ - error = aha_cmd(aha, BOP_INQUIRE_BOARD_ID, NULL, /*parmlen*/0, + error = aha_cmd(aha, AOP_INQUIRE_BOARD_ID, NULL, /*parmlen*/0, (u_int8_t*)&board_id, sizeof(board_id), DEFAULT_CMD_TIMEOUT); if (error != 0) { @@ -328,8 +355,11 @@ aha_probe(struct aha_softc* aha) */ if (aha->boardid <= 0x42) { status = aha_inb(aha, GEOMETRY_REG); - if (status != 0xff) + if (status != 0xff) { + PRVERB(("%s: Geometry Register test failed\n", + aha_name(aha))); return (ENXIO); + } } return (0); @@ -389,10 +419,10 @@ aha_fetch_adapter_info(struct aha_softc *aha) (aha->boardid == 0x41 && aha->fw_major == 0x31 && aha->fw_minor >= 0x34)) { - error = aha_cmd(aha, BOP_RETURN_EXT_BIOS_INFO, NULL, + error = aha_cmd(aha, AOP_RETURN_EXT_BIOS_INFO, NULL, /*paramlen*/0, (u_char *)&extbios, sizeof(extbios), DEFAULT_CMD_TIMEOUT); - error = aha_cmd(aha, BOP_MBOX_IF_ENABLE, (u_int8_t *)&extbios, + error = aha_cmd(aha, AOP_MBOX_IF_ENABLE, (u_int8_t *)&extbios, /*paramlen*/2, NULL, 0, DEFAULT_CMD_TIMEOUT); } if (aha->boardid < 0x41) @@ -406,7 +436,7 @@ aha_fetch_adapter_info(struct aha_softc *aha) aha->max_ccbs = 16; /* Determine Sync/Wide/Disc settings */ length_param = sizeof(setup_info); - error = aha_cmd(aha, BOP_INQUIRE_SETUP_INFO, &length_param, + error = aha_cmd(aha, AOP_INQUIRE_SETUP_INFO, &length_param, /*paramlen*/1, (u_int8_t*)&setup_info, sizeof(setup_info), DEFAULT_CMD_TIMEOUT); if (error != 0) { @@ -424,7 +454,7 @@ aha_fetch_adapter_info(struct aha_softc *aha) /* Determine our SCSI ID */ - error = aha_cmd(aha, BOP_INQUIRE_CONFIG, NULL, /*parmlen*/0, + error = aha_cmd(aha, AOP_INQUIRE_CONFIG, NULL, /*parmlen*/0, (u_int8_t*)&config_data, sizeof(config_data), DEFAULT_CMD_TIMEOUT); if (error != 0) { @@ -649,7 +679,7 @@ void aha_mark_probed_bio(isa_compat_io_t port) { if (port < BIO_DISABLED) - aha_isa_ports[port].probed = 1; + aha_mark_probed_iop(aha_board_ports[port]); } void @@ -665,6 +695,43 @@ aha_mark_probed_iop(u_int ioport) } } +void +aha_find_probe_range(int ioport, int *port_index, int *max_port_index) +{ + if (ioport > 0) { + int i; + + for (i = 0;i < AHA_NUM_ISAPORTS; i++) + if (ioport <= aha_isa_ports[i].addr) + break; + if ((i >= AHA_NUM_ISAPORTS) + || (ioport != aha_isa_ports[i].addr)) { + printf(" +aha_isa_probe: Invalid baseport of 0x%x specified. +aha_isa_probe: Nearest valid baseport is 0x%x. +aha_isa_probe: Failing probe.\n", + ioport, + (i < AHA_NUM_ISAPORTS) + ? aha_isa_ports[i].addr + : aha_isa_ports[AHA_NUM_ISAPORTS - 1].addr); + *port_index = *max_port_index = -1; + return; + } + *port_index = *max_port_index = aha_isa_ports[i].bio; + } else { + *port_index = 0; + *max_port_index = AHA_NUM_ISAPORTS - 1; + } +} + +int +aha_iop_from_bio(isa_compat_io_t bio_index) +{ + if (bio_index >= 0 && bio_index < AHA_NUM_ISAPORTS) + return (aha_board_ports[bio_index]); + return (-1); +} + static void ahaallocccbs(struct aha_softc *aha) { @@ -703,7 +770,7 @@ ahaallocccbs(struct aha_softc *aha) next_ccb->sg_list = segs; next_ccb->sg_list_phys = physaddr; - next_ccb->flags = BCCB_FREE; + next_ccb->flags = ACCB_FREE; error = bus_dmamap_create(aha->buffer_dmat, /*flags*/0, &next_ccb->dmamap); if (error != 0) @@ -716,50 +783,54 @@ ahaallocccbs(struct aha_softc *aha) } /* Reserve a CCB for error recovery */ - if (aha->recovery_bccb == NULL) { - aha->recovery_bccb = SLIST_FIRST(&aha->free_aha_ccbs); + if (aha->recovery_accb == NULL) { + aha->recovery_accb = SLIST_FIRST(&aha->free_aha_ccbs); SLIST_REMOVE_HEAD(&aha->free_aha_ccbs, links); } } static __inline void -ahafreeccb(struct aha_softc *aha, struct aha_ccb *bccb) +ahafreeccb(struct aha_softc *aha, struct aha_ccb *accb) { int s; s = splcam(); - if ((bccb->flags & BCCB_ACTIVE) != 0) - LIST_REMOVE(&bccb->ccb->ccb_h, sim_links.le); + if ((accb->flags & ACCB_ACTIVE) != 0) + LIST_REMOVE(&accb->ccb->ccb_h, sim_links.le); if (aha->resource_shortage != 0 - && (bccb->ccb->ccb_h.status & CAM_RELEASE_SIMQ) == 0) { - bccb->ccb->ccb_h.status |= CAM_RELEASE_SIMQ; + && (accb->ccb->ccb_h.status & CAM_RELEASE_SIMQ) == 0) { + accb->ccb->ccb_h.status |= CAM_RELEASE_SIMQ; aha->resource_shortage = FALSE; } - bccb->flags = BCCB_FREE; - SLIST_INSERT_HEAD(&aha->free_aha_ccbs, bccb, links); + accb->flags = ACCB_FREE; + SLIST_INSERT_HEAD(&aha->free_aha_ccbs, accb, links); + aha->active_ccbs--; splx(s); } static struct aha_ccb* ahagetccb(struct aha_softc *aha) { - struct aha_ccb* bccb; + struct aha_ccb* accb; int s; s = splcam(); - if ((bccb = SLIST_FIRST(&aha->free_aha_ccbs)) != NULL) { + if ((accb = SLIST_FIRST(&aha->free_aha_ccbs)) != NULL) { SLIST_REMOVE_HEAD(&aha->free_aha_ccbs, links); + aha->active_ccbs++; } else if (aha->num_ccbs < aha->max_ccbs) { ahaallocccbs(aha); - bccb = SLIST_FIRST(&aha->free_aha_ccbs); - if (bccb == NULL) - printf("%s: Can't malloc BCCB\n", aha_name(aha)); - else + accb = SLIST_FIRST(&aha->free_aha_ccbs); + if (accb == NULL) + printf("%s: Can't malloc ACCB\n", aha_name(aha)); + else { SLIST_REMOVE_HEAD(&aha->free_aha_ccbs, links); + aha->active_ccbs++; + } } splx(s); - return (bccb); + return (accb); } static void @@ -776,13 +847,13 @@ ahaaction(struct cam_sim *sim, union ccb *ccb) case XPT_SCSI_IO: /* Execute the requested I/O operation */ case XPT_RESET_DEV: /* Bus Device Reset the specified SCSI device */ { - struct aha_ccb *bccb; + struct aha_ccb *accb; struct aha_hccb *hccb; /* - * get a bccb to use. + * get a accb to use. */ - if ((bccb = ahagetccb(aha)) == NULL) { + if ((accb = ahagetccb(aha)) == NULL) { int s; s = splcam(); @@ -794,17 +865,17 @@ ahaaction(struct cam_sim *sim, union ccb *ccb) return; } - hccb = &bccb->hccb; + hccb = &accb->hccb; /* - * So we can find the BCCB when an abort is requested + * So we can find the ACCB when an abort is requested */ - bccb->ccb = ccb; - ccb->ccb_h.ccb_bccb_ptr = bccb; + accb->ccb = ccb; + ccb->ccb_h.ccb_accb_ptr = accb; ccb->ccb_h.ccb_aha_ptr = aha; /* - * Put all the arguments for the xfer in the bccb + * Put all the arguments for the xfer in the accb */ hccb->target = ccb->ccb_h.target_id; hccb->lun = ccb->ccb_h.target_lun; @@ -823,7 +894,7 @@ ahaaction(struct cam_sim *sim, union ccb *ccb) hccb->cmd_len = csio->cdb_len; if (hccb->cmd_len > sizeof(hccb->scsi_cdb)) { ccb->ccb_h.status = CAM_REQ_INVALID; - ahafreeccb(aha, bccb); + ahafreeccb(aha, accb); xpt_done(ccb); return; } @@ -835,7 +906,7 @@ ahaaction(struct cam_sim *sim, union ccb *ccb) } else { /* I guess I could map it in... */ ccbh->status = CAM_REQ_INVALID; - ahafreeccb(aha, bccb); + ahafreeccb(aha, accb); xpt_done(ccb); return; } @@ -861,11 +932,11 @@ ahaaction(struct cam_sim *sim, union ccb *ccb) s = splsoftvm(); error = bus_dmamap_load( aha->buffer_dmat, - bccb->dmamap, + accb->dmamap, csio->data_ptr, csio->dxfer_len, ahaexecuteccb, - bccb, + accb, /*flags*/0); if (error == EINPROGRESS) { /* @@ -888,7 +959,7 @@ ahaaction(struct cam_sim *sim, union ccb *ccb) seg.ds_addr = (bus_addr_t)csio->data_ptr; seg.ds_len = csio->dxfer_len; - ahaexecuteccb(bccb, &seg, 1, 0); + ahaexecuteccb(accb, &seg, 1, 0); } } else { struct bus_dma_segment *segs; @@ -906,11 +977,11 @@ ahaaction(struct cam_sim *sim, union ccb *ccb) /* Just use the segments provided */ segs = (struct bus_dma_segment *) csio->data_ptr; - ahaexecuteccb(bccb, segs, + ahaexecuteccb(accb, segs, csio->sglist_cnt, 0); } } else { - ahaexecuteccb(bccb, NULL, 0, 0); + ahaexecuteccb(accb, NULL, 0, 0); } } else { hccb->opcode = INITIATOR_BUS_DEV_RESET; @@ -919,7 +990,7 @@ ahaaction(struct cam_sim *sim, union ccb *ccb) hccb->dataout = TRUE; hccb->cmd_len = 0; hccb->sense_len = 0; - ahaexecuteccb(bccb, NULL, 0, 0); + ahaexecuteccb(accb, NULL, 0, 0); } break; } @@ -1044,14 +1115,14 @@ ahaaction(struct cam_sim *sim, union ccb *ccb) static void ahaexecuteccb(void *arg, bus_dma_segment_t *dm_segs, int nseg, int error) { - struct aha_ccb *bccb; + struct aha_ccb *accb; union ccb *ccb; struct aha_softc *aha; int s; u_int32_t paddr; - bccb = (struct aha_ccb *)arg; - ccb = bccb->ccb; + accb = (struct aha_ccb *)arg; + ccb = accb->ccb; aha = (struct aha_softc *)ccb->ccb_h.ccb_aha_ptr; if (error != 0) { @@ -1062,7 +1133,7 @@ ahaexecuteccb(void *arg, bus_dma_segment_t *dm_segs, int nseg, int error) xpt_freeze_devq(ccb->ccb_h.path, /*count*/1); ccb->ccb_h.status = CAM_REQ_TOO_BIG|CAM_DEV_QFRZN; } - ahafreeccb(aha, bccb); + ahafreeccb(aha, accb); xpt_done(ccb); return; } @@ -1075,7 +1146,7 @@ ahaexecuteccb(void *arg, bus_dma_segment_t *dm_segs, int nseg, int error) end_seg = dm_segs + nseg; /* Copy the segments into our SG list */ - sg = bccb->sg_list; + sg = accb->sg_list; while (dm_segs < end_seg) { ahautoa24(dm_segs->ds_len, sg->len); ahautoa24(dm_segs->ds_addr, sg->addr); @@ -1084,13 +1155,13 @@ ahaexecuteccb(void *arg, bus_dma_segment_t *dm_segs, int nseg, int error) } if (nseg > 1) { - bccb->hccb.opcode = INITIATOR_SG_CCB_WRESID; + accb->hccb.opcode = INITIATOR_SG_CCB_WRESID; ahautoa24((sizeof(aha_sg_t) * nseg), - bccb->hccb.data_len); - ahautoa24(bccb->sg_list_phys, bccb->hccb.data_addr); + accb->hccb.data_len); + ahautoa24(accb->sg_list_phys, accb->hccb.data_addr); } else { - bcopy(bccb->sg_list->len, bccb->hccb.data_len, 3); - bcopy(bccb->sg_list->addr, bccb->hccb.data_addr, 3); + bcopy(accb->sg_list->len, accb->hccb.data_len, 3); + bcopy(accb->sg_list->addr, accb->hccb.data_addr, 3); } if ((ccb->ccb_h.flags & CAM_DIR_MASK) == CAM_DIR_IN) @@ -1098,12 +1169,12 @@ ahaexecuteccb(void *arg, bus_dma_segment_t *dm_segs, int nseg, int error) else op = BUS_DMASYNC_PREWRITE; - bus_dmamap_sync(aha->buffer_dmat, bccb->dmamap, op); + bus_dmamap_sync(aha->buffer_dmat, accb->dmamap, op); } else { - bccb->hccb.opcode = INITIATOR_CCB_WRESID; - ahautoa24(0, bccb->hccb.data_len); - ahautoa24(0, bccb->hccb.data_addr); + accb->hccb.opcode = INITIATOR_CCB_WRESID; + ahautoa24(0, accb->hccb.data_len); + ahautoa24(0, accb->hccb.data_addr); } s = splcam(); @@ -1114,28 +1185,47 @@ ahaexecuteccb(void *arg, bus_dma_segment_t *dm_segs, int nseg, int error) */ if (ccb->ccb_h.status != CAM_REQ_INPROG) { if (nseg != 0) - bus_dmamap_unload(aha->buffer_dmat, bccb->dmamap); - ahafreeccb(aha, bccb); + bus_dmamap_unload(aha->buffer_dmat, accb->dmamap); + ahafreeccb(aha, accb); xpt_done(ccb); splx(s); return; } - bccb->flags = BCCB_ACTIVE; + accb->flags = ACCB_ACTIVE; ccb->ccb_h.status |= CAM_SIM_QUEUED; LIST_INSERT_HEAD(&aha->pending_ccbs, &ccb->ccb_h, sim_links.le); ccb->ccb_h.timeout_ch = - timeout(ahatimeout, (caddr_t)bccb, + timeout(ahatimeout, (caddr_t)accb, (ccb->ccb_h.timeout * hz) / 1000); /* Tell the adapter about this command */ - paddr = ahaccbvtop(aha, bccb); + if (aha->cur_outbox->action_code != AMBO_FREE) { + /* + * We should never encounter a busy mailbox. + * If we do, warn the user, and treat it as + * a resource shortage. If the controller is + * hung, one of the pending transactions will + * timeout causing us to start recovery operations. + */ + printf("%s: Encountered busy mailbox with %d out of %d " + "commands active!!!", aha_name(aha), aha->active_ccbs, + aha->max_ccbs); + untimeout(ahatimeout, accb, ccb->ccb_h.timeout_ch); + if (nseg != 0) + bus_dmamap_unload(aha->buffer_dmat, accb->dmamap); + ahafreeccb(aha, accb); + aha->resource_shortage = TRUE; + xpt_freeze_simq(aha->sim, /*count*/1); + ccb->ccb_h.status = CAM_REQUEUE_REQ; + xpt_done(ccb); + return; + } + paddr = ahaccbvtop(aha, accb); ahautoa24(paddr, aha->cur_outbox->ccb_addr); - if (aha->cur_outbox->action_code != BMBO_FREE) - panic("%s: Too few mailboxes or to many ccbs???", aha_name(aha)); - aha->cur_outbox->action_code = BMBO_START; - aha_outb(aha, COMMAND_REG, BOP_START_MBOX); + aha->cur_outbox->action_code = AMBO_START; + aha_outb(aha, COMMAND_REG, AOP_START_MBOX); ahanextoutbox(aha); splx(s); @@ -1157,13 +1247,13 @@ aha_intr(void *arg) aha_outb(aha, CONTROL_REG, RESET_INTR); if ((intstat & IMB_LOADED) != 0) { - while (aha->cur_inbox->comp_code != BMBI_FREE) { + while (aha->cur_inbox->comp_code != AMBI_FREE) { u_int32_t paddr; paddr = aha_a24tou(aha->cur_inbox->ccb_addr); ahadone(aha, ahaccbptov(aha, paddr), aha->cur_inbox->comp_code); - aha->cur_inbox->comp_code = BMBI_FREE; + aha->cur_inbox->comp_code = AMBI_FREE; ahanextinbox(aha); } } @@ -1175,17 +1265,17 @@ aha_intr(void *arg) } static void -ahadone(struct aha_softc *aha, struct aha_ccb *bccb, aha_mbi_comp_code_t comp_code) +ahadone(struct aha_softc *aha, struct aha_ccb *accb, aha_mbi_comp_code_t comp_code) { union ccb *ccb; struct ccb_scsiio *csio; - ccb = bccb->ccb; - csio = &bccb->ccb->csio; + ccb = accb->ccb; + csio = &accb->ccb->csio; - if ((bccb->flags & BCCB_ACTIVE) == 0) { - printf("%s: ahadone - Attempt to free non-active BCCB %p\n", - aha_name(aha), (void *)bccb); + if ((accb->flags & ACCB_ACTIVE) == 0) { + printf("%s: ahadone - Attempt to free non-active ACCB %p\n", + aha_name(aha), (void *)accb); return; } @@ -1196,13 +1286,13 @@ ahadone(struct aha_softc *aha, struct aha_ccb *bccb, aha_mbi_comp_code_t comp_co op = BUS_DMASYNC_POSTREAD; else op = BUS_DMASYNC_POSTWRITE; - bus_dmamap_sync(aha->buffer_dmat, bccb->dmamap, op); - bus_dmamap_unload(aha->buffer_dmat, bccb->dmamap); + bus_dmamap_sync(aha->buffer_dmat, accb->dmamap, op); + bus_dmamap_unload(aha->buffer_dmat, accb->dmamap); } - if (bccb == aha->recovery_bccb) { + if (accb == aha->recovery_accb) { /* - * The recovery BCCB does not have a CCB associated + * The recovery ACCB does not have a CCB associated * with it, so short circuit the normal error handling. * We now traverse our list of pending CCBs and process * any that were terminated by the recovery CCBs action. @@ -1216,7 +1306,7 @@ ahadone(struct aha_softc *aha, struct aha_ccb *bccb, aha_mbi_comp_code_t comp_co /* Notify all clients that a BDR occured */ error = xpt_create_path(&path, /*periph*/NULL, cam_sim_path(aha->sim), - bccb->hccb.target, + accb->hccb.target, CAM_LUN_WILDCARD); if (error == CAM_REQ_CMP) @@ -1224,16 +1314,16 @@ ahadone(struct aha_softc *aha, struct aha_ccb *bccb, aha_mbi_comp_code_t comp_co ccb_h = LIST_FIRST(&aha->pending_ccbs); while (ccb_h != NULL) { - struct aha_ccb *pending_bccb; + struct aha_ccb *pending_accb; - pending_bccb = (struct aha_ccb *)ccb_h->ccb_bccb_ptr; - if (pending_bccb->hccb.target == bccb->hccb.target) { - pending_bccb->hccb.ahastat = AHASTAT_HA_BDR; + pending_accb = (struct aha_ccb *)ccb_h->ccb_accb_ptr; + if (pending_accb->hccb.target == accb->hccb.target) { + pending_accb->hccb.ahastat = AHASTAT_HA_BDR; ccb_h = LIST_NEXT(ccb_h, sim_links.le); - ahadone(aha, pending_bccb, BMBI_ERROR); + ahadone(aha, pending_accb, AMBI_ERROR); } else { ccb_h->timeout_ch = - timeout(ahatimeout, (caddr_t)pending_bccb, + timeout(ahatimeout, (caddr_t)pending_accb, (ccb_h->timeout * hz) / 1000); ccb_h = LIST_NEXT(ccb_h, sim_links.le); } @@ -1242,29 +1332,29 @@ ahadone(struct aha_softc *aha, struct aha_ccb *bccb, aha_mbi_comp_code_t comp_co return; } - untimeout(ahatimeout, bccb, ccb->ccb_h.timeout_ch); + untimeout(ahatimeout, accb, ccb->ccb_h.timeout_ch); switch (comp_code) { - case BMBI_FREE: + case AMBI_FREE: printf("%s: ahadone - CCB completed with free status!\n", aha_name(aha)); break; - case BMBI_NOT_FOUND: + case AMBI_NOT_FOUND: printf("%s: ahadone - CCB Abort failed to find CCB\n", aha_name(aha)); break; - case BMBI_ABORT: - case BMBI_ERROR: + case AMBI_ABORT: + case AMBI_ERROR: /* An error occured */ - switch(bccb->hccb.ahastat) { + switch(accb->hccb.ahastat) { case AHASTAT_DATARUN_ERROR: - if (bccb->hccb.data_len <= 0) { + if (accb->hccb.data_len <= 0) { csio->ccb_h.status = CAM_DATA_RUN_ERR; break; } /* FALLTHROUGH */ case AHASTAT_NOERROR: - csio->scsi_status = bccb->hccb.sdstat; + csio->scsi_status = accb->hccb.sdstat; csio->ccb_h.status |= CAM_SCSI_STATUS_ERROR; switch(csio->scsi_status) { case SCSI_STATUS_CHECK_COND: @@ -1274,10 +1364,10 @@ ahadone(struct aha_softc *aha, struct aha_ccb *bccb, aha_mbi_comp_code_t comp_co * The aha writes the sense data at different * offsets based on the scsi cmd len */ - bcopy((caddr_t) &bccb->hccb.scsi_cdb + - bccb->hccb.cmd_len, + bcopy((caddr_t) &accb->hccb.scsi_cdb + + accb->hccb.cmd_len, (caddr_t) &csio->sense_data, - bccb->hccb.sense_len); + accb->hccb.sense_len); break; default: break; @@ -1285,7 +1375,7 @@ ahadone(struct aha_softc *aha, struct aha_ccb *bccb, aha_mbi_comp_code_t comp_co csio->ccb_h.status = CAM_REQ_CMP; break; } - csio->resid = aha_a24tou(bccb->hccb.data_len); + csio->resid = aha_a24tou(accb->hccb.data_len); break; case AHASTAT_SELTIMEOUT: csio->ccb_h.status = CAM_SEL_TIMEOUT; @@ -1301,7 +1391,7 @@ ahadone(struct aha_softc *aha, struct aha_ccb *bccb, aha_mbi_comp_code_t comp_co break; case AHASTAT_INVALID_OPCODE: panic("%s: Inavlid CCB Opcode code %x hccb = %p", - aha_name(aha), bccb->hccb.opcode, &bccb->hccb); + aha_name(aha), accb->hccb.opcode, &accb->hccb); break; case AHASTAT_LINKED_CCB_LUN_MISMATCH: /* We don't even support linked commands... */ @@ -1316,7 +1406,7 @@ ahadone(struct aha_softc *aha, struct aha_ccb *bccb, aha_mbi_comp_code_t comp_co csio->ccb_h.status = CAM_SCSI_BUS_RESET; break; case AHASTAT_HA_BDR: - if ((bccb->flags & BCCB_DEVICE_RESET) == 0) + if ((accb->flags & ACCB_DEVICE_RESET) == 0) csio->ccb_h.status = CAM_BDR_SENT; else csio->ccb_h.status = CAM_CMD_TIMEOUT; @@ -1326,18 +1416,18 @@ ahadone(struct aha_softc *aha, struct aha_ccb *bccb, aha_mbi_comp_code_t comp_co xpt_freeze_devq(csio->ccb_h.path, /*count*/1); csio->ccb_h.status |= CAM_DEV_QFRZN; } - if ((bccb->flags & BCCB_RELEASE_SIMQ) != 0) + if ((accb->flags & ACCB_RELEASE_SIMQ) != 0) ccb->ccb_h.status |= CAM_RELEASE_SIMQ; - ahafreeccb(aha, bccb); + ahafreeccb(aha, accb); xpt_done(ccb); break; - case BMBI_OK: + case AMBI_OK: /* All completed without incident */ /* XXX DO WE NEED TO COPY SENSE BYTES HERE???? XXX */ ccb->ccb_h.status |= CAM_REQ_CMP; - if ((bccb->flags & BCCB_RELEASE_SIMQ) != 0) + if ((accb->flags & ACCB_RELEASE_SIMQ) != 0) ccb->ccb_h.status |= CAM_RELEASE_SIMQ; - ahafreeccb(aha, bccb); + ahafreeccb(aha, accb); xpt_done(ccb); break; } @@ -1425,11 +1515,11 @@ ahareset(struct aha_softc* aha, int hard_reset) * Perform completion processing for all outstanding CCBs. */ while ((ccb_h = LIST_FIRST(&aha->pending_ccbs)) != NULL) { - struct aha_ccb *pending_bccb; + struct aha_ccb *pending_accb; - pending_bccb = (struct aha_ccb *)ccb_h->ccb_bccb_ptr; - pending_bccb->hccb.ahastat = AHASTAT_HA_SCSI_BUS_RESET; - ahadone(aha, pending_bccb, BMBI_ERROR); + pending_accb = (struct aha_ccb *)ccb_h->ccb_accb_ptr; + pending_accb->hccb.ahastat = AHASTAT_HA_SCSI_BUS_RESET; + ahadone(aha, pending_accb, AMBI_ERROR); } return (0); @@ -1609,7 +1699,7 @@ ahainitmboxes(struct aha_softc *aha) /* Tell the adapter about them */ init_mbox.num_mboxes = aha->num_boxes; ahautoa24(aha->mailbox_physbase, init_mbox.base_addr); - error = aha_cmd(aha, BOP_INITIALIZE_MBOX, (u_int8_t *)&init_mbox, + error = aha_cmd(aha, AOP_INITIALIZE_MBOX, (u_int8_t *)&init_mbox, /*parmlen*/sizeof(init_mbox), /*reply_buf*/NULL, /*reply_len*/0, DEFAULT_CMD_TIMEOUT); @@ -1642,7 +1732,7 @@ ahafetchtransinfo(struct aha_softc *aha, struct ccb_trans_settings* cts) * the sync info for older models. */ param = sizeof(setup_info); - error = aha_cmd(aha, BOP_INQUIRE_SETUP_INFO, ¶m, /*paramlen*/1, + error = aha_cmd(aha, AOP_INQUIRE_SETUP_INFO, ¶m, /*paramlen*/1, (u_int8_t*)&setup_info, sizeof(setup_info), DEFAULT_CMD_TIMEOUT); @@ -1712,24 +1802,24 @@ ahapoll(struct cam_sim *sim) void ahatimeout(void *arg) { - struct aha_ccb *bccb; + struct aha_ccb *accb; union ccb *ccb; struct aha_softc *aha; int s; u_int32_t paddr; - bccb = (struct aha_ccb *)arg; - ccb = bccb->ccb; + accb = (struct aha_ccb *)arg; + ccb = accb->ccb; aha = (struct aha_softc *)ccb->ccb_h.ccb_aha_ptr; xpt_print_path(ccb->ccb_h.path); - printf("CCB %p - timed out\n", (void *)bccb); + printf("CCB %p - timed out\n", (void *)accb); s = splcam(); - if ((bccb->flags & BCCB_ACTIVE) == 0) { + if ((accb->flags & ACCB_ACTIVE) == 0) { xpt_print_path(ccb->ccb_h.path); printf("CCB %p - timed out CCB already completed\n", - (void *)bccb); + (void *)accb); splx(s); return; } @@ -1744,26 +1834,26 @@ ahatimeout(void *arg) * in attempting to handle errors in parrallel. Timeouts will * be reinstated when the recovery process ends. */ - if ((bccb->flags & BCCB_DEVICE_RESET) == 0) { + if ((accb->flags & ACCB_DEVICE_RESET) == 0) { struct ccb_hdr *ccb_h; - if ((bccb->flags & BCCB_RELEASE_SIMQ) == 0) { + if ((accb->flags & ACCB_RELEASE_SIMQ) == 0) { xpt_freeze_simq(aha->sim, /*count*/1); - bccb->flags |= BCCB_RELEASE_SIMQ; + accb->flags |= ACCB_RELEASE_SIMQ; } ccb_h = LIST_FIRST(&aha->pending_ccbs); while (ccb_h != NULL) { - struct aha_ccb *pending_bccb; + struct aha_ccb *pending_accb; - pending_bccb = (struct aha_ccb *)ccb_h->ccb_bccb_ptr; - untimeout(ahatimeout, pending_bccb, ccb_h->timeout_ch); + pending_accb = (struct aha_ccb *)ccb_h->ccb_accb_ptr; + untimeout(ahatimeout, pending_accb, ccb_h->timeout_ch); ccb_h = LIST_NEXT(ccb_h, sim_links.le); } } - if ((bccb->flags & BCCB_DEVICE_RESET) != 0 - || aha->cur_outbox->action_code != BMBO_FREE) { + if ((accb->flags & ACCB_DEVICE_RESET) != 0 + || aha->cur_outbox->action_code != AMBO_FREE) { /* * Try a full host adapter/SCSI bus reset. * We do this only if we have already attempted @@ -1785,22 +1875,22 @@ ahatimeout(void *arg) * If this fails, we'll get another timeout 2 seconds * later which will attempt a bus reset. */ - bccb->flags |= BCCB_DEVICE_RESET; - ccb->ccb_h.timeout_ch = timeout(ahatimeout, (caddr_t)bccb, 2 * hz); - aha->recovery_bccb->hccb.opcode = INITIATOR_BUS_DEV_RESET; + accb->flags |= ACCB_DEVICE_RESET; + ccb->ccb_h.timeout_ch = timeout(ahatimeout, (caddr_t)accb, 2 * hz); + aha->recovery_accb->hccb.opcode = INITIATOR_BUS_DEV_RESET; /* No Data Transfer */ - aha->recovery_bccb->hccb.datain = TRUE; - aha->recovery_bccb->hccb.dataout = TRUE; - aha->recovery_bccb->hccb.ahastat = 0; - aha->recovery_bccb->hccb.sdstat = 0; - aha->recovery_bccb->hccb.target = ccb->ccb_h.target_id; + aha->recovery_accb->hccb.datain = TRUE; + aha->recovery_accb->hccb.dataout = TRUE; + aha->recovery_accb->hccb.ahastat = 0; + aha->recovery_accb->hccb.sdstat = 0; + aha->recovery_accb->hccb.target = ccb->ccb_h.target_id; /* Tell the adapter about this command */ - paddr = ahaccbvtop(aha, aha->recovery_bccb); + paddr = ahaccbvtop(aha, aha->recovery_accb); ahautoa24(paddr, aha->cur_outbox->ccb_addr); - aha->cur_outbox->action_code = BMBO_START; - aha_outb(aha, COMMAND_REG, BOP_START_MBOX); + aha->cur_outbox->action_code = AMBO_START; + aha_outb(aha, COMMAND_REG, AOP_START_MBOX); ahanextoutbox(aha); } diff --git a/sys/dev/aha/ahareg.h b/sys/dev/aha/ahareg.h index 7af8b537d40d..48bb20caf6a9 100644 --- a/sys/dev/aha/ahareg.h +++ b/sys/dev/aha/ahareg.h @@ -30,7 +30,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: ahareg.h,v 1.2 1998/10/01 04:53:55 imp Exp $ + * $Id: ahareg.h,v 1.3 1998/10/02 04:37:49 imp Exp $ */ #ifndef _AHAREG_H_ @@ -101,41 +101,41 @@ * Opcodes for Adapter commands. */ typedef enum { - BOP_NOP = 0x00, - BOP_INITIALIZE_MBOX = 0x01, - BOP_START_MBOX = 0x02, - BOP_EXECUTE_BIOS_CMD = 0x03, - BOP_INQUIRE_BOARD_ID = 0x04, - BOP_ENABLE_OMBR_INT = 0x05, - BOP_SET_SEL_TIMOUT = 0x06, - BOP_SET_TIME_ON_BUS = 0x07, - BOP_SET_TIME_OFF_BUS = 0x08, - BOP_SET_BUS_TRANS_RATE = 0x09, - BOP_INQUIRE_INST_LDEVS = 0x0A, - BOP_INQUIRE_CONFIG = 0x0B, - BOP_ENABLE_TARGET_MODE = 0x0C, - BOP_INQUIRE_SETUP_INFO = 0x0D, - BOP_WRITE_LRAM = 0x1A, - BOP_READ_LRAM = 0x1B, - BOP_WRITE_CHIP_FIFO = 0x1C, - BOP_READ_CHIP_FIFO = 0x1D, - BOP_ECHO_DATA_BYTE = 0x1F, - BOP_ADAPTER_DIAGNOSTICS = 0x20, - BOP_SET_ADAPTER_OPTIONS = 0x21, - BOP_SET_EEPROM = 0x22, - BOP_RETURN_EEPROM = 0x23, - BOP_ENABLE_SHADOW_RAM = 0x24, - BOP_INIT_BIOS_MBOX = 0x25, - BOP_SET_BIOS_BANK_1 = 0x26, - BOP_SET_BIOS_BANK_2 = 0x27, - BOP_RETURN_EXT_BIOS_INFO= 0x28, - BOP_MBOX_IF_ENABLE = 0x29, - BOP_SCSI_TERM_STATUS = 0x2C, - BOP_INQUIRE_SCAM_DEV = 0x2D, - BOP_SCSI_DEV_TABLE = 0x2E, - BOP_SCAM_OP = 0x2F, - BOP_START_BIOS_CMD = 0x82, - BOP_INQUIRE_ESETUP_INFO = 0x8D + AOP_NOP = 0x00, + AOP_INITIALIZE_MBOX = 0x01, + AOP_START_MBOX = 0x02, + AOP_EXECUTE_BIOS_CMD = 0x03, + AOP_INQUIRE_BOARD_ID = 0x04, + AOP_ENABLE_OMBR_INT = 0x05, + AOP_SET_SEL_TIMOUT = 0x06, + AOP_SET_TIME_ON_BUS = 0x07, + AOP_SET_TIME_OFF_BUS = 0x08, + AOP_SET_BUS_TRANS_RATE = 0x09, + AOP_INQUIRE_INST_LDEVS = 0x0A, + AOP_INQUIRE_CONFIG = 0x0B, + AOP_ENABLE_TARGET_MODE = 0x0C, + AOP_INQUIRE_SETUP_INFO = 0x0D, + AOP_WRITE_LRAM = 0x1A, + AOP_READ_LRAM = 0x1B, + AOP_WRITE_CHIP_FIFO = 0x1C, + AOP_READ_CHIP_FIFO = 0x1D, + AOP_ECHO_DATA_BYTE = 0x1F, + AOP_ADAPTER_DIAGNOSTICS = 0x20, + AOP_SET_ADAPTER_OPTIONS = 0x21, + AOP_SET_EEPROM = 0x22, + AOP_RETURN_EEPROM = 0x23, + AOP_ENABLE_SHADOW_RAM = 0x24, + AOP_INIT_BIOS_MBOX = 0x25, + AOP_SET_BIOS_BANK_1 = 0x26, + AOP_SET_BIOS_BANK_2 = 0x27, + AOP_RETURN_EXT_BIOS_INFO= 0x28, + AOP_MBOX_IF_ENABLE = 0x29, + AOP_SCSI_TERM_STATUS = 0x2C, + AOP_INQUIRE_SCAM_DEV = 0x2D, + AOP_SCSI_DEV_TABLE = 0x2E, + AOP_SCAM_OP = 0x2F, + AOP_START_BIOS_CMD = 0x82, + AOP_INQUIRE_ESETUP_INFO = 0x8D } aha_op_t; /************** Definitions of Multi-byte commands and responses ************/ @@ -217,10 +217,9 @@ typedef struct { struct aha_isa_port { u_int16_t addr; u_int8_t probed; + u_int8_t bio; /* board IO offset */ }; -extern struct aha_isa_port aha_isa_ports[]; - #define AHA_NUM_ISAPORTS 6 typedef enum { @@ -246,9 +245,9 @@ typedef struct { /********************** Mail Box definitions *******************************/ typedef enum { - BMBO_FREE = 0x0, /* MBO intry is free */ - BMBO_START = 0x1, /* MBO activate entry */ - BMBO_ABORT = 0x2 /* MBO abort entry */ + AMBO_FREE = 0x0, /* MBO intry is free */ + AMBO_START = 0x1, /* MBO activate entry */ + AMBO_ABORT = 0x2 /* MBO abort entry */ } aha_mbo_action_code_t; typedef struct aha_mbox_out { @@ -257,11 +256,11 @@ typedef struct aha_mbox_out { } aha_mbox_out_t; typedef enum { - BMBI_FREE = 0x0, /* MBI entry is free */ - BMBI_OK = 0x1, /* completed without error */ - BMBI_ABORT = 0x2, /* aborted ccb */ - BMBI_NOT_FOUND = 0x3, /* Tried to abort invalid CCB */ - BMBI_ERROR = 0x4 /* Completed with error */ + AMBI_FREE = 0x0, /* MBI entry is free */ + AMBI_OK = 0x1, /* completed without error */ + AMBI_ABORT = 0x2, /* aborted ccb */ + AMBI_NOT_FOUND = 0x3, /* Tried to abort invalid CCB */ + AMBI_ERROR = 0x4 /* Completed with error */ } aha_mbi_comp_code_t; typedef struct aha_mbox_in { @@ -313,11 +312,11 @@ struct aha_hccb { }; typedef enum { - BCCB_FREE = 0x0, - BCCB_ACTIVE = 0x1, - BCCB_DEVICE_RESET = 0x2, - BCCB_RELEASE_SIMQ = 0x4 -} bccb_flags_t; + ACCB_FREE = 0x0, + ACCB_ACTIVE = 0x1, + ACCB_DEVICE_RESET = 0x2, + ACCB_RELEASE_SIMQ = 0x4 +} accb_flags_t; struct aha_ccb { struct aha_hccb hccb; /* hccb assumed to be at 0 */ @@ -348,12 +347,13 @@ struct aha_softc { struct aha_ccb *aha_ccb_array; SLIST_HEAD(,aha_ccb) free_aha_ccbs; LIST_HEAD(,ccb_hdr) pending_ccbs; + u_int active_ccbs; u_int32_t aha_ccb_physbase; aha_mbox_in_t *in_boxes; aha_mbox_out_t *out_boxes; struct scsi_sense_data *sense_buffers; u_int32_t sense_buffers_physbase; - struct aha_ccb *recovery_bccb; + struct aha_ccb *recovery_accb; u_int num_boxes; bus_dma_tag_t parent_dmat; /* * All dmat's derive from @@ -410,6 +410,11 @@ char * aha_name(struct aha_softc *aha); int aha_check_probed_iop(u_int ioport); void aha_mark_probed_bio(isa_compat_io_t port); void aha_mark_probed_iop(u_int ioport); +void aha_find_probe_range(int ioport, + int *port_index, + int *max_port_index); + +int aha_iop_from_bio(isa_compat_io_t bio_index); #define DEFAULT_CMD_TIMEOUT 10000 /* 1 sec */ int aha_cmd(struct aha_softc *aha, aha_op_t opcode,