<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Tue, Oct 4, 2016 at 9:26 AM Ben Widawsky <<a href="mailto:ben@bwidawsk.net">ben@bwidawsk.net</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 16-10-04 15:38:52, Lionel Landwerlin wrote:<br class="gmail_msg">
>Embed the xml files into the binary, so aubinator can be used from any<br class="gmail_msg">
>location.<br class="gmail_msg">
><br class="gmail_msg">
>Signed-off-by: Lionel Landwerlin <<a href="mailto:lionel.g.landwerlin@intel.com" class="gmail_msg" target="_blank">lionel.g.landwerlin@intel.com</a>><br class="gmail_msg">
>Cc: Sirisha Gandikota <<a href="mailto:Sirisha.Gandikota@intel.com" class="gmail_msg" target="_blank">Sirisha.Gandikota@intel.com</a>><br class="gmail_msg">
>---<br class="gmail_msg">
> src/intel/Makefile.am | 1 +<br class="gmail_msg">
> src/intel/<a href="http://Makefile.aubinator.am" rel="noreferrer" class="gmail_msg" target="_blank">Makefile.aubinator.am</a> | 36 +++++++++++++++<br class="gmail_msg">
> src/intel/Makefile.sources | 7 +++<br class="gmail_msg">
> src/intel/tools/.gitignore | 5 +++<br class="gmail_msg">
> src/intel/tools/aubinator.c | 97 +++++++++++++++++------------------------<br class="gmail_msg">
> src/intel/tools/decoder.c | 82 ++++++++++++++++++++--------------<br class="gmail_msg">
> src/intel/tools/decoder.h | 4 +-<br class="gmail_msg">
> 7 files changed, 141 insertions(+), 91 deletions(-)<br class="gmail_msg">
> create mode 100644 src/intel/<a href="http://Makefile.aubinator.am" rel="noreferrer" class="gmail_msg" target="_blank">Makefile.aubinator.am</a><br class="gmail_msg">
><br class="gmail_msg">
>diff --git a/src/intel/Makefile.am b/src/intel/Makefile.am<br class="gmail_msg">
>index 9186b5c..c3cb9fb 100644<br class="gmail_msg">
>--- a/src/intel/Makefile.am<br class="gmail_msg">
>+++ b/src/intel/Makefile.am<br class="gmail_msg">
>@@ -52,6 +52,7 @@ BUILT_SOURCES =<br class="gmail_msg">
> CLEANFILES =<br class="gmail_msg">
> EXTRA_DIST =<br class="gmail_msg">
><br class="gmail_msg">
>+include <a href="http://Makefile.aubinator.am" rel="noreferrer" class="gmail_msg" target="_blank">Makefile.aubinator.am</a><br class="gmail_msg">
> include <a href="http://Makefile.blorp.am" rel="noreferrer" class="gmail_msg" target="_blank">Makefile.blorp.am</a><br class="gmail_msg">
> include <a href="http://Makefile.common.am" rel="noreferrer" class="gmail_msg" target="_blank">Makefile.common.am</a><br class="gmail_msg">
> include <a href="http://Makefile.genxml.am" rel="noreferrer" class="gmail_msg" target="_blank">Makefile.genxml.am</a><br class="gmail_msg">
>diff --git a/src/intel/<a href="http://Makefile.aubinator.am" rel="noreferrer" class="gmail_msg" target="_blank">Makefile.aubinator.am</a> b/src/intel/<a href="http://Makefile.aubinator.am" rel="noreferrer" class="gmail_msg" target="_blank">Makefile.aubinator.am</a><br class="gmail_msg">
>new file mode 100644<br class="gmail_msg">
>index 0000000..9772700<br class="gmail_msg">
>--- /dev/null<br class="gmail_msg">
>+++ b/src/intel/<a href="http://Makefile.aubinator.am" rel="noreferrer" class="gmail_msg" target="_blank">Makefile.aubinator.am</a><br class="gmail_msg">
>@@ -0,0 +1,36 @@<br class="gmail_msg">
>+# Copyright © 2016 Intel Corporation<br class="gmail_msg">
>+#<br class="gmail_msg">
>+# Permission is hereby granted, free of charge, to any person obtaining a<br class="gmail_msg">
>+# copy of this software and associated documentation files (the "Software"),<br class="gmail_msg">
>+# to deal in the Software without restriction, including without limitation<br class="gmail_msg">
>+# the rights to use, copy, modify, merge, publish, distribute, sublicense,<br class="gmail_msg">
>+# and/or sell copies of the Software, and to permit persons to whom the<br class="gmail_msg">
>+# Software is furnished to do so, subject to the following conditions:<br class="gmail_msg">
>+#<br class="gmail_msg">
>+# The above copyright notice and this permission notice (including the next<br class="gmail_msg">
>+# paragraph) shall be included in all copies or substantial portions of the<br class="gmail_msg">
>+# Software.<br class="gmail_msg">
>+#<br class="gmail_msg">
>+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br class="gmail_msg">
>+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br class="gmail_msg">
>+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL<br class="gmail_msg">
>+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER<br class="gmail_msg">
>+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING<br class="gmail_msg">
>+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS<br class="gmail_msg">
>+# IN THE SOFTWARE.<br class="gmail_msg">
>+<br class="gmail_msg">
>+BUILT_SOURCES += $(AUBINATOR_GENERATED_FILES)<br class="gmail_msg">
>+<br class="gmail_msg">
>+SUFFIXES = _aubinator_xml.h .xml<br class="gmail_msg">
>+<br class="gmail_msg">
>+tools/gen6_aubinator_xml.h: genxml/gen6.xml<br class="gmail_msg">
>+tools/gen7_aubinator_xml.h: genxml/gen7.xml<br class="gmail_msg">
>+tools/gen75_aubinator_xml.h: genxml/gen75.xml<br class="gmail_msg">
>+tools/gen8_aubinator_xml.h: genxml/gen8.xml<br class="gmail_msg">
>+tools/gen9_aubinator_xml.h: genxml/gen9.xml<br class="gmail_msg">
>+<br class="gmail_msg">
>+$(AUBINATOR_GENERATED_FILES): Makefile<br class="gmail_msg">
>+<br class="gmail_msg">
>+%_aubinator_xml.h:<br class="gmail_msg">
>+ $(MKDIR_GEN)<br class="gmail_msg">
>+ $(AM_V_GEN) xxd -i $< > $@<br class="gmail_msg">
>diff --git a/src/intel/Makefile.sources b/src/intel/Makefile.sources<br class="gmail_msg">
>index 94073d2..a5c2bf0 100644<br class="gmail_msg">
>--- a/src/intel/Makefile.sources<br class="gmail_msg">
>+++ b/src/intel/Makefile.sources<br class="gmail_msg">
>@@ -1,3 +1,10 @@<br class="gmail_msg">
>+AUBINATOR_GENERATED_FILES = \<br class="gmail_msg">
>+ tools/gen6_aubinator_xml.h \<br class="gmail_msg">
>+ tools/gen7_aubinator_xml.h \<br class="gmail_msg">
>+ tools/gen75_aubinator_xml.h \<br class="gmail_msg">
>+ tools/gen8_aubinator_xml.h \<br class="gmail_msg">
>+ tools/gen9_aubinator_xml.h<br class="gmail_msg">
>+<br class="gmail_msg">
> BLORP_FILES = \<br class="gmail_msg">
> blorp/blorp.c \<br class="gmail_msg">
> blorp/blorp.h \<br class="gmail_msg">
>diff --git a/src/intel/tools/.gitignore b/src/intel/tools/.gitignore<br class="gmail_msg">
>index 0c80a6f..c4eebde 100644<br class="gmail_msg">
>--- a/src/intel/tools/.gitignore<br class="gmail_msg">
>+++ b/src/intel/tools/.gitignore<br class="gmail_msg">
>@@ -1 +1,6 @@<br class="gmail_msg">
> /aubinator<br class="gmail_msg">
>+gen6_aubinator_xml.h<br class="gmail_msg">
>+gen75_aubinator_xml.h<br class="gmail_msg">
>+gen7_aubinator_xml.h<br class="gmail_msg">
>+gen8_aubinator_xml.h<br class="gmail_msg">
>+gen9_aubinator_xml.h<br class="gmail_msg">
>diff --git a/src/intel/tools/aubinator.c b/src/intel/tools/aubinator.c<br class="gmail_msg">
>index a31dcb2..83328b5 100644<br class="gmail_msg">
>--- a/src/intel/tools/aubinator.c<br class="gmail_msg">
>+++ b/src/intel/tools/aubinator.c<br class="gmail_msg">
>@@ -35,6 +35,8 @@<br class="gmail_msg">
> #include <sys/wait.h><br class="gmail_msg">
> #include <sys/mman.h><br class="gmail_msg">
><br class="gmail_msg">
>+#include "util/macros.h"<br class="gmail_msg">
>+<br class="gmail_msg">
> #include "decoder.h"<br class="gmail_msg">
> #include "intel_aub.h"<br class="gmail_msg">
> #include "gen_disasm.h"<br class="gmail_msg">
>@@ -1059,11 +1061,24 @@ int main(int argc, char *argv[])<br class="gmail_msg">
> {<br class="gmail_msg">
> struct gen_spec *spec;<br class="gmail_msg">
> struct aub_file *file;<br class="gmail_msg">
>- int i, pci_id = 0;<br class="gmail_msg">
>+ int i;<br class="gmail_msg">
> bool found_arg_gen = false, pager = true;<br class="gmail_msg">
>- int gen_major, gen_minor;<br class="gmail_msg">
>- const char *value;<br class="gmail_msg">
>- char gen_file[256], gen_val[24];<br class="gmail_msg">
>+ const char *value, *input_file = NULL;<br class="gmail_msg">
>+ char gen_val[24];<br class="gmail_msg">
>+ const struct {<br class="gmail_msg">
>+ const char *name;<br class="gmail_msg">
>+ int pci_id;<br class="gmail_msg">
>+ } gens[] = {<br class="gmail_msg">
>+ { "ivb", 0x0166 }, /* Intel(R) Ivybridge Mobile GT2 */<br class="gmail_msg">
>+ { "hsw", 0x0416 }, /* Intel(R) Haswell Mobile GT2 */<br class="gmail_msg">
>+ { "byt", 0x0155 }, /* Intel(R) Bay Trail */<br class="gmail_msg">
>+ { "bdw", 0x1616 }, /* Intel(R) HD Graphics 5500 (Broadwell GT2) */<br class="gmail_msg">
>+ { "chv", 0x22B3 }, /* Intel(R) HD Graphics (Cherryview) */<br class="gmail_msg">
>+ { "skl", 0x1912 }, /* Intel(R) HD Graphics 530 (Skylake GT2) */<br class="gmail_msg">
>+ { "kbl", 0x591D }, /* Intel(R) Kabylake GT2 */<br class="gmail_msg">
>+ { "bxt", 0x0A84 } /* Intel(R) HD Graphics (Broxton) */<br class="gmail_msg">
>+ }, *gen = NULL;<br class="gmail_msg">
>+ struct gen_device_info devinfo;<br class="gmail_msg">
><br class="gmail_msg">
> if (argc == 1) {<br class="gmail_msg">
> print_help(argv[0], stderr);<br class="gmail_msg">
>@@ -1081,8 +1096,6 @@ int main(int argc, char *argv[])<br class="gmail_msg">
> exit(EXIT_FAILURE);<br class="gmail_msg">
> }<br class="gmail_msg">
> found_arg_gen = true;<br class="gmail_msg">
>- gen_major = 0;<br class="gmail_msg">
>- gen_minor = 0;<br class="gmail_msg">
> snprintf(gen_val, sizeof(gen_val), "%s", value);<br class="gmail_msg">
> } else if (strcmp(argv[i], "--headers") == 0) {<br class="gmail_msg">
> option_full_decode = false;<br class="gmail_msg">
>@@ -1105,6 +1118,7 @@ int main(int argc, char *argv[])<br class="gmail_msg">
> fprintf(stderr, "unknown option %s\n", argv[i]);<br class="gmail_msg">
> exit(EXIT_FAILURE);<br class="gmail_msg">
> }<br class="gmail_msg">
>+ input_file = argv[i];<br class="gmail_msg">
> break;<br class="gmail_msg">
> }<br class="gmail_msg">
> }<br class="gmail_msg">
>@@ -1114,52 +1128,26 @@ int main(int argc, char *argv[])<br class="gmail_msg">
> exit(EXIT_FAILURE);<br class="gmail_msg">
> }<br class="gmail_msg">
><br class="gmail_msg">
>- if (strstr(gen_val, "ivb") != NULL) {<br class="gmail_msg">
>- /* Intel(R) Ivybridge Mobile GT2 */<br class="gmail_msg">
>- pci_id = 0x0166;<br class="gmail_msg">
>- gen_major = 7;<br class="gmail_msg">
>- gen_minor = 0;<br class="gmail_msg">
>- } else if (strstr(gen_val, "hsw") != NULL) {<br class="gmail_msg">
>- /* Intel(R) Haswell Mobile GT2 */<br class="gmail_msg">
>- pci_id = 0x0416;<br class="gmail_msg">
>- gen_major = 7;<br class="gmail_msg">
>- gen_minor = 5;<br class="gmail_msg">
>- } else if (strstr(gen_val, "byt") != NULL) {<br class="gmail_msg">
>- /* Intel(R) Bay Trail */<br class="gmail_msg">
>- pci_id = 0x0155;<br class="gmail_msg">
>- gen_major = 7;<br class="gmail_msg">
>- gen_minor = 5;<br class="gmail_msg">
>- } else if (strstr(gen_val, "bdw") != NULL) {<br class="gmail_msg">
>- /* Intel(R) HD Graphics 5500 (Broadwell GT2) */<br class="gmail_msg">
>- pci_id = 0x1616;<br class="gmail_msg">
>- gen_major = 8;<br class="gmail_msg">
>- gen_minor = 0;<br class="gmail_msg">
>- } else if (strstr(gen_val, "chv") != NULL) {<br class="gmail_msg">
>- /* Intel(R) HD Graphics (Cherryview) */<br class="gmail_msg">
>- pci_id = 0x22B3;<br class="gmail_msg">
>- gen_major = 8;<br class="gmail_msg">
>- gen_minor = 0;<br class="gmail_msg">
>- } else if (strstr(gen_val, "skl") != NULL) {<br class="gmail_msg">
>- /* Intel(R) HD Graphics 530 (Skylake GT2) */<br class="gmail_msg">
>- pci_id = 0x1912;<br class="gmail_msg">
>- gen_major = 9;<br class="gmail_msg">
>- gen_minor = 0;<br class="gmail_msg">
>- } else if (strstr(gen_val, "kbl") != NULL) {<br class="gmail_msg">
>- /* Intel(R) Kabylake GT2 */<br class="gmail_msg">
>- pci_id = 0x591D;<br class="gmail_msg">
>- gen_major = 9;<br class="gmail_msg">
>- gen_minor = 0;<br class="gmail_msg">
>- } else if (strstr(gen_val, "bxt") != NULL) {<br class="gmail_msg">
>- /* Intel(R) HD Graphics (Broxton) */<br class="gmail_msg">
>- pci_id = 0x0A84;<br class="gmail_msg">
>- gen_major = 9;<br class="gmail_msg">
>- gen_minor = 0;<br class="gmail_msg">
>- } else {<br class="gmail_msg">
>+ for (i = 0; i < ARRAY_SIZE(gens); i++) {<br class="gmail_msg">
>+ if (!strcmp(gen_val, gens[i].name)) {<br class="gmail_msg">
>+ gen = &gens[i];<br class="gmail_msg">
>+ break;<br class="gmail_msg">
>+ }<br class="gmail_msg">
>+ }<br class="gmail_msg">
>+<br class="gmail_msg">
>+ if (gen == NULL) {<br class="gmail_msg">
<br class="gmail_msg">
Since we're redoing this, I'm wondering if it makes sense to use "name" at all.<br class="gmail_msg">
Maybe just the actual gen major/minor would be better? Just a thought.<br class="gmail_msg">
<br class="gmail_msg">
> fprintf(stderr, "can't parse gen: %s, expected ivb, byt, hsw, "<br class="gmail_msg">
> "bdw, chv, skl, kbl or bxt\n", gen_val);<br class="gmail_msg">
> exit(EXIT_FAILURE);<br class="gmail_msg">
> }<br class="gmail_msg">
><br class="gmail_msg">
>+ if (!gen_get_device_info(gen->pci_id, &devinfo)) {<br class="gmail_msg">
>+ fprintf(stderr, "can't find device information: pci_id=0x%x name=%s\n",<br class="gmail_msg">
>+ gen->pci_id, gen->name);<br class="gmail_msg">
>+ exit(EXIT_FAILURE);<br class="gmail_msg">
>+ }<br class="gmail_msg">
>+<br class="gmail_msg">
>+<br class="gmail_msg">
> /* Do this before we redirect stdout to pager. */<br class="gmail_msg">
> if (option_color == COLOR_AUTO)<br class="gmail_msg">
> option_color = isatty(1) ? COLOR_ALWAYS : COLOR_NEVER;<br class="gmail_msg">
>@@ -1167,21 +1155,14 @@ int main(int argc, char *argv[])<br class="gmail_msg">
> if (isatty(1) && pager)<br class="gmail_msg">
> setup_pager();<br class="gmail_msg">
><br class="gmail_msg">
>- if (gen_minor > 0) {<br class="gmail_msg">
>- snprintf(gen_file, sizeof(gen_file), "../genxml/gen%d%d.xml",<br class="gmail_msg">
>- gen_major, gen_minor);<br class="gmail_msg">
>- } else {<br class="gmail_msg">
>- snprintf(gen_file, sizeof(gen_file), "../genxml/gen%d.xml", gen_major);<br class="gmail_msg">
>- }<br class="gmail_msg">
>-<br class="gmail_msg">
>- spec = gen_spec_load(gen_file);<br class="gmail_msg">
>- disasm = gen_disasm_create(pci_id);<br class="gmail_msg">
>+ spec = gen_spec_load(&devinfo);<br class="gmail_msg">
>+ disasm = gen_disasm_create(gen->pci_id);<br class="gmail_msg">
><br class="gmail_msg">
>- if (argv[i] == NULL) {<br class="gmail_msg">
>+ if (input_file == NULL) {<br class="gmail_msg">
> print_help(argv[0], stderr);<br class="gmail_msg">
> exit(EXIT_FAILURE);<br class="gmail_msg">
> } else {<br class="gmail_msg">
>- file = aub_file_open(argv[i]);<br class="gmail_msg">
>+ file = aub_file_open(input_file);<br class="gmail_msg">
> }<br class="gmail_msg">
><br class="gmail_msg">
> while (aub_file_more_stuff(file))<br class="gmail_msg">
>diff --git a/src/intel/tools/decoder.c b/src/intel/tools/decoder.c<br class="gmail_msg">
>index be3558b..f3edc71 100644<br class="gmail_msg">
>--- a/src/intel/tools/decoder.c<br class="gmail_msg">
>+++ b/src/intel/tools/decoder.c<br class="gmail_msg">
>@@ -32,6 +32,12 @@<br class="gmail_msg">
><br class="gmail_msg">
> #include "decoder.h"<br class="gmail_msg">
><br class="gmail_msg">
>+#include "gen6_aubinator_xml.h"<br class="gmail_msg">
>+#include "gen7_aubinator_xml.h"<br class="gmail_msg">
>+#include "gen75_aubinator_xml.h"<br class="gmail_msg">
>+#include "gen8_aubinator_xml.h"<br class="gmail_msg">
>+#include "gen9_aubinator_xml.h"<br class="gmail_msg">
>+<br class="gmail_msg">
> #define XML_BUFFER_SIZE 4096<br class="gmail_msg">
><br class="gmail_msg">
> #define MAKE_GEN(major, minor) ( ((major) << 8) | (minor) )<br class="gmail_msg">
>@@ -394,57 +400,69 @@ character_data(void *data, const XML_Char *s, int len)<br class="gmail_msg">
> {<br class="gmail_msg">
> }<br class="gmail_msg">
><br class="gmail_msg">
>+static void *<br class="gmail_msg">
>+devinfo_to_xml_data(const struct gen_device_info *devinfo,<br class="gmail_msg">
>+ uint32_t *data_length)<br class="gmail_msg">
>+{<br class="gmail_msg">
>+ switch (devinfo->gen) {<br class="gmail_msg">
>+ case 6:<br class="gmail_msg">
>+ *data_length = sizeof(genxml_gen6_xml);<br class="gmail_msg">
>+ return genxml_gen6_xml;<br class="gmail_msg">
>+ case 7:<br class="gmail_msg">
>+ if (devinfo->is_haswell) {<br class="gmail_msg">
>+ *data_length = sizeof(genxml_gen75_xml);<br class="gmail_msg">
>+ return genxml_gen75_xml;<br class="gmail_msg">
>+ }<br class="gmail_msg">
>+ *data_length = sizeof(genxml_gen7_xml);<br class="gmail_msg">
>+ return genxml_gen7_xml;<br class="gmail_msg">
>+ case 8:<br class="gmail_msg">
>+ *data_length = sizeof(genxml_gen8_xml);<br class="gmail_msg">
>+ return genxml_gen8_xml;<br class="gmail_msg">
>+ case 9:<br class="gmail_msg">
>+ *data_length = sizeof(genxml_gen9_xml);<br class="gmail_msg">
>+ return genxml_gen9_xml;<br class="gmail_msg">
>+ default:<br class="gmail_msg">
>+ return NULL;<br class="gmail_msg">
>+ }<br class="gmail_msg">
>+}<br class="gmail_msg">
>+<br class="gmail_msg">
> struct gen_spec *<br class="gmail_msg">
>-gen_spec_load(const char *filename)<br class="gmail_msg">
>+gen_spec_load(const struct gen_device_info *devinfo)<br class="gmail_msg">
> {<br class="gmail_msg">
> struct parser_context ctx;<br class="gmail_msg">
>- void *buf;<br class="gmail_msg">
>- int len;<br class="gmail_msg">
>- FILE *input;<br class="gmail_msg">
>-<br class="gmail_msg">
>- input = fopen(filename, "r");<br class="gmail_msg">
>- printf("xml filename = %s\n", filename);<br class="gmail_msg">
>- if (input == NULL) {<br class="gmail_msg">
>- fprintf(stderr, "failed to open xml description\n");<br class="gmail_msg">
>- exit(EXIT_FAILURE);<br class="gmail_msg">
>- }<br class="gmail_msg">
>+ void *buf, *data;<br class="gmail_msg">
>+ uint32_t data_length = 0;<br class="gmail_msg">
><br class="gmail_msg">
> memset(&ctx, 0, sizeof ctx);<br class="gmail_msg">
> ctx.parser = XML_ParserCreate(NULL);<br class="gmail_msg">
> XML_SetUserData(ctx.parser, &ctx);<br class="gmail_msg">
> if (ctx.parser == NULL) {<br class="gmail_msg">
> fprintf(stderr, "failed to create parser\n");<br class="gmail_msg">
>- fclose(input);<br class="gmail_msg">
> return NULL;<br class="gmail_msg">
> }<br class="gmail_msg">
><br class="gmail_msg">
> XML_SetElementHandler(ctx.parser, start_element, end_element);<br class="gmail_msg">
> XML_SetCharacterDataHandler(ctx.parser, character_data);<br class="gmail_msg">
>- ctx.loc.filename = filename;<br class="gmail_msg">
><br class="gmail_msg">
> ctx.spec = xzalloc(sizeof(*ctx.spec));<br class="gmail_msg">
><br class="gmail_msg">
>- do {<br class="gmail_msg">
>- buf = XML_GetBuffer(ctx.parser, XML_BUFFER_SIZE);<br class="gmail_msg">
>- len = fread(buf, 1, XML_BUFFER_SIZE, input);<br class="gmail_msg">
>- if (len < 0) {<br class="gmail_msg">
>- fprintf(stderr, "fread: %m\n");<br class="gmail_msg">
>- fclose(input);<br class="gmail_msg">
>- return NULL;<br class="gmail_msg">
>- }<br class="gmail_msg">
>- if (XML_ParseBuffer(ctx.parser, len, len == 0) == 0) {<br class="gmail_msg">
>- fprintf(stderr,<br class="gmail_msg">
>- "Error parsing XML at line %ld col %ld: %s\n",<br class="gmail_msg">
>- XML_GetCurrentLineNumber(ctx.parser),<br class="gmail_msg">
>- XML_GetCurrentColumnNumber(ctx.parser),<br class="gmail_msg">
>- XML_ErrorString(XML_GetErrorCode(ctx.parser)));<br class="gmail_msg">
>- fclose(input);<br class="gmail_msg">
>- return NULL;<br class="gmail_msg">
>- }<br class="gmail_msg">
>- } while (len > 0);<br class="gmail_msg">
>+<br class="gmail_msg">
>+ data = devinfo_to_xml_data(devinfo, &data_length);<br class="gmail_msg">
>+ buf = XML_GetBuffer(ctx.parser, data_length);<br class="gmail_msg">
>+<br class="gmail_msg">
>+ memcpy(buf, data, data_length);<br class="gmail_msg">
>+<br class="gmail_msg">
>+ if (XML_ParseBuffer(ctx.parser, data_length, data_length == 0) == 0) {<br class="gmail_msg">
>+ fprintf(stderr,<br class="gmail_msg">
>+ "Error parsing XML at line %ld col %ld: %s\n",<br class="gmail_msg">
>+ XML_GetCurrentLineNumber(ctx.parser),<br class="gmail_msg">
>+ XML_GetCurrentColumnNumber(ctx.parser),<br class="gmail_msg">
>+ XML_ErrorString(XML_GetErrorCode(ctx.parser)));<br class="gmail_msg">
>+ XML_ParserFree(ctx.parser);<br class="gmail_msg">
>+ return NULL;<br class="gmail_msg">
>+ }<br class="gmail_msg">
><br class="gmail_msg">
> XML_ParserFree(ctx.parser);<br class="gmail_msg">
>- fclose(input);<br class="gmail_msg">
><br class="gmail_msg">
> return ctx.spec;<br class="gmail_msg">
> }<br class="gmail_msg">
>diff --git a/src/intel/tools/decoder.h b/src/intel/tools/decoder.h<br class="gmail_msg">
>index f688ba5..5bea9b9 100644<br class="gmail_msg">
>--- a/src/intel/tools/decoder.h<br class="gmail_msg">
>+++ b/src/intel/tools/decoder.h<br class="gmail_msg">
>@@ -26,6 +26,8 @@<br class="gmail_msg">
> #include <stdint.h><br class="gmail_msg">
> #include <stdbool.h><br class="gmail_msg">
><br class="gmail_msg">
>+#include "common/gen_device_info.h"<br class="gmail_msg">
>+<br class="gmail_msg">
> struct gen_spec;<br class="gmail_msg">
> struct gen_group;<br class="gmail_msg">
> struct gen_field;<br class="gmail_msg">
>@@ -36,7 +38,7 @@ static inline uint32_t gen_make_gen(uint32_t major, uint32_t minor)<br class="gmail_msg">
> }<br class="gmail_msg">
><br class="gmail_msg">
> struct gen_group *gen_spec_find_struct(struct gen_spec *spec, const char *name);<br class="gmail_msg">
>-struct gen_spec *gen_spec_load(const char *filename);<br class="gmail_msg">
>+struct gen_spec *gen_spec_load(const struct gen_device_info *devinfo);<br class="gmail_msg">
> uint32_t gen_spec_get_gen(struct gen_spec *spec);<br class="gmail_msg">
> struct gen_group *gen_spec_find_instruction(struct gen_spec *spec, const uint32_t *p);<br class="gmail_msg">
> struct gen_group *gen_spec_find_register(struct gen_spec *spec, uint32_t offset);<br class="gmail_msg">
<br class="gmail_msg">
LGTM. Might want to run it by Kristian in terms of moving away from the XML<br class="gmail_msg">
parsing. It's hard to tell if he did it because it seemed fun, or because it was<br class="gmail_msg">
for some use (honestly, being able to change XML without rebuilding does seem<br class="gmail_msg">
kind of nice to me - but I don't care much either way).<br class="gmail_msg"></blockquote><div><br></div><div>Embedding the XML works, but if we're moving away from parsing the XML from disk, a better option may be to write another python parser to generate a static const C data structure.</div><div><br></div><div>Kristian</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
_______________________________________________<br class="gmail_msg">
mesa-dev mailing list<br class="gmail_msg">
<a href="mailto:mesa-dev@lists.freedesktop.org" class="gmail_msg" target="_blank">mesa-dev@lists.freedesktop.org</a><br class="gmail_msg">
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" class="gmail_msg" target="_blank">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br class="gmail_msg">
</blockquote></div></div>