if (siop_target->status == TARST_PPR_NEG) {  sync = tables->msg_in[3]; offset = tables->msg_in[5]; options = tables->msg_in[7]; if (options != MSG_EXT_PPR_PROT_DT) {  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);  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) {  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);  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]);  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 {  printf("%s: rejecting invalid PPR negotiation from " "target %d\n", sc->sc_dev.dv_xname, target); reject:
siop_ppr_neg(siop_cmd)	struct siop_cmd *siop_cmd;{	struct siop_softc *sc = siop_cmd->siop_sc;	struct siop_target *siop_target = siop_cmd->siop_target;	int target = siop_cmd->xs->sc_link->target;	struct siop_xfer_common *tables = &siop_cmd->siop_xfer->tables;	int offset, sync, protocol, scf;	sync     = tables->msg_in[3];	offset   = tables->msg_in[5];	protocol = tables->msg_in[7];#ifdef DEBUG	printf("%s: siop_ppr_neg: sync = %x, offset = %x, protocol = %x\n",	    sc->sc_dev.dv_xname, sync, offset, protocol);#endif	/*	 * Process protocol bits first, because finding the correct scf	 * via siop_period_factor_to_scf() requires the TARF_ISDT flag	 * to be correctly set.	 */	if (protocol & MSG_EXT_PPR_PROT_IUS)		siop_target->flags |= TARF_ISIUS;	if (protocol & MSG_EXT_PPR_PROT_DT) {		siop_target->flags |= TARF_ISDT;		sc->targets[target]->id |= SCNTL4_ULTRA3;	}	if (protocol & MSG_EXT_PPR_PROT_QAS)		siop_target->flags |= TARF_ISQAS;	scf = siop_period_factor_to_scf(sc, sync, siop_target->flags);	if ((offset > sc->maxoff) ||	    (scf == 0) ||	    ((siop_target->flags & TARF_ISDT) && (offset == 1))) {		tables->t_msgout.count= htole32(1);		tables->msg_out[0] = MSG_MESSAGE_REJECT;		return (SIOP_NEG_MSGOUT);	}	siop_target->id |= scf << (24 + SCNTL3_SCF_SHIFT);	if (((sc->features & SF_CHIP_C10) == 0) && (sync < 25))		siop_target->id |= SCNTL3_ULTRA << 24;	siop_target->id |= (offset & 0xff) << 8;		if (tables->msg_in[6] == MSG_EXT_WDTR_BUS_16_BIT) {		siop_target->flags |= TARF_ISWIDE;		sc->targets[target]->id |= (SCNTL3_EWS << 24);	}#ifdef DEBUG	printf("%s: siop_ppr_neg: id now 0x%x, flags is now 0x%x\n",	    sc->sc_dev.dv_xname, siop_target->id, siop_target->flags);#endif	tables->id = htole32(siop_target->id);	bus_space_write_1(sc->sc_rt, sc->sc_rh, SIOP_SCNTL3,	    (siop_target->id >> 24) & 0xff);	bus_space_write_1(sc->sc_rt, sc->sc_rh, SIOP_SXFER,	    (siop_target->id >> 8) & 0xff);	/* Only cards with SCNTL4 can cause PPR negotiations, so ... */	bus_space_write_1(sc->sc_rt, sc->sc_rh, SIOP_SCNTL4,	    (siop_target->id & 0xff));	siop_target->status = TARST_OK;	siop_print_info(sc, target);		return (SIOP_NEG_ACK);}