summaryrefslogtreecommitdiffstats
path: root/src/intel
diff options
context:
space:
mode:
authorLionel Landwerlin <[email protected]>2016-10-04 16:19:43 +0100
committerLionel Landwerlin <[email protected]>2016-10-08 02:17:03 +0100
commit63a366a8813fec3836213cfd5ab006add332ec84 (patch)
tree1a063ce5fcdaa7bb449c05bedb02ed6ec3894cab /src/intel
parent4d7d9825f34a31368e63c493c28d57c8f84a984c (diff)
intel: aubinator: generate a standalone binary
Embed the xml files into the binary, so aubinator can be used from any location. v2: Split generation packing into another patch (Jason) Check for xxd (Jason) v3: Fix out of tree builds (Jason) Generate custom variable name rather than names generated by xxd (Lionel) v4: Move generated _xml.h files to genxml/ (Sirisha) v5: Remove newline from makefile (Jason) v6: Add comment on gen*_xml.h creation (Jason) Signed-off-by: Lionel Landwerlin <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
Diffstat (limited to 'src/intel')
-rw-r--r--src/intel/Makefile.genxml.am12
-rw-r--r--src/intel/Makefile.sources7
-rw-r--r--src/intel/genxml/.gitignore1
-rw-r--r--src/intel/tools/aubinator.c37
-rw-r--r--src/intel/tools/decoder.c94
-rw-r--r--src/intel/tools/decoder.h4
6 files changed, 102 insertions, 53 deletions
diff --git a/src/intel/Makefile.genxml.am b/src/intel/Makefile.genxml.am
index f80e2fd3bb8..8d7d4026638 100644
--- a/src/intel/Makefile.genxml.am
+++ b/src/intel/Makefile.genxml.am
@@ -21,7 +21,7 @@
BUILT_SOURCES += $(GENXML_GENERATED_FILES)
-SUFFIXES = _pack.h .xml
+SUFFIXES = _pack.h _xml.h .xml
$(GENXML_GENERATED_FILES): genxml/gen_pack_header.py
@@ -29,6 +29,16 @@ $(GENXML_GENERATED_FILES): genxml/gen_pack_header.py
$(MKDIR_GEN)
$(PYTHON_GEN) $(srcdir)/genxml/gen_pack_header.py $< > $@
+# xxd generates variable names based on the path of the input file. We
+# prefer to generate our own name here, so it doesn't vary from
+# in/out-of-tree builds.
+%_xml.h: %.xml Makefile
+ $(MKDIR_GEN)
+ $(AM_V_GEN) echo -n "static const uint8_t " > $@; \
+ sed -e 's,_xml.h,,' <<< "`basename $@`_xml[] = {" >> $@; \
+ cat $< | $(XXD) -i >> $@; \
+ echo "};" >> $@
+
EXTRA_DIST += \
genxml/gen4.xml \
genxml/gen45.xml \
diff --git a/src/intel/Makefile.sources b/src/intel/Makefile.sources
index 22ca63bc388..5b759bf98f0 100644
--- a/src/intel/Makefile.sources
+++ b/src/intel/Makefile.sources
@@ -21,7 +21,12 @@ GENXML_GENERATED_FILES = \
genxml/gen7_pack.h \
genxml/gen75_pack.h \
genxml/gen8_pack.h \
- genxml/gen9_pack.h
+ genxml/gen9_pack.h \
+ genxml/gen6_xml.h \
+ genxml/gen7_xml.h \
+ genxml/gen75_xml.h \
+ genxml/gen8_xml.h \
+ genxml/gen9_xml.h
ISL_FILES = \
isl/isl.c \
diff --git a/src/intel/genxml/.gitignore b/src/intel/genxml/.gitignore
index dd114953c31..c5672b5595c 100644
--- a/src/intel/genxml/.gitignore
+++ b/src/intel/genxml/.gitignore
@@ -1 +1,2 @@
gen*_pack.h
+gen*_xml.h
diff --git a/src/intel/tools/aubinator.c b/src/intel/tools/aubinator.c
index 44a6bb2aa7b..8be7580c2b1 100644
--- a/src/intel/tools/aubinator.c
+++ b/src/intel/tools/aubinator.c
@@ -1048,21 +1048,19 @@ int main(int argc, char *argv[])
int c, i;
bool help = false, pager = true;
const char *input_file = NULL;
- char gen_file[256], gen_val[24];
+ char gen_val[24];
const struct {
const char *name;
int pci_id;
- int major;
- int minor;
} gens[] = {
- { "ivb", 0x0166, 7, 0 }, /* Intel(R) Ivybridge Mobile GT2 */
- { "hsw", 0x0416, 7, 5 }, /* Intel(R) Haswell Mobile GT2 */
- { "byt", 0x0155, 7, 5 }, /* Intel(R) Bay Trail */
- { "bdw", 0x1616, 8, 0 }, /* Intel(R) HD Graphics 5500 (Broadwell GT2) */
- { "chv", 0x22B3, 8, 0 }, /* Intel(R) HD Graphics (Cherryview) */
- { "skl", 0x1912, 9, 0 }, /* Intel(R) HD Graphics 530 (Skylake GT2) */
- { "kbl", 0x591D, 9, 0 }, /* Intel(R) Kabylake GT2 */
- { "bxt", 0x0A84, 9, 0 } /* Intel(R) HD Graphics (Broxton) */
+ { "ivb", 0x0166 }, /* Intel(R) Ivybridge Mobile GT2 */
+ { "hsw", 0x0416 }, /* Intel(R) Haswell Mobile GT2 */
+ { "byt", 0x0155 }, /* Intel(R) Bay Trail */
+ { "bdw", 0x1616 }, /* Intel(R) HD Graphics 5500 (Broadwell GT2) */
+ { "chv", 0x22B3 }, /* Intel(R) HD Graphics (Cherryview) */
+ { "skl", 0x1912 }, /* Intel(R) HD Graphics 530 (Skylake GT2) */
+ { "kbl", 0x591D }, /* Intel(R) Kabylake GT2 */
+ { "bxt", 0x0A84 } /* Intel(R) HD Graphics (Broxton) */
}, *gen = NULL;
const struct option aubinator_opts[] = {
{ "help", no_argument, (int *) &help, true },
@@ -1073,6 +1071,7 @@ int main(int argc, char *argv[])
{ "color", required_argument, NULL, 'c' },
{ NULL, 0, NULL, 0 }
};
+ struct gen_device_info devinfo;
i = 0;
while ((c = getopt_long(argc, argv, "", aubinator_opts, &i)) != -1) {
@@ -1118,6 +1117,13 @@ int main(int argc, char *argv[])
exit(EXIT_FAILURE);
}
+ if (!gen_get_device_info(gen->pci_id, &devinfo)) {
+ fprintf(stderr, "can't find device information: pci_id=0x%x name=%s\n",
+ gen->pci_id, gen->name);
+ exit(EXIT_FAILURE);
+ }
+
+
/* Do this before we redirect stdout to pager. */
if (option_color == COLOR_AUTO)
option_color = isatty(1) ? COLOR_ALWAYS : COLOR_NEVER;
@@ -1125,14 +1131,7 @@ int main(int argc, char *argv[])
if (isatty(1) && pager)
setup_pager();
- if (gen->minor > 0) {
- snprintf(gen_file, sizeof(gen_file), "../genxml/gen%d%d.xml",
- gen->major, gen->minor);
- } else {
- snprintf(gen_file, sizeof(gen_file), "../genxml/gen%d.xml", gen->major);
- }
-
- spec = gen_spec_load(gen_file);
+ spec = gen_spec_load(&devinfo);
disasm = gen_disasm_create(gen->pci_id);
if (input_file == NULL) {
diff --git a/src/intel/tools/decoder.c b/src/intel/tools/decoder.c
index 4cbaab2e0c3..778cd5bd9b5 100644
--- a/src/intel/tools/decoder.c
+++ b/src/intel/tools/decoder.c
@@ -33,6 +33,12 @@
#include "decoder.h"
+#include "genxml/gen6_xml.h"
+#include "genxml/gen7_xml.h"
+#include "genxml/gen75_xml.h"
+#include "genxml/gen8_xml.h"
+#include "genxml/gen9_xml.h"
+
#define XML_BUFFER_SIZE 4096
#define MAKE_GEN(major, minor) ( ((major) << 8) | (minor) )
@@ -395,57 +401,83 @@ character_data(void *data, const XML_Char *s, int len)
{
}
+static int
+devinfo_to_gen(const struct gen_device_info *devinfo)
+{
+ int value = 10 * devinfo->gen;
+
+ if (devinfo->is_baytrail || devinfo->is_haswell)
+ value += 5;
+
+ return value;
+}
+
+static const struct {
+ int gen;
+ const uint8_t *data;
+ size_t data_length;
+} gen_data[] = {
+ { .gen = 60, .data = gen6_xml, .data_length = sizeof(gen6_xml) },
+ { .gen = 70, .data = gen7_xml, .data_length = sizeof(gen7_xml) },
+ { .gen = 75, .data = gen75_xml, .data_length = sizeof(gen75_xml) },
+ { .gen = 80, .data = gen8_xml, .data_length = sizeof(gen8_xml) },
+ { .gen = 90, .data = gen9_xml, .data_length = sizeof(gen9_xml) }
+};
+
+static const uint8_t *
+devinfo_to_xml_data(const struct gen_device_info *devinfo,
+ uint32_t *data_length)
+{
+ int i, gen = devinfo_to_gen(devinfo);
+
+ for (i = 0; i < ARRAY_SIZE(gen_data); i++) {
+ if (gen_data[i].gen == gen) {
+ *data_length = gen_data[i].data_length;
+ return gen_data[i].data;
+ }
+ }
+
+ unreachable("Unknown generation");
+ return NULL;
+}
+
struct gen_spec *
-gen_spec_load(const char *filename)
+gen_spec_load(const struct gen_device_info *devinfo)
{
struct parser_context ctx;
void *buf;
- int len;
- FILE *input;
-
- input = fopen(filename, "r");
- printf("xml filename = %s\n", filename);
- if (input == NULL) {
- fprintf(stderr, "failed to open xml description\n");
- exit(EXIT_FAILURE);
- }
+ const void *data;
+ uint32_t data_length = 0;
memset(&ctx, 0, sizeof ctx);
ctx.parser = XML_ParserCreate(NULL);
XML_SetUserData(ctx.parser, &ctx);
if (ctx.parser == NULL) {
fprintf(stderr, "failed to create parser\n");
- fclose(input);
return NULL;
}
XML_SetElementHandler(ctx.parser, start_element, end_element);
XML_SetCharacterDataHandler(ctx.parser, character_data);
- ctx.loc.filename = filename;
ctx.spec = xzalloc(sizeof(*ctx.spec));
- do {
- buf = XML_GetBuffer(ctx.parser, XML_BUFFER_SIZE);
- len = fread(buf, 1, XML_BUFFER_SIZE, input);
- if (len < 0) {
- fprintf(stderr, "fread: %m\n");
- fclose(input);
- return NULL;
- }
- if (XML_ParseBuffer(ctx.parser, len, len == 0) == 0) {
- fprintf(stderr,
- "Error parsing XML at line %ld col %ld: %s\n",
- XML_GetCurrentLineNumber(ctx.parser),
- XML_GetCurrentColumnNumber(ctx.parser),
- XML_ErrorString(XML_GetErrorCode(ctx.parser)));
- fclose(input);
- return NULL;
- }
- } while (len > 0);
+ data = devinfo_to_xml_data(devinfo, &data_length);
+ buf = XML_GetBuffer(ctx.parser, data_length);
+
+ memcpy(buf, data, data_length);
+
+ if (XML_ParseBuffer(ctx.parser, data_length, true) == 0) {
+ fprintf(stderr,
+ "Error parsing XML at line %ld col %ld: %s\n",
+ XML_GetCurrentLineNumber(ctx.parser),
+ XML_GetCurrentColumnNumber(ctx.parser),
+ XML_ErrorString(XML_GetErrorCode(ctx.parser)));
+ XML_ParserFree(ctx.parser);
+ return NULL;
+ }
XML_ParserFree(ctx.parser);
- fclose(input);
return ctx.spec;
}
diff --git a/src/intel/tools/decoder.h b/src/intel/tools/decoder.h
index f688ba59e8b..5bea9b957f6 100644
--- a/src/intel/tools/decoder.h
+++ b/src/intel/tools/decoder.h
@@ -26,6 +26,8 @@
#include <stdint.h>
#include <stdbool.h>
+#include "common/gen_device_info.h"
+
struct gen_spec;
struct gen_group;
struct gen_field;
@@ -36,7 +38,7 @@ static inline uint32_t gen_make_gen(uint32_t major, uint32_t minor)
}
struct gen_group *gen_spec_find_struct(struct gen_spec *spec, const char *name);
-struct gen_spec *gen_spec_load(const char *filename);
+struct gen_spec *gen_spec_load(const struct gen_device_info *devinfo);
uint32_t gen_spec_get_gen(struct gen_spec *spec);
struct gen_group *gen_spec_find_instruction(struct gen_spec *spec, const uint32_t *p);
struct gen_group *gen_spec_find_register(struct gen_spec *spec, uint32_t offset);