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 static int jim_arc_set_aux_reg(Jim_Interp
*interp
, int argc
, Jim_Obj
* const *argv
)
284 struct command_context
*context
;
285 struct target
*target
;
289 struct jim_getopt_info goi
;
290 JIM_CHECK_RETVAL(jim_getopt_setup(&goi
, interp
, argc
-1, argv
+1));
293 Jim_SetResultFormatted(goi
.interp
,
294 "usage: %s <aux_reg_num> <aux_reg_value>", Jim_GetString(argv
[0], NULL
));
298 context
= current_command_context(interp
);
301 target
= get_current_target(context
);
303 Jim_SetResultFormatted(goi
.interp
, "No current target");
307 /* Register number */
308 JIM_CHECK_RETVAL(arc_cmd_jim_get_uint32(&goi
, ®num
));
311 JIM_CHECK_RETVAL(arc_cmd_jim_get_uint32(&goi
, &value
));
313 struct arc_common
*arc
= target_to_arc(target
);
316 CHECK_RETVAL(arc_jtag_write_aux_reg_one(&arc
->jtag_info
, regnum
, value
));
321 COMMAND_HANDLER(arc_handle_get_aux_reg
)
324 return ERROR_COMMAND_SYNTAX_ERROR
;
326 struct target
*target
= get_current_target(CMD_CTX
);
328 command_print(CMD
, "No current target");
332 /* Register number */
334 COMMAND_PARSE_NUMBER(u32
, CMD_ARGV
[0], regnum
);
336 struct arc_common
*arc
= target_to_arc(target
);
340 CHECK_RETVAL(arc_jtag_read_aux_reg_one(&arc
->jtag_info
, regnum
, &value
));
342 command_print(CMD
, "0x%" PRIx32
, value
);
347 static int jim_arc_get_core_reg(Jim_Interp
*interp
, int argc
, Jim_Obj
* const *argv
)
349 struct command_context
*context
;
350 struct target
*target
;
354 struct jim_getopt_info goi
;
355 JIM_CHECK_RETVAL(jim_getopt_setup(&goi
, interp
, argc
-1, argv
+1));
358 Jim_SetResultFormatted(goi
.interp
,
359 "usage: %s <core_reg_num>", Jim_GetString(argv
[0], NULL
));
363 context
= current_command_context(interp
);
366 target
= get_current_target(context
);
368 Jim_SetResultFormatted(goi
.interp
, "No current target");
372 /* Register number */
373 JIM_CHECK_RETVAL(arc_cmd_jim_get_uint32(&goi
, ®num
));
374 if (regnum
> CORE_REG_MAX_NUMBER
|| regnum
== ARC_R61
|| regnum
== ARC_R62
) {
375 Jim_SetResultFormatted(goi
.interp
, "Core register number %i "
376 "is invalid. Must less then 64 and not 61 and 62.", regnum
);
380 struct arc_common
*arc
= target_to_arc(target
);
384 CHECK_RETVAL(arc_jtag_read_core_reg_one(&arc
->jtag_info
, regnum
, &value
));
385 Jim_SetResultInt(interp
, value
);
390 static int jim_arc_set_core_reg(Jim_Interp
*interp
, int argc
, Jim_Obj
* const *argv
)
392 struct command_context
*context
;
393 struct target
*target
;
397 struct jim_getopt_info goi
;
398 JIM_CHECK_RETVAL(jim_getopt_setup(&goi
, interp
, argc
-1, argv
+1));
401 Jim_SetResultFormatted(goi
.interp
,
402 "usage: %s <core_reg_num> <core_reg_value>", Jim_GetString(argv
[0], NULL
));
406 context
= current_command_context(interp
);
409 target
= get_current_target(context
);
411 Jim_SetResultFormatted(goi
.interp
, "No current target");
415 /* Register number */
416 JIM_CHECK_RETVAL(arc_cmd_jim_get_uint32(&goi
, ®num
));
417 if (regnum
> CORE_REG_MAX_NUMBER
|| regnum
== ARC_R61
|| regnum
== ARC_R62
) {
418 Jim_SetResultFormatted(goi
.interp
, "Core register number %i "
419 "is invalid. Must less then 64 and not 61 and 62.", regnum
);
424 JIM_CHECK_RETVAL(arc_cmd_jim_get_uint32(&goi
, &value
));
426 struct arc_common
*arc
= target_to_arc(target
);
429 CHECK_RETVAL(arc_jtag_write_core_reg_one(&arc
->jtag_info
, regnum
, value
));
434 static const struct command_registration arc_jtag_command_group
[] = {
436 .name
= "get-aux-reg",
437 .handler
= arc_handle_get_aux_reg
,
438 .mode
= COMMAND_EXEC
,
439 .help
= "Get AUX register by number. This command does a "
440 "raw JTAG request that bypasses OpenOCD register cache "
441 "and thus is unsafe and can have unexpected consequences. "
442 "Use at your own risk.",
446 .name
= "set-aux-reg",
447 .jim_handler
= jim_arc_set_aux_reg
,
448 .mode
= COMMAND_EXEC
,
449 .help
= "Set AUX register by number. This command does a "
450 "raw JTAG request that bypasses OpenOCD register cache "
451 "and thus is unsafe and can have unexpected consequences. "
452 "Use at your own risk.",
453 .usage
= "<regnum> <value>"
456 .name
= "get-core-reg",
457 .jim_handler
= jim_arc_get_core_reg
,
458 .mode
= COMMAND_EXEC
,
459 .help
= "Get/Set core register by number. This command does a "
460 "raw JTAG request that bypasses OpenOCD register cache "
461 "and thus is unsafe and can have unexpected consequences. "
462 "Use at your own risk.",
463 .usage
= "<regnum> [<value>]"
466 .name
= "set-core-reg",
467 .jim_handler
= jim_arc_set_core_reg
,
468 .mode
= COMMAND_EXEC
,
469 .help
= "Get/Set core register by number. This command does a "
470 "raw JTAG request that bypasses OpenOCD register cache "
471 "and thus is unsafe and can have unexpected consequences. "
472 "Use at your own risk.",
473 .usage
= "<regnum> [<value>]"
475 COMMAND_REGISTRATION_DONE
479 /* This function supports only bitfields. */
480 static int jim_arc_add_reg_type_struct(Jim_Interp
*interp
, int argc
,
481 Jim_Obj
* const *argv
)
483 struct jim_getopt_info goi
;
484 JIM_CHECK_RETVAL(jim_getopt_setup(&goi
, interp
, argc
-1, argv
+1));
488 struct command_context
*ctx
;
489 struct target
*target
;
491 ctx
= current_command_context(interp
);
493 target
= get_current_target(ctx
);
495 Jim_SetResultFormatted(goi
.interp
, "No current target");
501 /* Check if the amount of arguments is not zero */
503 Jim_SetResultFormatted(goi
.interp
, "The command has no arguments");
507 /* Estimate number of registers as (argc - 2)/4 as each -bitfield option has 3
508 * arguments while -name is required. */
509 unsigned int fields_sz
= (goi
.argc
- 2) / 4;
510 unsigned int cur_field
= 0;
512 /* The maximum amount of bitfields is 32 */
513 if (fields_sz
> 32) {
514 Jim_SetResultFormatted(goi
.interp
, "The amount of bitfields exceed 32");
518 struct arc_reg_data_type
*type
= calloc(1, sizeof(*type
));
519 struct reg_data_type_struct
*struct_type
= &type
->data_type_struct
;
520 struct reg_data_type_struct_field
*fields
= calloc(fields_sz
, sizeof(*fields
));
521 type
->reg_type_struct_field
= fields
;
522 struct arc_reg_bitfield
*bitfields
= calloc(fields_sz
, sizeof(*bitfields
));
523 if (!(type
&& fields
&& bitfields
)) {
524 Jim_SetResultFormatted(goi
.interp
, "Failed to allocate memory.");
528 /* Initialize type */
529 type
->data_type
.id
= type
->data_type_id
;
530 type
->bitfields
= bitfields
;
531 type
->data_type
.type
= REG_TYPE_ARCH_DEFINED
;
532 type
->data_type
.type_class
= REG_TYPE_CLASS_STRUCT
;
533 type
->data_type
.reg_type_struct
= struct_type
;
534 struct_type
->size
= 4; /* For now ARC has only 32-bit registers */
536 while (goi
.argc
> 0 && e
== JIM_OK
) {
538 e
= jim_getopt_nvp(&goi
, nvp_add_reg_type_struct_opts
, &n
);
540 jim_getopt_nvp_unknown(&goi
, nvp_add_reg_type_struct_opts
, 0);
545 case CFG_ADD_REG_TYPE_STRUCT_NAME
:
547 const char *name
= NULL
;
550 e
= jim_arc_read_reg_name_field(&goi
, &name
, &name_len
);
552 Jim_SetResultFormatted(goi
.interp
, "Unable to read reg name.");
556 if (name_len
> REG_TYPE_MAX_NAME_LENGTH
) {
557 Jim_SetResultFormatted(goi
.interp
, "Reg type name is too big.");
561 strncpy((void *)type
->data_type
.id
, name
, name_len
);
562 if (!type
->data_type
.id
) {
563 Jim_SetResultFormatted(goi
.interp
, "Unable to setup reg type name.");
569 case CFG_ADD_REG_TYPE_STRUCT_BITFIELD
:
571 const char *field_name
= NULL
;
572 int field_name_len
= 0;
573 e
= jim_arc_read_reg_type_field(&goi
, &field_name
, &field_name_len
, bitfields
,
574 cur_field
, CFG_ADD_REG_TYPE_STRUCT
);
576 Jim_SetResultFormatted(goi
.interp
, "Unable to add reg_type_struct field.");
580 if (field_name_len
> REG_TYPE_MAX_NAME_LENGTH
) {
581 Jim_SetResultFormatted(goi
.interp
, "Reg type field_name_len is too big.");
585 fields
[cur_field
].name
= bitfields
[cur_field
].name
;
586 strncpy(bitfields
[cur_field
].name
, field_name
, field_name_len
);
587 if (!fields
[cur_field
].name
) {
588 Jim_SetResultFormatted(goi
.interp
, "Unable to setup field name. ");
592 fields
[cur_field
].bitfield
= &(bitfields
[cur_field
].bitfield
);
593 fields
[cur_field
].use_bitfields
= true;
595 fields
[cur_field
- 1].next
= &(fields
[cur_field
]);
597 struct_type
->fields
= fields
;
606 if (!type
->data_type
.id
) {
607 Jim_SetResultFormatted(goi
.interp
, "-name is a required option");
611 arc_reg_data_type_add(target
, type
);
612 LOG_DEBUG("added struct type {name=%s}", type
->data_type
.id
);
626 CFG_ADD_REG_ARCH_NUM
,
629 CFG_ADD_REG_GDB_FEATURE
,
634 static struct jim_nvp opts_nvp_add_reg
[] = {
635 { .name
= "-name", .value
= CFG_ADD_REG_NAME
},
636 { .name
= "-num", .value
= CFG_ADD_REG_ARCH_NUM
},
637 { .name
= "-core", .value
= CFG_ADD_REG_IS_CORE
},
638 { .name
= "-bcr", .value
= CFG_ADD_REG_IS_BCR
},
639 { .name
= "-feature", .value
= CFG_ADD_REG_GDB_FEATURE
},
640 { .name
= "-type", .value
= CFG_ADD_REG_TYPE
},
641 { .name
= "-g", .value
= CFG_ADD_REG_GENERAL
},
642 { .name
= NULL
, .value
= -1 }
645 void free_reg_desc(struct arc_reg_desc
*r
)
648 free(r
->gdb_xml_feature
);
652 static int jim_arc_add_reg(Jim_Interp
*interp
, int argc
, Jim_Obj
* const *argv
)
654 struct jim_getopt_info goi
;
655 JIM_CHECK_RETVAL(jim_getopt_setup(&goi
, interp
, argc
-1, argv
+1));
657 struct arc_reg_desc
*reg
= calloc(1, sizeof(*reg
));
659 Jim_SetResultFormatted(goi
.interp
, "Failed to allocate memory.");
663 /* There is no architecture number that we could treat as invalid, so
664 * separate variable required to ensure that arch num has been set. */
665 bool arch_num_set
= false;
666 const char *type_name
= "int"; /* Default type */
667 int type_name_len
= strlen(type_name
);
670 /* At least we need to specify 4 parameters: name, number and gdb_feature,
671 * which means there should be 6 arguments. Also there can be additional parameters
672 * "-type <type>", "-g" and "-core" or "-bcr" which makes maximum 10 parameters. */
673 if (goi
.argc
< 6 || goi
.argc
> 10) {
675 Jim_SetResultFormatted(goi
.interp
,
676 "Should be at least 6 arguments and not greater than 10: "
677 " -name <name> -num <num> -feature <gdb_feature> "
678 " [-type <type_name>] [-core|-bcr] [-g].");
683 while (goi
.argc
> 0) {
685 e
= jim_getopt_nvp(&goi
, opts_nvp_add_reg
, &n
);
687 jim_getopt_nvp_unknown(&goi
, opts_nvp_add_reg
, 0);
693 case CFG_ADD_REG_NAME
:
695 const char *reg_name
= NULL
;
696 int reg_name_len
= 0;
698 e
= jim_arc_read_reg_name_field(&goi
, ®_name
, ®_name_len
);
700 Jim_SetResultFormatted(goi
.interp
, "Unable to read register name.");
705 reg
->name
= strndup(reg_name
, reg_name_len
);
708 case CFG_ADD_REG_IS_CORE
:
711 case CFG_ADD_REG_IS_BCR
:
714 case CFG_ADD_REG_ARCH_NUM
:
720 Jim_WrongNumArgs(interp
, goi
.argc
, goi
.argv
, "-num <int> ...");
724 e
= jim_getopt_wide(&goi
, &archnum
);
730 reg
->arch_num
= archnum
;
734 case CFG_ADD_REG_GDB_FEATURE
:
736 const char *feature
= NULL
;
739 e
= jim_arc_read_reg_name_field(&goi
, &feature
, &feature_len
);
741 Jim_SetResultFormatted(goi
.interp
, "Unable to read gdb_feature.");
746 reg
->gdb_xml_feature
= strndup(feature
, feature_len
);
749 case CFG_ADD_REG_TYPE
:
750 e
= jim_arc_read_reg_name_field(&goi
, &type_name
, &type_name_len
);
752 Jim_SetResultFormatted(goi
.interp
, "Unable to read register type.");
758 case CFG_ADD_REG_GENERAL
:
759 reg
->is_general
= true;
762 LOG_DEBUG("Error: Unknown parameter");
768 /* Check that required fields are set */
769 const char * const errmsg
= validate_register(reg
, arch_num_set
);
771 Jim_SetResultFormatted(goi
.interp
, errmsg
);
776 /* Add new register */
777 struct command_context
*ctx
;
778 struct target
*target
;
780 ctx
= current_command_context(interp
);
782 target
= get_current_target(ctx
);
784 Jim_SetResultFormatted(goi
.interp
, "No current target");
789 reg
->target
= target
;
791 e
= arc_reg_add(target
, reg
, type_name
, type_name_len
);
792 if (e
== ERROR_ARC_REGTYPE_NOT_FOUND
) {
793 Jim_SetResultFormatted(goi
.interp
,
794 "Cannot find type `%s' for register `%s'.",
795 type_name
, reg
->name
);
803 /* arc set-reg-exists ($reg_name)+
804 * Accepts any amount of register names - will set them as existing in a loop.*/
805 COMMAND_HANDLER(arc_set_reg_exists
)
807 struct target
* const target
= get_current_target(CMD_CTX
);
809 command_print(CMD
, "Unable to get current target.");
814 command_print(CMD
, "At least one register name must be specified.");
815 return ERROR_COMMAND_SYNTAX_ERROR
;
818 for (unsigned int i
= 0; i
< CMD_ARGC
; i
++) {
819 const char * const reg_name
= CMD_ARGV
[i
];
820 struct reg
* const r
= arc_reg_get_by_name(target
->reg_cache
, reg_name
, true);
823 command_print(CMD
, "Register `%s' is not found.", reg_name
);
824 return ERROR_COMMAND_ARGUMENT_INVALID
;
833 /* arc reg-field ($reg_name) ($reg_field)
834 * Reads struct type register field */
835 static int jim_arc_get_reg_field(Jim_Interp
*interp
, int argc
, Jim_Obj
* const *argv
)
837 struct jim_getopt_info goi
;
838 const char *reg_name
, *field_name
;
842 JIM_CHECK_RETVAL(jim_getopt_setup(&goi
, interp
, argc
-1, argv
+1));
844 LOG_DEBUG("Reading register field");
847 Jim_WrongNumArgs(interp
, goi
.argc
, goi
.argv
, "<regname> <fieldname>");
848 else if (goi
.argc
== 1)
849 Jim_WrongNumArgs(interp
, goi
.argc
, goi
.argv
, "<fieldname>");
851 Jim_WrongNumArgs(interp
, goi
.argc
, goi
.argv
, "<regname> <fieldname>");
852 return ERROR_COMMAND_SYNTAX_ERROR
;
855 JIM_CHECK_RETVAL(jim_getopt_string(&goi
, ®_name
, NULL
));
856 JIM_CHECK_RETVAL(jim_getopt_string(&goi
, &field_name
, NULL
));
860 struct command_context
* const ctx
= current_command_context(interp
);
862 struct target
* const target
= get_current_target(ctx
);
864 Jim_SetResultFormatted(goi
.interp
, "No current target");
868 retval
= arc_reg_get_field(target
, reg_name
, field_name
, &value
);
873 case ERROR_ARC_REGISTER_NOT_FOUND
:
874 Jim_SetResultFormatted(goi
.interp
,
875 "Register `%s' has not been found.", reg_name
);
876 return ERROR_COMMAND_ARGUMENT_INVALID
;
877 case ERROR_ARC_REGISTER_IS_NOT_STRUCT
:
878 Jim_SetResultFormatted(goi
.interp
,
879 "Register `%s' must have 'struct' type.", reg_name
);
880 return ERROR_COMMAND_ARGUMENT_INVALID
;
881 case ERROR_ARC_REGISTER_FIELD_NOT_FOUND
:
882 Jim_SetResultFormatted(goi
.interp
,
883 "Field `%s' has not been found in register `%s'.",
884 field_name
, reg_name
);
885 return ERROR_COMMAND_ARGUMENT_INVALID
;
886 case ERROR_ARC_FIELD_IS_NOT_BITFIELD
:
887 Jim_SetResultFormatted(goi
.interp
,
888 "Field `%s' is not a 'bitfield' field in a structure.",
890 return ERROR_COMMAND_ARGUMENT_INVALID
;
892 /* Pass through other errors. */
896 Jim_SetResultInt(interp
, value
);
901 COMMAND_HANDLER(arc_l1_cache_disable_auto_cmd
)
905 struct arc_common
*arc
= target_to_arc(get_current_target(CMD_CTX
));
906 retval
= CALL_COMMAND_HANDLER(handle_command_parse_bool
,
907 &value
, "target has caches enabled");
908 arc
->has_l2cache
= value
;
909 arc
->has_dcache
= value
;
910 arc
->has_icache
= value
;
914 COMMAND_HANDLER(arc_l2_cache_disable_auto_cmd
)
916 struct arc_common
*arc
= target_to_arc(get_current_target(CMD_CTX
));
917 return CALL_COMMAND_HANDLER(handle_command_parse_bool
,
918 &arc
->has_l2cache
, "target has l2 cache enabled");
921 static int jim_handle_actionpoints_num(Jim_Interp
*interp
, int argc
,
922 Jim_Obj
* const *argv
)
924 struct jim_getopt_info goi
;
925 jim_getopt_setup(&goi
, interp
, argc
- 1, argv
+ 1);
930 Jim_WrongNumArgs(interp
, goi
.argc
, goi
.argv
, "[<unsigned integer>]");
934 struct command_context
*context
= current_command_context(interp
);
937 struct target
*target
= get_current_target(context
);
940 Jim_SetResultFormatted(goi
.interp
, "No current target");
944 struct arc_common
*arc
= target_to_arc(target
);
945 /* It is not possible to pass &arc->actionpoints_num directly to
946 * handle_command_parse_uint, because this value should be valid during
947 * "actionpoint reset, initiated by arc_set_actionpoints_num. */
948 uint32_t ap_num
= arc
->actionpoints_num
;
951 JIM_CHECK_RETVAL(arc_cmd_jim_get_uint32(&goi
, &ap_num
));
952 int e
= arc_set_actionpoints_num(target
, ap_num
);
954 Jim_SetResultFormatted(goi
.interp
,
955 "Failed to set number of actionpoints");
960 Jim_SetResultInt(interp
, ap_num
);
965 /* ----- Exported target commands ------------------------------------------ */
967 static const struct command_registration arc_l2_cache_group_handlers
[] = {
970 .handler
= arc_l2_cache_disable_auto_cmd
,
973 .help
= "Disable or enable L2",
975 COMMAND_REGISTRATION_DONE
978 static const struct command_registration arc_cache_group_handlers
[] = {
981 .handler
= arc_l1_cache_disable_auto_cmd
,
983 .help
= "Disable or enable L1",
989 .help
= "L2 cache command group",
991 .chain
= arc_l2_cache_group_handlers
,
993 COMMAND_REGISTRATION_DONE
997 static const struct command_registration arc_core_command_handlers
[] = {
999 .name
= "add-reg-type-flags",
1000 .jim_handler
= jim_arc_add_reg_type_flags
,
1001 .mode
= COMMAND_CONFIG
,
1002 .usage
= "-name <string> -flag <name> <position> "
1003 "[-flag <name> <position>]...",
1004 .help
= "Add new 'flags' register data type. Only single bit flags "
1005 "are supported. Type name is global. Bitsize of register is fixed "
1009 .name
= "add-reg-type-struct",
1010 .jim_handler
= jim_arc_add_reg_type_struct
,
1011 .mode
= COMMAND_CONFIG
,
1012 .usage
= "-name <string> -bitfield <name> <start> <end> "
1013 "[-bitfield <name> <start> <end>]...",
1014 .help
= "Add new 'struct' register data type. Only bit-fields are "
1015 "supported so far, which means that for each bitfield start and end "
1016 "position bits must be specified. GDB also support type-fields, "
1017 "where common type can be used instead. Type name is global. Bitsize of "
1018 "register is fixed at 32 bits.",
1022 .jim_handler
= jim_arc_add_reg
,
1023 .mode
= COMMAND_CONFIG
,
1024 .usage
= "-name <string> -num <int> -feature <string> [-gdbnum <int>] "
1025 "[-core|-bcr] [-type <type_name>] [-g]",
1026 .help
= "Add new register. Name, architectural number and feature name "
1027 "are required options. GDB regnum will default to previous register "
1028 "(gdbnum + 1) and shouldn't be specified in most cases. Type "
1029 "defaults to default GDB 'int'.",
1032 .name
= "set-reg-exists",
1033 .handler
= arc_set_reg_exists
,
1034 .mode
= COMMAND_ANY
,
1035 .usage
= "<register-name> [<register-name>]...",
1036 .help
= "Set that register exists. Accepts multiple register names as "
1040 .name
= "get-reg-field",
1041 .jim_handler
= jim_arc_get_reg_field
,
1042 .mode
= COMMAND_ANY
,
1043 .usage
= "<regname> <field_name>",
1044 .help
= "Returns value of field in a register with 'struct' type.",
1048 .mode
= COMMAND_ANY
,
1049 .help
= "ARC JTAG specific commands",
1051 .chain
= arc_jtag_command_group
,
1055 .mode
= COMMAND_ANY
,
1056 .help
= "cache command group",
1058 .chain
= arc_cache_group_handlers
,
1061 .name
= "num-actionpoints",
1062 .jim_handler
= jim_handle_actionpoints_num
,
1063 .mode
= COMMAND_ANY
,
1064 .usage
= "[<unsigned integer>]",
1065 .help
= "Prints or sets amount of actionpoints in the processor.",
1067 COMMAND_REGISTRATION_DONE
1070 const struct command_registration arc_monitor_command_handlers
[] = {
1073 .mode
= COMMAND_ANY
,
1074 .help
= "ARC monitor command group",
1076 .chain
= arc_core_command_handlers
,
1078 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)