Skip to content

Commit

Permalink
Introduce arc_add_reg_data_type function
Browse files Browse the repository at this point in the history
This patch introduces arc_add_reg_data_type function,
which is a routine of adding common and ARC-specific
register types.

Added functions:
        * arc_add_reg_data_type
        * target_to_arc

Added structures:
        * arc_reg_data_type
        * standard_gdb_types[]

Signed-off-by: Evgeniy Didin <didin@synopsys.com>
  • Loading branch information
EvgeniiDidin committed Jun 5, 2019
1 parent 5e3834e commit 8f734b0
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/target/arc.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,17 @@

#include "arc.h"

void arc_add_reg_data_type(struct target *target,
struct arc_reg_data_type *data_type)
{
LOG_DEBUG("-");

This comment has been minimized.

Copy link
@abrodkin

abrodkin Jun 7, 2019

Member

Is this LOG_DEBUG() is really necessary here? If so maybe it makes sense to print some valuable info then?

struct arc_common *arc = target_to_arc(target);
assert(arc);

list_add_tail(&data_type->list, &arc->reg_data_types);
}


/* Initialize arc_common structure, which passes to openocd target instance */
int arc_init_arch_info(struct target *target, struct arc_common *arc,
struct jtag_tap *tap)
Expand Down Expand Up @@ -55,7 +66,20 @@ int arc_init_arch_info(struct target *target, struct arc_common *arc,
/* TODO: uncomment this as this function be introduced */
//arc_reset_caches_states(target);

/* TODO: Add standard GDB data types */
/* Add standard GDB data types */
INIT_LIST_HEAD(&arc->reg_data_types);
struct arc_reg_data_type *std_types = calloc(ARRAY_SIZE(standard_gdb_types),
sizeof(struct arc_reg_data_type));
if (!std_types) {
LOG_ERROR("Cannot allocate memory");
return ERROR_FAIL;
}
for (unsigned int i = 0; i < ARRAY_SIZE(standard_gdb_types); i++) {
std_types[i].data_type.type = standard_gdb_types[i].type;
std_types[i].data_type.id = standard_gdb_types[i].id;
arc_add_reg_data_type(target, &(std_types[i]));
}


/* Fields related to target descriptions */
INIT_LIST_HEAD(&arc->core_reg_descriptions);
Expand Down
36 changes: 36 additions & 0 deletions src/target/arc.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,33 @@

#define ARC_COMMON_MAGIC 0xB32EB324 /* just a unique number */

/* Register data type */
struct arc_reg_data_type {

This comment has been minimized.

Copy link
@abrodkin

abrodkin Jun 7, 2019

Member

I'm wondering if this boilerplate stuff is really required?
Why cannot we re-use generic substance?

This comment has been minimized.

Copy link
@EvgeniiDidin

EvgeniiDidin Jun 13, 2019

Author Member

reg_data_type is not a linked list substance. In other architectures the array of reg_data_type structures usually is hardcoded. In ARC case we dynamically adding register_types from .tcl, so using list_head is a good way to store variable amount of register_types. So, I guess we need to leave this substance.

struct list_head list;
struct reg_data_type data_type;
};

/* Standard GDB register types */
static const struct reg_data_type standard_gdb_types[] = {
{ .type = REG_TYPE_INT, .id = "int" },
{ .type = REG_TYPE_INT8, .id = "int8" },
{ .type = REG_TYPE_INT16, .id = "int16" },
{ .type = REG_TYPE_INT32, .id = "int32" },
{ .type = REG_TYPE_INT64, .id = "int64" },
{ .type = REG_TYPE_INT128, .id = "int128" },
{ .type = REG_TYPE_UINT8, .id = "uint8" },
{ .type = REG_TYPE_UINT16, .id = "uint16" },
{ .type = REG_TYPE_UINT32, .id = "uint32" },
{ .type = REG_TYPE_UINT64, .id = "uint64" },
{ .type = REG_TYPE_UINT128, .id = "uint128" },
{ .type = REG_TYPE_CODE_PTR, .id = "code_ptr" },
{ .type = REG_TYPE_DATA_PTR, .id = "data_ptr" },
{ .type = REG_TYPE_FLOAT, .id = "float" },
{ .type = REG_TYPE_IEEE_SINGLE, .id = "ieee_single" },
{ .type = REG_TYPE_IEEE_DOUBLE, .id = "ieee_double" },
};


struct arc_common {
uint32_t common_magic;
void *arch_info;
Expand Down Expand Up @@ -121,8 +148,17 @@ struct arc_common {
} \
} while (0)

static inline struct arc_common * target_to_arc(struct target *target)
{
return target->arch_info;
}

/* ----- Exported functions ------------------------------------------------ */
int arc_init_arch_info(struct target *target, struct arc_common *arc,
struct jtag_tap *tap);

/* Configurable registers functions */
void arc_add_reg_data_type(struct target *target,
struct arc_reg_data_type *data_type);

#endif /* ARC_H */

0 comments on commit 8f734b0

Please sign in to comment.