uboot中内存测试内存检测方法二Word格式文档下载.docx
《uboot中内存测试内存检测方法二Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《uboot中内存测试内存检测方法二Word格式文档下载.docx(9页珍藏版)》请在冰豆网上搜索。
*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&
lt;
num_patterns;
i++)
move64((unsignedlonglong*)&
amp;
(pattern[i]),pmem++);
*Putadifferentpatternonthedatalines:
otherwisethey
*mayfloatlongenoughtoreadbackwhatwewrote.
/*预防floatingbuses错误*/
otherpattern,pmem--);
move64(pmem,&
temp64);
#ifdefINJECT_DATA_ERRORS
temp64^=0x00008000;
#endif
if(temp64!
=pattern[i])
pathi=(pattern[i]&
gt;
&
32)&
0xffffffff;
patlo=pattern[i]&
hi=(temp64&
lo=temp64&
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;
end=(ulong*)((ulong)base+size);
/*pointerarith!
*/
xor=0;
for(xor=sizeof(ulong);
xor&
0;
=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;
/*出现此种情况只有testaddr==target,即某根地址线翻转无效*/
if(readback==*testaddr)
Memory(addressline)errorat%08x&
-&
%08x,"
XORvalue%08x!
testaddr,target,xor);
staticintmemory_post_test1(unsignedlongstart,
unsignedlongsize,
unsignedlongval)
unsignedlongi;
ulong*mem=(ulong*)start;
for(i=0;
size/sizeof(ulong);
i++){
mem[i]=val;
if(i%1024==0)
WATCHDOG_RESET();
size/sizeof(ulong)&
ret==0;
readback=mem[i];
if(readback!
=val){
Memoryerrorat%08x,"
wrote%08x,read%08x!
mem+i,val,readback);
break;
staticintmemory_post_test2(unsignedlongstart,unsignedlongsize)
mem[i]=1&
(i%32);
=(1&
(i%32))){
mem+i,1&
(i%32),readback);
staticintmemory_post_test3(unsignedlongstart,unsignedlongsize)
mem[i]=i;
=i){
mem+i,i,readback);
staticintmemory_post_test4(unsignedlongstart,unsignedlongsize)
mem[i]=~i;
=~i){
mem+i,~i,readback);
staticintmemory_post_tests(unsignedlongstart,unsignedlongsize)
if(ret==0)
ret=memory_post_dataline((unsignedlonglong*)start);
ret=memory_post_addrline((ulong*)start,(ulong*)start,size);
ret=memory_post_addrline((ulong*)(start+size-8),
(ulong*)start,size);
ret=memory_post_test1(start,size,0x00000000);
ret=memory_post_test1(start,size,0xffffffff);
ret=memory_post_test1(start,size,0x55555555);
ret=memory_post_test1(start,size,0xaaaaaaaa);
ret=memory_post_test2(start,size);
ret=memory_post_test3(start,size);
ret=memory_post_test4(start,size);