diff options
author | barthess <barthess@yandex.ru> | 2015-10-15 10:51:11 +0300 |
---|---|---|
committer | barthess <barthess@yandex.ru> | 2015-10-15 10:51:11 +0300 |
commit | bf7d3ef855907657a9a22f09721c2d910575c455 (patch) | |
tree | 32d50246662f454b7c05f8bd9bae34084b2f6190 | |
parent | c457b4d7d14a37eca844b5979cb705264ed4c155 (diff) | |
download | ChibiOS-Contrib-bf7d3ef855907657a9a22f09721c2d910575c455.tar.gz ChibiOS-Contrib-bf7d3ef855907657a9a22f09721c2d910575c455.tar.bz2 ChibiOS-Contrib-bf7d3ef855907657a9a22f09721c2d910575c455.zip |
Memtest. Added uint64_t test.
-rw-r--r-- | os/various/memtest.cpp | 36 | ||||
-rw-r--r-- | os/various/memtest.h | 1 |
2 files changed, 27 insertions, 10 deletions
diff --git a/os/various/memtest.cpp b/os/various/memtest.cpp index 8fb5262..090d602 100644 --- a/os/various/memtest.cpp +++ b/os/various/memtest.cpp @@ -128,13 +128,19 @@ public: T get(void) { T ret; - T mask = -1; + if ((step & 1) == 0) { - ret = rand() & mask; + ret = 0; + ret |= rand(); + if (8 == sizeof(T)) { + // multiplication used instead of 32 bit shift for warning avoidance + ret *= 0x100000000; + ret |= rand(); + } prev = ret; } else { - ret = ~prev & mask; + ret = ~prev; } step++; @@ -226,7 +232,8 @@ static void moving_inversion_rand(memtest_t *testp) { static void memtest_wrapper(memtest_t *testp, void (*p_u8)(memtest_t *testp), void (*p_u16)(memtest_t *testp), - void (*p_u32)(memtest_t *testp)) { + void (*p_u32)(memtest_t *testp), + void (*p_u64)(memtest_t *testp)) { if (testp->width_mask & MEMTEST_WIDTH_8) p_u8(testp); @@ -236,6 +243,9 @@ static void memtest_wrapper(memtest_t *testp, if (testp->width_mask & MEMTEST_WIDTH_32) p_u32(testp); + + if (testp->width_mask & MEMTEST_WIDTH_64) + p_u64(testp); } /* @@ -247,42 +257,48 @@ void memtest_run(memtest_t *testp, uint32_t testmask) { memtest_wrapper(testp, walking_one<uint8_t>, walking_one<uint16_t>, - walking_one<uint32_t>); + walking_one<uint32_t>, + walking_one<uint64_t>); } if (testmask & MEMTEST_WALKING_ZERO) { memtest_wrapper(testp, walking_zero<uint8_t>, walking_zero<uint16_t>, - walking_zero<uint32_t>); + walking_zero<uint32_t>, + walking_zero<uint64_t>); } if (testmask & MEMTEST_OWN_ADDRESS) { memtest_wrapper(testp, own_address<uint8_t>, own_address<uint16_t>, - own_address<uint32_t>); + own_address<uint32_t>, + own_address<uint64_t>); } if (testmask & MEMTEST_MOVING_INVERSION_ZERO) { memtest_wrapper(testp, moving_inversion_zero<uint8_t>, moving_inversion_zero<uint16_t>, - moving_inversion_zero<uint32_t>); + moving_inversion_zero<uint32_t>, + moving_inversion_zero<uint64_t>); } if (testmask & MEMTEST_MOVING_INVERSION_55AA) { memtest_wrapper(testp, moving_inversion_55aa<uint8_t>, moving_inversion_55aa<uint16_t>, - moving_inversion_55aa<uint32_t>); + moving_inversion_55aa<uint32_t>, + moving_inversion_55aa<uint64_t>); } if (testmask & MEMTEST_MOVING_INVERSION_RAND) { memtest_wrapper(testp, moving_inversion_rand<uint8_t>, moving_inversion_rand<uint16_t>, - moving_inversion_rand<uint32_t>); + moving_inversion_rand<uint32_t>, + moving_inversion_rand<uint64_t>); } } diff --git a/os/various/memtest.h b/os/various/memtest.h index e67df5f..9c31b54 100644 --- a/os/various/memtest.h +++ b/os/various/memtest.h @@ -43,6 +43,7 @@ #define MEMTEST_WIDTH_8 (1 << 0) #define MEMTEST_WIDTH_16 (1 << 1) #define MEMTEST_WIDTH_32 (1 << 2) +#define MEMTEST_WIDTH_64 (1 << 3) typedef struct memtest_t memtest_t; typedef uint32_t testtype; |