/******************************************************************************** * Given a detected drive, attach it to the bio interface. * * This is called from twe_add_unit. */ int twe_attach_drive(struct twe_softc *sc, struct twe_drive *dr) { char buf[80]; int error; dr->td_disk = device_add_child(sc->twe_dev, NULL, -1); if (dr->td_disk == NULL) { twe_printf(sc, "Cannot add unit\n"); return (EIO); } device_set_ivars(dr->td_disk, dr); /* * XXX It would make sense to test the online/initialising bits, but they seem to be * always set... */ sprintf(buf, "Unit %d, %s, %s", dr->td_twe_unit, twe_describe_code(twe_table_unittype, dr->td_type), twe_describe_code(twe_table_unitstate, dr->td_state & TWE_PARAM_UNITSTATUS_MASK)); device_set_desc_copy(dr->td_disk, buf); if ((error = bus_generic_attach(sc->twe_dev)) != 0) { twe_printf(sc, "Cannot attach unit to controller. error = %d\n", error); return (EIO); } return (0); }
static void twe_aen_enqueue(struct twe_softc *sc, uint16_t aen, int quiet) { const char *str, *msg; int s, next, nextnext, level; /* * First report the AEN on the console. Maybe. */ if (! quiet) { str = twe_describe_code(twe_table_aen, TWE_AEN_CODE(aen)); if (str == NULL) { aprint_error_dev(sc->sc_dev, "unknown AEN 0x%04x\n", aen); } else { msg = str + 3; switch (str[1]) { case 'E': level = LOG_EMERG; break; case 'a': level = LOG_ALERT; break; case 'c': level = LOG_CRIT; break; case 'e': level = LOG_ERR; break; case 'w': level = LOG_WARNING; break; case 'n': level = LOG_NOTICE; break; case 'i': level = LOG_INFO; break; case 'd': level = LOG_DEBUG; break; default: /* Don't use syslog. */ level = -1; } if (level < 0) { switch (str[0]) { case 'u': case 'p': printf("%s: %s %d: %s\n", device_xname(sc->sc_dev), str[0] == 'u' ? "unit" : "port", TWE_AEN_UNIT(aen), msg); break; default: printf("%s: %s\n", device_xname(sc->sc_dev), msg); } } else { switch (str[0]) { case 'u': case 'p': log(level, "%s: %s %d: %s\n", device_xname(sc->sc_dev), str[0] == 'u' ? "unit" : "port", TWE_AEN_UNIT(aen), msg); break; default: log(level, "%s: %s\n", device_xname(sc->sc_dev), msg); } } } } /* Now enqueue the AEN for mangement tools. */ s = splbio(); next = (sc->sc_aen_head + 1) % TWE_AEN_Q_LENGTH; nextnext = (sc->sc_aen_head + 2) % TWE_AEN_Q_LENGTH; /* * If this is the last free slot, then queue up a "queue * full" message. */ if (nextnext == sc->sc_aen_tail) aen = TWE_AEN_QUEUE_FULL; if (next != sc->sc_aen_tail) { sc->sc_aen_queue[sc->sc_aen_head] = aen; sc->sc_aen_head = next; } if (sc->sc_flags & TWEF_AENQ_WAIT) { sc->sc_flags &= ~TWEF_AENQ_WAIT; wakeup(&sc->sc_aen_queue); } splx(s); }