#include <stdio.h>
#include <stdlib.h>
#define LEVEL 5
#define RAM_TEST_PATTERNS 2
int
main (int argc, char *argv[])
{
ulong *ptrMalloc = NULL;
int i = 0, j = 0;
ulong test_value;
ulong *ptrl = NULL;
int level = 0;
/*
for ( i = 0; i < 10000; i++) {
fprintf(stderr," i = %d\n", i);
ptrMalloc = (char*) malloc(1024 * 1024 * i);
if (!ptrMalloc) {
fprintf(stderr,"malloc %d failed\n", i);
break;
}
free(ptrMalloc);
}
*/
static const ulong TestPattern[LEVEL][RAM_TEST_PATTERNS] = {
{0xFFFFFFFF, 0x00000000},
{0x55555555, 0xAAAAAAAA},
{0xA5A5A5A5, 0x5A5A5A5A},
{0x96969696, 0x69696969},
{0xCCCCCCCC, 0x33333333}
};
ptrMalloc = (ulong*) malloc(1024 * 1024 * 20 * sizeof(ulong));
if (!ptrMalloc) {
fprintf(stderr,"malloc failed\n");
return -1;
}
level = 0;
for(i = 0; i < RAM_TEST_PATTERNS; i++) {
test_value = TestPattern[level][i];
/* Fill Test Pattern */
for (ptrl = ptrMalloc, j = 0; j < 1024 * 1024 * 20; j++, ptrl++) {
*ptrl = test_value;
/*debug*/
//fprintf(stdout,"Fill test Pattern 0x%x\n",*ptrl);
//fprintf(stdout,"DRAM Test at address 0x%p\n",ptrl);
}
/* Check Test Pattern */
for (ptrl = ptrMalloc, j = 0; j < 1024 * 1024 * 20 ; j++, ptrl++) {
if (*ptrl != test_value) {
printf(" ...FAIL\n");
printf("DRAM Test Fail at address 0x%p, read:0x%x, should:0x%x\n", ptrl, *ptrl, test_value );
return 1;
}
}
}
return 0;
}
dram test
最新推荐文章于 2024-10-15 10:32:38 发布