Memtest improvements
This commit is contained in:
parent
cabe3aafad
commit
8c8c0a0be4
|
@ -20,6 +20,8 @@
|
|||
|
||||
#include "memtest.hpp"
|
||||
|
||||
static unsigned int prng_seed = 42;
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
|
@ -156,6 +158,8 @@ static void memtest_sequential(memtest_t *testp, Generator<T> &generator, T seed
|
|||
const size_t steps = testp->size / sizeof(T);
|
||||
size_t i;
|
||||
T *mem = static_cast<T *>(testp->start);
|
||||
T got;
|
||||
T expect;
|
||||
|
||||
/* fill ram */
|
||||
generator.init(seed);
|
||||
|
@ -165,8 +169,10 @@ static void memtest_sequential(memtest_t *testp, Generator<T> &generator, T seed
|
|||
/* read back and compare */
|
||||
generator.init(seed);
|
||||
for (i=0; i<steps; i++) {
|
||||
if (mem[i] != generator.get()) {
|
||||
testp->ecb(testp, generator.get_type(), i*sizeof(T));
|
||||
got = mem[i];
|
||||
expect = generator.get();
|
||||
if ((got != expect) && (nullptr != testp->errcb)) {
|
||||
testp->errcb(testp, generator.get_type(), i, sizeof(T), got, expect);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -210,7 +216,8 @@ template <typename T>
|
|||
static void moving_inversion_rand(memtest_t *testp) {
|
||||
GeneratorMovingInvRand<T> generator;
|
||||
T mask = -1;
|
||||
memtest_sequential<T>(testp, generator, testp->rand_seed & mask);
|
||||
prng_seed++;
|
||||
memtest_sequential<T>(testp, generator, prng_seed & mask);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -37,7 +37,8 @@ typedef uint32_t testtype;
|
|||
/*
|
||||
* Error call back.
|
||||
*/
|
||||
typedef void (*memtestecb_t)(memtest_t *testp, testtype type, size_t address);
|
||||
typedef void (*memtestecb_t)(memtest_t *testp, testtype type, size_t offset,
|
||||
size_t current_width, uint32_t got, uint32_t expect);
|
||||
|
||||
/*
|
||||
*
|
||||
|
@ -45,18 +46,32 @@ typedef void (*memtestecb_t)(memtest_t *testp, testtype type, size_t address);
|
|||
typedef enum {
|
||||
MEMTEST_WIDTH_8,
|
||||
MEMTEST_WIDTH_16,
|
||||
MEMTEST_WIDTH_32
|
||||
MEMTEST_WIDTH_32,
|
||||
} memtest_bus_width_t;
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
struct memtest_t {
|
||||
/*
|
||||
* Pointer to the test area start. Must be word aligned.
|
||||
*/
|
||||
void *start;
|
||||
/*
|
||||
* Test area size in bytes.
|
||||
*/
|
||||
size_t size;
|
||||
/*
|
||||
* Maximum width of transactions.
|
||||
* Note: it implies all narrower tests.
|
||||
* Note: width my be wider then your memory interface because AHB is
|
||||
* smart enough to split big transactions to smaller ones.
|
||||
*/
|
||||
memtest_bus_width_t width;
|
||||
memtestecb_t ecb;
|
||||
unsigned int rand_seed;
|
||||
/*
|
||||
* Error callback pointer. Set to NULL if unused.
|
||||
*/
|
||||
memtestecb_t errcb;
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue