From: Benoit Monin <benoit.monin@laposte.net>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] Add the "mfill" and "mcheck" memory commands.
Date: Tue, 3 Mar 2009 15:29:27 +0100 (CET) [thread overview]
Message-ID: <28907262.11403.1236090567026.JavaMail.www@wwinf8303> (raw)
The mfill command writes the value of a counter to a memory area.
The mcheck command verifies the memory area against the counter value.
Those commands are useful for debugging memory/framebuffer controller.
The configuration option is CONFIG_MFILL and this only takes effect if
the memory commands are activated globally (CONFIG_CMD_MEM).
Signed-off-by: Beno?t Monin <bmonin <at> adeneo.eu>
---
README | 17 +++++++-
common/cmd_mem.c | 127 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 143 insertions(+), 1 deletions(-)
diff --git a/README b/README
index 43fb1c0..d0a636e 100644
--- a/README
+++ b/README
@@ -627,7 +627,7 @@ The following options need to be configured:
CONFIG_CMD_LOADB loadb
CONFIG_CMD_LOADS loads
CONFIG_CMD_MEMORY md, mm, nm, mw, cp, cmp, crc, base,
- loop, loopw, mtest
+ loop, loopw, mtest, mfill, mcheck
CONFIG_CMD_MISC Misc functions like sleep etc
CONFIG_CMD_MMC * MMC memory mapped support
CONFIG_CMD_MII * MII utility commands
@@ -2678,6 +2678,21 @@ Low Level (hardware related) configuration options:
This only takes effect if the memory commands are activated
globally (CONFIG_CMD_MEM).
+- CONFIG_MFILL
+ Add the "mfill" and "mcheck" memory commands. "mfill" writes
+ a memory area with the value of a counter. "mcheck" checks
+ a memory area against the value of a counter and can be run
+ after mfill.
+
+ (mfill/mcheck)[.b, .w, .l] address count [init]
+ [.b, .w, .l] : Access size (default to l).
+ address : Address in hexadecimal.
+ count : Number of elements to write in hex.
+ [init] : Initial value of the counter (default to 0).
+
+ This only takes effect if the memory commands are activated
+ globally (CONFIG_CMD_MEM).
+
- CONFIG_SKIP_LOWLEVEL_INIT
- CONFIG_SKIP_RELOCATE_UBOOT
diff --git a/common/cmd_mem.c b/common/cmd_mem.c
index 2d4fc2a..0191687 100644
--- a/common/cmd_mem.c
+++ b/common/cmd_mem.c
@@ -943,6 +943,117 @@ int do_mem_mtest (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
return rcode;
}
+#ifdef CONFIG_MFILL
+/* Memory fill
+ *
+ * Write a memory area with the value of a counter
+ *
+ * mfill{.b, .w, .l} {address} {count} {init}
+ */
+static int do_mem_mfill(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+{
+ volatile void* addr;
+ ulong count;
+ ulong val;
+ int size;
+
+ if (argc < 3) {
+ printf ("Usage:\n%s\n", cmdtp->usage);
+ return 1;
+ }
+ /* Scan for data size */
+ if ((size = cmd_get_data_size(argv[0], 4)) < 0)
+ return 1;
+ addr = (void*)simple_strtoul(argv[1], NULL, 16);
+ addr += base_address;
+ count = simple_strtoul(argv[2], NULL, 16);
+ if (argc == 4) {
+ val = simple_strtoul(argv[3], NULL, 16);
+ } else {
+ val = 0;
+ }
+ if (size == 4) {
+ while (count-- > 0) {
+ *((ulong*)addr) = (ulong)val++;
+ addr += size;
+ }
+ } else if (size == 2) {
+ while (count-- > 0) {
+ *((ushort*)addr) = (ushort)val++;
+ addr += size;
+ }
+ } else {
+ while (count-- > 0) {
+ *((uchar*)addr) = (uchar)val++;
+ addr += size;
+ }
+ }
+ return 0;
+}
+
+/* Memory check
+ *
+ * Check a memory area against the value of a counter
+ * Run this after mfill.
+ *
+ * mcheck{.b, .w, .l} {address} {count} {init}
+ */
+static int do_mem_mcheck(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+{
+ volatile void* addr;
+ ulong count;
+ ulong val;
+ int size;
+
+ if (argc < 3) {
+ printf ("Usage:\n%s\n", cmdtp->usage);
+ return 1;
+ }
+ /* Scan for data size */
+ if ((size = cmd_get_data_size(argv[0], 4)) < 0)
+ return 1;
+ addr = (void*)simple_strtoul(argv[1], NULL, 16);
+ addr += base_address;
+ count = simple_strtoul(argv[2], NULL, 16);
+ if (argc == 4) {
+ val = simple_strtoul(argv[3], NULL, 16);
+ } else {
+ val = 0;
+ }
+ if (size == 4) {
+ while (count-- > 0) {
+ if (*((ulong*)addr) != (ulong)val) {
+ printf ("Mem error @ 0x%p: found 0x%08lx, expected 0x%08lx\n",
+ addr, *((ulong*)addr), (ulong)val);
+ if (ctrlc()) return 1;
+ }
+ addr += size;
+ val++;
+ }
+ } else if (size == 2) {
+ while (count-- > 0) {
+ if (*((ushort*)addr) != (ushort)val) {
+ printf ("Mem error @ 0x%p: found 0x%04x, expected 0x%04x\n",
+ addr, *((ushort*)addr), (ushort)val);
+ if (ctrlc()) return 1;
+ }
+ addr += size;
+ val++;
+ }
+ } else {
+ while (count-- > 0) {
+ if (*((uchar*)addr) != (uchar)val) {
+ printf ("Mem error @ 0x%p: found 0x%02x, expected 0x%02x\n",
+ addr, *((uchar*)addr), (uchar)val);
+ if (ctrlc()) return 1;
+ }
+ addr += size;
+ val++;
+ }
+ }
+ return 0;
+}
+#endif /* CONFIG_MFILL */
/* Modify memory.
*
@@ -1256,6 +1367,22 @@ U_BOOT_CMD(
" - simple RAM read/write test\n"
);
+#ifdef CONFIG_MFILL
+U_BOOT_CMD(
+ mfill, 4, 1, do_mem_mfill,
+ "mfill - Fill memory with the value of a counter\n",
+ "[.b, .w, .l] address count [init]\n"
+ " - Fill memory range with the value of a counter\n"
+);
+
+U_BOOT_CMD(
+ mcheck, 4, 1, do_mem_mcheck,
+ "mcheck - Check memory after mfill\n",
+ "[.b, .w, .l] address count [init]\n"
+ " - Check memory range after mfill\n"
+);
+#endif /* CONFIG_MFILL */
+
#ifdef CONFIG_MX_CYCLIC
U_BOOT_CMD(
mdc, 4, 1, do_mem_mdc,
--
Cr?ez votre adresse ?lectronique prenom.nom at laposte.net
1 Go d'espace de stockage, anti-spam et anti-virus int?gr?s.
next reply other threads:[~2009-03-03 14:29 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-03 14:29 Benoit Monin [this message]
2009-03-05 23:55 ` [U-Boot] [PATCH] Add the "mfill" and "mcheck" memory commands Wolfgang Denk
-- strict thread matches above, loose matches on Subject: below --
2009-03-06 16:17 Benoit Monin
2009-03-08 22:20 ` Wolfgang Denk
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=28907262.11403.1236090567026.JavaMail.www@wwinf8303 \
--to=benoit.monin@laposte.net \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox