⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testscsi.c

📁 Curtiss-Wright Controls Embedded Computing公司的cw183板bsp源代码
💻 C
字号:
/************************************************************************** * *   Copyright (c) 2005 Curtiss-Wright Controls, Inc. All rights *   reserved.  This Source Code is the Property of Curtiss-Wright *   Controls, Inc. and can only be used in accordance with Source *   Code License Agreement(s) of Curtiss-Wright Controls, Inc. or any *   of its subsidiaries. * **************************************************************************//*FILE HEADER************************************************************** * Product Name: 182/183 BSP * * Header %name:  testscsi.c % * Instance:      kanata_1 * * Description: 182 test for scsi * * %created_by:   tissa % * %date_created: Tue Dec 13 16:42:28 2005 % * * Notes: * * History: *      02b, 13dec05, tis fixed compiler warnings CR#12706  *      02a, 20oct05, rsr CR3191: Added bsp.h to includes * *END FILE HEADER*********************************************************//* ------------------------------------------------------------------------ **** testScsi.c - NCR53C885 SCSI PCI                                          **** ------------------------------------------------------------------------ ****                                                                          ****  DY 4 NCR885 VxWorks demonstration SCSI driver for SVME-179/18x          ****                                                                          ****  Copyright (C) 1999                                                      ****  DY 4 Systems, Inc.                                                      ****                                                                          ****  Project:                                                                ****                                                                          **** ------------------------------------------------------------------------ ****                                                                          ****  Prepared by Innformission Group Incorporated                            ****                                                                          **** ------------------------------------------------------------------------ ****                                                                          ****  DESCRIPTION                                                             ****  This library contains routines which relate to the SCSI functions of    ****  the NCR53C885 SCSI chip.                                                ****                                                                          ****  The functions addressed here include:                                   ****                                                                          ****      - Test SCSI driver                                                  ****          - Create file and put data in it                                ****          - Read and compare file                                         ****          - Delete file                                                   ****          - Compare buffer                                                ****                                                                          **** ------------------------------------------------------------------------ ****                                                                          ****  Author:                DUD Informission                                 ****                                                                          ****  Language:              C                                                ****                                                                          **\* ------------------------------------------------------------------------ *//* ------------------------------------------------------------------------ *\    Filename:              $Source: C:\tornado2\target\config\svme179\src\demo\testscsi.c    Current Revision:      $Revision: 1 $    Last Updated:          $Date: 1/10/00 3:49p $    Last Modified by:      $Author: Dud $    Currently Locked by:   $Locker:  $    Change History:    Revision 1.0  1999/01/11 15:04:01  DUD Informission    Initial revision\* ------------------------------------------------------------------------ *//* System Include Files */#include "vxWorks.h"#include <usrConfig.h>#define DOS_DISK_NAME           "/sd0/"#include <config.h>#include "bsp.h"/* Declarations */#define DATA_SCSI			ROM_BASE_ADRS + 100#define FILE_TO_TEST			9#define NUMBER_OF_BYTE_MAX		1024IMPORT int logMsg    (    char * fmt,               /* format string for print */    int    arg1,              /* first of six required args for fmt */    int    arg2,    int    arg3,    int    arg4,    int    arg5,    int    arg6    );/* Function prototypes */void  createFile( const char* name, int numberOfByte );void  readAndCompareFile( const char* name, int numberOfByte );void  compareData( char* dataInRamWriteToScsi, char* dataInRamReadFromScsi,                   int numberOfByte );void  DeleteFile( const char* name );void  testScsiDriver( void );/* Functions *//*HEADER***************************************************/void  createFile( const char* name, int numberOfByte )/*  Description : Create file with name and the numberOfByte *                of data. * *   Return Value : *       None. * *   Comments: * **END HEADER**********************************************/{  char * dataInRamWriteToScsi = (char*)DATA_SCSI;  int fd;    logMsg("Create file %s and write %dbytes of data.\n",(UINT32)name,numberOfByte,0,0,0,0);    if((fd = open( name, O_CREAT | O_RDWR, 0 )) != ERROR)  {   do   {    if( numberOfByte > NUMBER_OF_BYTE_MAX )    {     write(fd, dataInRamWriteToScsi, NUMBER_OF_BYTE_MAX );     numberOfByte -= NUMBER_OF_BYTE_MAX;     dataInRamWriteToScsi += 1;    }    else    {     write(fd, dataInRamWriteToScsi, numberOfByte );     numberOfByte = 0;    }   }   while(numberOfByte != 0);   close( fd );  }  else   logMsg("*** ERROR Can't create file %s. ***\n",(UINT32)name,0,0,0,0,0);}/*HEADER***************************************************/void  readAndCompareFile( const char* name, int numberOfByte )/*  Description : Read and compare file specify in parameters. *  * *   Return Value : *       None. * *   Comments: * **END HEADER**********************************************/{  char * dataInRamWriteToScsi = (char*)DATA_SCSI;  char dataInRamReadFromScsi[NUMBER_OF_BYTE_MAX];  int fd;    logMsg("Open file %s, read and compare %dbytes of data.\n",(UINT32)name,numberOfByte,0,0,0,0);  if((fd = open( name, O_RDWR, 0 )) != ERROR)  {   do   {    if( numberOfByte > NUMBER_OF_BYTE_MAX )    {     read(fd, dataInRamReadFromScsi, NUMBER_OF_BYTE_MAX );     compareData(dataInRamWriteToScsi, dataInRamReadFromScsi, NUMBER_OF_BYTE_MAX);     numberOfByte -= NUMBER_OF_BYTE_MAX;     dataInRamWriteToScsi += 1;    }    else    {     read(fd, dataInRamReadFromScsi, numberOfByte );     compareData(dataInRamWriteToScsi, dataInRamReadFromScsi, numberOfByte);     numberOfByte = 0;    }   }   while(numberOfByte != 0);   close( fd );  }   else   logMsg("*** ERROR Can't open file %s. ***\n",(UINT32)name,0,0,0,0,0);}/****************************************************************/  /*HEADER***************************************************/void  compareData( char* dataInRamWriteToScsi, char* dataInRamReadFromScsi,                   int numberOfByte )/*  Description : Compare two buffers of data with a number of byte specify *  * *   Return Value : *       None. * *   Comments: * **END HEADER**********************************************/{  int i;    for( i=0; i<numberOfByte; i++ ){  if( dataInRamReadFromScsi[i] != dataInRamWriteToScsi[i] )  printf("**** ERROR DATA COMPARE: Offset: %04d  RD: 0x%02x  WR: 0x%02x ****\n",            i, dataInRamReadFromScsi[i], dataInRamWriteToScsi[i] );  }}/****************************************************************/  /*HEADER***************************************************/void  deleteFile( const char* name )/*  Description : Delete file specify from SCSI disk *  * *   Return Value : *       None. * *   Comments: * **END HEADER**********************************************/{  logMsg("Delete file %s.\n",(UINT32)name,0,0,0,0,0);  remove( name );}/***************************************************************    Main Test Function***************************************************************/void testScsiDriver(void){ int i;char fileName[20];int sizeTable[9] = {1,100,1024,10240,51200,102400,512000,1024000,10240000};logMsg("-----------------------------------------------\n",0,0,0,0,0,0);logMsg("Results of:\n",0,0,0,0,0,0);logMsg("testDriverScsi\n",0,0,0,0,0,0);logMsg("-----------------------------------------------\n\n\n",0,0,0,0,0,0);logMsg("Change drive to /sd0/ (SCSI DRIVE).\n",0,0,0,0,0,0);cd(DOS_DISK_NAME);   /* Point on SCSI drive *//* Create all file on disk */logMsg("\n\nCreate all files on SCSI disk\n\n",0,0,0,0,0,0);for(i=0; i<FILE_TO_TEST; i++)    {    sprintf(fileName, "%d", sizeTable[i]);    createFile(fileName, sizeTable[i]);    }/* Read and compare all files */logMsg("\n\nRead and compare all files on SCSI disk\n\n",0,0,0,0,0,0);for(i=0; i<FILE_TO_TEST; i++)    {    sprintf(fileName, "%d", sizeTable[i]);    readAndCompareFile(fileName, sizeTable[i]);    }/* Delete all files */logMsg("\n\nDelete all files on SCSI disk\n\n",0,0,0,0,0,0);for(i=0; i<FILE_TO_TEST; i++)    {    sprintf(fileName, "%d", sizeTable[i]);    deleteFile(fileName);    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -