?? scsitestlib.c
字號:
/* scsiTest.c - Program to test SCSI library *//* Copyright 1994-1996 Wind River Systems, Inc. */#include "copyright_wrs.h"/*modification history--------------------01b,25sep96,dds added documentation and corrected for wrs coding standards.01a,25jan94,ccc written.*//* DESCRIPTIONThese set of routines are written to test the functionality of the SCSIlibrary.*/#include "vxWorks.h"#include "tickLib.h"#include "taskLib.h"#include "ioLib.h"#include "memLib.h"#include "usrLib.h"#include "fppLib.h"#include "scsiLib.h"/* defines */#define FACTOR (0x800 * 512)#define TOTAL 0x1000000#define BLOCK (0x400 * 512)#define LINES (TOTAL / FACTOR)#define THIS_TASK 0#define TEST_VERBOSE \if (testVerbose) \ printf IMPORT errno;VOID printf ();VOID bzero ();IMPORT STATUS scsiTargetOptionsGet ();IMPORT STATUS scsiTargetOptionsSet ();IMPORT STATUS scsiTestUnitRdy ();IMPORT void logMsg ();IMPORT STATUS scsiTapeModeSense ();IMPORT STATUS scsiTapeModeSelect ();IMPORT STATUS scsiReadBlockLimits ();IMPORT STATUS scsiLoad ();IMPORT STATUS scsiReserveUnit ();IMPORT STATUS scsiRewind ();IMPORT STATUS scsiErase ();IMPORT STATUS scsiReleaseUnit ();IMPORT STATUS scsiWrtTape ();IMPORT STATUS scsiWrtFileMarks ();IMPORT STATUS scsiSpace ();IMPORT STATUS scsiRdTape ();IMPORT STATUS scsiReserve ();IMPORT STATUS scsiRelease ();IMPORT STATUS scsiStartStopUnit ();/* global variables */BOOL testVerbose;/* COMMON COMMANDS *//******************************************************************************** scsiTestTestUnitRdy - run TEST UNIT READY command** This routine executes the TEST UNIT READY command to the specified* SCSI physical device.** RETURNS: OK if passes, or ERROR if an error is encountered.*/STATUS scsiTestTestUnitRdy ( SCSI_PHYS_DEV *pScsiPhysDev ) { if (scsiTestUnitRdy (pScsiPhysDev) == ERROR) { printf ("Failed TEST UNIT READY\n"); return (ERROR); } TEST_VERBOSE ("\tPass TEST UNIT READY\n"); return (OK); }/******************************************************************************** scsiTestInquiry - run INQUIRY command** This routine executes the INQUIRY command to the specified* SCSI physical device.** RETURNS: OK if passes, or ERROR if an error is encountered.*/STATUS scsiTestInquiry ( SCSI_PHYS_DEV *pScsiPhysDev, /* ptr to SCSI physical device */ char *buffer, /* ptr to data buffer */ int bufLength /* length of buffer in bytes */ ) { int i; if (scsiInquiry (pScsiPhysDev, buffer, bufLength) == ERROR) { printf ("Failed INQUIRY\n"); return (ERROR); } switch (buffer [0]) { case 0x00: TEST_VERBOSE ("\n\nDirect-access device (e.g. disk):\n"); break; case 0x01: TEST_VERBOSE ("\n\nSequential-access device (e.g. tape):\n"); break; default: TEST_VERBOSE ("\n\nDevice type = 0x%02x:\n", buffer [0]); break; } switch (buffer [2] & 0x07) { case 0x00: TEST_VERBOSE (" Pre SCSI-1 standard\n"); break; case 0x01: TEST_VERBOSE (" SCSI-1 device\n"); break; case 0x02: TEST_VERBOSE (" SCSI-2 device\n"); break; default: TEST_VERBOSE (" Reserved version number\n"); break; } switch (buffer [7] & 0x60) { case 0x40: TEST_VERBOSE (" Supports 32 bit transfers\n"); break; case 0x20: TEST_VERBOSE (" Supports 16 bit transfers\n"); break; default: TEST_VERBOSE (" Supports 8 bit transfers\n"); break; } if ((buffer [7] & 0x02) == 0x02) TEST_VERBOSE (" Supports command queuing\n"); TEST_VERBOSE ("ID: "); for (i = 8; i < 16; i++) TEST_VERBOSE ("%c", buffer[i]); TEST_VERBOSE ("\n\n"); TEST_VERBOSE ("\tPass INQUIRY\n"); return (OK); }/******************************************************************************** scsiTestReqSense - runs REQUEST SENSE command** This routine executes the REQUEST SENSE command to the specified* SCSI physical device.** RETURNS: OK if passes, or ERROR if an error is encountered.*/STATUS scsiTestReqSense ( SCSI_PHYS_DEV *pScsiPhysDev, /* ptr to SCSI physical device */ char *buffer, /* ptr to data buffer */ int bufLength /* length of buffer in bytes */ ) { if (scsiReqSense (pScsiPhysDev, buffer, bufLength) == ERROR) { printf ("Failed REQUEST SENSE\n"); return (ERROR); } TEST_VERBOSE ("\tPass REQUEST SENSE\n"); return (OK); }/* SEQUENTIAL COMMANDS */#if FALSE/******************************************************************************** scsiTestTapeModeSense - runs tape MODE SENSE command** This routine executes the tape MODE SENSE command to the specified* SCSI physical device.** RETURNS: OK if passes, or ERROR if an error is encountered.*/STATUS scsiTestTapeModeSense ( SCSI_PHYS_DEV *pScsiPhysDev, /* ptr to SCSI physical device */ int pageControl, /* value of the page control field */ int pageCode, /* value of the page code field */ char *buffer, /* ptr to data buffer */ int bufLength /* length of buffer in bytes */ ) { if (scsiTapeModeSense (pScsiPhysDev, pageControl, pageCode, buffer, bufLength) == ERROR) { printf ("Failed tape MODE SENSE\n"); return (ERROR); } TEST_VERBOSE ("\tPass tape MODE SENSE\n"); return (OK); }/****************************************************************************** * * scsiTestTapeModeSelect - runs tape MODE SELECT command * * This routine executes the tape MODE SELECT command to the specified * SCSI physical device. * * RETURNS: OK if passes, or ERROR if an error is encountered. */STATUS scsiTestTapeModeSelect ( SCSI_PHYS_DEV *pScsiPhysDev, /* ptr to SCSI physical device */ int pageFormat, /* value of the page format bit */ int saveParams, /* value of the save parameters bit */ char *buffer, /* ptr to data buffer */ int bufLength /* length of buffer in bytes */ ) { if (scsiTapeModeSelect (pScsiPhysDev, pageFormat, saveParams, buffer, bufLength) == ERROR) { printf ("Failed tape MODE SELECT\n"); return (ERROR); } TEST_VERBOSE ("\tPass tape MODE SELECT\n"); return (OK); }/******************************************************************************** scsiTestReadBlockLimits - runs tape READ BLOCK LIMITS command** This routine executes the tape READ BLOCK LIMITS command to the specified* SCSI physical device.** RETURNS: OK if passes, or ERROR if an error is encountered.*/STATUS scsiTestReadBlockLimits ( SCSI_PHYS_DEV *pScsiPhysDev, /* ptr to SCSI physical device */ int *pMaxBlockLength, /* where to return maximum block length */ UINT16 *pMinBlockLength /* where to return minimum block length */ ) { if (scsiReadBlockLimits (pScsiPhysDev, pMaxBlockLength, pMinBlockLength) == ERROR) { printf ("Failed tape READ BLOCK LIMITS\n"); return (ERROR); } TEST_VERBOSE ("\tPass tape READ BLOCK LIMITS\n"); return (OK); }/******************************************************************************** scsiTestLoad - runs tape LOAD command** This routine executes the tape LOAD command to the specified* SCSI physical device.** RETURNS: OK if passes, or ERROR if an error is encountered.*/STATUS scsiTestLoad ( SCSI_PHYS_DEV *pScsiPhysDev /* ptr to SCSI physical device */ ) { if (scsiLoad (pScsiPhysDev, TRUE) == ERROR) { printf ("Failed tape LOAD\n"); return (ERROR); } TEST_VERBOSE ("\tPass tape LOAD\n"); return (OK); }/******************************************************************************** scsiTestUnload - runs tape UNLOAD command** This routine executes the tape UNLOAD command to the specified* SCSI physical device.** RETURNS: OK if passes, or ERROR if an error is encountered.*/STATUS scsiTestUnload ( SCSI_PHYS_DEV *pScsiPhysDev /* ptr to SCSI physical device */ ) { if (scsiLoad (pScsiPhysDev, FALSE) == ERROR) { printf ("Failed tape UNLOAD\n"); return (ERROR); } TEST_VERBOSE ("\tPass tape UNLOAD\n"); return (OK); }/******************************************************************************** scsiTestReserveUnit - runs tape RESERVE UNIT command** This routine executes the tape RESERVE UNIT command to the specified* SCSI physical device.** RETURNS: OK if passes, or ERROR if an error is encountered.*/STATUS scsiTestReserveUnit ( SCSI_PHYS_DEV *pScsiPhysDev /* ptr to SCSI physical device */ ) { if (scsiReserveUnit (pScsiPhysDev) == ERROR) { printf ("Failed tape RESERVE UNIT\n"); return (ERROR); } TEST_VERBOSE ("\tPass tape RESERVE UNIT\n"); return (OK); }/******************************************************************************** scsiTestReleaseUnit - runs tape RELEASE UNIT command** This routine executes the tape RELEASE UNIT command to the specified* SCSI physical device.** RETURNS: OK if passes, or ERROR if an error is encountered.*/STATUS scsiTestReleaseUnit ( SCSI_PHYS_DEV *pScsiPhysDev /* ptr to SCSI physical device */ ) { if (scsiReleaseUnit (pScsiPhysDev) == ERROR) { printf ("Failed tape RELEASE UNIT\n"); return (ERROR); } TEST_VERBOSE ("\tPass tape RELEASE UNIT\n"); return (OK); }/******************************************************************************** scsiTestRewind - runs tape REWIND command** This routine executes the tape REWIND command to the specified* SCSI physical device.** RETURNS: OK if passes, or ERROR if an error is encountered.*/STATUS scsiTestRewind ( SCSI_PHYS_DEV *pScsiPhysDev /* ptr to SCSI physical device */ ) { if (scsiRewind (pScsiPhysDev) == ERROR) { printf ("Failed tape REWIND\n"); return (ERROR); } TEST_VERBOSE ("\tPass tape REWIND\n"); return (OK); }/******************************************************************************** scsiTestErase - runs tape ERASE command** This routine executes the tape ERASE command to the specified* SCSI physical device.** RETURNS: OK if passes, or ERROR if an error is encountered.*/STATUS scsiTestErase (
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -