target: $_TARGET mdw now has a phys option
authorØyvind Harboe <oyvind.harboe@zylin.com>
Tue, 22 Jun 2010 10:35:00 +0000 (12:35 +0200)
committerØyvind Harboe <oyvind.harboe@zylin.com>
Tue, 22 Jun 2010 10:43:30 +0000 (12:43 +0200)
just like the mdw command

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

index d6efe5b24ed22325c47b623048be9b1728648ca2..3bf6824be289a496643aa2342bb763573f51a8cf 100644 (file)
@@ -4021,23 +4021,36 @@ static int jim_target_md(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 != 1) && (argc != 2))
+       if ((goi.argc < 1) || (goi.argc > 3))
        {
                Jim_SetResult_sprintf(goi.interp,
-                               "usage: %s <address> [<count>]", cmd_name);
+                               "usage: %s [phys] <address> [<count>]", cmd_name);
                return JIM_ERR;
        }
 
+       int (*fn)(struct target *target,
+                       uint32_t address, uint32_t size, uint32_t count, uint8_t *buffer);
+       fn=target_read_memory;
+
+       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_read_phys_memory;
+       }
+
        jim_wide a;
-       int e = Jim_GetOpt_Wide(&goi, &a);
+       e = Jim_GetOpt_Wide(&goi, &a);
        if (e != JIM_OK) {
                return JIM_ERR;
        }
        jim_wide c;
-       if (argc == 2) {
+       if (goi.argc == 1) {
                e = Jim_GetOpt_Wide(&goi, &c);
                if (e != JIM_OK) {
                        return JIM_ERR;
@@ -4045,6 +4058,13 @@ static int jim_target_md(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
        } else {
                c = 1;
        }
+
+       /* all args must be consumed */
+       if (goi.argc != 0)
+       {
+               return JIM_ERR;
+       }
+
        jim_wide b = 1; /* shut up gcc */
        if (strcasecmp(cmd_name, "mdw") == 0)
                b = 4;
@@ -4068,7 +4088,7 @@ static int jim_target_md(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
                if (y > 16) {
                        y = 16;
                }
-               e = target_read_memory(target, a, b, y / b, target_buf);
+               e = fn(target, a, b, y / b, target_buf);
                if (e != ERROR_OK) {
                        Jim_SetResult_sprintf(interp, "error reading target @ 0x%08lx", (int)(a));
                        return JIM_ERR;

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)