📄 pxa_memory.c
字号:
DisplayMemTestProgess(arg, testName, memPhAddr, length);
e = (PVUINT)(memVtAddr+length);
// Walk a 0 thru the memory
for (j = 0; j < 32; j++)
{
// Shifting bit position.
mask = 1 << j;
PlatformLeds(~mask);
// Write the pattern thru the memory range.
for (p = (PVUINT)memVtAddr; p < e; p++)
{
// Write the data.
*p = ~mask;
// Shifting bit position.
if ((mask <<= 1) == 0) mask = 1;
if (!((UINT32)p&0xfffff)) ROS_Release();
}
// Shifting bit position.
mask = 1 << j;
// Verify the pattern thru the memory range.
for (p = (PVUINT)memVtAddr; p < e; p++)
{
// Check the data written.
if (*p != ~mask) break;
// Shifting bit position.
if ((mask <<= 1) == 0) mask = 1;
if (!((UINT32)p&0x3ffff)) ROS_Release();
}
if (p < e) {
DM_CwDbgPrintf(DM_CW_MEM, " Failed at %08x, wrote: %08x, read: %08x",
p, mask, *p);
LOGERROR(loggedError, ERR_L_SDRAM, ERR_TS_SDRAM_WZ,
ERR_T_WRONG_VALUE, (UINT32)p, mask, *p);
XllpUtilityOutputError(loggedError);
testFailed = TRUE;
return;
}
}
PostDisplayProgress(ERR_L_MEMORY, ERR_TS_SDRAM_WZ, 3);
testFailed = FALSE;
printf (" Success!\r\n");
}
/*
*******************************************************************************
*
* FUNCTION:
* MemoryOnesSum
*
* DESCRIPTION:
* This routine adds 0x11111111 to each location within the memory region
* under test.
*
* INPUT PARAMETERS:
* PVOID ctxP - Pointer to the memory context structure (NULL).
* PCHAR arg - Pointer to the input string.
*
* RETURNS:
* None.
*
* GLOBAL EFFECTS:
* Tests multiple bits within the memory region.
*
* ASSUMPTIONS:
* The memory region has been mapped to actual RAM.
*
* CALLS:
* PlatformLeds, DM_StartTest, DM_DbgPrintf, GetParameters,
* DM_ErrPrintf, LOGERROR, DM_FinishTest.
*
* CALLED BY:
* Menu system or User script.
*
* PROTOTYPE:
* VOID MemoryOnesSum(PVOID ctxP, PCHAR arg);
*
*******************************************************************************
*/
VOID MemoryOnesSum(PVOID ctxP, PCHAR arg)
{
register PVUINT p, e;
register UINT pattern;
UINT memVtAddr;
UINT memPhAddr;
UINT length;
UINT loggedError = 0;
CHAR testName[64];
UINT readvalue;
sprintf (testName, "Ones Sum");
PostDisplayProgress(ERR_L_MEMORY, ERR_TS_SDRAM_OS, 1);
// Get the parameters needed to test memory.
if (GetParameters(arg, &memVtAddr, &memPhAddr, &length))
{
testFailed = TRUE;
return;
}
PostDisplayProgress(ERR_L_MEMORY, ERR_TS_SDRAM_OS, 2);
DisplayMemTestProgess(arg, testName, memPhAddr, length);
e = (PVUINT)(memVtAddr+length);
// Write the pattern thru the memory range.
for (p = (PVUINT)memVtAddr, pattern = 0; p < e; p++)
{
// Write the data.
*p = pattern;
pattern += ONES_PATTERN;
if (!(((UINT32)p)&0xfffff)) ROS_Release();
}
PostDisplayProgress(ERR_L_MEMORY, ERR_TS_SDRAM_OS, 3);
// Verify the pattern thru the memory range.
for (p = (PVUINT)memVtAddr, pattern = 0; p < e; p++)
{
// Check the data written.
readvalue = *p;
if (readvalue != pattern) break;
pattern += ONES_PATTERN;
if (!(((UINT32)p)&0x3ffff)) ROS_Release();
}
if (p < e) {
DM_CwDbgPrintf(DM_CW_MEM, " Failed at %08x, wrote: %08x, read: %08x",
p, pattern, readvalue);
LOGERROR(loggedError, ERR_L_SDRAM, ERR_TS_SDRAM_OS,
ERR_T_WRONG_VALUE, (UINT32)p, pattern, *p);
XllpUtilityOutputError(loggedError);
testFailed = TRUE;
return;
}
PostDisplayProgress(ERR_L_MEMORY, ERR_TS_SDRAM_OS, 3);
testFailed = FALSE;
printf (" Success!\r\n");
}
/*
*******************************************************************************
*
* FUNCTION:
* MemoryNotOnesSum
*
* DESCRIPTION:
* This routine adds 0xEEEEEEEE to each location within the memory region
* under test.
*
* INPUT PARAMETERS:
* PVOID ctxP - Pointer to the memory context structure (NULL).
* PCHAR arg - Pointer to the input string.
*
* RETURNS:
* None.
*
* GLOBAL EFFECTS:
* Tests multiple bits within the memory region.
*
* ASSUMPTIONS:
* The memory region has been mapped to actual RAM.
*
* CALLS:
* PlatformLeds, DM_StartTest, DM_DbgPrintf, GetParameters,
* DM_ErrPrintf, LOGERROR, DM_FinishTest.
*
* CALLED BY:
* Menu system or User script.
*
* PROTOTYPE:
* VOID MemoryNotOnesSum(PVOID ctxP, PCHAR arg);
*
*******************************************************************************
*/
VOID MemoryNotOnesSum(PVOID ctxP, PCHAR arg)
{
register PVUINT p, e;
register UINT pattern;
UINT memVtAddr;
UINT memPhAddr;
UINT length;
UINT loggedError = 0;
CHAR testName[64];
sprintf (testName, "Not Ones Sum");
PostDisplayProgress(ERR_L_MEMORY, ERR_TS_SDRAM_COS, 1);
// Get the parameters needed to test memory.
if (GetParameters(arg, &memVtAddr, &memPhAddr, &length))
{
testFailed = TRUE;
return;
}
PostDisplayProgress(ERR_L_MEMORY, ERR_TS_SDRAM_COS, 2);
DisplayMemTestProgess(arg, testName, memPhAddr, length);
e = (PVUINT)(memVtAddr+length);
// Write the pattern thru the memory range.
for (p = (PVUINT)memVtAddr, pattern = 0; p < e; p++)
{
// Write the data.
*p = ~pattern;
pattern += ONES_PATTERN;
if (!(((UINT32)p)&0xfffff)) ROS_Release();
}
PostDisplayProgress(ERR_L_MEMORY, ERR_TS_SDRAM_COS, 3);
// Verify the pattern thru the memory range.
for (p = (PVUINT)memVtAddr, pattern = 0; p < e; p++)
{
// Check the data written.
if (*p != ~pattern) break;
pattern += ONES_PATTERN;
if (!(((UINT32)p)&0x3ffff)) ROS_Release();
}
if (p < e) {
DM_CwDbgPrintf(DM_CW_MEM, " Failed at %08x, wrote: %08x, read: %08x",
p, ~pattern, *p);
LOGERROR(loggedError, ERR_L_SDRAM, ERR_TS_SDRAM_COS,
ERR_T_WRONG_VALUE, (UINT32)p, ~pattern, *p);
XllpUtilityOutputError(loggedError);
testFailed = TRUE;
return;
}
PostDisplayProgress(ERR_L_MEMORY, ERR_TS_SDRAM_COS, 3);
testFailed = FALSE;
printf (" Success!\r\n");
}
/*
*******************************************************************************
*
* FUNCTION:
* DmaMemToMemTest
*
* DESCRIPTION:
* In this test the DMA is used to demonstrate memory to memory transfer.
*
*
* INPUT PARAMETERS:
* Not used in this test
*
* RETURNS: none.
*
* GLOBAL EFFECTS: none.
*
* ASSUMPTIONS: none.
*
* CALLS:
*
*
* CALLED BY:
* Menu system
*
* PROTOTYPE:
* VOID DmaMemToMemTest (PVOID arg, PCHAR param);
*
*******************************************************************************
*/
VOID DmaMemToMemTest (PVOID arg, PCHAR param)
{
static XsDmaDescriptorElementsT * firstDescVtP;
UINT32 error;
INT channel;
UINT status;
INT length;
// Setup the display handler
printf(" Testing DMA Memory to Memory transfer\r\n");
// Configure the DMA channel to be used to service transmit FIFO:
PostDisplayProgress(ERR_L_MEMORY, ERR_TS_DMAMEM, 1);
error = XsDmaConfigureMemToMem (XSDMA_CH_PR_LOW,
XSDMA_DN_MEMORY,
&firstDescVtP,
NUM_BUF,
DMA_BUFSIZ,
NULL,
NULL,
0,
(PINT)&channel);
if (error != 0)
{
// DMA channel or source memory can not be allocated
status = ERRORCODE(ERR_L_MEMORY,
ERR_TS_DMAMEM,
ERR_T_DMA_NOCHAN);
XllpUtilityOutputError(status);
testFailed = TRUE;
return;
}
PostDisplayProgress(ERR_L_MEMORY, ERR_TS_DMAMEM, 2);
// Fill transmit buffers with a known pattern
FillTxBufferSerial (firstDescVtP, NUM_BUF, DMA_BUFSIZ, 0xAA);
PostDisplayProgress(ERR_L_MEMORY, ERR_TS_DMAMEM, 3);
// Clear receive buffers
ClearRxBufferSerial (firstDescVtP, NUM_BUF, DMA_BUFSIZ);
PostDisplayProgress(ERR_L_MEMORY, ERR_TS_DMAMEM, 4);
// Set the Run bit in the DCSR for the specified DMA channel.
error = XsDmaStart (channel);
if (error != 0)
{
// DMA channel or source memory can not be allocated
// printf(" DMA Channel already in use\r\n");
status = ERRORCODE(ERR_L_MEMORY,
ERR_TS_DMAMEM,
ERR_T_DMA_NOCHAN);
XllpUtilityOutputError(status);
testFailed = TRUE;
return;
}
PostDisplayProgress(ERR_L_MEMORY, ERR_TS_DMAMEM, 5);
length = XsDmaGetRemainingLength (channel);
status = XsDmaReadChannelStatus (channel);
DM_CwDbgPrintf(DM_CW_DMA_0, "Tx Xfer Length: %x", (UINT)length);
DM_CwDbgPrintf(DM_CW_DMA_0, "Tx DSCR: %x", (UINT)status);
// Wait for the completion of the Tx transfer
PostDisplayProgress(ERR_L_MEMORY, ERR_TS_DMAMEM, 6);
error = XsDmaWaitUntilStopped(channel);
if (error != 0)
{
// Time out on Tx DMA channel
// printf(" DMA Timeout\r\n");
status = ERRORCODEX(ERR_L_MEMORY,
ERR_TS_DMAMEM, 1,
ERR_T_TIMEOUT);
XllpUtilityOutputError(status);
testFailed = TRUE;
return;
}
PostDisplayProgress(ERR_L_MEMORY, ERR_TS_DMAMEM, 7);
// Compare the data between receive and transmit buffers
CompareDataDmaXferSerial (firstDescVtP, firstDescVtP, NUM_BUF, DMA_BUFSIZ, XFER_LEN);
PostDisplayProgress(ERR_L_MEMORY, ERR_TS_DMAMEM, 8);
// Cleanup the allocated resources
XsDmaFreeChannel (channel);
PostDisplayProgress(ERR_L_MEMORY, ERR_TS_DMAMEM, 9);
XsDmaDestroyChain (firstDescVtP);
// Test done
testFailed = FALSE;
printf(" Success!\r\n");
}
INT PostMemory(VOID)
{
CHAR arg[80];
INT errorCount = 0;
PostDisplayProgress(ERR_L_MEMORY, ERR_TS_POSTMEM, 1);
// Test SRAM.
strcpy(arg, "SRAM");
// Check for high test level.
if ((POSTRunState() & VS_TEST_LEVEL_HI) == VS_TEST_LEVEL_HI)
{
// Run address test.
MemoryAddressLines(NULL, arg);
if (testFailed) ++errorCount;
// Run ones sum test on SRAM.
MemoryOnesSum(NULL, arg);
if (testFailed) ++errorCount;
// Run complement ones sum test on SRAM.
MemoryNotOnesSum(NULL, arg);
if (testFailed) ++errorCount;
// Run walking 1's test on SRAM.
MemoryWalking1(NULL, arg);
if (testFailed) ++errorCount;
// Run walking 0's test SRAM.
MemoryWalking0(NULL, arg);
if (testFailed) ++errorCount;
}
else
{
// Run address test.
MemoryAddressLines(NULL, arg);
if (testFailed) ++errorCount;
// Run ones sum test on SRAM.
MemoryOnesSum(NULL, arg);
if (testFailed) ++errorCount;
// Run complement ones sum test on SRAM.
MemoryNotOnesSum(NULL, arg);
if (testFailed) ++errorCount;
}
// Start SDRAM test.
// Test Non-Cached/Non-Buffered SDRAM Space.
strcpy(arg, "SDRAM");
// Run address test.
MemoryAddressLines(NULL, arg);
if (testFailed) ++errorCount;
// Run ones sum test on SDRAM.
MemoryOnesSum(NULL, arg);
if (testFailed) ++errorCount;
// Run complement ones sum test on SDRAM.
MemoryNotOnesSum(NULL, arg);
if (testFailed) ++errorCount;
// Check if test level is high
if ((POSTRunState() & VS_TEST_LEVEL_HI) == VS_TEST_LEVEL_HI)
{
// Run walking 1's test on SDRAM.
MemoryWalking1(NULL, arg);
if (testFailed) ++errorCount;
// Run walking 0's test on SDRAM.
MemoryWalking0(NULL, arg);
if (testFailed) ++errorCount;
// Test Cached/Non-Buffered SDRAM Space.
strcpy(arg,"SDRAM_CACHED");
// Run address test.
MemoryAddressLines(NULL, arg);
if (testFailed) ++errorCount;
// Run ones sum test on SDRAM.
MemoryOnesSum(NULL, arg);
if (testFailed) ++errorCount;
// Run complement ones sum test on SDRAM.
MemoryNotOnesSum(NULL, arg);
if (testFailed) ++errorCount;
// Run walking 1's test on SDRAM.
MemoryWalking1(NULL, arg);
if (testFailed) ++errorCount;
// Run walking 0's test on SDRAM.
MemoryWalking0(NULL, arg);
if (testFailed) ++errorCount;
// Test Cached/Buffered SDRAM Space
strcpy(arg,"SDRAM_CACHEDBUFFERED");
// Run address test.
MemoryAddressLines(NULL, arg);
if (testFailed) ++errorCount;
// Run ones sum test on SDRAM.
MemoryOnesSum(NULL, arg);
if (testFailed) ++errorCount;
// Run complement ones sum test on SDRAM.
MemoryNotOnesSum(NULL, arg);
if (testFailed) ++errorCount;
// Run walking 1's test on SDRAM.
MemoryWalking1(NULL, arg);
if (testFailed) ++errorCount;
// Run walking 0's test on SDRAM.
MemoryWalking0(NULL, arg);
if (testFailed) ++errorCount;
}
// Memory to memory DMA test
DmaMemToMemTest (NULL, NULL);
if (testFailed) ++errorCount;
PostDisplayProgress(ERR_L_MEMORY, ERR_TS_POSTMEM, 2);
return errorCount;
}
VOID PostMemoryTest (PVOID ctxP, PCHAR arg)
{
PostMemory();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -