intel/genxml: Add support for dword/bits in fields to rest of the code

Change code to temporarily support both the start/end old format and the
dword/bits new format.

Acked-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Acked-by: José Roberto de Souza <jose.souza@intel.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36138>
This commit is contained in:
Caio Oliveira
2025-07-21 22:43:38 -07:00
committed by Marge Bot
parent 001f207ee0
commit fb8f14820a
5 changed files with 177 additions and 13 deletions
+54 -7
View File
@@ -147,6 +147,11 @@ static void
get_array_offset_count(const char **atts, uint32_t *offset, uint32_t *count,
uint32_t *size, bool *variable)
{
bool is_old_format = false;
bool is_new_format = false;
*offset = 0;
for (int i = 0; atts[i]; i += 2) {
char *p;
@@ -155,12 +160,21 @@ get_array_offset_count(const char **atts, uint32_t *offset, uint32_t *count,
if (*count == 0)
*variable = true;
} else if (strcmp(atts[i], "start") == 0) {
assert(!is_new_format);
is_old_format = true;
*offset = strtoul(atts[i + 1], &p, 0);
} else if (strcmp(atts[i], "dword") == 0) {
assert(!is_old_format);
is_new_format = true;
*offset += 32 * strtoul(atts[i + 1], &p, 0);
} else if (strcmp(atts[i], "offset_bits") == 0) {
assert(!is_old_format);
is_new_format = true;
*offset += strtoul(atts[i + 1], &p, 0);
} else if (strcmp(atts[i], "size") == 0) {
*size = strtoul(atts[i + 1], &p, 0);
}
}
return;
}
static struct intel_group *
@@ -336,6 +350,16 @@ create_field(struct parser_context *ctx, const char **atts)
field = rzalloc(ctx->group, struct intel_field);
field->parent = ctx->group;
bool is_old_format = false;
bool is_new_format = false;
uint32_t dword = 0;
uint32_t bits_start = 0;
uint32_t bits_end = 0;
bool has_default = false;
uint32_t default_value = 0;
for (int i = 0; atts[i]; i += 2) {
char *p;
@@ -345,18 +369,41 @@ create_field(struct parser_context *ctx, const char **atts)
field->parent->dword_length_field = field;
}
} else if (strcmp(atts[i], "start") == 0) {
field->start = strtoul(atts[i + 1], &p, 0);
assert(!is_new_format);
is_old_format = true;
bits_start = strtoul(atts[i + 1], &p, 0);
} else if (strcmp(atts[i], "end") == 0) {
field->end = strtoul(atts[i + 1], &p, 0);
assert(!is_new_format);
is_old_format = true;
bits_end = strtoul(atts[i + 1], &p, 0);
} else if (strcmp(atts[i], "dword") == 0) {
assert(!is_old_format);
is_new_format = true;
dword = strtoul(atts[i + 1], &p, 10);
} else if (strcmp(atts[i], "bits") == 0) {
assert(!is_old_format);
is_new_format = true;
const char *bits_str = atts[i + 1];
const char *colon = strchr(bits_str, ':');
assert(colon);
bits_end = strtoul(bits_str, NULL, 10);
bits_start = strtoul(colon+1, NULL, 10);
} else if (strcmp(atts[i], "type") == 0) {
field->type = string_to_type(ctx, atts[i + 1]);
} else if (strcmp(atts[i], "default") == 0 &&
field->start >= 16 && field->end <= 31) {
field->has_default = true;
field->default_value = strtoul(atts[i + 1], &p, 0);
} else if (strcmp(atts[i], "default") == 0) {
has_default = true;
default_value = strtoul(atts[i + 1], &p, 0);
}
}
field->start = dword * 32 + bits_start;
field->end = dword * 32 + bits_end;
if (has_default && field->start >= 16 && field->end <= 31) {
field->has_default = true;
field->default_value = default_value;
}
return field;
}