model[i++] = ei->ei_model[i];
model[i++] = ei->ei_suffix[j];
dpt_init(sc, intrstr)	struct dpt_softc *sc;	const char *intrstr;{	struct eata_inquiry_data *ei;	int i, j, error, rseg, mapsize;	bus_dma_segment_t seg;	struct eata_cfg *ec;	char model[16];	ec = &sc->sc_ec;		/* Allocate the CCB/status packet/scratch DMA map and load */	sc->sc_nccbs = min(betoh16(*(int16_t *)ec->ec_queuedepth),			   DPT_MAX_CCBS);	sc->sc_spoff = sc->sc_nccbs * sizeof(struct dpt_ccb);	sc->sc_scroff = sc->sc_spoff + sizeof(struct eata_sp);	sc->sc_scrlen = 256; /* XXX */	mapsize = sc->sc_nccbs * sizeof(struct dpt_ccb) + sc->sc_scrlen +	    sizeof(struct eata_sp);			if ((error = bus_dmamem_alloc(sc->sc_dmat, mapsize, NBPG, 0, 	    &seg, 1, &rseg, BUS_DMA_NOWAIT)) != 0) {		printf("%s: unable to allocate CCBs, error = %d\n",		    sc->sc_dv.dv_xname, error);		return;	}	if ((error = bus_dmamem_map(sc->sc_dmat, &seg, rseg, mapsize,	    (caddr_t *)&sc->sc_ccbs, BUS_DMA_NOWAIT|BUS_DMA_COHERENT)) != 0) {		printf("%s: unable to map CCBs, error = %d\n",		    sc->sc_dv.dv_xname, error);		return;	}	if ((error = bus_dmamap_create(sc->sc_dmat, mapsize, mapsize, 1, 0, 	    BUS_DMA_NOWAIT, &sc->sc_dmamap_ccb)) != 0) {		printf("%s: unable to create CCB DMA map, error = %d\n",		    sc->sc_dv.dv_xname, error);		return;	}	if ((error = bus_dmamap_load(sc->sc_dmat, sc->sc_dmamap_ccb,	    sc->sc_ccbs, mapsize, NULL, BUS_DMA_NOWAIT)) != 0) {		printf("%s: unable to load CCB DMA map, error = %d\n",		    sc->sc_dv.dv_xname, error);		return;	}	sc->sc_statpack = (struct eata_sp *)((caddr_t)sc->sc_ccbs +	    sc->sc_spoff);	sc->sc_sppa = sc->sc_dmamap_ccb->dm_segs[0].ds_addr + sc->sc_spoff;	sc->sc_scr = (caddr_t)sc->sc_ccbs + sc->sc_scroff;	sc->sc_scrpa = sc->sc_dmamap_ccb->dm_segs[0].ds_addr + sc->sc_scroff;	sc->sc_statpack->sp_ccbid = -1;	/* Initialize the CCBs */	TAILQ_INIT(&sc->sc_free_ccb);	i = dpt_create_ccbs(sc, sc->sc_ccbs, sc->sc_nccbs);	if (i == 0) {		printf("%s: unable to create CCBs\n", sc->sc_dv.dv_xname);		return;	} else if (i != sc->sc_nccbs) {		printf("%s: %d/%d CCBs created!\n", sc->sc_dv.dv_xname, i, 		    sc->sc_nccbs);		sc->sc_nccbs = i;	}	/* Set shutdownhook before we start any device activity */	sc->sc_sdh = shutdownhook_establish(dpt_shutdown, sc);	/* Get the page 0 inquiry data from the HBA */	dpt_hba_inquire(sc, &ei);	/* 	 * dpt0 at pci0 dev 12 function 0: DPT SmartRAID III (PM3224A/9X-R)	 * dpt0: interrupting at irq 10	 * dpt0: 64 queued commands, 1 channel(s), adapter on ID(s) 7	 */	for (i = 0; ei->ei_vendor[i] != ' ' && i < 8; i++)		;	ei->ei_vendor[i] = '\0';	for (i = 0; ei->ei_model[i] != ' ' && i < 7; i++)		model[i] = ei->ei_model[i];	for (j = 0; ei->ei_suffix[j] != ' ' && j < 7; j++)		model[i++] = ei->ei_model[i];	model[i] = '\0';	/* Find the cannonical name for the board */	for (i = 0; dpt_cname[i] != NULL; i += 2)		if (memcmp(ei->ei_model, dpt_cname[i], 6) == 0)			break;				printf("%s %s (%s)\n", ei->ei_vendor, dpt_cname[i + 1], model);	if (intrstr != NULL)		printf("%s: interrupting at %s\n", sc->sc_dv.dv_xname, intrstr);	printf("%s: %d queued commands, %d channel(s), adapter on ID(s)", 	    sc->sc_dv.dv_xname, sc->sc_nccbs, ec->ec_maxchannel + 1);	for (i = 0; i <= ec->ec_maxchannel; i++)		printf(" %d", ec->ec_hba[3 - i]);	printf("\n");	/* Reset the SCSI bus */	if (dpt_cmd(sc, NULL, 0, CP_IMMEDIATE, CPI_BUS_RESET))		panic("%s: dpt_cmd failed", sc->sc_dv.dv_xname);        DELAY(20000);		/* Fill in the adapter, each link and attach in turn */#ifdef __NetBSD__	sc->sc_adapter.scsipi_cmd = dpt_scsi_cmd;	sc->sc_adapter.scsipi_minphys = dpt_minphys;#endif /* __NetBSD__ */#ifdef __OpenBSD__	sc->sc_adapter.scsi_cmd = dpt_scsi_cmd;	sc->sc_adapter.scsi_minphys = dpt_minphys;#endif /* __OpenBSD__ */	for (i = 0; i <= ec->ec_maxchannel; i++) {#ifdef __NetBSD__		struct scsipi_link *link;#endif /* __NetBSD__ */#ifdef __OpenBSD__		struct scsi_link *link;#endif /* __OpenBSD__ */		sc->sc_hbaid[i] = ec->ec_hba[3 - i];		link = &sc->sc_link[i];#ifdef __NetBSD__		link->scsipi_scsi.scsibus = i;		link->scsipi_scsi.adapter_target = sc->sc_hbaid[i];		link->scsipi_scsi.max_lun = ec->ec_maxlun;		link->scsipi_scsi.max_target = ec->ec_maxtarget;		link->type = BUS_SCSI;#endif /* __NetBSD__ */#ifdef __OpenBSD__		link->scsibus = i;		link->adapter_target = sc->sc_hbaid[i];#endif /* __OpenBSD__ */		link->device = &dpt_dev;		link->adapter = &sc->sc_adapter;		link->adapter_softc = sc;		link->openings = sc->sc_nccbs;		config_found(&sc->sc_dv, link, scsiprint);	}}