summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Ringle <jon@ringle.org>2011-06-08 11:33:17 -0400
committerMarc Kleine-Budde <mkl@pengutronix.de>2011-06-08 23:52:07 +0200
commit2212e84b2b07c80f09ba3af01a2f367d58964c3f (patch)
treefbd6ebe5529ac2c7513888255e708ef4968bd4ff
parent38a583ee26a8fbd20eed9747b5dee386cdf68bce (diff)
downloadmemedit-2212e84b2b07c80f09ba3af01a2f367d58964c3f.tar.gz
memedit-2212e84b2b07c80f09ba3af01a2f367d58964c3f.tar.xz
readback on write disable option
Registers sometimes have read side-effects. Provide an option to disable readback on write. Readback on write can be disabled with '-r 0' on command line or 'readback = 0' from memedit prompt. Signed-off-by: Jon Ringle <jon@ringle.org> Removed some braces and added some help text. Signed-off-by: Wolfram Sang <w.sang@pengutronix.de> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
-rw-r--r--memedit.13
-rw-r--r--memedit.c4
-rw-r--r--memedit.y24
-rw-r--r--memedit_parser.gp3
4 files changed, 26 insertions, 8 deletions
diff --git a/memedit.1 b/memedit.1
index 5063a73..4e8429e 100644
--- a/memedit.1
+++ b/memedit.1
@@ -35,6 +35,9 @@ the line is treated as a comment. E.g.:
SR0 = 0x0 # Some Control / Status Register
.br
.br
+.TP
+\fB\-\-readback | \-r\fR
+readback on write (default on)
.TP
\fB\-\-help | \-h\fR
Output help information and exit.
diff --git a/memedit.c b/memedit.c
index 8389302..062355a 100644
--- a/memedit.c
+++ b/memedit.c
@@ -20,6 +20,7 @@ extern int yyparse();
int debug = 0;
+int readback = 1;
int mmaped_access = 0;
FILE *rl_instream;
int fd = -1;
@@ -51,7 +52,8 @@ int main (int argc, char *argv[])
return EXIT_FAILURE;
}
- debug = kom_arg->V;
+ debug = kom_arg->V;
+ readback = !kom_arg->r;
if (kom_arg->s)
{
diff --git a/memedit.y b/memedit.y
index 61f242a..35d7850 100644
--- a/memedit.y
+++ b/memedit.y
@@ -14,7 +14,7 @@
extern int errno;
extern int fd;
-extern int debug, mmaped_access;
+extern int debug, mmaped_access, readback;
extern void *mem;
unsigned int cur_position;
@@ -209,7 +209,8 @@ mm: MM { write_len = $1; if (debug > 3) printf ("write_len = %d\n", write_len);}
exp: num {
cur_position = $1;
- printf ("new values:\n0x%08x: ",cur_position);
+ if (readback)
+ printf ("new values:\n0x%08x: ",cur_position);
}
| exp num {
unsigned int c = $2;
@@ -218,16 +219,19 @@ exp: num {
case 1:
c &= 0xff;
*(volatile unsigned char *)(mem + cur_position) = c;
- printf ("%02x ", *(volatile unsigned char *)(mem + cur_position));
+ if (readback)
+ printf ("%02x ", *(volatile unsigned char *)(mem + cur_position));
break;
case 2:
c &= 0xffff;
*(volatile unsigned short *)(mem + cur_position) = c;
- printf ("%04x ", *(volatile unsigned short *)(mem + cur_position));
+ if (readback)
+ printf ("%04x ", *(volatile unsigned short *)(mem + cur_position));
break;
case 4:
*(volatile unsigned long *)(mem + cur_position) = c;
- printf ("%08lx ", *(volatile unsigned long *)(mem + cur_position));
+ if (readback)
+ printf ("%08lx ", *(volatile unsigned long *)(mem + cur_position));
break;
}
cur_position += write_len;
@@ -263,6 +267,8 @@ void print_help (void) {
printf ("mm <offset> <val1> .. <valN> modify from value <offset>\n");
printf ("mf <start> <length> <value> fill from <offset> for <length> with <value>\n");
printf ("env print all currently defined variables\n");
+ printf ("readback <val> if true (default), read back values after write operation\n");
+ printf (" disable to avoid side-effects (e.g. for irq-registers)\n");
printf ("<var> = <expr> set variable <var> to <expr>\n");
printf ("<var> print variable <var>\n");
printf ("\n");
@@ -281,7 +287,13 @@ void print_help (void) {
void set_variable (char *param, int val) {
variable *l, *tmp;
-
+
+ if (strncmp (param, "readback", 8) == 0) {
+ readback = val;
+ printf ("readback = %d\n", readback);
+ return;
+ }
+
if (strncmp (param, "debug", 5) == 0) {
debug = val;
printf ("debug = %d\n", debug);
diff --git a/memedit_parser.gp b/memedit_parser.gp
index 3eb75c3..5402503 100644
--- a/memedit_parser.gp
+++ b/memedit_parser.gp
@@ -1,4 +1,5 @@
/* memedit_parser.gp */
-#mandatory memedit
+#mandatory file
V / verbose int 0 "verbose output"
s / startfile string "" "execute startup file"
+r / readback flag 1 "readback on write (default on)"