From 8c8c0a0be4dc937c36bac5c5f29a1974e5a1e0ec Mon Sep 17 00:00:00 2001 From: barthess Date: Tue, 4 Aug 2015 00:35:44 +0300 Subject: Memtest improvements --- os/various/memtest.cpp | 13 ++++++++++--- os/various/memtest.hpp | 23 +++++++++++++++++++---- 2 files changed, 29 insertions(+), 7 deletions(-) (limited to 'os') diff --git a/os/various/memtest.cpp b/os/various/memtest.cpp index 49828ec..175ac56 100644 --- a/os/various/memtest.cpp +++ b/os/various/memtest.cpp @@ -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 &generator, T seed const size_t steps = testp->size / sizeof(T); size_t i; T *mem = static_cast(testp->start); + T got; + T expect; /* fill ram */ generator.init(seed); @@ -165,8 +169,10 @@ static void memtest_sequential(memtest_t *testp, Generator &generator, T seed /* read back and compare */ generator.init(seed); for (i=0; iecb(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 static void moving_inversion_rand(memtest_t *testp) { GeneratorMovingInvRand generator; T mask = -1; - memtest_sequential(testp, generator, testp->rand_seed & mask); + prng_seed++; + memtest_sequential(testp, generator, prng_seed & mask); } /* diff --git a/os/various/memtest.hpp b/os/various/memtest.hpp index 200db1f..ba686a3 100644 --- a/os/various/memtest.hpp +++ b/os/various/memtest.hpp @@ -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; }; /* -- cgit v1.2.3