From d5e967add437774023b20e51ef49b81f5064f7f6 Mon Sep 17 00:00:00 2001 From: barthess Date: Mon, 28 Sep 2015 17:36:25 +0300 Subject: [PATCH] Memtest. Changed way to specify memtest data width --- os/various/memtest.cpp | 17 ++++++----------- os/various/memtest.h | 35 ++++++++++++++++++----------------- 2 files changed, 24 insertions(+), 28 deletions(-) diff --git a/os/various/memtest.cpp b/os/various/memtest.cpp index b853fe77..8fb5262a 100644 --- a/os/various/memtest.cpp +++ b/os/various/memtest.cpp @@ -227,20 +227,15 @@ 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)) { - switch(testp->width) { - case MEMTEST_WIDTH_32: + + if (testp->width_mask & MEMTEST_WIDTH_8) p_u8(testp); + + if (testp->width_mask & MEMTEST_WIDTH_16) p_u16(testp); + + if (testp->width_mask & MEMTEST_WIDTH_32) p_u32(testp); - break; - case MEMTEST_WIDTH_16: - p_u8(testp); - p_u16(testp); - break; - case MEMTEST_WIDTH_8: - p_u8(testp); - break; - } } /* diff --git a/os/various/memtest.h b/os/various/memtest.h index 721b36b2..e67df5f8 100644 --- a/os/various/memtest.h +++ b/os/various/memtest.h @@ -17,6 +17,9 @@ #ifndef MEMTEST_H_ #define MEMTEST_H_ +/* + * Memtest types + */ #define MEMTEST_WALKING_ONE (1 << 0) #define MEMTEST_WALKING_ZERO (1 << 1) #define MEMTEST_OWN_ADDRESS (1 << 2) @@ -24,6 +27,9 @@ #define MEMTEST_MOVING_INVERSION_55AA (1 << 4) #define MEMTEST_MOVING_INVERSION_RAND (1 << 5) +/* + * combined types for convenient + */ #define MEMTEST_RUN_ALL (MEMTEST_WALKING_ONE | \ MEMTEST_WALKING_ZERO | \ MEMTEST_OWN_ADDRESS | \ @@ -31,6 +37,13 @@ MEMTEST_MOVING_INVERSION_55AA | \ MEMTEST_MOVING_INVERSION_RAND) +/* + * Memtest data widths + */ +#define MEMTEST_WIDTH_8 (1 << 0) +#define MEMTEST_WIDTH_16 (1 << 1) +#define MEMTEST_WIDTH_32 (1 << 2) + typedef struct memtest_t memtest_t; typedef uint32_t testtype; @@ -40,15 +53,6 @@ typedef uint32_t testtype; typedef void (*memtestecb_t)(memtest_t *testp, testtype type, size_t index, size_t current_width, uint32_t got, uint32_t expect); -/* - * - */ -typedef enum { - MEMTEST_WIDTH_8, - MEMTEST_WIDTH_16, - MEMTEST_WIDTH_32, -} memtest_bus_width_t; - /* * */ @@ -56,22 +60,19 @@ struct memtest_t { /* * Pointer to the test area start. Must be word aligned. */ - void *start; + void *start; /* * Test area size in bytes. */ - size_t size; + 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. + * Allowable data widths mask. */ - memtest_bus_width_t width; + uint32_t width_mask; /* * Error callback pointer. Set to NULL if unused. */ - memtestecb_t errcb; + memtestecb_t errcb; }; /*