X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fbroadcom%2Fcle%2Fv3d_decoder.c;h=23ee59fd0cf1187e71dec25e0d6e6aa46508373b;hb=3550e20229bfc1872ae041e66958187ee4a97ac6;hp=f97aa6604cb1a5218b8d93959e273332f7707e6e;hpb=3c02838d2956692101ae205f1aff362fa3a93c76;p=mesa.git diff --git a/src/broadcom/cle/v3d_decoder.c b/src/broadcom/cle/v3d_decoder.c index f97aa6604cb..23ee59fd0cf 100644 --- a/src/broadcom/cle/v3d_decoder.c +++ b/src/broadcom/cle/v3d_decoder.c @@ -316,6 +316,8 @@ string_to_type(struct parser_context *ctx, const char *s) return (struct v3d_type) { .kind = V3D_TYPE_BOOL }; else if (strcmp(s, "float") == 0) return (struct v3d_type) { .kind = V3D_TYPE_FLOAT }; + else if (strcmp(s, "f187") == 0) + return (struct v3d_type) { .kind = V3D_TYPE_F187 }; else if (strcmp(s, "address") == 0) return (struct v3d_type) { .kind = V3D_TYPE_ADDRESS }; else if (strcmp(s, "offset") == 0) @@ -451,7 +453,9 @@ start_element(void *data, const char *element_name, const char **atts) ctx->loc.line_number = XML_GetCurrentLineNumber(ctx->parser); for (i = 0; atts[i]; i += 2) { - if (strcmp(atts[i], "name") == 0) + if (strcmp(atts[i], "shortname") == 0) + name = atts[i + 1]; + else if (strcmp(atts[i], "name") == 0 && !name) name = atts[i + 1]; else if (strcmp(atts[i], "gen") == 0) ver = atts[i + 1]; @@ -511,6 +515,13 @@ skip: ctx->parse_depth++; } +static int +field_offset_compare(const void *a, const void *b) +{ + return ((*(const struct v3d_field **)a)->start - + (*(const struct v3d_field **)b)->start); +} + static void end_element(void *data, const char *name) { @@ -549,6 +560,13 @@ end_element(void *data, const char *name) else if (strcmp(name, "register") == 0) spec->registers[spec->nregisters++] = group; + /* Sort the fields in increasing offset order. The XML might + * be specified in any order, but we'll want to iterate from + * the bottom. + */ + qsort(group->fields, group->nfields, sizeof(*group->fields), + field_offset_compare); + assert(spec->ncommands < ARRAY_SIZE(spec->commands)); assert(spec->nstructs < ARRAY_SIZE(spec->structs)); assert(spec->nregisters < ARRAY_SIZE(spec->registers)); @@ -633,7 +651,8 @@ v3d_spec_load(const struct v3d_device_info *devinfo) struct parser_context ctx; void *buf; uint8_t *text_data = NULL; - uint32_t text_offset = 0, text_length = 0, total_length; + uint32_t text_offset = 0, text_length = 0; + ASSERTED uint32_t total_length; for (int i = 0; i < ARRAY_SIZE(genxml_files_table); i++) { if (i != 0) { @@ -816,7 +835,7 @@ iter_advance_field(struct v3d_field_iterator *iter) iter->field = iter->group->fields[iter->field_iter++]; if (iter->field->name) - strncpy(iter->name, iter->field->name, sizeof(iter->name)); + snprintf(iter->name, sizeof(iter->name), "%s", iter->field->name); else memset(iter->name, 0, sizeof(iter->name)); iter->offset = iter_group_offset_bits(iter, iter->group_iter) / 8 + @@ -827,7 +846,7 @@ iter_advance_field(struct v3d_field_iterator *iter) } bool -v3d_field_iterator_next(struct v3d_field_iterator *iter) +v3d_field_iterator_next(struct clif_dump *clif, struct v3d_field_iterator *iter) { if (!iter_advance_field(iter)) return false; @@ -872,7 +891,31 @@ v3d_field_iterator_next(struct v3d_field_iterator *iter) snprintf(iter->value, sizeof(iter->value), "%f", __gen_unpack_float(iter->p, s, e)); break; - case V3D_TYPE_ADDRESS: + + case V3D_TYPE_F187: + snprintf(iter->value, sizeof(iter->value), "%f", + __gen_unpack_f187(iter->p, s, e)); + break; + + case V3D_TYPE_ADDRESS: { + uint32_t addr = + __gen_unpack_uint(iter->p, s, e) << (31 - (e - s)); + struct clif_bo *bo = clif_lookup_bo(clif, addr); + if (bo) { + snprintf(iter->value, sizeof(iter->value), + "[%s+0x%08x] /* 0x%08x */", + bo->name, addr - bo->offset, addr); + } else if (addr) { + snprintf(iter->value, sizeof(iter->value), + "/* XXX: BO unknown */ 0x%08x", addr); + } else { + snprintf(iter->value, sizeof(iter->value), + "[null]"); + } + + break; + } + case V3D_TYPE_OFFSET: snprintf(iter->value, sizeof(iter->value), "0x%08"PRIx64, __gen_unpack_uint(iter->p, s, e) << (31 - (e - s))); @@ -885,14 +928,24 @@ v3d_field_iterator_next(struct v3d_field_iterator *iter) iter->field->type.v3d_struct->name); break; case V3D_TYPE_SFIXED: - snprintf(iter->value, sizeof(iter->value), "%f", - __gen_unpack_sfixed(iter->p, s, e, - iter->field->type.f)); + if (clif->pretty) { + snprintf(iter->value, sizeof(iter->value), "%f", + __gen_unpack_sfixed(iter->p, s, e, + iter->field->type.f)); + } else { + snprintf(iter->value, sizeof(iter->value), "%u", + (unsigned)__gen_unpack_uint(iter->p, s, e)); + } break; case V3D_TYPE_UFIXED: - snprintf(iter->value, sizeof(iter->value), "%f", - __gen_unpack_ufixed(iter->p, s, e, - iter->field->type.f)); + if (clif->pretty) { + snprintf(iter->value, sizeof(iter->value), "%f", + __gen_unpack_ufixed(iter->p, s, e, + iter->field->type.f)); + } else { + snprintf(iter->value, sizeof(iter->value), "%u", + (unsigned)__gen_unpack_uint(iter->p, s, e)); + } break; case V3D_TYPE_MBO: break; @@ -926,8 +979,22 @@ v3d_print_group(struct clif_dump *clif, struct v3d_group *group, struct v3d_field_iterator iter; v3d_field_iterator_init(&iter, group, p); - while (v3d_field_iterator_next(&iter)) { - fprintf(clif->out, " %s: %s\n", iter.name, iter.value); + while (v3d_field_iterator_next(clif, &iter)) { + /* Clif parsing uses the packet name, and expects no + * sub-id. + */ + if (strcmp(iter.field->name, "sub-id") == 0 || + strcmp(iter.field->name, "unused") == 0 || + strcmp(iter.field->name, "Pad") == 0) + continue; + + if (clif->pretty) { + fprintf(clif->out, " %s: %s\n", + iter.name, iter.value); + } else { + fprintf(clif->out, " /* %30s: */ %s\n", + iter.name, iter.value); + } if (iter.struct_desc) { uint64_t struct_offset = offset + iter.offset; v3d_print_group(clif, iter.struct_desc,