<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Oct 4, 2016 at 8:59 AM, Lionel Landwerlin <span dir="ltr"><<a href="mailto:llandwerlin@gmail.com" target="_blank">llandwerlin@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">Embed the xml files into the binary, so aubinator can be used from any<br>
location.<br>
<br>
</span>v2: Split generation packing into another patch (Jason)<br>
Check for xxd (Jason)<br>
<span class=""><br>
Signed-off-by: Lionel Landwerlin <<a href="mailto:lionel.g.landwerlin@intel.com">lionel.g.landwerlin@intel.com</a><wbr>><br>
Cc: Sirisha Gandikota <<a href="mailto:Sirisha.Gandikota@intel.com">Sirisha.Gandikota@intel.com</a>><br>
---<br>
</span> <a href="http://configure.ac" rel="noreferrer" target="_blank">configure.ac</a> | 1 +<br>
src/intel/Makefile.am | 1 +<br>
src/intel/<a href="http://Makefile.aubinator.am" rel="noreferrer" target="_blank">Makefile.aubinator.<wbr>am</a> | 36 ++++++++++++++++++<br>
src/intel/Makefile.sources | 7 ++++<br>
src/intel/tools/.gitignore | 5 +++<br>
src/intel/tools/aubinator.c | 39 ++++++++++----------<br>
src/intel/tools/decoder.c | 82 +++++++++++++++++++++++++-----<wbr>-----------<br>
src/intel/tools/decoder.h | 4 +-<br>
8 files changed, 122 insertions(+), 53 deletions(-)<br>
create mode 100644 src/intel/<a href="http://Makefile.aubinator.am" rel="noreferrer" target="_blank">Makefile.aubinator.<wbr>am</a><br>
<br>
diff --git a/<a href="http://configure.ac" rel="noreferrer" target="_blank">configure.ac</a> b/<a href="http://configure.ac" rel="noreferrer" target="_blank">configure.ac</a><br>
index 1bfac3b..7046349 100644<br>
--- a/<a href="http://configure.ac" rel="noreferrer" target="_blank">configure.ac</a><br>
+++ b/<a href="http://configure.ac" rel="noreferrer" target="_blank">configure.ac</a><br>
@@ -110,6 +110,7 @@ LT_PREREQ([2.2])<br>
LT_INIT([disable-static])<br>
<br>
AC_CHECK_PROG(RM, rm, [rm -f])<br>
+AC_CHECK_PROG(XXD, xxd, [xxd])<br>
<br>
AX_PROG_BISON([],<br>
AS_IF([test ! -f "$srcdir/src/compiler/glsl/<wbr>glcpp/glcpp-parse.c"],<br>
<span class="">diff --git a/src/intel/Makefile.am b/src/intel/Makefile.am<br>
index 9186b5c..c3cb9fb 100644<br>
--- a/src/intel/Makefile.am<br>
+++ b/src/intel/Makefile.am<br>
@@ -52,6 +52,7 @@ BUILT_SOURCES =<br>
CLEANFILES =<br>
EXTRA_DIST =<br>
<br>
+include <a href="http://Makefile.aubinator.am" rel="noreferrer" target="_blank">Makefile.aubinator.am</a><br>
include <a href="http://Makefile.blorp.am" rel="noreferrer" target="_blank">Makefile.blorp.am</a><br>
include <a href="http://Makefile.common.am" rel="noreferrer" target="_blank">Makefile.common.am</a><br>
include <a href="http://Makefile.genxml.am" rel="noreferrer" target="_blank">Makefile.genxml.am</a><br>
diff --git a/src/intel/<a href="http://Makefile.aubinator.am" rel="noreferrer" target="_blank">Makefile.<wbr>aubinator.am</a> b/src/intel/<a href="http://Makefile.aubinator.am" rel="noreferrer" target="_blank">Makefile.<wbr>aubinator.am</a><br>
new file mode 100644<br>
</span>index 0000000..3d05d30<br>
<div><div class="h5">--- /dev/null<br>
+++ b/src/intel/<a href="http://Makefile.aubinator.am" rel="noreferrer" target="_blank">Makefile.<wbr>aubinator.am</a><br>
@@ -0,0 +1,36 @@<br>
+# Copyright © 2016 Intel Corporation<br>
+#<br>
+# Permission is hereby granted, free of charge, to any person obtaining a<br>
+# copy of this software and associated documentation files (the "Software"),<br>
+# to deal in the Software without restriction, including without limitation<br>
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
+# and/or sell copies of the Software, and to permit persons to whom the<br>
+# Software is furnished to do so, subject to the following conditions:<br>
+#<br>
+# The above copyright notice and this permission notice (including the next<br>
+# paragraph) shall be included in all copies or substantial portions of the<br>
+# Software.<br>
+#<br>
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL<br>
+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER<br>
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING<br>
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS<br>
+# IN THE SOFTWARE.<br>
+<br>
+BUILT_SOURCES += $(AUBINATOR_GENERATED_FILES)<br>
+<br>
+SUFFIXES = _aubinator_xml.h .xml<br>
+<br>
+tools/gen6_aubinator_xml.h: genxml/gen6.xml<br>
+tools/gen7_aubinator_xml.h: genxml/gen7.xml<br>
+tools/gen75_aubinator_xml.h: genxml/gen75.xml<br>
+tools/gen8_aubinator_xml.h: genxml/gen8.xml<br>
+tools/gen9_aubinator_xml.h: genxml/gen9.xml<br>
+<br>
+$(AUBINATOR_GENERATED_FILES): Makefile<br>
+<br>
+%_aubinator_xml.h:<br>
+ $(MKDIR_GEN)<br>
</div></div>+ $(AM_V_GEN) $(XXD) -i $< > $@<br>
<div><div class="h5">diff --git a/src/intel/Makefile.sources b/src/intel/Makefile.sources<br>
index 94073d2..a5c2bf0 100644<br>
--- a/src/intel/Makefile.sources<br>
+++ b/src/intel/Makefile.sources<br>
@@ -1,3 +1,10 @@<br>
+AUBINATOR_GENERATED_FILES = \<br>
+ tools/gen6_aubinator_xml.h \<br>
+ tools/gen7_aubinator_xml.h \<br>
+ tools/gen75_aubinator_xml.h \<br>
+ tools/gen8_aubinator_xml.h \<br>
+ tools/gen9_aubinator_xml.h<br>
+<br>
BLORP_FILES = \<br>
blorp/blorp.c \<br>
blorp/blorp.h \<br>
diff --git a/src/intel/tools/.gitignore b/src/intel/tools/.gitignore<br>
index 0c80a6f..c4eebde 100644<br>
--- a/src/intel/tools/.gitignore<br>
+++ b/src/intel/tools/.gitignore<br>
@@ -1 +1,6 @@<br>
/aubinator<br>
+gen6_aubinator_xml.h<br>
+gen75_aubinator_xml.h<br>
+gen7_aubinator_xml.h<br>
+gen8_aubinator_xml.h<br>
+gen9_aubinator_xml.h<br>
diff --git a/src/intel/tools/aubinator.c b/src/intel/tools/aubinator.c<br>
</div></div>index 459e3d4..3599867 100644<br>
--- a/src/intel/tools/aubinator.c<br>
+++ b/src/intel/tools/aubinator.c<br>
@@ -1065,22 +1065,21 @@ int main(int argc, char *argv[])<br>
<span class=""> int i;<br>
bool found_arg_gen = false, pager = true;<br>
</span><span class=""> const char *value, *input_file = NULL;<br>
- char gen_file[256], gen_val[24];<br>
</span>+ char gen_val[24];<br>
const struct {<br>
const char *name;<br>
int pci_id;<br>
- int major;<br>
- int minor;<br>
} gens[] = {<br>
- { "ivb", 0x0166, 7, 0 }, /* Intel(R) Ivybridge Mobile GT2 */<br>
- { "hsw", 0x0416, 7, 5 }, /* Intel(R) Haswell Mobile GT2 */<br>
- { "byt", 0x0155, 7, 5 }, /* Intel(R) Bay Trail */<br>
- { "bdw", 0x1616, 8, 0 }, /* Intel(R) HD Graphics 5500 (Broadwell GT2) */<br>
- { "chv", 0x22B3, 8, 0 }, /* Intel(R) HD Graphics (Cherryview) */<br>
- { "skl", 0x1912, 9, 0 }, /* Intel(R) HD Graphics 530 (Skylake GT2) */<br>
- { "kbl", 0x591D, 9, 0 }, /* Intel(R) Kabylake GT2 */<br>
- { "bxt", 0x0A84, 9, 0 } /* Intel(R) HD Graphics (Broxton) */<br>
+ { "ivb", 0x0166 }, /* Intel(R) Ivybridge Mobile GT2 */<br>
<span class="">+ { "hsw", 0x0416 }, /* Intel(R) Haswell Mobile GT2 */<br>
+ { "byt", 0x0155 }, /* Intel(R) Bay Trail */<br>
+ { "bdw", 0x1616 }, /* Intel(R) HD Graphics 5500 (Broadwell GT2) */<br>
+ { "chv", 0x22B3 }, /* Intel(R) HD Graphics (Cherryview) */<br>
+ { "skl", 0x1912 }, /* Intel(R) HD Graphics 530 (Skylake GT2) */<br>
+ { "kbl", 0x591D }, /* Intel(R) Kabylake GT2 */<br>
+ { "bxt", 0x0A84 } /* Intel(R) HD Graphics (Broxton) */<br>
</span><span class=""> }, *gen = NULL;<br>
+ struct gen_device_info devinfo;<br>
<br>
if (argc == 1) {<br>
print_help(argv[0], stderr);<br>
</span>@@ -1143,6 +1142,13 @@ int main(int argc, char *argv[])<br>
exit(EXIT_FAILURE);<br>
}<br>
<br>
<span class="">+ if (!gen_get_device_info(gen-><wbr>pci_id, &devinfo)) {<br>
+ fprintf(stderr, "can't find device information: pci_id=0x%x name=%s\n",<br>
+ gen->pci_id, gen->name);<br>
+ exit(EXIT_FAILURE);<br>
+ }<br>
+<br>
+<br>
/* Do this before we redirect stdout to pager. */<br>
if (option_color == COLOR_AUTO)<br>
option_color = isatty(1) ? COLOR_ALWAYS : COLOR_NEVER;<br>
</span>@@ -1150,17 +1156,10 @@ int main(int argc, char *argv[])<br>
<span class=""> if (isatty(1) && pager)<br>
setup_pager();<br>
<br>
</span>- if (gen->minor > 0) {<br>
<span class="">- snprintf(gen_file, sizeof(gen_file), "../genxml/gen%d%d.xml",<br>
</span>- gen->major, gen->minor);<br>
- } else {<br>
- snprintf(gen_file, sizeof(gen_file), "../genxml/gen%d.xml", gen->major);<br>
<span class="">- }<br>
-<br>
- spec = gen_spec_load(gen_file);<br>
</span>+ spec = gen_spec_load(&devinfo);<br>
<span class=""> disasm = gen_disasm_create(gen->pci_id)<wbr>;<br>
<br>
- if (argv[i] == NULL) {<br>
+ if (input_file == NULL) {<br></span></blockquote><div><br></div><div>I think this hunk belongs in the next commit.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
print_help(argv[0], stderr);<br>
exit(EXIT_FAILURE);<br>
} else {<br>
</span>diff --git a/src/intel/tools/decoder.c b/src/intel/tools/decoder.c<br>
index 4cbaab2..2be26e9 100644<br>
--- a/src/intel/tools/decoder.c<br>
+++ b/src/intel/tools/decoder.c<br>
@@ -33,6 +33,12 @@<br>
<span class=""><br>
#include "decoder.h"<br>
<br>
+#include "gen6_aubinator_xml.h"<br>
+#include "gen7_aubinator_xml.h"<br>
+#include "gen75_aubinator_xml.h"<br>
+#include "gen8_aubinator_xml.h"<br>
+#include "gen9_aubinator_xml.h"<br>
+<br>
#define XML_BUFFER_SIZE 4096<br>
<br>
#define MAKE_GEN(major, minor) ( ((major) << 8) | (minor) )<br>
</span>@@ -395,57 +401,69 @@ character_data(void *data, const XML_Char *s, int len)<br>
<div class="HOEnZb"><div class="h5"> {<br>
}<br>
<br>
+static void *<br>
+devinfo_to_xml_data(const struct gen_device_info *devinfo,<br>
+ uint32_t *data_length)<br>
+{<br>
+ switch (devinfo->gen) {<br>
+ case 6:<br>
+ *data_length = sizeof(genxml_gen6_xml);<br>
+ return genxml_gen6_xml;<br>
+ case 7:<br>
+ if (devinfo->is_haswell) {<br>
+ *data_length = sizeof(genxml_gen75_xml);<br>
+ return genxml_gen75_xml;<br>
+ }<br>
+ *data_length = sizeof(genxml_gen7_xml);<br>
+ return genxml_gen7_xml;<br>
+ case 8:<br>
+ *data_length = sizeof(genxml_gen8_xml);<br>
+ return genxml_gen8_xml;<br>
+ case 9:<br>
+ *data_length = sizeof(genxml_gen9_xml);<br>
+ return genxml_gen9_xml;<br>
+ default:<br>
+ return NULL;<br>
+ }<br>
+}<br>
+<br>
struct gen_spec *<br>
-gen_spec_load(const char *filename)<br>
+gen_spec_load(const struct gen_device_info *devinfo)<br>
{<br>
struct parser_context ctx;<br>
- void *buf;<br>
- int len;<br>
- FILE *input;<br>
-<br>
- input = fopen(filename, "r");<br>
- printf("xml filename = %s\n", filename);<br>
- if (input == NULL) {<br>
- fprintf(stderr, "failed to open xml description\n");<br>
- exit(EXIT_FAILURE);<br>
- }<br>
+ void *buf, *data;<br>
+ uint32_t data_length = 0;<br>
<br>
memset(&ctx, 0, sizeof ctx);<br>
ctx.parser = XML_ParserCreate(NULL);<br>
XML_SetUserData(ctx.parser, &ctx);<br>
if (ctx.parser == NULL) {<br>
fprintf(stderr, "failed to create parser\n");<br>
- fclose(input);<br>
return NULL;<br>
}<br>
<br>
XML_SetElementHandler(ctx.<wbr>parser, start_element, end_element);<br>
XML_SetCharacterDataHandler(<wbr>ctx.parser, character_data);<br>
- ctx.loc.filename = filename;<br>
<br>
ctx.spec = xzalloc(sizeof(*ctx.spec));<br>
<br>
- do {<br>
- buf = XML_GetBuffer(ctx.parser, XML_BUFFER_SIZE);<br>
- len = fread(buf, 1, XML_BUFFER_SIZE, input);<br>
- if (len < 0) {<br>
- fprintf(stderr, "fread: %m\n");<br>
- fclose(input);<br>
- return NULL;<br>
- }<br>
- if (XML_ParseBuffer(ctx.parser, len, len == 0) == 0) {<br>
- fprintf(stderr,<br>
- "Error parsing XML at line %ld col %ld: %s\n",<br>
- XML_GetCurrentLineNumber(ctx.<wbr>parser),<br>
- XML_GetCurrentColumnNumber(<wbr>ctx.parser),<br>
- XML_ErrorString(XML_<wbr>GetErrorCode(ctx.parser)));<br>
- fclose(input);<br>
- return NULL;<br>
- }<br>
- } while (len > 0);<br>
+<br>
+ data = devinfo_to_xml_data(devinfo, &data_length);<br>
+ buf = XML_GetBuffer(ctx.parser, data_length);<br>
+<br>
+ memcpy(buf, data, data_length);<br>
+<br>
+ if (XML_ParseBuffer(ctx.parser, data_length, data_length == 0) == 0) {<br>
+ fprintf(stderr,<br>
+ "Error parsing XML at line %ld col %ld: %s\n",<br>
+ XML_GetCurrentLineNumber(ctx.<wbr>parser),<br>
+ XML_GetCurrentColumnNumber(<wbr>ctx.parser),<br>
+ XML_ErrorString(XML_<wbr>GetErrorCode(ctx.parser)));<br>
+ XML_ParserFree(ctx.parser);<br>
+ return NULL;<br>
+ }<br>
<br>
XML_ParserFree(ctx.parser);<br>
- fclose(input);<br>
<br>
return ctx.spec;<br>
}<br>
diff --git a/src/intel/tools/decoder.h b/src/intel/tools/decoder.h<br>
index f688ba5..5bea9b9 100644<br>
--- a/src/intel/tools/decoder.h<br>
+++ b/src/intel/tools/decoder.h<br>
@@ -26,6 +26,8 @@<br>
#include <stdint.h><br>
#include <stdbool.h><br>
<br>
+#include "common/gen_device_info.h"<br>
+<br>
struct gen_spec;<br>
struct gen_group;<br>
struct gen_field;<br>
@@ -36,7 +38,7 @@ static inline uint32_t gen_make_gen(uint32_t major, uint32_t minor)<br>
}<br>
<br>
struct gen_group *gen_spec_find_struct(struct gen_spec *spec, const char *name);<br>
-struct gen_spec *gen_spec_load(const char *filename);<br>
+struct gen_spec *gen_spec_load(const struct gen_device_info *devinfo);<br>
uint32_t gen_spec_get_gen(struct gen_spec *spec);<br>
struct gen_group *gen_spec_find_instruction(<wbr>struct gen_spec *spec, const uint32_t *p);<br>
struct gen_group *gen_spec_find_register(struct gen_spec *spec, uint32_t offset);<br>
--<br>
2.9.3<br>
<br>
______________________________<wbr>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
</div></div></blockquote></div><br></div></div>