1 // SPDX-License-Identifier: GPL-2.0-or-later
3 /***************************************************************************
4 * Copyright (C) 2013-2015,2019-2020 Synopsys, Inc. *
5 * Frank Dols <frank.dols@synopsys.com> *
6 * Mischa Jonker <mischa.jonker@synopsys.com> *
7 * Anton Kolesov <anton.kolesov@synopsys.com> *
8 * Evgeniy Didin <didin@synopsys.com> *
9 ***************************************************************************/
17 /* --------------------------------------------------------------------------
19 * ARC targets expose command interface.
20 * It can be accessed via GDB through the (gdb) monitor command.
22 * ------------------------------------------------------------------------- */
25 static int arc_cmd_jim_get_uint32(struct jim_getopt_info
*goi
, uint32_t *value
)
28 JIM_CHECK_RETVAL(jim_getopt_wide(goi
, &value_wide
));
29 *value
= (uint32_t)value_wide
;
34 CFG_ADD_REG_TYPE_FLAG
,
35 CFG_ADD_REG_TYPE_STRUCT
,
37 /* Add flags register data type */
38 enum add_reg_type_flags
{
39 CFG_ADD_REG_TYPE_FLAGS_NAME
,
40 CFG_ADD_REG_TYPE_FLAGS_FLAG
,
43 static struct jim_nvp nvp_add_reg_type_flags_opts
[] = {
44 { .name
= "-name", .value
= CFG_ADD_REG_TYPE_FLAGS_NAME
},
45 { .name
= "-flag", .value
= CFG_ADD_REG_TYPE_FLAGS_FLAG
},
46 { .name
= NULL
, .value
= -1 }
49 /* Helper function to check if all field required for register
51 static const char *validate_register(const struct arc_reg_desc
* const reg
, bool arch_num_set
)
53 /* Check that required fields are set */
55 return "-name option is required";
56 if (!reg
->gdb_xml_feature
)
57 return "-feature option is required";
59 return "-num option is required";
60 if (reg
->is_bcr
&& reg
->is_core
)
61 return "Register cannot be both -core and -bcr.";
65 /* Helper function to read the name of register type or register from
67 static int jim_arc_read_reg_name_field(struct jim_getopt_info
*goi
,
68 const char **name
, int *name_len
)
73 Jim_WrongNumArgs(goi
->interp
, goi
->argc
, goi
->argv
, "-name <name> ...");
76 e
= jim_getopt_string(goi
, name
, name_len
);
80 /* Helper function to read bitfields/flags of register type. */
81 static int jim_arc_read_reg_type_field(struct jim_getopt_info
*goi
, const char **field_name
, int *field_name_len
,
82 struct arc_reg_bitfield
*bitfields
, int cur_field
, int type
)
84 jim_wide start_pos
, end_pos
;
87 if ((type
== CFG_ADD_REG_TYPE_STRUCT
&& goi
->argc
< 3) ||
88 (type
== CFG_ADD_REG_TYPE_FLAG
&& goi
->argc
< 2)) {
89 Jim_SetResultFormatted(goi
->interp
, "Not enough arguments after -flag/-bitfield");
93 e
= jim_getopt_string(goi
, field_name
, field_name_len
);
97 /* read start position of bitfield/flag */
98 e
= jim_getopt_wide(goi
, &start_pos
);
104 /* Check if any arguments remain,
105 * set bitfields[cur_field].end if flag is multibit */
107 /* Check current argv[0], if it is equal to "-flag",
108 * than bitfields[cur_field].end remains start */
109 if ((strcmp(Jim_String(goi
->argv
[0]), "-flag") && type
== CFG_ADD_REG_TYPE_FLAG
)
110 || (type
== CFG_ADD_REG_TYPE_STRUCT
)) {
111 e
= jim_getopt_wide(goi
, &end_pos
);
113 Jim_SetResultFormatted(goi
->interp
, "Error reading end position");
118 bitfields
[cur_field
].bitfield
.start
= start_pos
;
119 bitfields
[cur_field
].bitfield
.end
= end_pos
;
120 if ((end_pos
!= start_pos
) || (type
== CFG_ADD_REG_TYPE_STRUCT
))
121 bitfields
[cur_field
].bitfield
.type
= REG_TYPE_INT
;
125 static int jim_arc_add_reg_type_flags(Jim_Interp
*interp
, int argc
,
126 Jim_Obj
* const *argv
)
128 struct jim_getopt_info goi
;
129 JIM_CHECK_RETVAL(jim_getopt_setup(&goi
, interp
, argc
-1, argv
+1));
133 struct command_context
*ctx
;
134 struct target
*target
;
136 ctx
= current_command_context(interp
);
138 target
= get_current_target(ctx
);
140 Jim_SetResultFormatted(goi
.interp
, "No current target");
146 /* Check if the amount of arguments is not zero */
148 Jim_SetResultFormatted(goi
.interp
, "The command has no arguments");
152 /* Estimate number of registers as (argc - 2)/3 as each -flag option has 2
153 * arguments while -name is required. */
154 unsigned int fields_sz
= (goi
.argc
- 2) / 3;
155 unsigned int cur_field
= 0;
157 /* The maximum amount of bitfields is 32 */
158 if (fields_sz
> 32) {
159 Jim_SetResultFormatted(goi
.interp
, "The amount of bitfields exceed 32");
163 struct arc_reg_data_type
*type
= calloc(1, sizeof(*type
));
164 struct reg_data_type_flags
*flags
= &type
->data_type_flags
;
165 struct reg_data_type_flags_field
*fields
= calloc(fields_sz
, sizeof(*fields
));
166 type
->reg_type_flags_field
= fields
;
167 struct arc_reg_bitfield
*bitfields
= calloc(fields_sz
, sizeof(*bitfields
));
168 if (!(type
&& fields
&& bitfields
)) {
169 Jim_SetResultFormatted(goi
.interp
, "Failed to allocate memory.");
173 /* Initialize type */
174 type
->bitfields
= bitfields
;
175 type
->data_type
.id
= type
->data_type_id
;
176 type
->data_type
.type
= REG_TYPE_ARCH_DEFINED
;
177 type
->data_type
.type_class
= REG_TYPE_CLASS_FLAGS
;
178 type
->data_type
.reg_type_flags
= flags
;
179 flags
->size
= 4; /* For now ARC has only 32-bit registers */
181 while (goi
.argc
> 0 && e
== JIM_OK
) {
183 e
= jim_getopt_nvp(&goi
, nvp_add_reg_type_flags_opts
, &n
);
185 jim_getopt_nvp_unknown(&goi
, nvp_add_reg_type_flags_opts
, 0);
190 case CFG_ADD_REG_TYPE_FLAGS_NAME
:
192 const char *name
= NULL
;
195 e
= jim_arc_read_reg_name_field(&goi
, &name
, &name_len
);
197 Jim_SetResultFormatted(goi
.interp
, "Unable to read reg name.");
201 if (name_len
> REG_TYPE_MAX_NAME_LENGTH
) {
202 Jim_SetResultFormatted(goi
.interp
, "Reg type name is too big.");
206 strncpy((void *)type
->data_type
.id
, name
, name_len
);
207 if (!type
->data_type
.id
) {
208 Jim_SetResultFormatted(goi
.interp
, "Unable to setup reg type name.");
215 case CFG_ADD_REG_TYPE_FLAGS_FLAG
:
217 const char *field_name
= NULL
;
218 int field_name_len
= 0;
220 e
= jim_arc_read_reg_type_field(&goi
, &field_name
, &field_name_len
, bitfields
,
221 cur_field
, CFG_ADD_REG_TYPE_FLAG
);
223 Jim_SetResultFormatted(goi
.interp
, "Unable to add reg_type_flag field.");
227 if (field_name_len
> REG_TYPE_MAX_NAME_LENGTH
) {
228 Jim_SetResultFormatted(goi
.interp
, "Reg type field_name_len is too big.");
232 fields
[cur_field
].name
= bitfields
[cur_field
].name
;
233 strncpy(bitfields
[cur_field
].name
, field_name
, field_name_len
);
234 if (!fields
[cur_field
].name
) {
235 Jim_SetResultFormatted(goi
.interp
, "Unable to setup field name. ");
239 fields
[cur_field
].bitfield
= &(bitfields
[cur_field
].bitfield
);
241 fields
[cur_field
- 1].next
= &(fields
[cur_field
]);
243 flags
->fields
= fields
;
251 if (!type
->data_type
.id
) {
252 Jim_SetResultFormatted(goi
.interp
, "-name is a required option");
256 arc_reg_data_type_add(target
, type
);
258 LOG_DEBUG("added flags type {name=%s}", type
->data_type
.id
);
269 /* Add struct register data type */
270 enum add_reg_type_struct
{
271 CFG_ADD_REG_TYPE_STRUCT_NAME
,
272 CFG_ADD_REG_TYPE_STRUCT_BITFIELD
,
275 static struct jim_nvp nvp_add_reg_type_struct_opts
[] = {
276 { .name
= "-name", .value
= CFG_ADD_REG_TYPE_STRUCT_NAME
},
277 { .name
= "-bitfield", .value
= CFG_ADD_REG_TYPE_STRUCT_BITFIELD
},
278 { .name
= NULL
, .value
= -1 }
281 COMMAND_HANDLER(arc_handle_set_aux_reg
)
284 return ERROR_COMMAND_SYNTAX_ERROR
;
286 struct target
*target
= get_current_target(CMD_CTX
);
288 command_print(CMD
, "No current target");
292 /* Register number */
294 COMMAND_PARSE_NUMBER(u32
, CMD_ARGV
[0], regnum
);
298 COMMAND_PARSE_NUMBER(u32
, CMD_ARGV
[1], value
);
300 struct arc_common
*arc
= target_to_arc(target
);
303 CHECK_RETVAL(arc_jtag_write_aux_reg_one(&arc
->jtag_info
, regnum
, value
));
308 COMMAND_HANDLER(arc_handle_get_aux_reg
)
311 return ERROR_COMMAND_SYNTAX_ERROR
;
313 struct target
*target
= get_current_target(CMD_CTX
);
315 command_print(CMD
, "No current target");
319 /* Register number */
321 COMMAND_PARSE_NUMBER(u32
, CMD_ARGV
[0], regnum
);
323 struct arc_common
*arc
= target_to_arc(target
);
327 CHECK_RETVAL(arc_jtag_read_aux_reg_one(&arc
->jtag_info
, regnum
, &value
));
329 command_print(CMD
, "0x%" PRIx32
, value
);
334 COMMAND_HANDLER(arc_handle_get_core_reg
)
337 return ERROR_COMMAND_SYNTAX_ERROR
;
339 struct target
*target
= get_current_target(CMD_CTX
);
341 command_print(CMD
, "No current target");
345 /* Register number */
347 COMMAND_PARSE_NUMBER(u32
, CMD_ARGV
[0], regnum
);
348 if (regnum
> CORE_REG_MAX_NUMBER
|| regnum
== ARC_R61
|| regnum
== ARC_R62
) {
349 command_print(CMD
, "Core register number %i "
350 "is invalid. Must less then 64 and not 61 and 62.", regnum
);
351 return ERROR_COMMAND_ARGUMENT_INVALID
;
354 struct arc_common
*arc
= target_to_arc(target
);
359 CHECK_RETVAL(arc_jtag_read_core_reg_one(&arc
->jtag_info
, regnum
, &value
));
361 command_print(CMD
, "0x%" PRIx32
, value
);
366 COMMAND_HANDLER(arc_handle_set_core_reg
)
369 return ERROR_COMMAND_SYNTAX_ERROR
;
371 struct target
*target
= get_current_target(CMD_CTX
);
373 command_print(CMD
, "No current target");
377 /* Register number */
379 COMMAND_PARSE_NUMBER(u32
, CMD_ARGV
[0], regnum
);
380 if (regnum
> CORE_REG_MAX_NUMBER
|| regnum
== ARC_R61
|| regnum
== ARC_R62
) {
381 command_print(CMD
, "Core register number %i "
382 "is invalid. Must less then 64 and not 61 and 62.", regnum
);
383 return ERROR_COMMAND_ARGUMENT_INVALID
;
388 COMMAND_PARSE_NUMBER(u32
, CMD_ARGV
[1], value
);
390 struct arc_common
*arc
= target_to_arc(target
);
393 CHECK_RETVAL(arc_jtag_write_core_reg_one(&arc
->jtag_info
, regnum
, value
));
398 static const struct command_registration arc_jtag_command_group
[] = {
400 .name
= "get-aux-reg",
401 .handler
= arc_handle_get_aux_reg
,
402 .mode
= COMMAND_EXEC
,
403 .help
= "Get AUX register by number. This command does a "
404 "raw JTAG request that bypasses OpenOCD register cache "
405 "and thus is unsafe and can have unexpected consequences. "
406 "Use at your own risk.",
410 .name
= "set-aux-reg",
411 .handler
= arc_handle_set_aux_reg
,
412 .mode
= COMMAND_EXEC
,
413 .help
= "Set AUX register by number. This command does a "
414 "raw JTAG request that bypasses OpenOCD register cache "
415 "and thus is unsafe and can have unexpected consequences. "
416 "Use at your own risk.",
417 .usage
= "<regnum> <value>"
420 .name
= "get-core-reg",
421 .handler
= arc_handle_get_core_reg
,
422 .mode
= COMMAND_EXEC
,
423 .help
= "Get/Set core register by number. This command does a "
424 "raw JTAG request that bypasses OpenOCD register cache "
425 "and thus is unsafe and can have unexpected consequences. "
426 "Use at your own risk.",
427 .usage
= "<regnum> [<value>]"
430 .name
= "set-core-reg",
431 .handler
= arc_handle_set_core_reg
,
432 .mode
= COMMAND_EXEC
,
433 .help
= "Get/Set core register by number. This command does a "
434 "raw JTAG request that bypasses OpenOCD register cache "
435 "and thus is unsafe and can have unexpected consequences. "
436 "Use at your own risk.",
437 .usage
= "<regnum> [<value>]"
439 COMMAND_REGISTRATION_DONE
443 /* This function supports only bitfields. */
444 static int jim_arc_add_reg_type_struct(Jim_Interp
*interp
, int argc
,
445 Jim_Obj
* const *argv
)
447 struct jim_getopt_info goi
;
448 JIM_CHECK_RETVAL(jim_getopt_setup(&goi
, interp
, argc
-1, argv
+1));
452 struct command_context
*ctx
;
453 struct target
*target
;
455 ctx
= current_command_context(interp
);
457 target
= get_current_target(ctx
);
459 Jim_SetResultFormatted(goi
.interp
, "No current target");
465 /* Check if the amount of arguments is not zero */
467 Jim_SetResultFormatted(goi
.interp
, "The command has no arguments");
471 /* Estimate number of registers as (argc - 2)/4 as each -bitfield option has 3
472 * arguments while -name is required. */
473 unsigned int fields_sz
= (goi
.argc
- 2) / 4;
474 unsigned int cur_field
= 0;
476 /* The maximum amount of bitfields is 32 */
477 if (fields_sz
> 32) {
478 Jim_SetResultFormatted(goi
.interp
, "The amount of bitfields exceed 32");
482 struct arc_reg_data_type
*type
= calloc(1, sizeof(*type
));
483 struct reg_data_type_struct
*struct_type
= &type
->data_type_struct
;
484 struct reg_data_type_struct_field
*fields
= calloc(fields_sz
, sizeof(*fields
));
485 type
->reg_type_struct_field
= fields
;
486 struct arc_reg_bitfield
*bitfields
= calloc(fields_sz
, sizeof(*bitfields
));
487 if (!(type
&& fields
&& bitfields
)) {
488 Jim_SetResultFormatted(goi
.interp
, "Failed to allocate memory.");
492 /* Initialize type */
493 type
->data_type
.id
= type
->data_type_id
;
494 type
->bitfields
= bitfields
;
495 type
->data_type
.type
= REG_TYPE_ARCH_DEFINED
;
496 type
->data_type
.type_class
= REG_TYPE_CLASS_STRUCT
;
497 type
->data_type
.reg_type_struct
= struct_type
;
498 struct_type
->size
= 4; /* For now ARC has only 32-bit registers */
500 while (goi
.argc
> 0 && e
== JIM_OK
) {
502 e
= jim_getopt_nvp(&goi
, nvp_add_reg_type_struct_opts
, &n
);
504 jim_getopt_nvp_unknown(&goi
, nvp_add_reg_type_struct_opts
, 0);
509 case CFG_ADD_REG_TYPE_STRUCT_NAME
:
511 const char *name
= NULL
;
514 e
= jim_arc_read_reg_name_field(&goi
, &name
, &name_len
);
516 Jim_SetResultFormatted(goi
.interp
, "Unable to read reg name.");
520 if (name_len
> REG_TYPE_MAX_NAME_LENGTH
) {
521 Jim_SetResultFormatted(goi
.interp
, "Reg type name is too big.");
525 strncpy((void *)type
->data_type
.id
, name
, name_len
);
526 if (!type
->data_type
.id
) {
527 Jim_SetResultFormatted(goi
.interp
, "Unable to setup reg type name.");
533 case CFG_ADD_REG_TYPE_STRUCT_BITFIELD
:
535 const char *field_name
= NULL
;
536 int field_name_len
= 0;
537 e
= jim_arc_read_reg_type_field(&goi
, &field_name
, &field_name_len
, bitfields
,
538 cur_field
, CFG_ADD_REG_TYPE_STRUCT
);
540 Jim_SetResultFormatted(goi
.interp
, "Unable to add reg_type_struct field.");
544 if (field_name_len
> REG_TYPE_MAX_NAME_LENGTH
) {
545 Jim_SetResultFormatted(goi
.interp
, "Reg type field_name_len is too big.");
549 fields
[cur_field
].name
= bitfields
[cur_field
].name
;
550 strncpy(bitfields
[cur_field
].name
, field_name
, field_name_len
);
551 if (!fields
[cur_field
].name
) {
552 Jim_SetResultFormatted(goi
.interp
, "Unable to setup field name. ");
556 fields
[cur_field
].bitfield
= &(bitfields
[cur_field
].bitfield
);
557 fields
[cur_field
].use_bitfields
= true;
559 fields
[cur_field
- 1].next
= &(fields
[cur_field
]);
561 struct_type
->fields
= fields
;
570 if (!type
->data_type
.id
) {
571 Jim_SetResultFormatted(goi
.interp
, "-name is a required option");
575 arc_reg_data_type_add(target
, type
);
576 LOG_DEBUG("added struct type {name=%s}", type
->data_type
.id
);
590 CFG_ADD_REG_ARCH_NUM
,
593 CFG_ADD_REG_GDB_FEATURE
,
598 static struct jim_nvp opts_nvp_add_reg
[] = {
599 { .name
= "-name", .value
= CFG_ADD_REG_NAME
},
600 { .name
= "-num", .value
= CFG_ADD_REG_ARCH_NUM
},
601 { .name
= "-core", .value
= CFG_ADD_REG_IS_CORE
},
602 { .name
= "-bcr", .value
= CFG_ADD_REG_IS_BCR
},
603 { .name
= "-feature", .value
= CFG_ADD_REG_GDB_FEATURE
},
604 { .name
= "-type", .value
= CFG_ADD_REG_TYPE
},
605 { .name
= "-g", .value
= CFG_ADD_REG_GENERAL
},
606 { .name
= NULL
, .value
= -1 }
609 void free_reg_desc(struct arc_reg_desc
*r
)
612 free(r
->gdb_xml_feature
);
616 static int jim_arc_add_reg(Jim_Interp
*interp
, int argc
, Jim_Obj
* const *argv
)
618 struct jim_getopt_info goi
;
619 JIM_CHECK_RETVAL(jim_getopt_setup(&goi
, interp
, argc
-1, argv
+1));
621 struct arc_reg_desc
*reg
= calloc(1, sizeof(*reg
));
623 Jim_SetResultFormatted(goi
.interp
, "Failed to allocate memory.");
627 /* There is no architecture number that we could treat as invalid, so
628 * separate variable required to ensure that arch num has been set. */
629 bool arch_num_set
= false;
630 const char *type_name
= "int"; /* Default type */
631 int type_name_len
= strlen(type_name
);
634 /* At least we need to specify 4 parameters: name, number and gdb_feature,
635 * which means there should be 6 arguments. Also there can be additional parameters
636 * "-type <type>", "-g" and "-core" or "-bcr" which makes maximum 10 parameters. */
637 if (goi
.argc
< 6 || goi
.argc
> 10) {
639 Jim_SetResultFormatted(goi
.interp
,
640 "Should be at least 6 arguments and not greater than 10: "
641 " -name <name> -num <num> -feature <gdb_feature> "
642 " [-type <type_name>] [-core|-bcr] [-g].");
647 while (goi
.argc
> 0) {
649 e
= jim_getopt_nvp(&goi
, opts_nvp_add_reg
, &n
);
651 jim_getopt_nvp_unknown(&goi
, opts_nvp_add_reg
, 0);
657 case CFG_ADD_REG_NAME
:
659 const char *reg_name
= NULL
;
660 int reg_name_len
= 0;
662 e
= jim_arc_read_reg_name_field(&goi
, ®_name
, ®_name_len
);
664 Jim_SetResultFormatted(goi
.interp
, "Unable to read register name.");
669 reg
->name
= strndup(reg_name
, reg_name_len
);
672 case CFG_ADD_REG_IS_CORE
:
675 case CFG_ADD_REG_IS_BCR
:
678 case CFG_ADD_REG_ARCH_NUM
:
684 Jim_WrongNumArgs(interp
, goi
.argc
, goi
.argv
, "-num <int> ...");
688 e
= jim_getopt_wide(&goi
, &archnum
);
694 reg
->arch_num
= archnum
;
698 case CFG_ADD_REG_GDB_FEATURE
:
700 const char *feature
= NULL
;
703 e
= jim_arc_read_reg_name_field(&goi
, &feature
, &feature_len
);
705 Jim_SetResultFormatted(goi
.interp
, "Unable to read gdb_feature.");
710 reg
->gdb_xml_feature
= strndup(feature
, feature_len
);
713 case CFG_ADD_REG_TYPE
:
714 e
= jim_arc_read_reg_name_field(&goi
, &type_name
, &type_name_len
);
716 Jim_SetResultFormatted(goi
.interp
, "Unable to read register type.");
722 case CFG_ADD_REG_GENERAL
:
723 reg
->is_general
= true;
726 LOG_DEBUG("Error: Unknown parameter");
732 /* Check that required fields are set */
733 const char * const errmsg
= validate_register(reg
, arch_num_set
);
735 Jim_SetResultFormatted(goi
.interp
, errmsg
);
740 /* Add new register */
741 struct command_context
*ctx
;
742 struct target
*target
;
744 ctx
= current_command_context(interp
);
746 target
= get_current_target(ctx
);
748 Jim_SetResultFormatted(goi
.interp
, "No current target");
753 reg
->target
= target
;
755 e
= arc_reg_add(target
, reg
, type_name
, type_name_len
);
756 if (e
== ERROR_ARC_REGTYPE_NOT_FOUND
) {
757 Jim_SetResultFormatted(goi
.interp
,
758 "Cannot find type `%s' for register `%s'.",
759 type_name
, reg
->name
);
767 /* arc set-reg-exists ($reg_name)+
768 * Accepts any amount of register names - will set them as existing in a loop.*/
769 COMMAND_HANDLER(arc_set_reg_exists
)
771 struct target
* const target
= get_current_target(CMD_CTX
);
773 command_print(CMD
, "Unable to get current target.");
778 command_print(CMD
, "At least one register name must be specified.");
779 return ERROR_COMMAND_SYNTAX_ERROR
;
782 for (unsigned int i
= 0; i
< CMD_ARGC
; i
++) {
783 const char * const reg_name
= CMD_ARGV
[i
];
784 struct reg
* const r
= arc_reg_get_by_name(target
->reg_cache
, reg_name
, true);
787 command_print(CMD
, "Register `%s' is not found.", reg_name
);
788 return ERROR_COMMAND_ARGUMENT_INVALID
;
797 /* arc reg-field ($reg_name) ($reg_field)
798 * Reads struct type register field */
799 static int jim_arc_get_reg_field(Jim_Interp
*interp
, int argc
, Jim_Obj
* const *argv
)
801 struct jim_getopt_info goi
;
802 const char *reg_name
, *field_name
;
806 JIM_CHECK_RETVAL(jim_getopt_setup(&goi
, interp
, argc
-1, argv
+1));
808 LOG_DEBUG("Reading register field");
811 Jim_WrongNumArgs(interp
, goi
.argc
, goi
.argv
, "<regname> <fieldname>");
812 else if (goi
.argc
== 1)
813 Jim_WrongNumArgs(interp
, goi
.argc
, goi
.argv
, "<fieldname>");
815 Jim_WrongNumArgs(interp
, goi
.argc
, goi
.argv
, "<regname> <fieldname>");
816 return ERROR_COMMAND_SYNTAX_ERROR
;
819 JIM_CHECK_RETVAL(jim_getopt_string(&goi
, ®_name
, NULL
));
820 JIM_CHECK_RETVAL(jim_getopt_string(&goi
, &field_name
, NULL
));
824 struct command_context
* const ctx
= current_command_context(interp
);
826 struct target
* const target
= get_current_target(ctx
);
828 Jim_SetResultFormatted(goi
.interp
, "No current target");
832 retval
= arc_reg_get_field(target
, reg_name
, field_name
, &value
);
837 case ERROR_ARC_REGISTER_NOT_FOUND
:
838 Jim_SetResultFormatted(goi
.interp
,
839 "Register `%s' has not been found.", reg_name
);
840 return ERROR_COMMAND_ARGUMENT_INVALID
;
841 case ERROR_ARC_REGISTER_IS_NOT_STRUCT
:
842 Jim_SetResultFormatted(goi
.interp
,
843 "Register `%s' must have 'struct' type.", reg_name
);
844 return ERROR_COMMAND_ARGUMENT_INVALID
;
845 case ERROR_ARC_REGISTER_FIELD_NOT_FOUND
:
846 Jim_SetResultFormatted(goi
.interp
,
847 "Field `%s' has not been found in register `%s'.",
848 field_name
, reg_name
);
849 return ERROR_COMMAND_ARGUMENT_INVALID
;
850 case ERROR_ARC_FIELD_IS_NOT_BITFIELD
:
851 Jim_SetResultFormatted(goi
.interp
,
852 "Field `%s' is not a 'bitfield' field in a structure.",
854 return ERROR_COMMAND_ARGUMENT_INVALID
;
856 /* Pass through other errors. */
860 Jim_SetResultInt(interp
, value
);
865 COMMAND_HANDLER(arc_l1_cache_disable_auto_cmd
)
869 struct arc_common
*arc
= target_to_arc(get_current_target(CMD_CTX
));
870 retval
= CALL_COMMAND_HANDLER(handle_command_parse_bool
,
871 &value
, "target has caches enabled");
872 arc
->has_l2cache
= value
;
873 arc
->has_dcache
= value
;
874 arc
->has_icache
= value
;
878 COMMAND_HANDLER(arc_l2_cache_disable_auto_cmd
)
880 struct arc_common
*arc
= target_to_arc(get_current_target(CMD_CTX
));
881 return CALL_COMMAND_HANDLER(handle_command_parse_bool
,
882 &arc
->has_l2cache
, "target has l2 cache enabled");
885 static int jim_handle_actionpoints_num(Jim_Interp
*interp
, int argc
,
886 Jim_Obj
* const *argv
)
888 struct jim_getopt_info goi
;
889 jim_getopt_setup(&goi
, interp
, argc
- 1, argv
+ 1);
894 Jim_WrongNumArgs(interp
, goi
.argc
, goi
.argv
, "[<unsigned integer>]");
898 struct command_context
*context
= current_command_context(interp
);
901 struct target
*target
= get_current_target(context
);
904 Jim_SetResultFormatted(goi
.interp
, "No current target");
908 struct arc_common
*arc
= target_to_arc(target
);
909 /* It is not possible to pass &arc->actionpoints_num directly to
910 * handle_command_parse_uint, because this value should be valid during
911 * "actionpoint reset, initiated by arc_set_actionpoints_num. */
912 uint32_t ap_num
= arc
->actionpoints_num
;
915 JIM_CHECK_RETVAL(arc_cmd_jim_get_uint32(&goi
, &ap_num
));
916 int e
= arc_set_actionpoints_num(target
, ap_num
);
918 Jim_SetResultFormatted(goi
.interp
,
919 "Failed to set number of actionpoints");
924 Jim_SetResultInt(interp
, ap_num
);
929 /* ----- Exported target commands ------------------------------------------ */
931 static const struct command_registration arc_l2_cache_group_handlers
[] = {
934 .handler
= arc_l2_cache_disable_auto_cmd
,
937 .help
= "Disable or enable L2",
939 COMMAND_REGISTRATION_DONE
942 static const struct command_registration arc_cache_group_handlers
[] = {
945 .handler
= arc_l1_cache_disable_auto_cmd
,
947 .help
= "Disable or enable L1",
953 .help
= "L2 cache command group",
955 .chain
= arc_l2_cache_group_handlers
,
957 COMMAND_REGISTRATION_DONE
961 static const struct command_registration arc_core_command_handlers
[] = {
963 .name
= "add-reg-type-flags",
964 .jim_handler
= jim_arc_add_reg_type_flags
,
965 .mode
= COMMAND_CONFIG
,
966 .usage
= "-name <string> -flag <name> <position> "
967 "[-flag <name> <position>]...",
968 .help
= "Add new 'flags' register data type. Only single bit flags "
969 "are supported. Type name is global. Bitsize of register is fixed "
973 .name
= "add-reg-type-struct",
974 .jim_handler
= jim_arc_add_reg_type_struct
,
975 .mode
= COMMAND_CONFIG
,
976 .usage
= "-name <string> -bitfield <name> <start> <end> "
977 "[-bitfield <name> <start> <end>]...",
978 .help
= "Add new 'struct' register data type. Only bit-fields are "
979 "supported so far, which means that for each bitfield start and end "
980 "position bits must be specified. GDB also support type-fields, "
981 "where common type can be used instead. Type name is global. Bitsize of "
982 "register is fixed at 32 bits.",
986 .jim_handler
= jim_arc_add_reg
,
987 .mode
= COMMAND_CONFIG
,
988 .usage
= "-name <string> -num <int> -feature <string> [-gdbnum <int>] "
989 "[-core|-bcr] [-type <type_name>] [-g]",
990 .help
= "Add new register. Name, architectural number and feature name "
991 "are required options. GDB regnum will default to previous register "
992 "(gdbnum + 1) and shouldn't be specified in most cases. Type "
993 "defaults to default GDB 'int'.",
996 .name
= "set-reg-exists",
997 .handler
= arc_set_reg_exists
,
999 .usage
= "<register-name> [<register-name>]...",
1000 .help
= "Set that register exists. Accepts multiple register names as "
1004 .name
= "get-reg-field",
1005 .jim_handler
= jim_arc_get_reg_field
,
1006 .mode
= COMMAND_ANY
,
1007 .usage
= "<regname> <field_name>",
1008 .help
= "Returns value of field in a register with 'struct' type.",
1012 .mode
= COMMAND_ANY
,
1013 .help
= "ARC JTAG specific commands",
1015 .chain
= arc_jtag_command_group
,
1019 .mode
= COMMAND_ANY
,
1020 .help
= "cache command group",
1022 .chain
= arc_cache_group_handlers
,
1025 .name
= "num-actionpoints",
1026 .jim_handler
= jim_handle_actionpoints_num
,
1027 .mode
= COMMAND_ANY
,
1028 .usage
= "[<unsigned integer>]",
1029 .help
= "Prints or sets amount of actionpoints in the processor.",
1031 COMMAND_REGISTRATION_DONE
1034 const struct command_registration arc_monitor_command_handlers
[] = {
1037 .mode
= COMMAND_ANY
,
1038 .help
= "ARC monitor command group",
1040 .chain
= arc_core_command_handlers
,
1042 COMMAND_REGISTRATION_DONE
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)