static void tws_intr_attn_error(struct tws_softc *sc) { u_int32_t db=0; TWS_TRACE(sc, "attn error", 0, 0); tws_write_reg(sc, TWS_I2O0_HOBDBC, ~0, 4); db = tws_read_reg(sc, TWS_I2O0_IOBDB, 4); device_printf(sc->tws_dev, "Micro controller error.\n"); tws_reset(sc); }
static void tws_timeout(void *arg) { struct tws_request *req = (struct tws_request *)arg; struct tws_softc *sc = req->sc; if ( tws_get_state(sc) != TWS_RESET ) { device_printf(sc->tws_dev, "Request timed out.\n"); tws_reset(sc); } }
static int tws_passthru(struct tws_softc *sc, void *buf) { struct tws_request *req; struct tws_ioctl_no_data_buf *ubuf = (struct tws_ioctl_no_data_buf *)buf; int error; u_int16_t lun4; if ( tws_get_state(sc) == TWS_RESET ) { return(EBUSY); } do { req = tws_get_request(sc, TWS_PASSTHRU_REQ); if ( !req ) { sc->chan = 1; error = tsleep((void *)&sc->chan, 0, "tws_sleep", TWS_IO_TIMEOUT*hz); if ( error == EWOULDBLOCK ) { return(ETIMEDOUT); } } else { break; } }while(1); req->length = ubuf->driver_pkt.buffer_length; TWS_TRACE_DEBUG(sc, "datal,rid", req->length, req->request_id); if ( req->length ) { req->data = kmalloc(req->length, M_TWS, M_WAITOK | M_ZERO); error = copyin(ubuf->pdata, req->data, req->length); } req->flags = TWS_DIR_IN | TWS_DIR_OUT; req->cb = tws_passthru_complete; memcpy(&req->cmd_pkt->cmd, &ubuf->cmd_pkt.cmd, sizeof(struct tws_command_apache)); if ( GET_OPCODE(req->cmd_pkt->cmd.pkt_a.res__opcode) == TWS_FW_CMD_EXECUTE_SCSI ) { lun4 = req->cmd_pkt->cmd.pkt_a.lun_l4__req_id & 0xF000; req->cmd_pkt->cmd.pkt_a.lun_l4__req_id = lun4 | req->request_id; } else { req->cmd_pkt->cmd.pkt_g.generic.request_id = (u_int8_t) req->request_id; } lockmgr(&sc->gen_lock, LK_EXCLUSIVE); req->error_code = tws_map_request(sc, req); error = lksleep(req, &sc->gen_lock, 0, "tws_passthru", TWS_IO_TIMEOUT*hz); if ( error == EWOULDBLOCK ) { error = ETIMEDOUT; TWS_TRACE_DEBUG(sc, "lksleep timeout", error, req->request_id); tws_reset((void *)sc); } if ( req->error_code == TWS_REQ_REQUEUE ) { error = EBUSY; } tws_unmap_request(sc, req); memcpy(&ubuf->cmd_pkt.hdr, &req->cmd_pkt->hdr, sizeof(struct tws_command_apache)); memcpy(&ubuf->cmd_pkt.cmd, &req->cmd_pkt->cmd, sizeof(struct tws_command_apache)); if ( !error && req->length ) { error = copyout(req->data, ubuf->pdata, req->length); } kfree(req->data, M_TWS); req->state = TWS_REQ_STATE_FREE; lockmgr(&sc->gen_lock, LK_RELEASE); if ( error ) TWS_TRACE_DEBUG(sc, "errored", error, 0); if ( req->error_code != TWS_REQ_SUBMIT_SUCCESS ) ubuf->driver_pkt.os_status = error; if ( sc->chan && tws_get_state(sc) != TWS_RESET ) { sc->chan = 0; wakeup((void *)&sc->chan); } return(error); }