target: add "phys" argument to mem2array, array2mem
[openocd.git] / src / target / target.c
index 084aea8b6d9c97daf4fedab7fb6cdea2b69bfe4d..0dbce9aecdc27cd5e6a4709ac46ace8abc5e7490 100644 (file)
@@ -3913,6 +3913,8 @@ static int target_mem2array(Jim_Interp *interp, struct target *target, int argc,
        uint32_t count;
        uint32_t v;
        const char *varname;
+       const char *phys;
+       bool is_phys;
        int  n, e, retval;
        uint32_t i;
 
@@ -3921,8 +3923,8 @@ static int target_mem2array(Jim_Interp *interp, struct target *target, int argc,
         * argv[3] = memory address
         * argv[4] = count of times to read
         */
-       if (argc != 4) {
-               Jim_WrongNumArgs(interp, 1, argv, "varname width addr nelems");
+       if (argc < 4 || argc > 5) {
+               Jim_WrongNumArgs(interp, 1, argv, "varname width addr nelems [phys]");
                return JIM_ERR;
        }
        varname = Jim_GetString(argv[0], &len);
@@ -3941,6 +3943,14 @@ static int target_mem2array(Jim_Interp *interp, struct target *target, int argc,
        len = l;
        if (e != JIM_OK)
                return e;
+       is_phys = false;
+       if (argc > 4) {
+               phys = Jim_GetString(argv[4], &n);
+               if (!strncmp(phys, "phys", n))
+                       is_phys = true;
+               else
+                       return JIM_ERR;
+       }
        switch (width) {
                case 8:
                        width = 1;
@@ -4006,7 +4016,10 @@ static int target_mem2array(Jim_Interp *interp, struct target *target, int argc,
                if (count > (buffersize / width))
                        count = (buffersize / width);
 
-               retval = target_read_memory(target, addr, width, count, buffer);
+               if (is_phys)
+                       retval = target_read_phys_memory(target, addr, width, count, buffer);
+               else
+                       retval = target_read_memory(target, addr, width, count, buffer);
                if (retval != ERROR_OK) {
                        /* BOO !*/
                        LOG_ERROR("mem2array: Read @ 0x%08x, w=%d, cnt=%d, failed",
@@ -4102,6 +4115,8 @@ static int target_array2mem(Jim_Interp *interp, struct target *target,
        uint32_t count;
        uint32_t v;
        const char *varname;
+       const char *phys;
+       bool is_phys;
        int  n, e, retval;
        uint32_t i;
 
@@ -4110,8 +4125,8 @@ static int target_array2mem(Jim_Interp *interp, struct target *target,
         * argv[3] = memory address
         * argv[4] = count to write
         */
-       if (argc != 4) {
-               Jim_WrongNumArgs(interp, 0, argv, "varname width addr nelems");
+       if (argc < 4 || argc > 5) {
+               Jim_WrongNumArgs(interp, 0, argv, "varname width addr nelems [phys]");
                return JIM_ERR;
        }
        varname = Jim_GetString(argv[0], &len);
@@ -4130,6 +4145,14 @@ static int target_array2mem(Jim_Interp *interp, struct target *target,
        len = l;
        if (e != JIM_OK)
                return e;
+       is_phys = false;
+       if (argc > 4) {
+               phys = Jim_GetString(argv[4], &n);
+               if (!strncmp(phys, "phys", n))
+                       is_phys = true;
+               else
+                       return JIM_ERR;
+       }
        switch (width) {
                case 8:
                        width = 1;
@@ -4216,7 +4239,10 @@ static int target_array2mem(Jim_Interp *interp, struct target *target,
                }
                len -= count;
 
-               retval = target_write_memory(target, addr, width, count, buffer);
+               if (is_phys)
+                       retval = target_write_phys_memory(target, addr, width, count, buffer);
+               else
+                       retval = target_write_memory(target, addr, width, count, buffer);
                if (retval != ERROR_OK) {
                        /* BOO !*/
                        LOG_ERROR("array2mem: Write @ 0x%08x, w=%d, cnt=%d, failed",

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)