Deleted Added
sdiff udiff text old ( 74094 ) new ( 74972 )
full compact
1/*
2 * Bus independent FreeBSD shim for the aic7xxx based adaptec SCSI controllers
3 *
4 * Copyright (c) 1994-2001 Justin T. Gibbs.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 16 unchanged lines hidden (view full) ---

25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 *
31 * $Id$
32 *
33 * $FreeBSD: head/sys/dev/aic7xxx/aic7xxx_osm.c 74094 2001-03-11 06:34:17Z gibbs $
34 */
35
36#include <dev/aic7xxx/aic7xxx_freebsd.h>
37#include <dev/aic7xxx/aic7xxx_inline.h>
38
39#ifndef AHC_TMODE_ENABLE
40#define AHC_TMODE_ENABLE 0
41#endif

--- 241 unchanged lines hidden (view full) ---

283 op = BUS_DMASYNC_POSTREAD;
284 else
285 op = BUS_DMASYNC_POSTWRITE;
286 bus_dmamap_sync(ahc->buffer_dmat, scb->dmamap, op);
287 bus_dmamap_unload(ahc->buffer_dmat, scb->dmamap);
288 }
289
290 if (ccb->ccb_h.func_code == XPT_CONT_TARGET_IO) {
291 if (ahc_get_transaction_status(scb) == CAM_REQ_INPROG)
292 ccb->ccb_h.status |= CAM_REQ_CMP;
293 ccb->ccb_h.status &= ~CAM_SIM_QUEUED;
294 ahc_free_scb(ahc, scb);
295 xpt_done(ccb);
296 return;
297 }
298

--- 57 unchanged lines hidden (view full) ---

356 ahc_free_scb(ahc, scb);
357 xpt_done(ccb);
358}
359
360static void
361ahc_action(struct cam_sim *sim, union ccb *ccb)
362{
363 struct ahc_softc *ahc;
364 struct tmode_lstate *lstate;
365 u_int target_id;
366 u_int our_id;
367 long s;
368
369 CAM_DEBUG(ccb->ccb_h.path, CAM_DEBUG_TRACE, ("ahc_action\n"));
370
371 ahc = (struct ahc_softc *)cam_sim_softc(sim);
372
373 target_id = ccb->ccb_h.target_id;
374 our_id = SIM_SCSI_ID(ahc, sim);
375
376 switch (ccb->ccb_h.func_code) {
377 /* Common cases first */
378 case XPT_ACCEPT_TARGET_IO: /* Accept Host Target Mode CDB */
379 case XPT_CONT_TARGET_IO:/* Continue Host Target I/O Connection*/
380 {
381 struct tmode_tstate *tstate;
382 cam_status status;
383
384 status = ahc_find_tmode_devs(ahc, sim, ccb, &tstate,
385 &lstate, TRUE);
386
387 if (status != CAM_REQ_CMP) {
388 if (ccb->ccb_h.func_code == XPT_CONT_TARGET_IO) {
389 /* Response from the black hole device */

--- 32 unchanged lines hidden (view full) ---

422 struct scb *scb;
423 struct hardware_scb *hscb;
424
425 if ((ahc->flags & AHC_INITIATORROLE) == 0
426 && (ccb->ccb_h.func_code == XPT_SCSI_IO
427 || ccb->ccb_h.func_code == XPT_RESET_DEV)) {
428 ccb->ccb_h.status = CAM_PROVIDE_FAIL;
429 xpt_done(ccb);
430 }
431
432 /*
433 * get an scb to use.
434 */
435 ahc_lock(ahc, &s);
436 if ((scb = ahc_get_scb(ahc)) == NULL) {
437

--- 27 unchanged lines hidden (view full) ---

465 scb->flags |= SCB_DEVICE_RESET;
466 hscb->control |= MK_MESSAGE;
467 ahc_execute_scb(scb, NULL, 0, 0);
468 } else {
469 if (ccb->ccb_h.func_code == XPT_CONT_TARGET_IO) {
470 struct target_data *tdata;
471
472 tdata = &hscb->shared_data.tdata;
473 if (ahc->pending_device == lstate) {
474 scb->flags |= SCB_TARGET_IMMEDIATE;
475 ahc->pending_device = NULL;
476 }
477 hscb->control |= TARGET_SCB;
478 tdata->target_phases = IDENTIFY_SEEN;
479 if ((ccb->ccb_h.flags & CAM_SEND_STATUS) != 0) {
480 tdata->target_phases |= SPHASE_PENDING;
481 tdata->scsi_status =
482 ccb->csio.scsi_status;
483 }
484 tdata->initiator_tag = ccb->csio.tag_id;
485 }
486 if (ccb->ccb_h.flags & CAM_TAG_ACTION_VALID)
487 hscb->control |= ccb->csio.tag_action;
488
489 ahc_setup_data(ahc, sim, &ccb->csio, scb);
490 }
491 break;
492 }
493 case XPT_NOTIFY_ACK:
494 case XPT_IMMED_NOTIFY:
495 {
496 struct tmode_tstate *tstate;
497 struct tmode_lstate *lstate;
498 cam_status status;
499
500 status = ahc_find_tmode_devs(ahc, sim, ccb, &tstate,
501 &lstate, TRUE);
502
503 if (status != CAM_REQ_CMP) {
504 ccb->ccb_h.status = status;
505 xpt_done(ccb);

--- 17 unchanged lines hidden (view full) ---

523 case XPT_SET_TRAN_SETTINGS:
524 {
525#ifdef AHC_NEW_TRAN_SETTINGS
526 struct ahc_devinfo devinfo;
527 struct ccb_trans_settings *cts;
528 struct ccb_trans_settings_scsi *scsi;
529 struct ccb_trans_settings_spi *spi;
530 struct ahc_initiator_tinfo *tinfo;
531 struct tmode_tstate *tstate;
532 uint16_t *discenable;
533 uint16_t *tagenable;
534 u_int update_type;
535
536 cts = &ccb->cts;
537 scsi = &cts->proto_specific.scsi;
538 spi = &cts->xport_specific.spi;
539 ahc_compile_devinfo(&devinfo, SIM_SCSI_ID(ahc, sim),

--- 107 unchanged lines hidden (view full) ---

647 }
648 ahc_unlock(ahc, &s);
649 ccb->ccb_h.status = CAM_REQ_CMP;
650 xpt_done(ccb);
651#else
652 struct ahc_devinfo devinfo;
653 struct ccb_trans_settings *cts;
654 struct ahc_initiator_tinfo *tinfo;
655 struct tmode_tstate *tstate;
656 uint16_t *discenable;
657 uint16_t *tagenable;
658 u_int update_type;
659 long s;
660
661 cts = &ccb->cts;
662 ahc_compile_devinfo(&devinfo, SIM_SCSI_ID(ahc, sim),
663 cts->ccb_h.target_id,

--- 226 unchanged lines hidden (view full) ---

890ahc_get_tran_settings(struct ahc_softc *ahc, int our_id, char channel,
891 struct ccb_trans_settings *cts)
892{
893#ifdef AHC_NEW_TRAN_SETTINGS
894 struct ahc_devinfo devinfo;
895 struct ccb_trans_settings_scsi *scsi;
896 struct ccb_trans_settings_spi *spi;
897 struct ahc_initiator_tinfo *targ_info;
898 struct tmode_tstate *tstate;
899 struct ahc_transinfo *tinfo;
900
901 scsi = &cts->proto_specific.scsi;
902 spi = &cts->xport_specific.spi;
903 ahc_compile_devinfo(&devinfo, our_id,
904 cts->ccb_h.target_id,
905 cts->ccb_h.target_lun,
906 channel, ROLE_UNKNOWN);

--- 42 unchanged lines hidden (view full) ---

949 } else {
950 scsi->valid = 0;
951 }
952
953 cts->ccb_h.status = CAM_REQ_CMP;
954#else
955 struct ahc_devinfo devinfo;
956 struct ahc_initiator_tinfo *targ_info;
957 struct tmode_tstate *tstate;
958 struct ahc_transinfo *tinfo;
959 long s;
960
961 ahc_compile_devinfo(&devinfo, our_id,
962 cts->ccb_h.target_id,
963 cts->ccb_h.target_lun,
964 channel, ROLE_UNKNOWN);
965 targ_info = ahc_fetch_transinfo(ahc, devinfo.channel,

--- 80 unchanged lines hidden (view full) ---

1046static void
1047ahc_execute_scb(void *arg, bus_dma_segment_t *dm_segs, int nsegments,
1048 int error)
1049{
1050 struct scb *scb;
1051 union ccb *ccb;
1052 struct ahc_softc *ahc;
1053 struct ahc_initiator_tinfo *tinfo;
1054 struct tmode_tstate *tstate;
1055 u_int mask;
1056 long s;
1057
1058 scb = (struct scb *)arg;
1059 ccb = scb->io_ctx;
1060 ahc = scb->ahc_softc;
1061
1062 if (error != 0) {

--- 118 unchanged lines hidden (view full) ---

1181 SCSIID_TARGET(ahc, scb->hscb->scsiid),
1182 &tstate);
1183
1184 mask = SCB_GET_TARGET_MASK(ahc, scb);
1185 scb->hscb->scsirate = tinfo->scsirate;
1186 scb->hscb->scsioffset = tinfo->current.offset;
1187 if ((tstate->ultraenb & mask) != 0)
1188 scb->hscb->control |= ULTRAENB;
1189
1190 if ((tstate->discenable & mask) != 0
1191 && (ccb->ccb_h.flags & CAM_DIS_DISCONNECT) == 0)
1192 scb->hscb->control |= DISCENB;
1193
1194 if ((ccb->ccb_h.flags & CAM_NEGOTIATE) != 0
1195 && (tinfo->goal.width != 0
1196 || tinfo->goal.period != 0
1197 || tinfo->goal.ppr_options != 0)) {
1198 scb->flags |= SCB_NEGOTIATE;
1199 scb->hscb->control |= MK_MESSAGE;
1200 }
1201
1202 LIST_INSERT_HEAD(&ahc->pending_scbs, scb, pending_links);
1203
1204 ccb->ccb_h.status |= CAM_SIM_QUEUED;
1205
1206 if (ccb->ccb_h.timeout != CAM_TIME_INFINITY) {
1207 uint64_t time;

--- 26 unchanged lines hidden (view full) ---

1234 if (TAILQ_FIRST(untagged_q) != scb) {
1235 ahc_unlock(ahc, &s);
1236 return;
1237 }
1238 }
1239 scb->flags |= SCB_ACTIVE;
1240
1241 if ((scb->flags & SCB_TARGET_IMMEDIATE) != 0) {
1242 ahc_pause(ahc);
1243 if ((ahc->flags & AHC_PAGESCBS) == 0)
1244 ahc_outb(ahc, SCBPTR, scb->hscb->tag);
1245 ahc_outb(ahc, SCB_TAG, scb->hscb->tag);
1246 ahc_outb(ahc, RETURN_1, CONT_MSG_LOOP);
1247 ahc_unpause(ahc);
1248 } else {
1249 ahc_queue_scb(ahc, scb);

--- 178 unchanged lines hidden (view full) ---

1428 return;
1429 }
1430
1431 target = SCB_GET_TARGET(ahc, scb);
1432 channel = SCB_GET_CHANNEL(ahc, scb);
1433 lun = SCB_GET_LUN(scb);
1434
1435 ahc_print_path(ahc, scb);
1436 printf("SCB 0x%x - timed out ", scb->hscb->tag);
1437 /*
1438 * Take a snapshot of the bus state and print out
1439 * some information so we can track down driver bugs.
1440 */
1441 last_phase = ahc_inb(ahc, LASTPHASE);
1442
1443 printf("%s", ahc_lookup_phase_entry(last_phase)->phasemsg);
1444
1445 printf(", SEQADDR == 0x%x\n",
1446 ahc_inb(ahc, SEQADDR0) | (ahc_inb(ahc, SEQADDR1) << 8));
1447
1448 printf("STACK == 0x%x, 0x%x, 0x%x, 0x%x\n",
1449 ahc_inb(ahc, STACK) | (ahc_inb(ahc, STACK) << 8),
1450 ahc_inb(ahc, STACK) | (ahc_inb(ahc, STACK) << 8),
1451 ahc_inb(ahc, STACK) | (ahc_inb(ahc, STACK) << 8),
1452 ahc_inb(ahc, STACK) | (ahc_inb(ahc, STACK) << 8));
1453
1454 printf("SXFRCTL0 == 0x%x\n", ahc_inb(ahc, SXFRCTL0));
1455
1456 ahc_dump_card_state(ahc);
1457 if (scb->sg_count > 0) {
1458 for (i = 0; i < scb->sg_count; i++) {
1459 printf("sg[%d] - Addr 0x%x : Length %d\n",
1460 i,
1461 scb->sg_list[i].addr,
1462 scb->sg_list[i].len & AHC_SG_LEN_MASK);
1463 }
1464 }

--- 213 unchanged lines hidden (view full) ---

1678 union ccb *abort_ccb;
1679
1680 abort_ccb = ccb->cab.abort_ccb;
1681 switch (abort_ccb->ccb_h.func_code) {
1682 case XPT_ACCEPT_TARGET_IO:
1683 case XPT_IMMED_NOTIFY:
1684 case XPT_CONT_TARGET_IO:
1685 {
1686 struct tmode_tstate *tstate;
1687 struct tmode_lstate *lstate;
1688 struct ccb_hdr_slist *list;
1689 cam_status status;
1690
1691 status = ahc_find_tmode_devs(ahc, sim, abort_ccb, &tstate,
1692 &lstate, TRUE);
1693
1694 if (status != CAM_REQ_CMP) {
1695 ccb->ccb_h.status = status;

--- 117 unchanged lines hidden (view full) ---

1813
1814void
1815ahc_platform_free(struct ahc_softc *ahc)
1816{
1817 struct ahc_platform_data *pdata;
1818
1819 pdata = ahc->platform_data;
1820 if (pdata != NULL) {
1821 device_printf(ahc->dev_softc, "Platform free\n");
1822 if (pdata->regs != NULL)
1823 bus_release_resource(ahc->dev_softc,
1824 pdata->regs_res_type,
1825 pdata->regs_res_id,
1826 pdata->regs);
1827
1828 if (pdata->irq != NULL)
1829 bus_release_resource(ahc->dev_softc,

--- 70 unchanged lines hidden ---