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 static int jim_arc_set_core_reg(Jim_Interp
*interp
, int argc
, Jim_Obj
* const *argv
)
368 struct command_context
*context
;
369 struct target
*target
;
373 struct jim_getopt_info goi
;
374 JIM_CHECK_RETVAL(jim_getopt_setup(&goi
, interp
, argc
-1, argv
+1));
377 Jim_SetResultFormatted(goi
.interp
,
378 "usage: %s <core_reg_num> <core_reg_value>", Jim_GetString(argv
[0], NULL
));
382 context
= current_command_context(interp
);
385 target
= get_current_target(context
);
387 Jim_SetResultFormatted(goi
.interp
, "No current target");
391 /* Register number */
392 JIM_CHECK_RETVAL(arc_cmd_jim_get_uint32(&goi
, ®num
));
393 if (regnum
> CORE_REG_MAX_NUMBER
|| regnum
== ARC_R61
|| regnum
== ARC_R62
) {
394 Jim_SetResultFormatted(goi
.interp
, "Core register number %i "
395 "is invalid. Must less then 64 and not 61 and 62.", regnum
);
400 JIM_CHECK_RETVAL(arc_cmd_jim_get_uint32(&goi
, &value
));
402 struct arc_common
*arc
= target_to_arc(target
);
405 CHECK_RETVAL(arc_jtag_write_core_reg_one(&arc
->jtag_info
, regnum
, value
));
410 static const struct command_registration arc_jtag_command_group
[] = {
412 .name
= "get-aux-reg",
413 .handler
= arc_handle_get_aux_reg
,
414 .mode
= COMMAND_EXEC
,
415 .help
= "Get AUX register by number. This command does a "
416 "raw JTAG request that bypasses OpenOCD register cache "
417 "and thus is unsafe and can have unexpected consequences. "
418 "Use at your own risk.",
422 .name
= "set-aux-reg",
423 .handler
= arc_handle_set_aux_reg
,
424 .mode
= COMMAND_EXEC
,
425 .help
= "Set AUX register by number. This command does a "
426 "raw JTAG request that bypasses OpenOCD register cache "
427 "and thus is unsafe and can have unexpected consequences. "
428 "Use at your own risk.",
429 .usage
= "<regnum> <value>"
432 .name
= "get-core-reg",
433 .handler
= arc_handle_get_core_reg
,
434 .mode
= COMMAND_EXEC
,
435 .help
= "Get/Set core register by number. This command does a "
436 "raw JTAG request that bypasses OpenOCD register cache "
437 "and thus is unsafe and can have unexpected consequences. "
438 "Use at your own risk.",
439 .usage
= "<regnum> [<value>]"
442 .name
= "set-core-reg",
443 .jim_handler
= jim_arc_set_core_reg
,
444 .mode
= COMMAND_EXEC
,
445 .help
= "Get/Set core register by number. This command does a "
446 "raw JTAG request that bypasses OpenOCD register cache "
447 "and thus is unsafe and can have unexpected consequences. "
448 "Use at your own risk.",
449 .usage
= "<regnum> [<value>]"
451 COMMAND_REGISTRATION_DONE
455 /* This function supports only bitfields. */
456 static int jim_arc_add_reg_type_struct(Jim_Interp
*interp
, int argc
,
457 Jim_Obj
* const *argv
)
459 struct jim_getopt_info goi
;
460 JIM_CHECK_RETVAL(jim_getopt_setup(&goi
, interp
, argc
-1, argv
+1));
464 struct command_context
*ctx
;
465 struct target
*target
;
467 ctx
= current_command_context(interp
);
469 target
= get_current_target(ctx
);
471 Jim_SetResultFormatted(goi
.interp
, "No current target");
477 /* Check if the amount of arguments is not zero */
479 Jim_SetResultFormatted(goi
.interp
, "The command has no arguments");
483 /* Estimate number of registers as (argc - 2)/4 as each -bitfield option has 3
484 * arguments while -name is required. */
485 unsigned int fields_sz
= (goi
.argc
- 2) / 4;
486 unsigned int cur_field
= 0;
488 /* The maximum amount of bitfields is 32 */
489 if (fields_sz
> 32) {
490 Jim_SetResultFormatted(goi
.interp
, "The amount of bitfields exceed 32");
494 struct arc_reg_data_type
*type
= calloc(1, sizeof(*type
));
495 struct reg_data_type_struct
*struct_type
= &type
->data_type_struct
;
496 struct reg_data_type_struct_field
*fields
= calloc(fields_sz
, sizeof(*fields
));
497 type
->reg_type_struct_field
= fields
;
498 struct arc_reg_bitfield
*bitfields
= calloc(fields_sz
, sizeof(*bitfields
));
499 if (!(type
&& fields
&& bitfields
)) {
500 Jim_SetResultFormatted(goi
.interp
, "Failed to allocate memory.");
504 /* Initialize type */
505 type
->data_type
.id
= type
->data_type_id
;
506 type
->bitfields
= bitfields
;
507 type
->data_type
.type
= REG_TYPE_ARCH_DEFINED
;
508 type
->data_type
.type_class
= REG_TYPE_CLASS_STRUCT
;
509 type
->data_type
.reg_type_struct
= struct_type
;
510 struct_type
->size
= 4; /* For now ARC has only 32-bit registers */
512 while (goi
.argc
> 0 && e
== JIM_OK
) {
514 e
= jim_getopt_nvp(&goi
, nvp_add_reg_type_struct_opts
, &n
);
516 jim_getopt_nvp_unknown(&goi
, nvp_add_reg_type_struct_opts
, 0);
521 case CFG_ADD_REG_TYPE_STRUCT_NAME
:
523 const char *name
= NULL
;
526 e
= jim_arc_read_reg_name_field(&goi
, &name
, &name_len
);
528 Jim_SetResultFormatted(goi
.interp
, "Unable to read reg name.");
532 if (name_len
> REG_TYPE_MAX_NAME_LENGTH
) {
533 Jim_SetResultFormatted(goi
.interp
, "Reg type name is too big.");
537 strncpy((void *)type
->data_type
.id
, name
, name_len
);
538 if (!type
->data_type
.id
) {
539 Jim_SetResultFormatted(goi
.interp
, "Unable to setup reg type name.");
545 case CFG_ADD_REG_TYPE_STRUCT_BITFIELD
:
547 const char *field_name
= NULL
;
548 int field_name_len
= 0;
549 e
= jim_arc_read_reg_type_field(&goi
, &field_name
, &field_name_len
, bitfields
,
550 cur_field
, CFG_ADD_REG_TYPE_STRUCT
);
552 Jim_SetResultFormatted(goi
.interp
, "Unable to add reg_type_struct field.");
556 if (field_name_len
> REG_TYPE_MAX_NAME_LENGTH
) {
557 Jim_SetResultFormatted(goi
.interp
, "Reg type field_name_len is too big.");
561 fields
[cur_field
].name
= bitfields
[cur_field
].name
;
562 strncpy(bitfields
[cur_field
].name
, field_name
, field_name_len
);
563 if (!fields
[cur_field
].name
) {
564 Jim_SetResultFormatted(goi
.interp
, "Unable to setup field name. ");
568 fields
[cur_field
].bitfield
= &(bitfields
[cur_field
].bitfield
);
569 fields
[cur_field
].use_bitfields
= true;
571 fields
[cur_field
- 1].next
= &(fields
[cur_field
]);
573 struct_type
->fields
= fields
;
582 if (!type
->data_type
.id
) {
583 Jim_SetResultFormatted(goi
.interp
, "-name is a required option");
587 arc_reg_data_type_add(target
, type
);
588 LOG_DEBUG("added struct type {name=%s}", type
->data_type
.id
);
602 CFG_ADD_REG_ARCH_NUM
,
605 CFG_ADD_REG_GDB_FEATURE
,
610 static struct jim_nvp opts_nvp_add_reg
[] = {
611 { .name
= "-name", .value
= CFG_ADD_REG_NAME
},
612 { .name
= "-num", .value
= CFG_ADD_REG_ARCH_NUM
},
613 { .name
= "-core", .value
= CFG_ADD_REG_IS_CORE
},
614 { .name
= "-bcr", .value
= CFG_ADD_REG_IS_BCR
},
615 { .name
= "-feature", .value
= CFG_ADD_REG_GDB_FEATURE
},
616 { .name
= "-type", .value
= CFG_ADD_REG_TYPE
},
617 { .name
= "-g", .value
= CFG_ADD_REG_GENERAL
},
618 { .name
= NULL
, .value
= -1 }
621 void free_reg_desc(struct arc_reg_desc
*r
)
624 free(r
->gdb_xml_feature
);
628 static int jim_arc_add_reg(Jim_Interp
*interp
, int argc
, Jim_Obj
* const *argv
)
630 struct jim_getopt_info goi
;
631 JIM_CHECK_RETVAL(jim_getopt_setup(&goi
, interp
, argc
-1, argv
+1));
633 struct arc_reg_desc
*reg
= calloc(1, sizeof(*reg
));
635 Jim_SetResultFormatted(goi
.interp
, "Failed to allocate memory.");
639 /* There is no architecture number that we could treat as invalid, so
640 * separate variable required to ensure that arch num has been set. */
641 bool arch_num_set
= false;
642 const char *type_name
= "int"; /* Default type */
643 int type_name_len
= strlen(type_name
);
646 /* At least we need to specify 4 parameters: name, number and gdb_feature,
647 * which means there should be 6 arguments. Also there can be additional parameters
648 * "-type <type>", "-g" and "-core" or "-bcr" which makes maximum 10 parameters. */
649 if (goi
.argc
< 6 || goi
.argc
> 10) {
651 Jim_SetResultFormatted(goi
.interp
,
652 "Should be at least 6 arguments and not greater than 10: "
653 " -name <name> -num <num> -feature <gdb_feature> "
654 " [-type <type_name>] [-core|-bcr] [-g].");
659 while (goi
.argc
> 0) {
661 e
= jim_getopt_nvp(&goi
, opts_nvp_add_reg
, &n
);
663 jim_getopt_nvp_unknown(&goi
, opts_nvp_add_reg
, 0);
669 case CFG_ADD_REG_NAME
:
671 const char *reg_name
= NULL
;
672 int reg_name_len
= 0;
674 e
= jim_arc_read_reg_name_field(&goi
, ®_name
, ®_name_len
);
676 Jim_SetResultFormatted(goi
.interp
, "Unable to read register name.");
681 reg
->name
= strndup(reg_name
, reg_name_len
);
684 case CFG_ADD_REG_IS_CORE
:
687 case CFG_ADD_REG_IS_BCR
:
690 case CFG_ADD_REG_ARCH_NUM
:
696 Jim_WrongNumArgs(interp
, goi
.argc
, goi
.argv
, "-num <int> ...");
700 e
= jim_getopt_wide(&goi
, &archnum
);
706 reg
->arch_num
= archnum
;
710 case CFG_ADD_REG_GDB_FEATURE
:
712 const char *feature
= NULL
;
715 e
= jim_arc_read_reg_name_field(&goi
, &feature
, &feature_len
);
717 Jim_SetResultFormatted(goi
.interp
, "Unable to read gdb_feature.");
722 reg
->gdb_xml_feature
= strndup(feature
, feature_len
);
725 case CFG_ADD_REG_TYPE
:
726 e
= jim_arc_read_reg_name_field(&goi
, &type_name
, &type_name_len
);
728 Jim_SetResultFormatted(goi
.interp
, "Unable to read register type.");
734 case CFG_ADD_REG_GENERAL
:
735 reg
->is_general
= true;
738 LOG_DEBUG("Error: Unknown parameter");
744 /* Check that required fields are set */
745 const char * const errmsg
= validate_register(reg
, arch_num_set
);
747 Jim_SetResultFormatted(goi
.interp
, errmsg
);
752 /* Add new register */
753 struct command_context
*ctx
;
754 struct target
*target
;
756 ctx
= current_command_context(interp
);
758 target
= get_current_target(ctx
);
760 Jim_SetResultFormatted(goi
.interp
, "No current target");
765 reg
->target
= target
;
767 e
= arc_reg_add(target
, reg
, type_name
, type_name_len
);
768 if (e
== ERROR_ARC_REGTYPE_NOT_FOUND
) {
769 Jim_SetResultFormatted(goi
.interp
,
770 "Cannot find type `%s' for register `%s'.",
771 type_name
, reg
->name
);
779 /* arc set-reg-exists ($reg_name)+
780 * Accepts any amount of register names - will set them as existing in a loop.*/
781 COMMAND_HANDLER(arc_set_reg_exists
)
783 struct target
* const target
= get_current_target(CMD_CTX
);
785 command_print(CMD
, "Unable to get current target.");
790 command_print(CMD
, "At least one register name must be specified.");
791 return ERROR_COMMAND_SYNTAX_ERROR
;
794 for (unsigned int i
= 0; i
< CMD_ARGC
; i
++) {
795 const char * const reg_name
= CMD_ARGV
[i
];
796 struct reg
* const r
= arc_reg_get_by_name(target
->reg_cache
, reg_name
, true);
799 command_print(CMD
, "Register `%s' is not found.", reg_name
);
800 return ERROR_COMMAND_ARGUMENT_INVALID
;
809 /* arc reg-field ($reg_name) ($reg_field)
810 * Reads struct type register field */
811 static int jim_arc_get_reg_field(Jim_Interp
*interp
, int argc
, Jim_Obj
* const *argv
)
813 struct jim_getopt_info goi
;
814 const char *reg_name
, *field_name
;
818 JIM_CHECK_RETVAL(jim_getopt_setup(&goi
, interp
, argc
-1, argv
+1));
820 LOG_DEBUG("Reading register field");
823 Jim_WrongNumArgs(interp
, goi
.argc
, goi
.argv
, "<regname> <fieldname>");
824 else if (goi
.argc
== 1)
825 Jim_WrongNumArgs(interp
, goi
.argc
, goi
.argv
, "<fieldname>");
827 Jim_WrongNumArgs(interp
, goi
.argc
, goi
.argv
, "<regname> <fieldname>");
828 return ERROR_COMMAND_SYNTAX_ERROR
;
831 JIM_CHECK_RETVAL(jim_getopt_string(&goi
, ®_name
, NULL
));
832 JIM_CHECK_RETVAL(jim_getopt_string(&goi
, &field_name
, NULL
));
836 struct command_context
* const ctx
= current_command_context(interp
);
838 struct target
* const target
= get_current_target(ctx
);
840 Jim_SetResultFormatted(goi
.interp
, "No current target");
844 retval
= arc_reg_get_field(target
, reg_name
, field_name
, &value
);
849 case ERROR_ARC_REGISTER_NOT_FOUND
:
850 Jim_SetResultFormatted(goi
.interp
,
851 "Register `%s' has not been found.", reg_name
);
852 return ERROR_COMMAND_ARGUMENT_INVALID
;
853 case ERROR_ARC_REGISTER_IS_NOT_STRUCT
:
854 Jim_SetResultFormatted(goi
.interp
,
855 "Register `%s' must have 'struct' type.", reg_name
);
856 return ERROR_COMMAND_ARGUMENT_INVALID
;
857 case ERROR_ARC_REGISTER_FIELD_NOT_FOUND
:
858 Jim_SetResultFormatted(goi
.interp
,
859 "Field `%s' has not been found in register `%s'.",
860 field_name
, reg_name
);
861 return ERROR_COMMAND_ARGUMENT_INVALID
;
862 case ERROR_ARC_FIELD_IS_NOT_BITFIELD
:
863 Jim_SetResultFormatted(goi
.interp
,
864 "Field `%s' is not a 'bitfield' field in a structure.",
866 return ERROR_COMMAND_ARGUMENT_INVALID
;
868 /* Pass through other errors. */
872 Jim_SetResultInt(interp
, value
);
877 COMMAND_HANDLER(arc_l1_cache_disable_auto_cmd
)
881 struct arc_common
*arc
= target_to_arc(get_current_target(CMD_CTX
));
882 retval
= CALL_COMMAND_HANDLER(handle_command_parse_bool
,
883 &value
, "target has caches enabled");
884 arc
->has_l2cache
= value
;
885 arc
->has_dcache
= value
;
886 arc
->has_icache
= value
;
890 COMMAND_HANDLER(arc_l2_cache_disable_auto_cmd
)
892 struct arc_common
*arc
= target_to_arc(get_current_target(CMD_CTX
));
893 return CALL_COMMAND_HANDLER(handle_command_parse_bool
,
894 &arc
->has_l2cache
, "target has l2 cache enabled");
897 static int jim_handle_actionpoints_num(Jim_Interp
*interp
, int argc
,
898 Jim_Obj
* const *argv
)
900 struct jim_getopt_info goi
;
901 jim_getopt_setup(&goi
, interp
, argc
- 1, argv
+ 1);
906 Jim_WrongNumArgs(interp
, goi
.argc
, goi
.argv
, "[<unsigned integer>]");
910 struct command_context
*context
= current_command_context(interp
);
913 struct target
*target
= get_current_target(context
);
916 Jim_SetResultFormatted(goi
.interp
, "No current target");
920 struct arc_common
*arc
= target_to_arc(target
);
921 /* It is not possible to pass &arc->actionpoints_num directly to
922 * handle_command_parse_uint, because this value should be valid during
923 * "actionpoint reset, initiated by arc_set_actionpoints_num. */
924 uint32_t ap_num
= arc
->actionpoints_num
;
927 JIM_CHECK_RETVAL(arc_cmd_jim_get_uint32(&goi
, &ap_num
));
928 int e
= arc_set_actionpoints_num(target
, ap_num
);
930 Jim_SetResultFormatted(goi
.interp
,
931 "Failed to set number of actionpoints");
936 Jim_SetResultInt(interp
, ap_num
);
941 /* ----- Exported target commands ------------------------------------------ */
943 static const struct command_registration arc_l2_cache_group_handlers
[] = {
946 .handler
= arc_l2_cache_disable_auto_cmd
,
949 .help
= "Disable or enable L2",
951 COMMAND_REGISTRATION_DONE
954 static const struct command_registration arc_cache_group_handlers
[] = {
957 .handler
= arc_l1_cache_disable_auto_cmd
,
959 .help
= "Disable or enable L1",
965 .help
= "L2 cache command group",
967 .chain
= arc_l2_cache_group_handlers
,
969 COMMAND_REGISTRATION_DONE
973 static const struct command_registration arc_core_command_handlers
[] = {
975 .name
= "add-reg-type-flags",
976 .jim_handler
= jim_arc_add_reg_type_flags
,
977 .mode
= COMMAND_CONFIG
,
978 .usage
= "-name <string> -flag <name> <position> "
979 "[-flag <name> <position>]...",
980 .help
= "Add new 'flags' register data type. Only single bit flags "
981 "are supported. Type name is global. Bitsize of register is fixed "
985 .name
= "add-reg-type-struct",
986 .jim_handler
= jim_arc_add_reg_type_struct
,
987 .mode
= COMMAND_CONFIG
,
988 .usage
= "-name <string> -bitfield <name> <start> <end> "
989 "[-bitfield <name> <start> <end>]...",
990 .help
= "Add new 'struct' register data type. Only bit-fields are "
991 "supported so far, which means that for each bitfield start and end "
992 "position bits must be specified. GDB also support type-fields, "
993 "where common type can be used instead. Type name is global. Bitsize of "
994 "register is fixed at 32 bits.",
998 .jim_handler
= jim_arc_add_reg
,
999 .mode
= COMMAND_CONFIG
,
1000 .usage
= "-name <string> -num <int> -feature <string> [-gdbnum <int>] "
1001 "[-core|-bcr] [-type <type_name>] [-g]",
1002 .help
= "Add new register. Name, architectural number and feature name "
1003 "are required options. GDB regnum will default to previous register "
1004 "(gdbnum + 1) and shouldn't be specified in most cases. Type "
1005 "defaults to default GDB 'int'.",
1008 .name
= "set-reg-exists",
1009 .handler
= arc_set_reg_exists
,
1010 .mode
= COMMAND_ANY
,
1011 .usage
= "<register-name> [<register-name>]...",
1012 .help
= "Set that register exists. Accepts multiple register names as "
1016 .name
= "get-reg-field",
1017 .jim_handler
= jim_arc_get_reg_field
,
1018 .mode
= COMMAND_ANY
,
1019 .usage
= "<regname> <field_name>",
1020 .help
= "Returns value of field in a register with 'struct' type.",
1024 .mode
= COMMAND_ANY
,
1025 .help
= "ARC JTAG specific commands",
1027 .chain
= arc_jtag_command_group
,
1031 .mode
= COMMAND_ANY
,
1032 .help
= "cache command group",
1034 .chain
= arc_cache_group_handlers
,
1037 .name
= "num-actionpoints",
1038 .jim_handler
= jim_handle_actionpoints_num
,
1039 .mode
= COMMAND_ANY
,
1040 .usage
= "[<unsigned integer>]",
1041 .help
= "Prints or sets amount of actionpoints in the processor.",
1043 COMMAND_REGISTRATION_DONE
1046 const struct command_registration arc_monitor_command_handlers
[] = {
1049 .mode
= COMMAND_ANY
,
1050 .help
= "ARC monitor command group",
1052 .chain
= arc_core_command_handlers
,
1054 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)