printf("%s: anserw on ppr negotiation:", sc->sc_dev.dv_xname);
printf("%s: answer on ppr negotiation:", sc->sc_dev.dv_xname);
siop_ppr_neg(siop_cmd)	struct siop_common_cmd *siop_cmd;{	struct siop_common_softc *sc = siop_cmd->siop_sc;	struct siop_common_target *siop_target = siop_cmd->siop_target;	int target = siop_cmd->xs->sc_link->target;	struct siop_common_xfer *tables = siop_cmd->siop_tables;	int sync, offset, options, scf = 0;	int i;#ifdef DEBUG_NEG	printf("%s: anserw on ppr negotiation:", sc->sc_dev.dv_xname);	for (i = 0; i < 8; i++)		printf(" 0x%x", tables->msg_in[i]);	printf("\n");#endif	if (siop_target->status == TARST_PPR_NEG) {		/* we initiated PPR negotiation */		sync = tables->msg_in[3];		offset = tables->msg_in[5];		options = tables->msg_in[7];		if (options != MSG_EXT_PPR_PROT_DT) {			/* should't happen */			printf("%s: ppr negotiation for target %d: "			    "no DT option\n", sc->sc_dev.dv_xname, target);			siop_target->status = TARST_ASYNC;			siop_target->flags &= ~(TARF_DT | TARF_ISDT);			siop_target->offset = 0;			siop_target->period = 0;			goto reject;		}					if (offset > sc->maxoff || sync < sc->dt_minsync ||		    sync > sc->dt_maxsync) {			printf("%s: ppr negotiation for target %d: "			    "offset (%d) or sync (%d) out of range\n",			    sc->sc_dev.dv_xname, target, offset, sync);			/* should not happen */			siop_target->status = TARST_ASYNC;			siop_target->flags &= ~(TARF_DT | TARF_ISDT);			siop_target->offset = 0;			siop_target->period = 0;			goto reject;		} else {			for (i = 0; i <			    sizeof(dt_scf_period) / sizeof(dt_scf_period[0]);			    i++) {				if (sc->clock_period != dt_scf_period[i].clock)					continue;				if (dt_scf_period[i].period == sync) {					/* ok, found it. we now are sync. */					siop_target->offset = offset;					siop_target->period = sync;					scf = dt_scf_period[i].scf;					siop_target->flags |= TARF_ISDT;				}			}			if ((siop_target->flags & TARF_ISDT) == 0) {				printf("%s: ppr negotiation for target %d: "				    "sync (%d) incompatible with adapter\n",				    sc->sc_dev.dv_xname, target, sync);				/*				 * we didn't find it in our table, do async				 * send reject msg, start SDTR/WDTR neg				 */				siop_target->status = TARST_ASYNC;				siop_target->flags &= ~(TARF_DT | TARF_ISDT);				siop_target->offset = 0;				siop_target->period = 0;				goto reject;			}		}		if (tables->msg_in[6] != 1) {			printf("%s: ppr negotiation for target %d: "			    "transfer width (%d) incompatible with dt\n",			    sc->sc_dev.dv_xname, target, tables->msg_in[6]);			/* DT mode can only be done with wide transfers */			siop_target->status = TARST_ASYNC;			siop_target->flags &= ~(TARF_DT | TARF_ISDT);			siop_target->offset = 0;			siop_target->period = 0;			goto reject;		} 		siop_target->flags |= TARF_ISWIDE;		sc->targets[target]->id |= (SCNTL3_EWS << 24);		sc->targets[target]->id &= ~(SCNTL3_SCF_MASK << 24);		sc->targets[target]->id |= scf << (24 + SCNTL3_SCF_SHIFT);		sc->targets[target]->id &= ~(SXFER_MO_MASK << 8);		sc->targets[target]->id |=		    (siop_target->offset & SXFER_MO_MASK) << 8;		sc->targets[target]->id &= ~0xff;		sc->targets[target]->id |= SCNTL4_U3EN;		siop_target->status = TARST_OK;		siop_update_xfer_mode(sc, target);		bus_space_write_1(sc->sc_rt, sc->sc_rh, SIOP_SCNTL3,		    (sc->targets[target]->id >> 24) & 0xff);		bus_space_write_1(sc->sc_rt, sc->sc_rh, SIOP_SXFER,		    (sc->targets[target]->id >> 8) & 0xff);		bus_space_write_1(sc->sc_rt, sc->sc_rh, SIOP_SCNTL4,		    sc->targets[target]->id & 0xff);		return SIOP_NEG_ACK;	} else {		/* target initiated PPR negotiation, shouldn't happen */		printf("%s: rejecting invalid PPR negotiation from "		    "target %d\n", sc->sc_dev.dv_xname, target);reject:		tables->t_msgout.count= htole32(1);		tables->msg_out[0] = MSG_MESSAGE_REJECT;		return SIOP_NEG_MSGOUT;	}}