📄 atapitest.c
字号:
If This test is ran twice it test first the DEVICE 0 and then the DEVICE 1. ******************************************************************/static ATAPI_TestResult_t ATAPI_TestAPINormal(ATAPI_TestParams_t * TestParams){ ST_ErrorCode_t Error; ATAPI_TestResult_t Result = TEST_RESULT_ZERO; U32 i; STATAPI_Params_t DriverParams; STATAPI_Capability_t Capability; STATAPI_PioMode_t Mode; STATAPI_PioTiming_t TimingParams; /* ATAPI driver parameters */ STATAPI_InitParams_t AtapiInitParams; STATAPI_TermParams_t AtapiTermParams; STATAPI_OpenParams_t AtapiOpenParams;#ifdef DMA_PRESENT STATAPI_DmaMode_t DmaMode; STATAPI_DmaTiming_t DmaTimingParams;#endif AtapiInitParams.DeviceType= STATAPI_EMI_PIO4; AtapiInitParams.DriverPartition= TEST_PARTITION_1; AtapiInitParams.BaseAddress= ATA_BASE_ADDRESS; AtapiInitParams.HW_ResetAddress= ATA_HRD_RST; AtapiInitParams.InterruptNumber = ATA_INTERRUPT_NUMBER; AtapiInitParams.InterruptLevel = ATA_INTERRUPT_LEVEL;#if defined(ST_5514) AtapiInitParams.ClockFrequency = ClockFrequency;#endif#if defined(ATAPI_GPDMA) strcpy(AtapiInitParams.GPDMADeviceName, GPDMADevName);#endif strcpy(AtapiInitParams.EVTDeviceName,EVTDevName); /* STATAPI_Init() */ STTBX_Print(("%d.0 STATAPI_Init() \n",TestParams->Ref)); STTBX_Print(("Purpose: to ensure a ATAPI device can be initialized\n")); { Error = STATAPI_Init(AtapiDevName, &AtapiInitParams); if(CheckCodeOk(Error)) { ATAPI_TestFailed(Result,"Unable to initialize ATAPI device"); goto api2_end; } ATAPI_TestPassed(Result); } for(i=0;i<1;i++) { if(Drives[i].Present) { /* STATAPI_Open() */ if(i==0) AtapiOpenParams.DeviceAddress=STATAPI_DEVICE_0; else AtapiOpenParams.DeviceAddress=STATAPI_DEVICE_1; STTBX_Print(("%d.1 STATAPI_Open() \n",TestParams->Ref)); STTBX_Print(("Purpose: to ensure a ATAPI device connection can be opened\n")); { Error = STATAPI_Open(AtapiDevName, &AtapiOpenParams,&Drives[i].Handle); if(CheckCodeOk(Error)) { ATAPI_TestFailed(Result,"Unable to open ATAPI device"); goto api2_end; } ATAPI_TestPassed(Result); } /* STATAPI_SetPioMode */ STTBX_Print(("%d.2 Set Pio mode 4 \n",TestParams->Ref)); STTBX_Print(("Purpose: to ensure we can set the Pio mode 4\n ")); { Error = STATAPI_SetPioMode(Drives[i].Handle,STATAPI_PIO_MODE_4); if(CheckCodeOk(Error)) { ATAPI_TestFailed(Result,"Unable to set Pio mode 4"); goto api2_end; } ATAPI_TestPassed(Result); } if(Drives[i].Type==STATAPI_ATA_DRIVE) { /* Simple Read/Write Test */ STTBX_Print(("%d.2a Simple R/W Test \n",TestParams->Ref)); STTBX_Print(("Purpose: to ensure we can write data and then read it back \n")); { Error = SimpleRWTest(Drives[i].Handle,&AddressTable[TestParams->Ref],3); if(CheckCodeOk(Error)) { ATAPI_TestFailed(Result,"Unable to Read/Write ATAPI device"); goto api2_end; } ATAPI_TestPassed(Result); } } else if(Drives[i].Type==STATAPI_ATAPI_DRIVE) { STTBX_Print(("%d.2a Read TOC Test \n",TestParams->Ref)); STTBX_Print(("Purpose: to ensure we can read data from the device \n")); { Error = ReadTOCTest(Drives[i].Handle); if(CheckCodeOk(Error)) { ATAPI_TestFailed(Result,"Unable to Read TOC from ATAPI device"); goto api2_end; } ATAPI_TestPassed(Result); } } #ifdef DMA_PRESENT /* Make sure the sectors are "empty". MWDMA write should then * fill the sectors, before reading them back to verify. UDMA * write currently doesn't work, so the UDMA read will read back * the data written by the MWDMA write and verify. When UDMA out * is fixed, this behaviour will need to be adjusted. Note that * this applies to virtually all of the MWDMA/UDMA tests * throughout the test harness. */ ClearSectors(Drives[i].Handle, &AddressTable[TestParams->Ref], 1); STTBX_Print(("%d.3 DMA mode tests \n",TestParams->Ref)); STTBX_Print(("%d.3a Purpose: to ensure we can set MWDMA mode 2\n",TestParams->Ref)); { Error = STATAPI_SetDmaMode(Drives[i].Handle,STATAPI_DMA_MWDMA_MODE_2); if(CheckCodeOk(Error)) { ATAPI_TestFailed(Result,"Unable to set MWDMA mode 2"); goto api2_end; } ATAPI_TestPassed(Result); } Error = SetTransferModeDma(Drives[i].Handle, STATAPI_DMA_MWDMA_MODE_2); if (Error != ST_NO_ERROR) goto api2_end; if(Drives[i].Type==STATAPI_ATA_DRIVE) { /* Simple Read/Write Test */ STTBX_Print(("%d.3a Simple R/W Test \n",TestParams->Ref)); STTBX_Print(("Purpose: to ensure we can write data and then read it back \n")); { Error = SimpleRWTestDma(Drives[i].Handle, &AddressTable[TestParams->Ref], 1); if(CheckCodeOk(Error)) { ATAPI_TestFailed(Result,"Unable to Read/Write ATAPI device"); } else { ATAPI_TestPassed(Result); } } } else if(Drives[i].Type==STATAPI_ATAPI_DRIVE) { STTBX_Print(("%d.3a Read TOC Test \n",TestParams->Ref)); STTBX_Print(("Purpose: to ensure we can read data from the device \n")); { Error = ReadTOCTest(Drives[i].Handle); if(CheckCodeOk(Error)) { ATAPI_TestFailed(Result,"Unable to Read TOC from ATAPI device"); } ATAPI_TestPassed(Result); } }#if !defined(HDDI_5514_CUT_2) STTBX_Print(("%d.3b Purpose: to ensure we can set UDMA mode 4\n", TestParams->Ref)); { Error = STATAPI_SetDmaMode(Drives[i].Handle, STATAPI_DMA_UDMA_MODE_4); if(CheckCodeOk(Error)) { ATAPI_TestFailed(Result,"Unable to set UDMA mode 4"); goto api2_end; } ATAPI_TestPassed(Result); } Error = SetTransferModeDma(Drives[i].Handle, STATAPI_DMA_UDMA_MODE_4); if (Error != ST_NO_ERROR) goto api2_end; if(Drives[i].Type==STATAPI_ATA_DRIVE) { /* Simple Read/Write Test */ STTBX_Print(("%d.3b Simple R/W Test \n",TestParams->Ref)); STTBX_Print(("Purpose: to ensure we can write data and then read it back \n")); { Error = SimpleRWTestDma(Drives[i].Handle, &AddressTable[TestParams->Ref], 1); if(CheckCodeOk(Error)) { ATAPI_TestFailed(Result,"Unable to Read/Write ATAPI device"); } else { ATAPI_TestPassed(Result); } } } else if(Drives[i].Type==STATAPI_ATAPI_DRIVE) { STTBX_Print(("%d.3b Read TOC Test \n",TestParams->Ref)); STTBX_Print(("Purpose: to ensure we can read data from the device \n")); { Error = ReadTOCTest(Drives[i].Handle); if(CheckCodeOk(Error)) { ATAPI_TestFailed(Result,"Unable to Read TOC from ATAPI device"); } ATAPI_TestPassed(Result); } }#endif /* HDDI_5514_CUT_2 */#endif /* STATAPI_Close() */ STTBX_Print(("%d.4 STATAPI_Close \n",TestParams->Ref)); STTBX_Print(("Purpose: to ensure we can close a connection\n")); { Error = STATAPI_Close(Drives[i].Handle); if(CheckCodeOk(Error)) { ATAPI_TestFailed(Result,"Unable to close a connection"); }else { ATAPI_TestPassed(Result); } } /* STATAPI_Open() */ AtapiOpenParams.DeviceAddress=TestParams->DevAddress; STTBX_Print(("%d.5 STATAPI_Open() \n",TestParams->Ref)); STTBX_Print(("Purpose: to ensure we can re-open a closed connection\n")); { Error = STATAPI_Open(AtapiDevName, &AtapiOpenParams,&Drives[i].Handle); if(CheckCodeOk(Error)) { ATAPI_TestFailed(Result,"Unable to re-open ATAPI device"); }else { ATAPI_TestPassed(Result); } } /* STATAPI_SetPioMode */ STTBX_Print(("%d.6 Set Pio mode 4 \n",TestParams->Ref)); STTBX_Print(("Purpose: to ensure we can set the Pio mode 4\n ")); { Error = STATAPI_SetPioMode(Drives[i].Handle,STATAPI_PIO_MODE_4); if(CheckCodeOk(Error)) { ATAPI_TestFailed(Result,"Unable to set Pio mode 4"); }else { ATAPI_TestPassed(Result); } } Error = SetTransferModePio(Drives[i].Handle, STATAPI_PIO_MODE_4); if (Error != ST_NO_ERROR) goto api2_end; /* Simple Read/Write Test */ if(Drives[i].Type==STATAPI_ATA_DRIVE) { /* Simple Read/Write Test */ STTBX_Print(("%d.7 Simple R/W Test \n",TestParams->Ref)); STTBX_Print(("Purpose: to ensure we can write data and then read it back \n")); { Error = SimpleRWTest(Drives[i].Handle,&AddressTable[TestParams->Ref],3); if(CheckCodeOk(Error)) { ATAPI_TestFailed(Result,"Unable to Read/Write ATAPI device"); goto api2_end; } ATAPI_TestPassed(Result); } } else if(Drives[i].Type==STATAPI_ATAPI_DRIVE) { STTBX_Print(("%d.7 Read TOC Test \n",TestParams->Ref)); STTBX_Print(("Purpose: to ensure we can read data from the device \n")); { Error = ReadTOCTest(Drives[i].Handle); if(CheckCodeOk(Error)) { ATAPI_TestFailed(Result,"Unable to Read TOC from ATAPI device"); goto api2_end; } ATAPI_TestPassed(Result); } } if(Drives[i].Type == STATAPI_ATA_DRIVE) { /* Multiple Read/Write Test */ STTBX_Print(("%d.8 Multiple Read Write Test \n",TestParams->Ref)); STTBX_Print(("Purpose: w/r 4 blocks in multiple mode 2\n")); { Error = MultipleRWTest(Drives[i].Handle, &AddressTable[TestParams->Ref], 4, 2); if(CheckCodeOk(Error)) { ATAPI_TestFailed(Result,"Unable to Erase/Read on the ATAPI device"); } else { ATAPI_TestPassed(Result); } } } else { STTBX_Print(("%d.8 Multiple Read Write Test overridden\n",TestParams->Ref)); ATAPI_TestPassed(Result); }#if defined(DMA_PRESENT) /* Make sure the sectors are "empty" */ ClearSectors(Drives[i].Handle, &AddressTable[TestParams->Ref], 10); STTBX_Print(("%d.8b Purpose: to ensure we can set MWDMA mode 2\n",TestParams->Ref)); { Error = STATAPI_SetDmaMode(Drives[i].Handle,STATAPI_DMA_MWDMA_MODE_2); if(CheckCodeOk(Error)) { ATAPI_TestFailed(Result,"Unable to set MWDMA mode 2"); goto api2_end; } ATAPI_TestPassed(Result); } Error = SetTransferModeDma(Drives[i].Handle, STATAPI_DMA_MWDMA_MODE_2); if (Error != ST_NO_ERROR) goto api2_end; if(Drives[i].Type == STATAPI_ATA_DRIVE) { U8 NumSectors = 10; /* Multiple Read/Write Test */ STTBX_Print(("%d.8b Multiple Sector Read Write Test \n",TestParams->Ref)); STTBX_Print(("Purpose: w/r %i sectors\n", NumSectors)); { Error = SimpleRWTestDma(Drives[i].Handle, &AddressTable[TestParams->Ref], NumSectors); if(CheckCodeOk(Error)) { ATAPI_TestFailed(Result,"Unable
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -