static int rdident(device_t parent, struct rd_softc *sc, struct hpibbus_attach_args *ha) { struct rd_describe *desc = sc != NULL ? &sc->sc_rddesc : NULL; u_char stat, cmd[3]; char name[7]; int i, id, n, ctlr, slave; ctlr = device_unit(parent); slave = ha->ha_slave; /* Verify that we have a CS80 device. */ if ((ha->ha_id & 0x200) == 0) return 0; /* Is it one of the disks we support? */ for (id = 0; id < numrdidentinfo; id++) if (ha->ha_id == rdidentinfo[id].ri_hwid) break; if (id == numrdidentinfo || ha->ha_punit > rdidentinfo[id].ri_maxunum) return 0; /* * If we're just probing for the device, that's all the * work we need to do. */ if (sc == NULL) return 1; /* * Reset device and collect description */ rdreset(sc); cmd[0] = C_SUNIT(ha->ha_punit); cmd[1] = C_SVOL(0); cmd[2] = C_DESC; hpibsend(ctlr, slave, C_CMD, cmd, sizeof(cmd)); hpibrecv(ctlr, slave, C_EXEC, desc, 37); hpibrecv(ctlr, slave, C_QSTAT, &stat, sizeof(stat)); memset(name, 0, sizeof(name)); if (stat == 0) { n = desc->d_name; for (i = 5; i >= 0; i--) { name[i] = (n & 0xf) + '0'; n >>= 4; } }
static int ctident(device_t parent, struct ct_softc *sc, struct hpibbus_attach_args *ha) { struct ct_describe desc; u_char stat, cmd[3]; char name[7]; int i, id, n, type, canstream; type = canstream = 0; /* Verify that we have a CS80 device. */ if ((ha->ha_id & 0x200) == 0) return 0; /* Is it one of the tapes we support? */ for (id = 0; id < nctinfo; id++) if (ha->ha_id == ctinfo[id].hwid) break; if (id == nctinfo) return 0; ha->ha_punit = ctinfo[id].punit; /* * So far, so good. Get drive parameters. Note command * is always issued to unit 0. */ cmd[0] = C_SUNIT(0); cmd[1] = C_SVOL(0); cmd[2] = C_DESC; hpibsend(device_unit(parent), ha->ha_slave, C_CMD, cmd, sizeof(cmd)); hpibrecv(device_unit(parent), ha->ha_slave, C_EXEC, &desc, 37); hpibrecv(device_unit(parent), ha->ha_slave, C_QSTAT, &stat, sizeof(stat)); memset(name, 0, sizeof(name)); if (stat == 0) { n = desc.d_name; for (i = 5; i >= 0; i--) { name[i] = (n & 0xf) + '0'; n >>= 4; } }
/* * Perform a read of "Device Status Jump" register and update the * status if necessary. If status is read, the given "ecmd" is also * performed, unless "ecmd" is zero. Returns DSJ value, -1 on failure * and -2 on "temporary" failure. */ static int mtreaddsj(struct mt_softc *sc, int ecmd) { int retval; if (sc->sc_flags & MTF_STATTIMEO) goto getstats; retval = hpibrecv(sc->sc_hpibno, (sc->sc_flags & MTF_DSJTIMEO) ? -1 : sc->sc_slave, MTT_DSJ, &(sc->sc_lastdsj), 1); sc->sc_flags &= ~MTF_DSJTIMEO; if (retval != 1) { dlog(LOG_DEBUG, "%s can't hpibrecv DSJ", device_xname(sc->sc_dev)); if (sc->sc_recvtimeo == 0) sc->sc_recvtimeo = hz; if (--sc->sc_recvtimeo == 0) return -1; if (retval == 0) sc->sc_flags |= MTF_DSJTIMEO; return -2; } sc->sc_recvtimeo = 0; sc->sc_statindex = 0; dlog(LOG_DEBUG, "%s readdsj: 0x%x", device_xname(sc->sc_dev), sc->sc_lastdsj); sc->sc_lastecmd = ecmd; switch (sc->sc_lastdsj) { case 0: if (ecmd & MTE_DSJ_FORCE) break; return 0; case 2: sc->sc_lastecmd = MTE_COMPLETE; case 1: break; default: log(LOG_ERR, "%s readdsj: DSJ 0x%x\n", device_xname(sc->sc_dev), sc->sc_lastdsj); return -1; } getstats: retval = hpibrecv(sc->sc_hpibno, (sc->sc_flags & MTF_STATCONT) ? -1 : sc->sc_slave, MTT_STAT, ((char *)&(sc->sc_stat)) + sc->sc_statindex, sizeof(sc->sc_stat) - sc->sc_statindex); sc->sc_flags &= ~(MTF_STATTIMEO | MTF_STATCONT); if (retval != sizeof(sc->sc_stat) - sc->sc_statindex) { if (sc->sc_recvtimeo == 0) sc->sc_recvtimeo = hz; if (--sc->sc_recvtimeo != 0) { if (retval >= 0) { sc->sc_statindex += retval; sc->sc_flags |= MTF_STATCONT; } sc->sc_flags |= MTF_STATTIMEO; return -2; } log(LOG_ERR, "%s readdsj: can't read status", device_xname(sc->sc_dev)); return -1; } sc->sc_recvtimeo = 0; sc->sc_statindex = 0; dlog(LOG_DEBUG, "%s readdsj: status is %x %x %x %x %x %x", device_xname(sc->sc_dev), sc->sc_stat1, sc->sc_stat2, sc->sc_stat3, sc->sc_stat4, sc->sc_stat5, sc->sc_stat6); if (sc->sc_lastecmd) (void) hpibsend(sc->sc_hpibno, sc->sc_slave, MTL_ECMD, &(sc->sc_lastecmd), 1); return (int)sc->sc_lastdsj; }