📄 ncr710lib.c
字号:
{ taskPriorityGet (taskId, &taskPriority); taskPrioritySet (taskId, pScsiCtrl->scsiPriority); } /* take the device and controller semaphores */ semTake (&pScsiPhysDev->devMutexSem, WAIT_FOREVER); if ((status = ncr710ScsiPhase(pScsiPhysDev, pScsiXaction)) == ERROR) { SCSI_DEBUG_MSG("ncr710ScsiTransact: scsiPhaseSequence ERROR.\n", 0, 0, 0, 0, 0, 0); goto cleanExit; } /* check device status and take appropriate action */ SCSI_DEBUG_MSG("ncr710ScsiTransact: Check Status value = 0x%x.\n", pScsiXaction->statusByte, 0, 0, 0, 0, 0); switch(pScsiXaction->statusByte & SCSI_STATUS_MASK) { case SCSI_STATUS_GOOD: status = OK; pScsiPhysDev->lastSenseKey = SCSI_SENSE_KEY_NO_SENSE; pScsiPhysDev->lastAddSenseCode = (UINT8) 0; goto cleanExit; case SCSI_STATUS_CHECK_CONDITION: { SCSI_COMMAND reqSenseCmd; /* REQUEST SENSE command */ SCSI_TRANSACTION reqSenseXaction; /* REQUEST SENSE xaction */ /* REQUEST SENSE buffer */ UINT8 reqSenseData [REQ_SENSE_ADD_LENGTH_BYTE + 1]; /* build a REQUEST SENSE command and transact it */ (void) scsiCmdBuild (reqSenseCmd, &reqSenseXaction.cmdLength, SCSI_OPCODE_REQUEST_SENSE, pScsiPhysDev->scsiDevLUN, FALSE, 0, pScsiPhysDev->reqSenseDataLength, (UINT8) 0); reqSenseXaction.cmdAddress = (UINT8 *) reqSenseCmd; /* if there is no user request sense buffer ,supply it */ if (pScsiPhysDev->pReqSenseData == (UINT8 *)NULL) { reqSenseXaction.dataAddress = reqSenseData; if (!pScsiPhysDev->extendedSense) reqSenseXaction.dataLength = 4; else reqSenseXaction.dataLength = REQ_SENSE_ADD_LENGTH_BYTE + 1; } else { reqSenseXaction.dataAddress = pScsiPhysDev->pReqSenseData; reqSenseXaction.dataLength = pScsiPhysDev->reqSenseDataLength; } reqSenseXaction.dataDirection = O_RDONLY; reqSenseXaction.addLengthByte = REQ_SENSE_ADD_LENGTH_BYTE; SCSI_DEBUG_MSG("ncr710ScsiTransact: issuing a REQUEST SENSE command.\n", 0, 0, 0, 0, 0, 0); if ((status = ncr710ScsiPhase (pScsiPhysDev, &reqSenseXaction)) == ERROR) { SCSI_DEBUG_MSG("ncr710ScsiTransact: scsiPhaseSequence ERROR.\n", 0, 0, 0, 0, 0, 0); goto cleanExit; } /* REQUEST SENSE command status != GOOD indicates fatal error */ if (reqSenseXaction.statusByte != SCSI_STATUS_GOOD) { SCSI_DEBUG_MSG("scsiTransact: non-zero REQ SENSE status.\n", 0, 0, 0, 0, 0, 0); errnoSet (S_scsiLib_REQ_SENSE_ERROR); status = ERROR; goto cleanExit; } /* if device uses Nonextended Sense Data Format, return now */ if (!pScsiPhysDev->extendedSense) { status = ERROR; goto cleanExit; } /* check sense key and take appropriate action */ pScsiPhysDev->lastSenseKey = (pScsiPhysDev->pReqSenseData)[2] & SCSI_SENSE_KEY_MASK; pScsiPhysDev->lastAddSenseCode = (pScsiPhysDev->pReqSenseData)[12]; addSenseCode = (int) pScsiPhysDev->lastAddSenseCode; switch (senseKey = (int) pScsiPhysDev->lastSenseKey) { case SCSI_SENSE_KEY_NO_SENSE: { SCSI_DEBUG_MSG("ncr710ScsiTransact: No Sense\n", 0, 0, 0, 0, 0, 0); status = OK; goto cleanExit; } case SCSI_SENSE_KEY_RECOVERED_ERROR: { SCSI_DEBUG_MSG("ncr710ScsiTransact: Recovered Error Sense,", 0, 0, 0, 0, 0, 0); SCSI_DEBUG_MSG("Additional Sense Code = 0x%02x\n", addSenseCode, 0, 0, 0, 0, 0); status = OK; goto cleanExit; } case SCSI_SENSE_KEY_NOT_READY: { SCSI_DEBUG_MSG("ncr710ScsiTransact: Not Ready Sense,", 0, 0, 0, 0, 0, 0); SCSI_DEBUG_MSG("Additional Sense Code = 0x%02x\n", addSenseCode, 0, 0, 0, 0, 0); errnoSet (S_scsiLib_DEV_NOT_READY); status = ERROR; goto cleanExit; } case SCSI_SENSE_KEY_UNIT_ATTENTION: { SCSI_DEBUG_MSG("ncr710ScsiTransact: Unit Attention Sense,", 0, 0, 0, 0, 0, 0); SCSI_DEBUG_MSG("Additional Sense Code = 0x%02x\n", addSenseCode, 0, 0, 0, 0, 0); if (addSenseCode == 0x28) { semTake (&pScsiPhysDev->blkDevList.listMutexSem, WAIT_FOREVER); for (pBlkDevNode = (SCSI_BLK_DEV_NODE *) lstFirst (&pScsiPhysDev->blkDevList.blkDevNodes); pBlkDevNode != NULL; pBlkDevNode = (SCSI_BLK_DEV_NODE *) lstNext (&pBlkDevNode->blkDevNode)) { pBlkDevNode->scsiBlkDev.blkDev.bd_readyChanged = TRUE; } semGive (&pScsiPhysDev->blkDevList.listMutexSem); } else if (addSenseCode == 0x29) { pScsiPhysDev->resetFlag = TRUE; } /* issue a MODE SENSE command */ { UINT8 modeSenseHeader [4]; /* mode sense data header */ SCSI_COMMAND modeSenseCommand;/* SCSI command byte array */ SCSI_TRANSACTION scsiXaction; /* info on a SCSI xaction */ if (scsiCmdBuild (modeSenseCommand, &scsiXaction.cmdLength, SCSI_OPCODE_MODE_SENSE, pScsiPhysDev->scsiDevLUN, FALSE, 0, sizeof (modeSenseHeader), (UINT8) 0) == ERROR) goto cleanExit; scsiXaction.cmdAddress = modeSenseCommand; scsiXaction.dataAddress = modeSenseHeader; scsiXaction.dataDirection = O_RDONLY; scsiXaction.dataLength = sizeof (modeSenseHeader); scsiXaction.addLengthByte = MODE_SENSE_ADD_LENGTH_BYTE; SCSI_DEBUG_MSG("ncr710ScsiTransact: issuing a MODE SENSE cmd.\n", 0, 0, 0, 0, 0, 0); if ((status = ncr710ScsiPhase (pScsiPhysDev, &scsiXaction)) == ERROR) { SCSI_DEBUG_MSG("ncr710ScsiTransact returned ERROR\n", 0, 0, 0, 0, 0, 0); goto cleanExit; } /* MODE SENSE command status != GOOD indicates * fatal error */ if (scsiXaction.statusByte != SCSI_STATUS_GOOD) { SCSI_DEBUG_MSG("ncr710ScsiTransact: bad MODE SELECT stat.\n", 0, 0, 0, 0, 0, 0); status = ERROR; goto cleanExit; } else { semTake (&pScsiPhysDev->blkDevList.listMutexSem, WAIT_FOREVER); for (pBlkDevNode = (SCSI_BLK_DEV_NODE *) lstFirst (&pScsiPhysDev->blkDevList.blkDevNodes); pBlkDevNode != NULL; pBlkDevNode = (SCSI_BLK_DEV_NODE *) lstNext (&pBlkDevNode->blkDevNode)) { pBlkDevNode->scsiBlkDev.blkDev.bd_mode = (modeSenseHeader [2] & (UINT8) 0x80) ? O_RDONLY : O_RDWR; } semGive (&pScsiPhysDev->blkDevList.listMutexSem); SCSI_DEBUG_MSG("Write-protect bit = %x.\n", (modeSenseHeader [2] & (UINT8) 0x80), 0, 0, 0, 0, 0); } } errnoSet (S_scsiLib_UNIT_ATTENTION); status = ERROR; goto cleanExit; } case SCSI_SENSE_KEY_DATA_PROTECT: { SCSI_DEBUG_MSG("ncr710ScsiTransact: Data Protect Sense,", 0, 0, 0, 0, 0, 0); SCSI_DEBUG_MSG("Additional Sense Code = 0x%02x\n", addSenseCode, 0, 0, 0, 0, 0); if (addSenseCode == 0x27) errnoSet (S_scsiLib_WRITE_PROTECTED); status = ERROR; goto cleanExit; } default: { SCSI_DEBUG_MSG("ncr710ScsiTransact: Sense = %x,", senseKey, 0, 0, 0, 0, 0); SCSI_DEBUG_MSG("Additional Sense Code = 0x%02x\n", addSenseCode, 0, 0, 0, 0, 0); status = ERROR; goto cleanExit; } } } case SCSI_STATUS_BUSY: errnoSet (S_scsiLib_DEV_NOT_READY); SCSI_DEBUG_MSG("device returned busy status.\n", 0, 0, 0, 0, 0, 0); status = ERROR; break; default: status = ERROR; }cleanExit: /* give back controller and device mutual exclusion semaphores */ SCSI_DEBUG_MSG("ncr710ScsiTransact Give devMutexSem\n", 0, 0, 0, 0, 0 ,0); semGive (&pScsiPhysDev->devMutexSem); /* restore task's normal priority, if previously altered */ if (pScsiCtrl->scsiPriority != NONE) taskPrioritySet (taskId, taskPriority); return (status); }/********************************************************************************* ncr710Show - display the values of all readable NCR 53C710 SIOP registers** This routine displays the state of the NCR 53C710 SIOP registers in a * user-friendly manner. It is useful primarily for debugging. * The input parameter is the pointer to the SIOP information structure * returned by the ncr710CtrlCreate() call.** NOTE* The only readable register during a script execution is the Istat register. * If this routine is used during the execution of a SCSI command, the result * could be unpredictable.** EXAMPLE:* .CS* -> ncr710Show* NCR710 Registers * ---------------- * 0xfff47000: Sien = 0xa5 Sdid = 0x00 Scntl1 = 0x00 Scntl0 = 0x04* 0xfff47004: Socl = 0x00 Sodl = 0x00 Sxfer = 0x80 Scid = 0x80* 0xfff47008: Sbcl = 0x00 Sbdl = 0x00 Sidl = 0x00 Sfbr = 0x00* 0xfff4700c: Sstat2 = 0x00 Sstat1 = 0x00 Sstat0 = 0x00 Dstat = 0x80* 0xfff47010: Dsa = 0x00000000* 0xfff47014: Ctest3 = ???? Ctest2 = 0x21 Ctest1 = 0xf0 Ctest0 = 0x00* 0xfff47018: Ctest7 = 0x32 Ctest6 = ???? Ctest5 = 0x00 Ctest4 = 0x00* 0xfff4701c: Temp = 0x00000000* 0xfff47020: Lcrc = 0x00 Ctest8 = 0x00 Istat = 0x00 Dfifo = 0x00* 0xfff47024: Dcmd/Ddc= 0x50000000* 0xfff47028: Dnad = 0x00066144* 0xfff4702c: Dsp = 0x00066144* 0xfff47030: Dsps = 0x00066174* 0xfff47037: Scratch3= 0x00 Scratch2= 0x00 Scratch1= 0x00 Scratch0= 0x0a* 0xfff47038: Dcntl = 0x21 Dwt = 0x00 Dien = 0x37 Dmode = 0x01* 0xfff4703c: Adder = 0x000cc2b8* .CE** RETURNS: OK, or ERROR if <pScsiCtrl> and <pSysScsiCtrl> are both NULL.** SEE ALSO: ncr710CtrlCreate()*/STATUS ncr710Show ( FAST SCSI_CTRL *pScsiCtrl /* ptr to SCSI controller info */ ) { FAST SIOP *pSiop; /* prt to SIOP info */ if (pScsiCtrl == NULL) { if (pSysScsiCtrl == NULL) { printErr ("No SCSI controller specified.\n"); return (ERROR); } pScsiCtrl = pSysScsiCtrl; } pSiop = (SIOP *) pScsiCtrl; printf ("NCR710 Registers \n"); printf ("---------------- \n"); printf ("0x%08x: ", (int) pSiop->pSien); printf ("Sien = 0x%02x ", *pSiop->pSien); printf ("Sdid = 0x%02x ", *pSiop->pSdid); printf ("Scntl1 = 0x%02x ", *pSiop->pScntl1); printf ("Scntl0 = 0x%02x\n", *pSiop->pScntl0); printf ("0x%08x: ", (int) pSiop->pSocl); printf ("Socl = 0x%02x ", *pSiop->pSocl); printf ("Sodl = 0x%02x ", *pSiop->pSodl); printf ("Sxfer = 0x%02x ", *pSiop->pSxfer); printf ("Scid = 0x%02x\n", *pSiop->pScid); printf ("0x%08x: ", (int) pSiop->pSbcl); printf ("Sbcl = 0x%02x ", *pSiop->pSbcl); printf ("Sbdl = 0x%02x ", *pSiop->pSbdl); printf ("Sidl = 0x%02x ", *pSiop->pSidl); printf ("Sfbr = 0x%02x\n", *pSiop->pSfbr); printf ("0x%08x: ", (int) pSiop->pSstat2); printf ("Sstat2 = 0x%02x ", *pSiop->pSstat2); printf ("Sstat1 = 0x%02x ", *pSiop->pSstat1); printf ("Sstat0 = 0x%02x ", *pSiop->pSstat0); printf ("Dstat = 0x%02x\n", *pSiop->pDstat); printf ("0x%08x: ", (int) pSiop->pDsa); printf ("Dsa = 0x%08x\n", *pSiop->pDsa); /* read fifo is not a good idea */ printf ("0x%08x: ", (int) pSiop->pCtest3); printf ("Ctest3 = ???? "); printf ("Ctest2 = 0x%02x ", *pSiop->pCtest2); printf ("Ctest1 = 0x%02x ", *pSiop->pCtest1); printf ("Ctest0 = 0x%02x\n", *pSiop->pCtest0); printf ("0x%08x: ", (int) pSiop->pCtest7); printf ("Ctest7 = 0x%02x ", *pSiop->pCtest7); /* read fifo is not a good idea */ printf ("Ctest6 = ???? "); printf ("Ctest5 = 0x%02x ", *pSiop->pCtest5); printf ("Ctest4 = 0x%02x\n", *pSiop->pCtest4); prin
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -