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

📄 rwbuffer.c

📁 ST5518机顶盒系统文件系统源代码!绝对超值!
💻 C
📖 第 1 页 / 共 4 页
字号:
                Result = TEST_FAILED;            }                        /* Check the data */                        else if (memcmp(WorkBuffer, Data, sizeof(Data)))            {                int i;                for (i = 0; (i < 16); i++)                {                    STTBX_Print(("0X%02X ", WorkBuffer[i]));                }                STTBX_Print(("\nIncorrect results (1)\n"));                Result = TEST_FAILED;            }                        /* Release the buffer */                        else if (ST_NO_ERROR != stavfs_DiscardRWBuffer(&Device, &RWBuffer))            {                STTBX_Print(("Failed Closing the R/W Buffer\n"));                Result = TEST_FAILED;            }                        /* Read the sector */                        else if (ST_NO_ERROR != ReadTheSector(&Obj, WorkBuffer))            {                STTBX_Print(("Failed Reading the Sector\n"));                Result = TEST_FAILED;            }                        /* Check the data */                        else if (memcmp(WorkBuffer, Data, sizeof(Data)))            {                int i;                for (i = 0; (i < 16); i++)                {                    STTBX_Print(("0X%02X ", WorkBuffer[i]));                }                STTBX_Print(("\nIncorrect results (2)\n"));                Result = TEST_FAILED;            }        }                /* Close down */                if (ST_NO_ERROR != stavfs_TermRWCache(&Device))        {            Result = TEST_FAILED;        }                if (ST_NO_ERROR != CloseHal(&Obj))        {            Result = TEST_FAILED;        }    }        return(Result);}/******************************************************************************Function Name : MultiTest  Description : Multiple Allocation of Buffers   Parameters :******************************************************************************/static TestResult_t MultiTest(int TestNo, TestVariant_t Variant){    TestResult_t Result = TEST_PASSED;    stavfs_HAL_t Obj;        if (Variant != TEST_VARIANT_A)    {        Result = TEST_FAILED;    }    else if (ST_NO_ERROR != OpenHal(&Obj))    {        Result = TEST_FAILED;    }    else    {        /* Initialise the data structures */                stavfs_Device_t Device;                Device.HALData         = &Obj;        Device.MemoryPartition = system_partition;        Device.RWCache         = NULL;                        if (ST_NO_ERROR != InitialiseData(&Obj))        {            Result = TEST_FAILED;        }        else if (ST_NO_ERROR != stavfs_InitRWCache(&Device))        {            Result = TEST_FAILED;        }        else        {            /* Run the test */                        stavfs_RWBufferRef_t RWBuffer1 = NULL;            stavfs_RWBufferRef_t RWBuffer2 = NULL;            stavfs_RWBufferRef_t RWBuffer3 = NULL;                        char WriteData[]  = {0X01, 0X02, 0X03, 0X04, 0X05, 0X06, 0X07, 0X08};            char ResultData[] = {0X01, 0X02, 0X03, 0X04,                                 0X01, 0X02, 0X03, 0X04,                                 0X05, 0X06, 0X07, 0X08,                                 0XF3, 0XF2, 0XF1, 0XF0};                        /* Acquire the buffers */                        if (NULL == (RWBuffer1 = stavfs_AcquireRWBuffer(&Device, &BufferLBA, FALSE)))            {                STTBX_Print(("Failed Acquiring the R/W Buffer\n"));                Result = TEST_FAILED;            }            else if (NULL == (RWBuffer2 = stavfs_AcquireRWBuffer(&Device, &BufferLBA, FALSE)))            {                STTBX_Print(("Failed Acquiring the R/W Buffer\n"));                Result = TEST_FAILED;            }            else if (NULL == (RWBuffer3 = stavfs_AcquireRWBuffer(&Device, &BufferLBA, FALSE)))            {                STTBX_Print(("Failed Acquiring the R/W Buffer\n"));                Result = TEST_FAILED;            }                        /* Write the buffers */                        else if (ST_NO_ERROR != stavfs_RWBufferWrite(&Device, RWBuffer1, 0, 8, WriteData, FALSE))            {                STTBX_Print(("Failed Writing the R/W Buffer\n"));                Result = TEST_FAILED;            }            else if (ST_NO_ERROR != stavfs_RWBufferWrite(&Device, RWBuffer2, 4, 8, WriteData, FALSE))            {                STTBX_Print(("Failed Writing the R/W Buffer\n"));                Result = TEST_FAILED;            }                        /* Read the buffer */                        else if (ST_NO_ERROR != stavfs_RWBufferRead(&Device, RWBuffer3, 0, 16, WorkBuffer))            {                STTBX_Print(("Failed Reading the R/W Buffer\n"));                Result = TEST_FAILED;            }                        /* Check the data */                        else if (memcmp(WorkBuffer, ResultData, 16))            {                int i;                for (i = 0; (i < 16); i++)                {                    STTBX_Print(("0X%02X ", WorkBuffer[i]));                }                STTBX_Print(("Incorrect results (1)\n"));                Result = TEST_FAILED;            }                        /* Release the buffers */                        else if (ST_NO_ERROR != stavfs_DiscardRWBuffer(&Device, &RWBuffer2))            {                STTBX_Print(("Failed Closing the R/W Buffer\n"));                Result = TEST_FAILED;            }            else if (ST_NO_ERROR != stavfs_DiscardRWBuffer(&Device, &RWBuffer1))            {                STTBX_Print(("Failed Closing the R/W Buffer\n"));                Result = TEST_FAILED;            }            else if (ST_NO_ERROR != stavfs_DiscardRWBuffer(&Device, &RWBuffer3))            {                STTBX_Print(("Failed Closing the R/W Buffer\n"));                Result = TEST_FAILED;            }                        /* Read the sector */                        else if (ST_NO_ERROR != ReadTheSector(&Obj, WorkBuffer))            {                STTBX_Print(("Failed Reading the Sector\n"));                Result = TEST_FAILED;            }                        /* Check the data */                        else if (memcmp(WorkBuffer, ResultData, 16))            {                int i;                for (i = 0; (i < 16); i++)                {                    STTBX_Print(("0X%02X ", WorkBuffer[i]));                }                STTBX_Print(("Incorrect results (2)\n"));                Result = TEST_FAILED;            }                }                /* Close down */                if (ST_NO_ERROR != stavfs_TermRWCache(&Device))        {            Result = TEST_FAILED;        }                if (ST_NO_ERROR != CloseHal(&Obj))        {            Result = TEST_FAILED;        }    }        return(Result);}/******************************************************************************Function Name : BlockWrite  Description : Block write   Parameters :******************************************************************************/static TestResult_t BlockWrite(int TestNo, TestVariant_t Variant){    TestResult_t Result = TEST_PASSED;    stavfs_HAL_t Obj;        if (Variant != TEST_VARIANT_A)    {        Result = TEST_FAILED;    }    else if (ST_NO_ERROR != OpenHal(&Obj))    {        Result = TEST_FAILED;    }    else    {        /* Initialise the data structures */                stavfs_Device_t Device;                Device.HALData         = &Obj;        Device.MemoryPartition = system_partition;        Device.RWCache         = NULL;                        if (ST_NO_ERROR != InitialiseData(&Obj))        {            Result = TEST_FAILED;        }        else if (ST_NO_ERROR != stavfs_InitRWCache(&Device))        {            Result = TEST_FAILED;        }        else        {            /* Run the test */                    U64 LocalLBA;                        stavfs_RWBufferRef_t RWBuffer = NULL;            U8 const *ResultData;                    switch (TestNo+1)            {                default:                case 4 :                    INT_I64_SetValue(SECTOR_LBA+1, 0, LocalLBA);                    ResultData = Pattern;                    break;                                    case 5 :                    INT_I64_SetValue(SECTOR_LBA-1, 0, LocalLBA);                    ResultData = BlockPattern;                    break;                                    case 6 :                    INT_I64_SetValue(SECTOR_LBA, 0, LocalLBA);                    ResultData = BlockPattern;                    break;                                    case 7 :                    INT_I64_SetValue(SECTOR_LBA-2, 0, LocalLBA);                    ResultData = BlockPattern;                    break;            }                        /* Acquire the buffer */                        if (NULL == (RWBuffer = stavfs_AcquireRWBuffer(&Device, &BufferLBA, FALSE)))            {                STTBX_Print(("Failed Acquiring the R/W Buffer\n"));                Result = TEST_FAILED;            }                        /* Block Write */                        else if (ST_NO_ERROR != stavfs_RWCacheBlockWrite(&Device, &LocalLBA, 3, (char*)BlockPattern, FALSE))            {                STTBX_Print(("Failed Writing the R/W Buffer\n"));                Result = TEST_FAILED;            }                        /* Read the buffer */                        else if (ST_NO_ERROR != stavfs_RWBufferRead(&Device, RWBuffer, 0, DISK_SECTOR_SIZE, WorkBuffer))            {                STTBX_Print(("Failed Reading the R/W Buffer\n"));                Result = TEST_FAILED;            }                        /* Check the data */                        else if (memcmp(WorkBuffer, ResultData, DISK_SECTOR_SIZE))            {                int i;                for (i = 0; (i < 16); i++)                {                    STTBX_Print(("0X%02X ", WorkBuffer[i]));                }                STTBX_Print(("Incorrect results (1)\n"));                Result = TEST_FAILED;            }                        /* Release the buffers */                        else if (ST_NO_ERROR != stavfs_DiscardRWBuffer(&Device, &RWBuffer))            {                STTBX_Print(("Failed Closing the R/W Buffer\n"));                Result = TEST_FAILED;            }                        /* Read the sector */                        else if (ST_NO_ERROR != ReadTheSector(&Obj, WorkBuffer))            {                STTBX_Print(("Failed Reading the Sector\n"));                Result = TEST_FAILED;            }                        /* Check the data */                        else if (memcmp(WorkBuffer, ResultData, DISK_SECTOR_SIZE))            {                int i;                for (i = 0; (i < 16); i++)                {                    STTBX_Print(("0X%02X ", WorkBuffer[i]));                }                STTBX_Print(("Incorrect results (2)\n"));                Result = TEST_FAILED;            }                }                /* Close down */                if (ST_NO_ERROR != stavfs_TermRWCache(&Device))        {            Result = TEST_FAILED;        }                if (ST_NO_ERROR != CloseHal(&Obj))        {            Result = TEST_FAILED;        }    }        return(Result);}/******************************************************************************Function Name : BlockRead  Description : Block read   Parameters :******************************************************************************/static TestResult_t BlockRead(int TestNo, TestVariant_t Variant){    TestResult_t Result = TEST_PASSED;    stavfs_HAL_t Obj;        if (Variant != TEST_VARIANT_A)    {        Result = TEST_FAILED;    }    else if (ST_NO_ERROR != OpenHal(&Obj))    {        Result = TEST_FAILED;    }    else    {        /* Initialise the data structures */                stavfs_Device_t Device;                Device.HALData         = &Obj;        Device.MemoryPartition = system_partition;        Device.RWCache         = NULL;                        if (ST_NO_ERROR != InitialiseData(&Obj))        {            Result = TEST_FAILED;        }        else if (ST_NO_ERROR != stavfs_InitRWCache(&Device))        {            Result = TEST_FAILED;        }        else        {            /* Run the test */                    U64 LocalLBA;            U32 Offset;                        stavfs_RWBufferRef_t RWBuffer = NULL;            U8 const *ResultData;

⌨️ 快捷键说明

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