/* * Retrieve list of supported cd-rw media types (feature 0x37) */ int get_supported_cdrw_media_types(SCSI *usalp) { Uchar cbuf[16]; int ret; fillbytes(cbuf, sizeof (cbuf), '\0'); usalp->silent++; ret = get_configuration(usalp, (char *)cbuf, sizeof (cbuf), 0x37, 2); usalp->silent--; if (ret < 0) return (-1); if (cbuf[3] < 12) /* Couldn't retrieve feature 0x37 */ return (-1); return (int)(cbuf[13]); }
EXPORT void initfifo() { int pagesize; if (obs == 0) obs = bs; if (fs == 0) { #if defined(sun) && defined(mc68000) fs = 1*1024*1024; #else #if defined(__linux) && !defined(USE_MMAP) fs = 4*1024*1024; #else fs = 8*1024*1024; #endif #endif } if (fs < bs + obs) fs = bs + obs; if (fs < 2*obs) fs = 2*obs; fs = roundup(fs, obs); #ifdef _SC_PAGESIZE pagesize = sysconf(_SC_PAGESIZE); #else pagesize = getpagesize(); #endif buflen = roundup(fs, pagesize) + pagesize; EDEBUG(("bs: %d obs: %d fs: %d buflen: %d\n", bs, obs, fs, buflen)); #if defined(USE_MMAP) && defined(USE_USGSHM) if (shmflag) buf = mkshm(buflen); else buf = mkshare(buflen); #else #if defined(USE_MMAP) buf = mkshare(buflen); #endif #if defined(USE_USGSHM) buf = mkshm(buflen); #endif #if defined(USE_OS2SHM) buf = mkos2shm(buflen); #endif #endif mp = (m_head *)buf; fillbytes((char *)mp, sizeof(*mp), '\0'); stats = &mp->stats; mp->base = &buf[pagesize]; fifo_setparams(); if (pipe(mp->gp) < 0) comerr("pipe\n"); if (pipe(mp->pp) < 0) comerr("pipe\n"); mp->putptr = mp->getptr = mp->base; prmp(); { /* Temporary until all modules know about mp->xxx */ extern int bufsize; extern char* bigbuf; extern char* bigptr; bufsize = mp->size; bigptr = bigbuf = mp->base; } }
static int usalo_send(SCSI *usalp) { struct usal_cmd *sp = usalp->scmd; ULONG rc; /* return value */ static SRB SRBlock; /* XXX makes it non reentrant */ Ulong cbreturn; Ulong cbParam; UCHAR* ptr; if (usalp->fd < 0) { /* Set in usalo_open() */ sp->error = SCG_FATAL; return (0); } if (sp->cdb_len > sizeof (SRBlock.u.cmd.cdb_st)) { /* commandsize too big */ sp->error = SCG_FATAL; sp->ux_errno = EINVAL; fprintf((FILE *)usalp->errfile, "sp->cdb_len > SRBlock.u.cmd.cdb_st. Fatal error in usalo_send, exiting...\n"); return (-1); } /* clear command block */ fillbytes((caddr_t)&SRBlock.u.cmd.cdb_st, sizeof (SRBlock.u.cmd.cdb_st), '\0'); /* copy cdrecord command into SRB */ movebytes(&sp->cdb, &SRBlock.u.cmd.cdb_st, sp->cdb_len); /* Build SRB command block */ SRBlock.cmd = SRB_Command; SRBlock.ha_num = usal_scsibus(usalp); /* host adapter number */ SRBlock.flags = SRB_Post; /* flags */ SRBlock.u.cmd.target = usal_target(usalp); /* Target SCSI ID */ SRBlock.u.cmd.lun = usal_lun(usalp); /* Target SCSI LUN */ SRBlock.u.cmd.data_len = sp->size; /* # of bytes transferred */ SRBlock.u.cmd.data_ptr = 0; /* pointer to data buffer */ SRBlock.u.cmd.sense_len = sp->sense_len; /* length of sense buffer */ SRBlock.u.cmd.link_ptr = 0; /* pointer to next SRB */ SRBlock.u.cmd.cdb_len = sp->cdb_len; /* SCSI command length */ /* Specify direction */ if (sp->flags & SCG_RECV_DATA) { SRBlock.flags |= SRB_Read; } else { if (sp->size > 0) { SRBlock.flags |= SRB_Write; if (usalp->bufbase != sp->addr) { /* Copy only if data not in ASPI-Mem */ movebytes(sp->addr, usalp->bufbase, sp->size); } } else { SRBlock.flags |= SRB_NoTransfer; } } sp->error = SCG_NO_ERROR; sp->sense_count = 0; sp->u_scb.cmd_scb[0] = 0; sp->resid = 0; /* execute SCSI command */ rc = DosDevIOCtl(driver_handle, 0x92, 0x02, (void*) &SRBlock, sizeof (SRB), &cbParam, (void*) &SRBlock, sizeof (SRB), &cbreturn); if (rc) { /* An error occured */ fprintf((FILE *)usalp->errfile, "DosDevIOCtl() in sendCommand failed.\n"); sp->error = SCG_FATAL; sp->ux_errno = EIO; /* Später vielleicht errno einsetzen */ return (rc); } else { /* Wait until the command is processed */ rc = wait_post(sp->timeout*1000); if (rc) { /* An error occured */ if (rc == 640) { /* Timeout */ sp->error = SCG_TIMEOUT; sp->ux_errno = EIO; fprintf((FILE *)usalp->errfile, "Timeout during SCSI-Command.\n"); return (1); } sp->error = SCG_FATAL; sp->ux_errno = EIO; fprintf((FILE *)usalp->errfile, "Fatal Error during DosWaitEventSem().\n"); return (1); } /* The command is processed */ if (SRBlock.status == SRB_Done) { /* succesful completion */ #ifdef DEBUG fprintf((FILE *)usalp->errfile, "Command successful finished. SRBlock.status=0x%x\n\n", SRBlock.status); #endif sp->sense_count = 0; sp->resid = 0; if (sp->flags & SCG_RECV_DATA) { /* We read data */ if (sp->addr && sp->size) { if (usalp->bufbase != sp->addr) /* Copy only if data not in ASPI-Mem */ movebytes(usalp->bufbase, sp->addr, SRBlock.u.cmd.data_len); ptr = (UCHAR*)sp->addr; sp->resid = sp->size - SRBlock.u.cmd.data_len; /*nicht übertragene bytes. Korrekt berechnet???*/ } } /* end of if (sp->flags & SCG_RECV_DATA) */ if (SRBlock.u.cmd.target_status == SRB_CheckStatus) { /* Sense data valid */ sp->sense_count = (int)SRBlock.u.cmd.sense_len; if (sp->sense_count > sp->sense_len) sp->sense_count = sp->sense_len; ptr = (UCHAR*)&SRBlock.u.cmd.cdb_st; ptr += SRBlock.u.cmd.cdb_len; fillbytes(&sp->u_sense.Sense, sizeof (sp->u_sense.Sense), '\0'); movebytes(ptr, &sp->u_sense.Sense, sp->sense_len); sp->u_scb.cmd_scb[0] = SRBlock.u.cmd.target_status; sp->ux_errno = EIO; /* Später differenzieren? */ } return (0); } /* SCSI-Error occured */ set_error(&SRBlock, sp); if (SRBlock.u.cmd.target_status == SRB_CheckStatus) { /* Sense data valid */ sp->sense_count = (int)SRBlock.u.cmd.sense_len; if (sp->sense_count > sp->sense_len) sp->sense_count = sp->sense_len; ptr = (UCHAR*)&SRBlock.u.cmd.cdb_st; ptr += SRBlock.u.cmd.cdb_len; fillbytes(&sp->u_sense.Sense, sizeof (sp->u_sense.Sense), '\0'); movebytes(ptr, &sp->u_sense.Sense, sp->sense_len); sp->u_scb.cmd_scb[0] = SRBlock.u.cmd.target_status; } if (sp->flags & SCG_RECV_DATA) { if (sp->addr && sp->size) { if (usalp->bufbase != sp->addr) /* Copy only if data not in ASPI-Mem */ movebytes(usalp->bufbase, sp->addr, SRBlock.u.cmd.data_len); } } #ifdef really sp->resid = SRBlock.u.cmd.data_len; /* XXXXX Got no Data ????? */ #else sp->resid = sp->size - SRBlock.u.cmd.data_len; #endif return (1); } }