diff options
Diffstat (limited to 'common/memtest.c')
-rw-r--r-- | common/memtest.c | 60 |
1 files changed, 28 insertions, 32 deletions
diff --git a/common/memtest.c b/common/memtest.c index 44ddedd3d4..aa16d94eed 100644 --- a/common/memtest.c +++ b/common/memtest.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-only /* * memtest.c * @@ -5,19 +6,6 @@ * * (C) Copyright 2000 * Wolfgang Denk, DENX Software Engineering, wd@denx.de. - * - * See file CREDITS for list of people who contributed to this - * project. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * */ #include <progress.h> @@ -172,7 +160,7 @@ static void mem_test_report_failure(const char *failure_description, } int mem_test_bus_integrity(resource_size_t _start, - resource_size_t _end) + resource_size_t _end, unsigned int flags) { static const uint64_t bitpattern[] = { 0x0000000000000001ULL, /* single bit */ @@ -202,13 +190,14 @@ int mem_test_bus_integrity(resource_size_t _start, dummy = start + 1; num_words = (_end - _start + 1)/sizeof(resource_size_t); - printf("Starting data line test.\n"); + if (flags & MEMTEST_VERBOSE) + printf("Starting data line test.\n"); /* * Data line test: write a pattern to the first * location, write the 1's complement to a 'parking' * address (changes the state of the data bus so a - * floating bus doen't give a false OK), and then + * floating bus doesn't give a false OK), and then * read the value back. Note that we read it back * into a variable because the next time we read it, * it might be right (been there, tough to explain to @@ -306,7 +295,8 @@ int mem_test_bus_integrity(resource_size_t _start, */ start[0] = anti_pattern; - printf("Check for address bits stuck high.\n"); + if (flags & MEMTEST_VERBOSE) + printf("Check for address bits stuck high.\n"); /* * Check for address bits stuck high. @@ -325,8 +315,8 @@ int mem_test_bus_integrity(resource_size_t _start, */ start[0] = pattern; - printf("Check for address bits stuck " - "low or shorted.\n"); + if (flags & MEMTEST_VERBOSE) + printf("Check for address bits stuck low or shorted.\n"); /* * Check for address bits stuck low or shorted. @@ -352,7 +342,7 @@ int mem_test_bus_integrity(resource_size_t _start, return 0; } -static int update_progress(resource_size_t offset) +static int update_progress(resource_size_t offset, unsigned flags) { /* Only check every 4k to reduce overhead */ if (offset & (SZ_4K - 1)) @@ -361,12 +351,14 @@ static int update_progress(resource_size_t offset) if (ctrlc()) return -EINTR; - show_progress(offset); + if (flags & MEMTEST_VERBOSE) + show_progress(offset); return 0; } -int mem_test_moving_inversions(resource_size_t _start, resource_size_t _end) +int mem_test_moving_inversions(resource_size_t _start, resource_size_t _end, + unsigned flags) { volatile resource_size_t *start, num_words, offset, temp, anti_pattern; int ret; @@ -380,8 +372,12 @@ int mem_test_moving_inversions(resource_size_t _start, resource_size_t _end) start = (resource_size_t *)_start; num_words = (_end - _start + 1)/sizeof(resource_size_t); - printf("Starting moving inversions test of RAM:\n" - "Fill with address, compare, fill with inverted address, compare again\n"); + if (flags & MEMTEST_VERBOSE) { + printf("Starting moving inversions test of RAM:\n" + "Fill with address, compare, fill with inverted address, compare again\n"); + + init_progression_bar(3 * num_words); + } /* * Description: Test the integrity of a physical @@ -394,11 +390,9 @@ int mem_test_moving_inversions(resource_size_t _start, resource_size_t _end) * selected by the caller. */ - init_progression_bar(3 * num_words); - /* Fill memory with a known pattern */ for (offset = 0; offset < num_words; offset++) { - ret = update_progress(offset); + ret = update_progress(offset, flags); if (ret) return ret; start[offset] = offset + 1; @@ -406,7 +400,7 @@ int mem_test_moving_inversions(resource_size_t _start, resource_size_t _end) /* Check each location and invert it for the second pass */ for (offset = 0; offset < num_words; offset++) { - ret = update_progress(num_words + offset); + ret = update_progress(num_words + offset, flags); if (ret) return ret; @@ -425,7 +419,7 @@ int mem_test_moving_inversions(resource_size_t _start, resource_size_t _end) /* Check each location for the inverted pattern and zero it */ for (offset = 0; offset < num_words; offset++) { - ret = update_progress(2 * num_words + offset); + ret = update_progress(2 * num_words + offset, flags); if (ret) return ret; @@ -442,10 +436,12 @@ int mem_test_moving_inversions(resource_size_t _start, resource_size_t _end) start[offset] = 0; } - show_progress(3 * num_words); + if (flags & MEMTEST_VERBOSE) { + show_progress(3 * num_words); - /* end of progressbar */ - printf("\n"); + /* end of progressbar */ + printf("\n"); + } return 0; } |