29     *value = (uint32_t)value_wide;
 
   46     { .name = 
NULL,     .value = -1 }
 
   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.";
 
   68     const char **
name, 
int *name_len)
 
   73         Jim_WrongNumArgs(goi->
interp, goi->
argc, goi->
argv, 
"-name <name> ...");
 
   84         jim_wide start_pos, end_pos;
 
   89             Jim_SetResultFormatted(goi->
interp, 
"Not enough arguments after -flag/-bitfield");
 
  113                                     Jim_SetResultFormatted(goi->
interp, 
"Error reading end position");
 
  126     Jim_Obj * 
const *argv)
 
  140         Jim_SetResultFormatted(goi.
interp, 
"No current target");
 
  148         Jim_SetResultFormatted(goi.
interp, 
"The command has no arguments");
 
  154     unsigned int fields_sz = (goi.
argc - 2) / 3;
 
  155     unsigned int cur_field = 0;
 
  158     if (fields_sz > 32) {
 
  159         Jim_SetResultFormatted(goi.
interp, 
"The amount of bitfields exceed 32");
 
  166     type->reg_type_flags_field = fields;
 
  168     if (!(
type && fields && bitfields)) {
 
  169         Jim_SetResultFormatted(goi.
interp, 
"Failed to allocate memory.");
 
  174     type->bitfields = bitfields;
 
  175     type->data_type.id = 
type->data_type_id;
 
  178     type->data_type.reg_type_flags = flags;
 
  181     while (goi.
argc > 0 && e == JIM_OK) {
 
  197                     Jim_SetResultFormatted(goi.
interp, 
"Unable to read reg name.");
 
  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.");
 
  217                 const char *field_name = 
NULL;
 
  218                 int field_name_len = 0;
 
  223                     Jim_SetResultFormatted(goi.
interp, 
"Unable to add reg_type_flag field.");
 
  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. ");
 
  241                     fields[cur_field - 1].
next = &(fields[cur_field]);
 
  251     if (!
type->data_type.id) {
 
  252         Jim_SetResultFormatted(goi.
interp, 
"-name is a required option");
 
  278     { .name = 
NULL,     .value = -1 }
 
  293         Jim_SetResultFormatted(goi.
interp,
 
  294             "usage: %s <aux_reg_num> <aux_reg_value>", Jim_GetString(
argv[0], 
NULL));
 
  303         Jim_SetResultFormatted(goi.
interp, 
"No current target");
 
  332         Jim_SetResultFormatted(goi.
interp,
 
  333             "usage: %s <aux_reg_num>", Jim_GetString(
argv[0], 
NULL));
 
  342         Jim_SetResultFormatted(goi.
interp, 
"No current target");
 
  353     Jim_SetResultInt(interp, value);
 
  369         Jim_SetResultFormatted(goi.
interp,
 
  370             "usage: %s <core_reg_num>", Jim_GetString(
argv[0], 
NULL));
 
  379         Jim_SetResultFormatted(goi.
interp, 
"No current target");
 
  386         Jim_SetResultFormatted(goi.
interp, 
"Core register number %i " 
  387             "is invalid. Must less then 64 and not 61 and 62.", regnum);
 
  396     Jim_SetResultInt(interp, value);
 
  412         Jim_SetResultFormatted(goi.
interp,
 
  413             "usage: %s <core_reg_num> <core_reg_value>", Jim_GetString(
argv[0], 
NULL));
 
  422         Jim_SetResultFormatted(goi.
interp, 
"No current target");
 
  429         Jim_SetResultFormatted(goi.
interp, 
"Core register number %i " 
  430             "is invalid. Must less then 64 and not 61 and 62.", regnum);
 
  447         .
name = 
"get-aux-reg",
 
  450         .help = 
"Get AUX register by number. This command does a " 
  451             "raw JTAG request that bypasses OpenOCD register cache " 
  452             "and thus is unsafe and can have unexpected consequences. " 
  453             "Use at your own risk.",
 
  457         .name = 
"set-aux-reg",
 
  460         .help = 
"Set AUX register by number. This command does a " 
  461             "raw JTAG request that bypasses OpenOCD register cache " 
  462             "and thus is unsafe and can have unexpected consequences. " 
  463             "Use at your own risk.",
 
  464         .usage = 
"<regnum> <value>" 
  467         .name = 
"get-core-reg",
 
  470         .help = 
"Get/Set core register by number. This command does a " 
  471             "raw JTAG request that bypasses OpenOCD register cache " 
  472             "and thus is unsafe and can have unexpected consequences. " 
  473             "Use at your own risk.",
 
  474         .usage = 
"<regnum> [<value>]" 
  477         .name = 
"set-core-reg",
 
  480         .help = 
"Get/Set core register by number. This command does a " 
  481             "raw JTAG request that bypasses OpenOCD register cache " 
  482             "and thus is unsafe and can have unexpected consequences. " 
  483             "Use at your own risk.",
 
  484         .usage = 
"<regnum> [<value>]" 
  492     Jim_Obj * 
const *argv)
 
  506         Jim_SetResultFormatted(goi.
interp, 
"No current target");
 
  514         Jim_SetResultFormatted(goi.
interp, 
"The command has no arguments");
 
  520     unsigned int fields_sz = (goi.
argc - 2) / 4;
 
  521     unsigned int cur_field = 0;
 
  524     if (fields_sz > 32) {
 
  525             Jim_SetResultFormatted(goi.
interp, 
"The amount of bitfields exceed 32");
 
  532     type->reg_type_struct_field = fields;
 
  534     if (!(
type && fields && bitfields)) {
 
  535         Jim_SetResultFormatted(goi.
interp, 
"Failed to allocate memory.");
 
  540     type->data_type.id = 
type->data_type_id;
 
  541     type->bitfields = bitfields;
 
  544     type->data_type.reg_type_struct = struct_type;
 
  545     struct_type->
size = 4; 
 
  547     while (goi.
argc > 0 && e == JIM_OK) {
 
  563                     Jim_SetResultFormatted(goi.
interp, 
"Unable to read reg name.");
 
  568                     Jim_SetResultFormatted(goi.
interp, 
"Reg type name is too big.");
 
  572                 strncpy((
void *)
type->data_type.id, 
name, name_len);
 
  573                 if (!
type->data_type.id) {
 
  574                     Jim_SetResultFormatted(goi.
interp, 
"Unable to setup reg type name.");
 
  582                 const char *field_name = 
NULL;
 
  583                 int field_name_len = 0;
 
  587                     Jim_SetResultFormatted(goi.
interp, 
"Unable to add reg_type_struct field.");
 
  592                     Jim_SetResultFormatted(goi.
interp, 
"Reg type field_name_len is too big.");
 
  596                 fields[cur_field].
name = bitfields[cur_field].
name;
 
  597                 strncpy(bitfields[cur_field].
name, field_name, field_name_len);
 
  598                 if (!fields[cur_field].
name) {
 
  599                     Jim_SetResultFormatted(goi.
interp, 
"Unable to setup field name. ");
 
  606                     fields[cur_field - 1].
next = &(fields[cur_field]);
 
  608                     struct_type->
fields = fields;
 
  617     if (!
type->data_type.id) {
 
  618         Jim_SetResultFormatted(goi.
interp, 
"-name is a required option");
 
  623     LOG_DEBUG(
"added struct type {name=%s}", 
type->data_type.id);
 
  653     { .name = 
NULL,       .value = -1 }
 
  670         Jim_SetResultFormatted(goi.
interp, 
"Failed to allocate memory.");
 
  676     bool arch_num_set = 
false;
 
  677     const char *type_name = 
"int"; 
 
  678     int type_name_len = strlen(type_name);
 
  684     if (goi.
argc < 6 || goi.
argc > 10) {
 
  686         Jim_SetResultFormatted(goi.
interp,
 
  687             "Should be at least 6 arguments and not greater than 10: " 
  688             " -name <name> -num <num> -feature <gdb_feature> " 
  689             " [-type <type_name>] [-core|-bcr] [-g].");
 
  694     while (goi.
argc > 0) {
 
  706                 const char *reg_name = 
NULL;
 
  707                 int reg_name_len = 0;
 
  711                     Jim_SetResultFormatted(goi.
interp, 
"Unable to read register name.");
 
  731                     Jim_WrongNumArgs(interp, goi.
argc, goi.
argv, 
"-num <int> ...");
 
  741                 reg->arch_num = archnum;
 
  752                     Jim_SetResultFormatted(goi.
interp, 
"Unable to read gdb_feature.");
 
  763                     Jim_SetResultFormatted(goi.
interp, 
"Unable to read register type.");
 
  770                 reg->is_general = 
true;
 
  782         Jim_SetResultFormatted(goi.
interp, errmsg);
 
  795         Jim_SetResultFormatted(goi.
interp, 
"No current target");
 
  804         Jim_SetResultFormatted(goi.
interp,
 
  805             "Cannot find type `%s' for register `%s'.",
 
  829     for (
unsigned int i = 0; i < 
CMD_ARGC; i++) {
 
  830         const char * 
const reg_name = 
CMD_ARGV[i];
 
  849     const char *reg_name, *field_name;
 
  858             Jim_WrongNumArgs(
interp, goi.
argc, goi.
argv, 
"<regname> <fieldname>");
 
  859         else if (goi.
argc == 1)
 
  862             Jim_WrongNumArgs(
interp, goi.
argc, goi.
argv, 
"<regname> <fieldname>");
 
  875         Jim_SetResultFormatted(goi.
interp, 
"No current target");
 
  885             Jim_SetResultFormatted(goi.
interp,
 
  886                 "Register `%s' has not been found.", reg_name);
 
  889             Jim_SetResultFormatted(goi.
interp,
 
  890                 "Register `%s' must have 'struct' type.", reg_name);
 
  893             Jim_SetResultFormatted(goi.
interp,
 
  894                 "Field `%s' has not been found in register `%s'.",
 
  895                 field_name, reg_name);
 
  898             Jim_SetResultFormatted(goi.
interp,
 
  899                 "Field `%s' is not a 'bitfield' field in a structure.",
 
  907     Jim_SetResultInt(interp, value);
 
  918         &value, 
"target has caches enabled");
 
  933     Jim_Obj * 
const *argv)
 
  941         Jim_WrongNumArgs(
interp, goi.
argc, goi.
argv, 
"[<unsigned integer>]");
 
  951         Jim_SetResultFormatted(goi.
interp, 
"No current target");
 
  965             Jim_SetResultFormatted(goi.
interp,
 
  966                 "Failed to set number of actionpoints");
 
  971     Jim_SetResultInt(interp, ap_num);
 
  981         .handler = arc_l2_cache_disable_auto_cmd,
 
  984         .help = 
"Disable or enable L2",
 
  992         .handler = arc_l1_cache_disable_auto_cmd,
 
  994         .help = 
"Disable or enable L1",
 
 1000         .help = 
"L2 cache command group",
 
 1010         .
name = 
"add-reg-type-flags",
 
 1013         .usage = 
"-name <string> -flag <name> <position> " 
 1014             "[-flag <name> <position>]...",
 
 1015         .help = 
"Add new 'flags' register data type. Only single bit flags " 
 1016             "are supported. Type name is global. Bitsize of register is fixed " 
 1020         .name = 
"add-reg-type-struct",
 
 1023         .usage = 
"-name <string> -bitfield <name> <start> <end> " 
 1024             "[-bitfield <name> <start> <end>]...",
 
 1025         .help = 
"Add new 'struct' register data type. Only bit-fields are " 
 1026             "supported so far, which means that for each bitfield start and end " 
 1027             "position bits must be specified. GDB also support type-fields, " 
 1028             "where common type can be used instead. Type name is global. Bitsize of " 
 1029             "register is fixed at 32 bits.",
 
 1035         .usage = 
"-name <string> -num <int> -feature <string> [-gdbnum <int>] " 
 1036             "[-core|-bcr] [-type <type_name>] [-g]",
 
 1037         .help = 
"Add new register. Name, architectural number and feature name " 
 1038             "are required options. GDB regnum will default to previous register " 
 1039             "(gdbnum + 1) and shouldn't be specified in most cases. Type " 
 1040             "defaults to default GDB 'int'.",
 
 1043         .name = 
"set-reg-exists",
 
 1044         .handler = arc_set_reg_exists,
 
 1046         .usage = 
"<register-name> [<register-name>]...",
 
 1047         .help = 
"Set that register exists. Accepts multiple register names as " 
 1051         .name = 
"get-reg-field",
 
 1054         .usage = 
"<regname> <field_name>",
 
 1055         .help = 
"Returns value of field in a register with 'struct' type.",
 
 1060         .help = 
"ARC JTAG specific commands",
 
 1067         .help = 
"cache command group",
 
 1072         .
name = 
"num-actionpoints",
 
 1075         .usage = 
"[<unsigned integer>]",
 
 1076         .help = 
"Prints or sets amount of actionpoints in the processor.",
 
 1085         .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 JIM_CHECK_RETVAL(action)
 
#define ERROR_ARC_REGISTER_NOT_FOUND
 
#define REG_TYPE_MAX_NAME_LENGTH
 
#define CHECK_RETVAL(action)
 
#define ERROR_ARC_FIELD_IS_NOT_BITFIELD
 
static int jim_arc_get_core_reg(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
 
static int jim_arc_get_reg_field(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
 
static struct jim_nvp nvp_add_reg_type_flags_opts[]
 
static int jim_arc_read_reg_name_field(struct jim_getopt_info *goi, const char **name, int *name_len)
 
static int jim_arc_add_reg_type_flags(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
 
@ CFG_ADD_REG_TYPE_STRUCT_BITFIELD
 
@ CFG_ADD_REG_TYPE_STRUCT_NAME
 
static int jim_arc_get_aux_reg(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
 
@ CFG_ADD_REG_TYPE_FLAGS_FLAG
 
@ CFG_ADD_REG_TYPE_FLAGS_NAME
 
static const struct command_registration arc_cache_group_handlers[]
 
static int arc_cmd_jim_get_uint32(struct jim_getopt_info *goi, uint32_t *value)
 
static int jim_handle_actionpoints_num(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
 
static int jim_arc_set_core_reg(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
 
static int jim_arc_add_reg_type_struct(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
 
@ CFG_ADD_REG_GDB_FEATURE
 
static const struct command_registration arc_core_command_handlers[]
 
static struct jim_nvp opts_nvp_add_reg[]
 
void free_reg_desc(struct arc_reg_desc *r)
 
static struct jim_nvp nvp_add_reg_type_struct_opts[]
 
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 int jim_arc_add_reg(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
 
static const struct command_registration arc_l2_cache_group_handlers[]
 
static const struct command_registration arc_jtag_command_group[]
 
static int jim_arc_read_reg_type_field(struct jim_getopt_info *goi, const char **field_name, int *field_name_len, struct arc_reg_bitfield *bitfields, int cur_field, int type)
 
static int jim_arc_set_aux_reg(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
 
COMMAND_HANDLER(arc_set_reg_exists)
 
@ 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.
 
struct command_context * current_command_context(Jim_Interp *interp)
 
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 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
 
int jim_getopt_wide(struct jim_getopt_info *goi, jim_wide *puthere)
Remove argv[0] as wide.
 
int jim_getopt_setup(struct jim_getopt_info *p, Jim_Interp *interp, int argc, Jim_Obj *const *argv)
GetOpt - how to.
 
int jim_getopt_string(struct jim_getopt_info *goi, const char **puthere, int *len)
Remove argv[0] as string.
 
int jim_getopt_nvp(struct jim_getopt_info *goi, const struct jim_nvp *nvp, struct jim_nvp **puthere)
Remove argv[0] as NVP.
 
void jim_getopt_nvp_unknown(struct jim_getopt_info *goi, const struct jim_nvp *nvptable, int hadprefix)
Create an appropriate error message for an NVP.
 
#define LOG_DEBUG(expr ...)
 
char * strndup(const char *s, size_t n)
 
unsigned int actionpoints_num
 
struct arc_jtag jtag_info
 
char name[REG_TYPE_MAX_NAME_LENGTH]
 
struct reg_data_type_bitfield bitfield
 
A TCL -ish GetOpt like code.
 
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)