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)
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];
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)
{
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));
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) {
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 +
__gen_unpack_float(iter->p, s, e));
break;
+ 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));
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;
v3d_field_iterator_init(&iter, group, p);
while (v3d_field_iterator_next(clif, &iter)) {
- fprintf(clif->out, " %s: %s\n", iter.name, iter.value);
+ /* 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,