Hongtao Zheng - fix a simulation error for "BX PC"
[openocd.git] / src / target / target.c
index 5fde4f8f1d05b49f8b3ac61f66b8521d03e634b7..6f086b3e44ff60803e3da50f7603e20a347a2a35 100644 (file)
@@ -533,10 +533,10 @@ int target_init(struct command_context_s *cmd_ctx)
                        target->type->examine = default_examine;
                }
 
-               if (target->type->init_target(cmd_ctx, target) != ERROR_OK)
+               if ((retval = target->type->init_target(cmd_ctx, target)) != ERROR_OK)
                {
                        LOG_ERROR("target '%s' init failed", target->type->name);
-                       exit(-1);
+                       return retval;
                }
 
                /* Set up default functions if none are provided by target */
@@ -938,10 +938,10 @@ void target_free_all_working_areas(struct target_s *target)
 int target_register_commands(struct command_context_s *cmd_ctx)
 {
 
-       register_command(cmd_ctx, NULL, "targets", handle_targets_command, COMMAND_EXEC, NULL);
-       register_command(cmd_ctx, NULL, "working_area", handle_working_area_command, COMMAND_ANY, "working_area <target#> <address> <size> <'backup'|'nobackup'> [virtual address]");
-       register_command(cmd_ctx, NULL, "virt2phys", handle_virt2phys_command, COMMAND_ANY, "virt2phys <virtual address>");
-       register_command(cmd_ctx, NULL, "profile", handle_profile_command, COMMAND_EXEC, "PRELIMINARY! - profile <seconds> <gmon.out>");
+       register_command(cmd_ctx, NULL, "targets", handle_targets_command, COMMAND_EXEC, "change the current command line target (one parameter) or lists targets (with no parameter)");
+       register_command(cmd_ctx, NULL, "working_area", handle_working_area_command, COMMAND_ANY, "set a new working space");
+       register_command(cmd_ctx, NULL, "virt2phys", handle_virt2phys_command, COMMAND_ANY, "translate a virtual address into a physical address");
+       register_command(cmd_ctx, NULL, "profile", handle_profile_command, COMMAND_EXEC, "profiling samples the CPU PC");
 
        register_jim(cmd_ctx, "target", jim_target, "configure target" );
 
@@ -1311,7 +1311,7 @@ int target_write_u8(struct target_s *target, u32 address, u8 value)
 int target_register_user_commands(struct command_context_s *cmd_ctx)
 {
        int retval = ERROR_OK;
-       register_command(cmd_ctx,  NULL, "reg", handle_reg_command, COMMAND_EXEC, NULL);
+       register_command(cmd_ctx,  NULL, "reg", handle_reg_command, COMMAND_EXEC, "display or set a register");
        register_command(cmd_ctx,  NULL, "poll", handle_poll_command, COMMAND_EXEC, "poll target state");
        register_command(cmd_ctx,  NULL, "wait_halt", handle_wait_halt_command, COMMAND_EXEC, "wait for target halt [time (s)]");
        register_command(cmd_ctx,  NULL, "halt", handle_halt_command, COMMAND_EXEC, "halt target");
@@ -3878,24 +3878,36 @@ jim_target( Jim_Interp *interp, int argc, Jim_Obj *const *argv )
        }
        if( target_types[x] ){
                /* YES IT IS OLD SYNTAX */
+               int      chain_position_offset;
                Jim_Obj *new_argv[10];
                int      new_argc;
 
                /* target_old_syntax
                 *
-                * argv[0] typename (above)
-                * argv[1] endian
-                * argv[2] reset method, deprecated/ignored
-                * argv[3] = old param
-                * argv[4] = old param
+                * It appears that there are 2 old syntaxes:
+                *
+                * target <typename> <endian> <chain position> <variant>
+                * 
+                * and
                 *
-                * We will combine all "old params" into a single param.
-                * Then later, split them again.
+                * target <typename> <endian> <reset mode> <chain position> <variant>
+                *
+                * The following uses the number of arguments to switch between them.
                 */
-               if( argc < 4 ){
-                       Jim_WrongNumArgs( interp, 1, argv, "[OLDSYNTAX] ?TYPE? ?ENDIAN? ?RESET? ?old-params?");
+               if( argc < 5 ){
+                       Jim_WrongNumArgs( interp, 1, argv, "[OLDSYNTAX] ?TYPE? ?ENDIAN? ?CHAIN-POSITION? ?VARIANT?");
                        return JIM_ERR;
                }
+
+               /* Use the correct argument offset for the chain position */
+               if (argc < 6) {
+                       /* target <type> <endian> <chain position> <variant> */
+                       chain_position_offset = 2;
+               } else {
+                       chain_position_offset = 3;
+                       /* target <type> <endian> <reset mode> <chain position> <variant> */
+               }
+
                /* the command */
                new_argv[0] = argv[0];
                new_argv[1] = Jim_NewStringObj( interp, "create", -1 );
@@ -3908,10 +3920,11 @@ jim_target( Jim_Interp *interp, int argc, Jim_Obj *const *argv )
                new_argv[4] = Jim_NewStringObj( interp, "-endian", -1 );
                new_argv[5] = goi.argv[1];
                new_argv[6] = Jim_NewStringObj( interp, "-chain-position", -1 );
-               new_argv[7] = goi.argv[2];
+               new_argv[7] = goi.argv[chain_position_offset];
                new_argv[8] = Jim_NewStringObj( interp, "-variant", -1 );
-               new_argv[9] = goi.argv[3];
+               new_argv[9] = goi.argv[chain_position_offset + 1];
                new_argc = 10;
+
                /*
                 * new arg syntax:
                 *   argv[0] = command

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)