]> git.sur5r.net Git - openocd/commitdiff
Rick Altherr <kc8apf@kc8apf.net> - fix support for old target syntax
authoroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Tue, 28 Oct 2008 08:06:07 +0000 (08:06 +0000)
committeroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Tue, 28 Oct 2008 08:06:07 +0000 (08:06 +0000)
git-svn-id: svn://svn.berlios.de/openocd/trunk@1108 b42882b7-edfa-0310-969c-e2dbd0fdcd60

src/target/target.c

index efb67a040ffa3299347fbc617803d8485211e7b0..6f086b3e44ff60803e3da50f7603e20a347a2a35 100644 (file)
@@ -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:
                 *
-                * We will combine all "old params" into a single param.
-                * Then later, split them again.
+                * target <typename> <endian> <chain position> <variant>
+                * 
+                * and
+                *
+                * 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[3];
+               new_argv[7] = goi.argv[chain_position_offset];
                new_argv[8] = Jim_NewStringObj( interp, "-variant", -1 );
-               new_argv[9] = goi.argv[4];
+               new_argv[9] = goi.argv[chain_position_offset + 1];
                new_argc = 10;
+
                /*
                 * new arg syntax:
                 *   argv[0] = command