uboot中内存测试内存检测方法二.docx

上传人:b****6 文档编号:7722973 上传时间:2023-01-26 格式:DOCX 页数:9 大小:15.36KB
下载 相关 举报
uboot中内存测试内存检测方法二.docx_第1页
第1页 / 共9页
uboot中内存测试内存检测方法二.docx_第2页
第2页 / 共9页
uboot中内存测试内存检测方法二.docx_第3页
第3页 / 共9页
uboot中内存测试内存检测方法二.docx_第4页
第4页 / 共9页
uboot中内存测试内存检测方法二.docx_第5页
第5页 / 共9页
点击查看更多>>
下载资源
资源描述

uboot中内存测试内存检测方法二.docx

《uboot中内存测试内存检测方法二.docx》由会员分享,可在线阅读,更多相关《uboot中内存测试内存检测方法二.docx(9页珍藏版)》请在冰豆网上搜索。

uboot中内存测试内存检测方法二.docx

uboot中内存测试内存检测方法二

uboot中内存测试、内存检测方法二

  具体代码实现如下:

staticvoidmove64(unsignedlonglong*src,unsignedlonglong*dest)

{

*dest=*src;

}

/*

*Thisis64bitwidetestpatterns.NotethattheyresideinROM

*(whichpresumablyworks)andthetestswritethemtoRAMwhichmay

*notwork.

*

*The"otherpattern"iswrittentodrivethedatabustovaluesother

*thanthetestpattern.Thisisfordetectingfloatingbuslines.

*

*/

conststaticunsignedlonglongpattern[]={

0xaaaaaaaaaaaaaaaaULL,

0xccccccccccccccccULL,

0xf0f0f0f0f0f0f0f0ULL,

0xff00ff00ff00ff00ULL,

0xffff0000ffff0000ULL,

0xffffffff00000000ULL,

0x00000000ffffffffULL,

0x0000ffff0000ffffULL,

0x00ff00ff00ff00ffULL,

0x0f0f0f0f0f0f0f0fULL,

0x3333333333333333ULL,

0x5555555555555555ULL

};

constunsignedlonglongotherpattern=0x0123456789abcdefULL;

/*数据线检测*/

staticintmemory_post_dataline(unsignedlonglong*pmem)

{

unsignedlonglongtemp64=0;

intnum_patterns=sizeof(pattern)/sizeof(pattern[0]);

inti;

unsignedinthi,lo,pathi,patlo;

intret=0;

for(i=0;i<num_patterns;i++)

{

move64((unsignedlonglong*)&(pattern[i]),pmem++);

/*

*Putadifferentpatternonthedatalines:

otherwisethey

*mayfloatlongenoughtoreadbackwhatwewrote.

*/

/*预防floatingbuses错误*/

move64((unsignedlonglong*)&otherpattern,pmem--);

move64(pmem,&temp64);

#ifdefINJECT_DATA_ERRORS

temp64^=0x00008000;

#endif

if(temp64!

=pattern[i])

{

pathi=(pattern[i]>>32)&0xffffffff;

patlo=pattern[i]&0xffffffff;

hi=(temp64>>32)&0xffffffff;

lo=temp64&0xffffffff;

post_log("Memory(dateline)errorat%08x,"

"wrote%08x%08x,read%08x%08x!

",

pmem,pathi,patlo,hi,lo);

ret=-1;

}

}

returnret;

}

/*地址线检测*/

staticintmemory_post_addrline(ulong*testaddr,ulong*base,ulongsize)

{

ulong*target;

ulong*end;

ulongreadback;

ulongxor;

intret=0;

end=(ulong*)((ulong)base+size);/*pointerarith!

*/

xor=0;

for(xor=sizeof(ulong);xor>0;xor<<=1)

{

/*对测试的地址的某一根地址线的值翻转*/

target=(ulong*)((ulong)testaddr^xor);

if((target>=base)&&(target<end))

{

/*由于target是testaddr某一根地址线的值翻转得来

故testaddr!

=target,下面赋值操作后

应有*testaddr!

=*target*/

*testaddr=~*target;

readback=*target;

#ifdefINJECT_ADDRESS_ERRORS

if(xor==0x00008000)

{

readback=*testaddr;

}

#endif

/*出现此种情况只有testaddr==target,即某根地址线翻转无效*/

if(readback==*testaddr)

{

post_log("Memory(addressline)errorat%08x<->%08x,"

"XORvalue%08x!

",

testaddr,target,xor);

ret=-1;

}

}

}

returnret;

}

staticintmemory_post_test1(unsignedlongstart,

unsignedlongsize,

unsignedlongval)

{

unsignedlongi;

ulong*mem=(ulong*)start;

ulongreadback;

intret=0;

for(i=0;i<size/sizeof(ulong);i++){

mem[i]=val;

if(i%1024==0)

WATCHDOG_RESET();

}

for(i=0;i<size/sizeof(ulong)&&ret==0;i++){

readback=mem[i];

if(readback!

=val){

post_log("Memoryerrorat%08x,"

"wrote%08x,read%08x!

",

mem+i,val,readback);

ret=-1;

break;

}

if(i%1024==0)

WATCHDOG_RESET();

}

returnret;

}

staticintmemory_post_test2(unsignedlongstart,unsignedlongsize)

{

unsignedlongi;

ulong*mem=(ulong*)start;

ulongreadback;

intret=0;

for(i=0;i<size/sizeof(ulong);i++){

mem[i]=1<<(i%32);

if(i%1024==0)

WATCHDOG_RESET();

}

for(i=0;i<size/sizeof(ulong)&&ret==0;i++){

readback=mem[i];

if(readback!

=(1<<(i%32))){

post_log("Memoryerrorat%08x,"

"wrote%08x,read%08x!

",

mem+i,1<<(i%32),readback);

ret=-1;

break;

}

if(i%1024==0)

WATCHDOG_RESET();

}

returnret;

}

staticintmemory_post_test3(unsignedlongstart,unsignedlongsize)

{

unsignedlongi;

ulong*mem=(ulong*)start;

ulongreadback;

intret=0;

for(i=0;i<size/sizeof(ulong);i++){

mem[i]=i;

if(i%1024==0)

WATCHDOG_RESET();

}

for(i=0;i<size/sizeof(ulong)&&ret==0;i++){

readback=mem[i];

if(readback!

=i){

post_log("Memoryerrorat%08x,"

"wrote%08x,read%08x!

",

mem+i,i,readback);

ret=-1;

break;

}

if(i%1024==0)

WATCHDOG_RESET();

}

returnret;

}

staticintmemory_post_test4(unsignedlongstart,unsignedlongsize)

{

unsignedlongi;

ulong*mem=(ulong*)start;

ulongreadback;

intret=0;

for(i=0;i<size/sizeof(ulong);i++){

mem[i]=~i;

if(i%1024==0)

WATCHDOG_RESET();

}

for(i=0;i<size/sizeof(ulong)&&ret==0;i++){

readback=mem[i];

if(readback!

=~i){

post_log("Memoryerrorat%08x,"

"wrote%08x,read%08x!

",

mem+i,~i,readback);

ret=-1;

break;

}

if(i%1024==0)

WATCHDOG_RESET();

}

returnret;

}

staticintmemory_post_tests(unsignedlongstart,unsignedlongsize)

{

intret=0;

if(ret==0)

ret=memory_post_dataline((unsignedlonglong*)start);

WATCHDOG_RESET();

if(ret==0)

ret=memory_post_addrline((ulong*)start,(ulong*)start,size);

WATCHDOG_RESET();

if(ret==0)

ret=memory_post_addrline((ulong*)(start+size-8),

(ulong*)start,size);

WATCHDOG_RESET();

if(ret==0)

ret=memory_post_test1(start,size,0x00000000);

WATCHDOG_RESET();

if(ret==0)

ret=memory_post_test1(start,size,0xffffffff);

WATCHDOG_RESET();

if(ret==0)

ret=memory_post_test1(start,size,0x55555555);

WATCHDOG_RESET();

if(ret==0)

ret=memory_post_test1(start,size,0xaaaaaaaa);

WATCHDOG_RESET();

if(ret==0)

ret=memory_post_test2(start,size);

WATCHDOG_RESET();

if(ret==0)

ret=memory_post_test3(start,size);

WATCHDOG_RESET();

if(ret==0)

ret=memory_post_test4(start,size);

WATCHDOG_RESET();

returnret;

}

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > PPT模板 > 动物植物

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1