📄 tstsdram.c
字号:
/*
* Copyright (C) 2003 Koninklijke Philips Electronics N.V.,
* All Rights Reserved.
*
* This source code and any compilation or derivative thereof is the
* proprietary information of Koninklijke Philips Electronics N.V.
* and is confidential in nature.
* Under no circumstances is this software to be exposed to or placed
* under an Open Source License of any type without the expressed
* written permission of Koninklijke Philips Electronics N.V.
*
*----------------------------------------------------------*/
/*!
* \file tstSdram.c
*
* Test largest malloc()'ed block of memory.
*
*/
/*-----------------------------------------------------------
*
* %version: 9 %
* instance: DS_4
* %date_created: Mon Jun 09 18:11:08 2003 %
*
*/
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Standard include files:
//-----------------------------------------------------------------------------
//
#include <stdio.h>
#include <stdlib.h>
#include <tmStdLib.h>
#include <tmNxTypes.h>
#include <tmDbg.h>
#include <tmosal.h>
#include <stdio.h>
#include <tmCache.h>
#include <tmMain.h>
//-----------------------------------------------------------------------------
// Project include files:
//-----------------------------------------------------------------------------
//
#include <unistd.h>
#include <mmio.h>
//-----------------------------------------------------------------------------
// Types and defines:
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Global data:
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
// Internal Prototypes:
//-----------------------------------------------------------------------------
//
custom_op void dcb(UInt32, UInt32);
custom_op void dinvalid(UInt32, UInt32);
custom_op UInt32 rdtag(UInt32, UInt32);
custom_op UInt32 ld32d(UInt32, UInt32);
#define CACHE_LINE_SIZE 0x40
#define CACHE_SIZE 0x4000
#define ERROR_MAX 16
//-----------------------------------------------------------------------------
// Code from old sdram_test.c
//-----------------------------------------------------------------------------
//
#define TRUE 1
#define FALSE 0
int sdram_fail;
int t_sdram_flipbits(unsigned value, unsigned *start, unsigned len) /* 64 byte aligned guarranteed */
{
unsigned *p, v, i, obs, errors;
errors = 0;
p = start;
v = value;
for(i = 0; i < (len/sizeof(unsigned)); p++, i++) {
*p = v;
v = ~v;
}
p = start;
v = value;
for(i = 0; i < (len/sizeof(unsigned)); p++, i++) {
if((obs = *p) != v) {
errors++;
printf("Read error: @ 0x%.8x, obs 0x%.8x, exp 0x%.8x, obs ^ exp 0x%.8x\n",
(unsigned)(p), obs, v, obs ^ v);
dinvalid(0, (UInt32) p) ;
if((obs = *p) != v) {
printf("Re-Read error: @ 0x%.8x, obs 0x%.8x, exp 0x%.8x, obs ^ exp 0x%.8x\n",
(unsigned)(p), obs, v, obs ^ v);
}
if (errors > ERROR_MAX) {
printf("errors > %d, exitting...\n", ERROR_MAX) ;
return errors ;
}
}
v = ~v;
}
return errors;
}
/*
* Test sdram by storing address at address
*/
int t_sdram_addr(UInt32 *begin_p, UInt32 len) {
UInt32 *end_p ;
UInt32 *ipp ;
UInt32 exp_val ;
UInt32 obs_val ;
int errors ;
end_p = (UInt32 *) (((char *) begin_p) + len) ;
errors = 0 ;
/*
* Fill memory with data==address
*/
ipp = begin_p ;
while (ipp < end_p) {
*ipp = (UInt32) ipp ;
ipp++;
}
/*
* Check memory with data==address
*/
ipp = begin_p ;
while (ipp < end_p) {
exp_val = (UInt32) ipp ;
obs_val = *ipp ;
if (obs_val != exp_val) {
errors++ ;
printf("read error: addr %08x exp %08x obs %08x xor %08x\n",
ipp, exp_val, obs_val, exp_val ^ obs_val) ;
dinvalid(0, (UInt32) ipp) ;
obs_val = *ipp ;
if (obs_val != exp_val) {
printf("re-read error: addr %08x exp %08x obs %08x xor %08x\n",
ipp, exp_val, obs_val, exp_val ^ obs_val) ;
}
if (errors > ERROR_MAX) {
printf("errors > %d, exitting...\n", ERROR_MAX) ;
return errors ;
}
}
ipp++ ;
}
return errors ;
}
/*
* Test sdram by storing 1's complement of address at address
*/
int t_sdram_inv_addr(UInt32 *begin_p, UInt32 len) {
UInt32 *end_p ;
UInt32 *ipp ;
UInt32 exp_val ;
UInt32 obs_val ;
int errors ;
end_p = (UInt32 *) (((char *) begin_p) + len) ;
errors = 0 ;
/*
* Fill memory with data==~address
*/
ipp = begin_p ;
while (ipp < end_p) {
*ipp = (~((UInt32) ipp)) ;
ipp++;
}
/*
* Check memory with data==~address
*/
ipp = begin_p ;
while (ipp < end_p) {
exp_val = (~((UInt32) ipp)) ;
obs_val = *ipp ;
if (obs_val != exp_val) {
errors++ ;
printf("read error: addr %08x exp %08x obs %08x xor %08x\n",
ipp, exp_val, obs_val, exp_val ^ obs_val) ;
dinvalid(0, (UInt32) ipp) ;
obs_val = *ipp ;
if (obs_val != exp_val) {
printf("re-read error: addr %08x exp %08x obs %08x xor %08x\n",
ipp, exp_val, obs_val, exp_val ^ obs_val) ;
}
if (errors > ERROR_MAX) {
printf("errors > %d, exitting...\n", ERROR_MAX) ;
return errors ;
}
}
ipp++ ;
}
return errors ;
}
/*
* Test sdram with walking ones
*/
int t_sdram_walk1(UInt32 *begin_p, UInt32 len) {
UInt32 *end_p ;
UInt32 *ipp ;
UInt32 start_val ;
UInt32 exp_val ;
UInt32 obs_val ;
int lap ;
int errors ;
end_p = (UInt32 *) (((char *) begin_p) + len) ;
errors = 0 ;
lap = 0 ;
start_val = 1 ;
while (start_val != 0) {
printf(" lap %2d\n", lap++) ;
/*
* Fill memory with data
*/
exp_val = start_val ;
ipp = begin_p ;
while (ipp < end_p) {
*ipp++ = exp_val ;
exp_val = exp_val << 1 ;
if (exp_val == 0) {
exp_val = 1 ;
}
}
/*
* Check memory
*/
exp_val = start_val ;
ipp = begin_p ;
while (ipp < end_p) {
obs_val = *ipp ;
if (obs_val != exp_val) {
errors++ ;
printf("read error: addr %08x exp %08x obs %08x xor %08x\n",
ipp, exp_val, obs_val, exp_val ^ obs_val) ;
dinvalid(0, (UInt32) ipp) ;
obs_val = *ipp ;
if (obs_val != exp_val) {
printf("re-read error: addr %08x exp %08x obs %08x xor %08x\n",
ipp, exp_val, obs_val, exp_val ^ obs_val) ;
}
if (errors > ERROR_MAX) {
printf("errors > %d, exitting...\n", ERROR_MAX) ;
return errors ;
}
}
exp_val = exp_val << 1 ;
if (exp_val == 0) {
exp_val = 1 ;
}
ipp++ ;
}
start_val = start_val << 1 ;
}
return errors ;
}
/*
* Test sdram with walking zeroes
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -