group->spec = ctx->spec;
group->group_offset = 0;
group->group_count = 0;
+ group->variable_offset = 0;
+ group->variable = false;
return group;
}
static void
get_group_offset_count(struct parser_context *ctx, const char *name,
- const char **atts, uint32_t *offset, uint32_t *count)
+ const char **atts, uint32_t *offset, uint32_t *count,
+ uint32_t *elem_size, bool *variable)
{
char *p;
int i;
for (i = 0; atts[i]; i += 2) {
- if (strcmp(atts[i], "count") == 0)
+ if (strcmp(atts[i], "count") == 0) {
*count = strtoul(atts[i + 1], &p, 0);
- else if (strcmp(atts[i], "start") == 0)
+ if (*count == 0)
+ *variable = true;
+ } else if (strcmp(atts[i], "start") == 0) {
*offset = strtoul(atts[i + 1], &p, 0);
+ } else if (strcmp(atts[i], "size") == 0) {
+ *elem_size = strtoul(atts[i + 1], &p, 0);
+ }
}
return;
}
field->start = ctx->group->group_offset+strtoul(atts[i + 1], &p, 0);
else if (strcmp(atts[i], "end") == 0) {
field->end = ctx->group->group_offset+strtoul(atts[i + 1], &p, 0);
- if (ctx->group->group_offset)
+ if (ctx->group->group_offset) {
ctx->group->group_offset = field->end+1;
+ if (ctx->group->variable)
+ ctx->group->variable_offset = ctx->group->group_offset;
+ }
} else if (strcmp(atts[i], "type") == 0)
field->type = string_to_type(ctx, atts[i + 1]);
else if (strcmp(atts[i], "default") == 0 &&
get_register_offset(atts, &ctx->group->register_offset);
} else if (strcmp(element_name, "group") == 0) {
get_group_offset_count(ctx, name, atts, &ctx->group->group_offset,
- &ctx->group->group_count);
+ &ctx->group->group_count, &ctx->group->elem_size,
+ &ctx->group->variable);
} else if (strcmp(element_name, "field") == 0) {
do {
ctx->fields[ctx->nfields++] = create_field(ctx, atts);
iter->p = p;
iter->i = 0;
iter->print_colors = print_colors;
+ iter->repeat = false;
+ iter->addr_inc = 0;
}
static const char *
float f;
} v;
- if (iter->i == iter->group->nfields)
+ if (iter->i == iter->group->nfields) {
+ if (iter->group->group_size > 0) {
+ int iter_length = iter->group->elem_size;
+
+ iter->group->group_size -= iter_length / 32;
+ iter->addr_inc += iter_length;
+ iter->dword = (iter->field->start + iter->addr_inc) / 32;
+ return true;
+ }
return false;
+ }
iter->field = iter->group->fields[iter->i++];
iter->name = iter->field->name;
return offset < gtt_end;
}
+/**
+ * Set group variable size for groups with count="0".
+ *
+ * By default the group size is fixed and not needed because the struct
+ * describing a group knows the number of elements. However, for groups with
+ * count="0" we have a variable number of elements, and the struct describing
+ * the group only includes one of them. So we calculate the remaining size of
+ * the group based on the size we get here, and the offset after the last
+ * element added to the group.
+ */
+static void
+group_set_size(struct gen_group *strct, uint32_t size)
+{
+ if (strct->variable && strct->elem_size)
+ strct->group_size = size - (strct->variable_offset / 32);
+}
+
static void
decode_group(struct gen_group *strct, const uint32_t *p, int starting_dword)
{
uint64_t offset = option_print_offsets ? (void *) p - gtt : 0;
+
gen_print_group(outfile, strct, offset, p, option_color == COLOR_ALWAYS);
}
gen_group_get_name(inst), reset_color);
if (option_full_decode) {
+ group_set_size(inst, length);
decode_group(inst, p, 0);
for (i = 0; i < ARRAY_LENGTH(custom_handlers); i++) {