target: mwX on target object now supporst phys argument
authorØyvind Harboe <oyvind.harboe@zylin.com>
Tue, 22 Jun 2010 09:49:00 +0000 (11:49 +0200)
committerØyvind Harboe <oyvind.harboe@zylin.com>
Tue, 22 Jun 2010 10:36:32 +0000 (12:36 +0200)
$_TARGETNAME mww phys 0x10 0xdeadbeef

=> write 0xdeadbeef to physical address 0x10

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
src/target/target.c

index 7513346a9a0069368a237db86bd5f5ac8619f2e4..d6efe5b24ed22325c47b623048be9b1728648ca2 100644 (file)
@@ -3950,19 +3950,30 @@ static int jim_target_mw(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
        Jim_GetOptInfo goi;
        Jim_GetOpt_Setup(&goi, interp, argc - 1, argv + 1);
 
-       /* danger! goi.argc will be modified below! */
-       argc = goi.argc;
-
-       if (argc != 2 && argc != 3)
+       if (goi.argc < 2 || goi.argc > 4)
        {
                Jim_SetResult_sprintf(goi.interp,
-                               "usage: %s <address> <data> [<count>]", cmd_name);
+                               "usage: %s [phys] <address> <data> [<count>]", cmd_name);
                return JIM_ERR;
        }
 
+       target_write_fn fn;
+       fn = target_write_memory_fast;
+
+       int e;
+       if (strcmp(Jim_GetString(argv[1], NULL), "phys") == 0)
+       {
+               /* consume it */
+               struct Jim_Obj *obj;
+               e = Jim_GetOpt_Obj(&goi, &obj);
+               if (e != JIM_OK)
+                       return e;
+
+               fn = target_write_phys_memory;
+       }
 
        jim_wide a;
-       int e = Jim_GetOpt_Wide(&goi, &a);
+       e = Jim_GetOpt_Wide(&goi, &a);
        if (e != JIM_OK)
                return e;
 
@@ -3972,13 +3983,19 @@ static int jim_target_mw(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
                return e;
 
        jim_wide c = 1;
-       if (argc == 3)
+       if (goi.argc == 1)
        {
                e = Jim_GetOpt_Wide(&goi, &c);
                if (e != JIM_OK)
                        return e;
        }
 
+       /* all args must be consumed */
+       if (goi.argc != 0)
+       {
+               return JIM_ERR;
+       }
+
        struct target *target = Jim_CmdPrivData(goi.interp);
        unsigned data_size;
        if (strcasecmp(cmd_name, "mww") == 0) {
@@ -3994,7 +4011,7 @@ static int jim_target_mw(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
                return JIM_ERR;
        }
 
-       return (target_fill_mem(target, a, target_write_memory_fast, data_size, b, c) == ERROR_OK) ? JIM_OK : JIM_ERR;
+       return (target_fill_mem(target, a, fn, data_size, b, c) == ERROR_OK) ? JIM_OK : JIM_ERR;
 }
 
 static int jim_target_md(Jim_Interp *interp, int argc, Jim_Obj *const *argv)

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)