39 { .name =
NULL, .value = -1 }
48 return "-name option is required";
49 if (!
reg->gdb_xml_feature)
50 return "-feature option is required";
52 return "-num option is required";
53 if (
reg->is_bcr &&
reg->is_core)
54 return "Register cannot be both -core and -bcr.";
63 unsigned int cur_field = 0;
83 strcpy((
void *)
type->data_type.id,
name);
91 const char *field_name =
CMD_ARGV[0];
103 fields[cur_field].
name = bitfields[cur_field].
name;
104 strcpy(bitfields[cur_field].
name, field_name);
108 fields[cur_field - 1].
next = &fields[cur_field];
121 if (!
type->data_type.id) {
147 unsigned int fields_sz = (
CMD_ARGC - 2) / 3;
150 if (fields_sz > 32) {
158 if (!
type || !fields || !bitfields) {
167 type->bitfields = bitfields;
168 type->data_type.id =
type->data_type_id;
171 type->data_type.reg_type_flags = flags;
201 { .name =
NULL, .value = -1 }
273 "is invalid. Must less then 64 and not 61 and 62.", regnum);
305 "is invalid. Must less then 64 and not 61 and 62.", regnum);
323 .
name =
"get-aux-reg",
324 .handler = arc_handle_get_aux_reg,
326 .help =
"Get AUX register by number. This command does a "
327 "raw JTAG request that bypasses OpenOCD register cache "
328 "and thus is unsafe and can have unexpected consequences. "
329 "Use at your own risk.",
333 .name =
"set-aux-reg",
334 .handler = arc_handle_set_aux_reg,
336 .help =
"Set AUX register by number. This command does a "
337 "raw JTAG request that bypasses OpenOCD register cache "
338 "and thus is unsafe and can have unexpected consequences. "
339 "Use at your own risk.",
340 .usage =
"<regnum> <value>"
343 .name =
"get-core-reg",
344 .handler = arc_handle_get_core_reg,
346 .help =
"Get/Set core register by number. This command does a "
347 "raw JTAG request that bypasses OpenOCD register cache "
348 "and thus is unsafe and can have unexpected consequences. "
349 "Use at your own risk.",
350 .usage =
"<regnum> [<value>]"
353 .name =
"set-core-reg",
354 .handler = arc_handle_set_core_reg,
356 .help =
"Get/Set core register by number. This command does a "
357 "raw JTAG request that bypasses OpenOCD register cache "
358 "and thus is unsafe and can have unexpected consequences. "
359 "Use at your own risk.",
360 .usage =
"<regnum> [<value>]"
372 unsigned int cur_field = 0;
392 strcpy((
void *)
type->data_type.id,
name);
399 uint32_t start_pos, end_pos;
400 const char *field_name =
CMD_ARGV[0];
414 fields[cur_field].
name = bitfields[cur_field].
name;
415 strcpy(bitfields[cur_field].
name, field_name);
420 fields[cur_field - 1].
next = &fields[cur_field];
422 struct_type->
fields = fields;
434 if (!
type->data_type.id) {
460 unsigned int fields_sz = (
CMD_ARGC - 2) / 4;
463 if (fields_sz > 32) {
471 if (!
type || !fields || !bitfields) {
480 type->data_type.id =
type->data_type_id;
481 type->bitfields = bitfields;
484 type->data_type.reg_type_struct = struct_type;
485 struct_type->
size = 4;
493 LOG_DEBUG(
"added struct type {name=%s}",
type->data_type.id);
524 { .name =
NULL, .value = -1 }
538 bool arch_num_set =
false;
539 const char *type_name =
"int";
544 if (CMD_ARGC < 6 || CMD_ARGC > 10)
591 if (!
reg->gdb_xml_feature) {
610 reg->is_general =
true;
638 "Cannot find type `%s' for register `%s'.",
678 for (
unsigned int i = 0; i <
CMD_ARGC; i++) {
679 const char *
const reg_name =
CMD_ARGV[i];
707 const char *field_name =
CMD_ARGV[1];
716 "Register `%s' has not been found.", reg_name);
720 "Register `%s' must have 'struct' type.", reg_name);
724 "Field `%s' has not been found in register `%s'.",
725 field_name, reg_name);
729 "Field `%s' is not a 'bitfield' field in a structure.",
748 &value,
"target has caches enabled");
786 "Failed to set number of actionpoints");
801 .handler = arc_l2_cache_disable_auto_cmd,
804 .help =
"Disable or enable L2",
812 .handler = arc_l1_cache_disable_auto_cmd,
814 .help =
"Disable or enable L1",
820 .help =
"L2 cache command group",
830 .
name =
"add-reg-type-flags",
831 .handler = arc_handle_add_reg_type_flags,
833 .usage =
"-name <string> -flag <name> <position> "
834 "[-flag <name> <position>]...",
835 .help =
"Add new 'flags' register data type. Only single bit flags "
836 "are supported. Type name is global. Bitsize of register is fixed "
840 .name =
"add-reg-type-struct",
841 .handler = arc_handle_add_reg_type_struct,
843 .usage =
"-name <string> -bitfield <name> <start> <end> "
844 "[-bitfield <name> <start> <end>]...",
845 .help =
"Add new 'struct' register data type. Only bit-fields are "
846 "supported so far, which means that for each bitfield start and end "
847 "position bits must be specified. GDB also support type-fields, "
848 "where common type can be used instead. Type name is global. Bitsize of "
849 "register is fixed at 32 bits.",
853 .handler = arc_handle_add_reg,
855 .usage =
"-name <string> -num <int> -feature <string> [-gdbnum <int>] "
856 "[-core|-bcr] [-type <type_name>] [-g]",
857 .help =
"Add new register. Name, architectural number and feature name "
858 "are required options. GDB regnum will default to previous register "
859 "(gdbnum + 1) and shouldn't be specified in most cases. Type "
860 "defaults to default GDB 'int'.",
863 .name =
"set-reg-exists",
864 .handler = arc_set_reg_exists,
866 .usage =
"<register-name> [<register-name>]...",
867 .help =
"Set that register exists. Accepts multiple register names as "
871 .name =
"get-reg-field",
872 .handler = arc_handle_get_reg_field,
874 .usage =
"<regname> <field_name>",
875 .help =
"Returns value of field in a register with 'struct' type.",
880 .help =
"ARC JTAG specific commands",
887 .help =
"cache command group",
892 .
name =
"num-actionpoints",
893 .handler = arc_handle_actionpoints_num,
895 .usage =
"[<unsigned integer>]",
896 .help =
"Prints or sets amount of actionpoints in the processor.",
905 .help =
"ARC monitor command group",
int arc_reg_get_field(struct target *target, const char *reg_name, const char *field_name, uint32_t *value_ptr)
int arc_reg_add(struct target *target, struct arc_reg_desc *arc_reg, const char *const type_name, const size_t type_name_len)
void arc_reg_data_type_add(struct target *target, struct arc_reg_data_type *data_type)
int arc_set_actionpoints_num(struct target *target, uint32_t ap_num)
struct reg * arc_reg_get_by_name(struct reg_cache *first, const char *name, bool search_all)
Private implementation of register_get_by_name() for ARC that doesn't skip not [yet] existing registe...
static struct arc_common * target_to_arc(struct target *target)
#define ERROR_ARC_REGTYPE_NOT_FOUND
#define ERROR_ARC_REGISTER_FIELD_NOT_FOUND
#define CORE_REG_MAX_NUMBER
#define ERROR_ARC_REGISTER_IS_NOT_STRUCT
#define ERROR_ARC_REGISTER_NOT_FOUND
#define REG_TYPE_MAX_NAME_LENGTH
#define CHECK_RETVAL(action)
#define ERROR_ARC_FIELD_IS_NOT_BITFIELD
static COMMAND_HELPER(arc_handle_add_reg_type_flags_ops, struct arc_reg_data_type *type)
static const struct nvp opts_nvp_add_reg[]
@ CFG_ADD_REG_TYPE_STRUCT_BITFIELD
@ CFG_ADD_REG_TYPE_STRUCT_NAME
COMMAND_HANDLER(arc_handle_add_reg_type_flags)
@ CFG_ADD_REG_TYPE_FLAGS_FLAG
@ CFG_ADD_REG_TYPE_FLAGS_NAME
static const struct nvp nvp_add_reg_type_struct_opts[]
static const struct command_registration arc_cache_group_handlers[]
@ CFG_ADD_REG_GDB_FEATURE
static const struct nvp nvp_add_reg_type_flags_opts[]
static const struct command_registration arc_core_command_handlers[]
void free_reg_desc(struct arc_reg_desc *r)
const struct command_registration arc_monitor_command_handlers[]
static const char * validate_register(const struct arc_reg_desc *const reg, bool arch_num_set)
static const struct command_registration arc_l2_cache_group_handlers[]
static const struct command_registration arc_jtag_command_group[]
@ CFG_ADD_REG_TYPE_STRUCT
int arc_jtag_read_core_reg_one(struct arc_jtag *jtag_info, uint32_t addr, uint32_t *value)
Wrapper function to ease reading of one core register.
int arc_jtag_write_aux_reg_one(struct arc_jtag *jtag_info, uint32_t addr, uint32_t value)
Wrapper function to ease writing of one AUX register.
int arc_jtag_write_core_reg_one(struct arc_jtag *jtag_info, uint32_t addr, uint32_t value)
Wrapper function to ease writing of one core register.
int arc_jtag_read_aux_reg_one(struct arc_jtag *jtag_info, uint32_t addr, uint32_t *value)
Wrapper function to ease reading of one AUX register.
void command_print(struct command_invocation *cmd, const char *format,...)
#define CMD
Use this macro to access the command being handled, rather than accessing the variable directly.
#define CALL_COMMAND_HANDLER(name, extra ...)
Use this to macro to call a command helper (or a nested handler).
#define CMD_ARGV
Use this macro to access the arguments for the command being handled, rather than accessing the varia...
#define ERROR_COMMAND_SYNTAX_ERROR
#define CMD_ARGC
Use this macro to access the number of arguments for the command being handled, rather than accessing...
#define COMMAND_PARSE_NUMBER(type, in, out)
parses the string in into out as a type, or prints a command error and passes the error code to the c...
#define CMD_CTX
Use this macro to access the context of the command being handled, rather than accessing the variable...
#define COMMAND_REGISTRATION_DONE
Use this as the last entry in an array of command_registration records.
#define ERROR_COMMAND_ARGUMENT_INVALID
#define LOG_ERROR(expr ...)
#define LOG_DEBUG(expr ...)
void nvp_unknown_command_print(struct command_invocation *cmd, const struct nvp *nvp, const char *param_name, const char *param_value)
const struct nvp * nvp_name2value(const struct nvp *p, const char *name)
unsigned int actionpoints_num
struct arc_jtag jtag_info
char name[REG_TYPE_MAX_NAME_LENGTH]
struct reg_data_type_bitfield bitfield
Name Value Pairs, aka: NVP.
struct reg_data_type_flags_field * next
struct reg_data_type_bitfield * bitfield
struct reg_data_type_flags_field * fields
struct reg_data_type_bitfield * bitfield
struct reg_data_type_struct_field * next
struct reg_data_type_struct_field * fields
struct reg_cache * reg_cache
struct target * get_current_target(struct command_context *cmd_ctx)