2016-08-19 12:13:24 -07:00
|
|
|
/*
|
|
|
|
|
* Copyright © 2016 Intel Corporation
|
|
|
|
|
*
|
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
|
*
|
|
|
|
|
* The above copyright notice and this permission notice (including the next
|
|
|
|
|
* paragraph) shall be included in all copies or substantial portions of the
|
|
|
|
|
* Software.
|
|
|
|
|
*
|
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
|
|
|
* IN THE SOFTWARE.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <stdint.h>
|
2018-07-28 14:27:49 +01:00
|
|
|
#include <stdbool.h>
|
2016-10-04 16:29:55 +01:00
|
|
|
#include <getopt.h>
|
2016-08-19 12:13:24 -07:00
|
|
|
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <signal.h>
|
|
|
|
|
#include <errno.h>
|
2016-10-04 12:03:14 +11:00
|
|
|
#include <inttypes.h>
|
2016-08-19 12:13:24 -07:00
|
|
|
#include <sys/types.h>
|
|
|
|
|
#include <sys/stat.h>
|
|
|
|
|
#include <sys/wait.h>
|
|
|
|
|
#include <sys/mman.h>
|
|
|
|
|
|
2025-01-15 21:45:32 -08:00
|
|
|
#include "intel_tools.h"
|
2016-10-04 16:17:56 +01:00
|
|
|
#include "util/macros.h"
|
|
|
|
|
|
2018-07-28 19:13:04 +01:00
|
|
|
#include "aub_read.h"
|
2018-07-29 01:01:36 +01:00
|
|
|
#include "aub_mem.h"
|
2016-08-19 12:13:24 -07:00
|
|
|
|
|
|
|
|
#define CSI "\e["
|
2016-10-17 09:11:04 -07:00
|
|
|
#define GREEN_HEADER CSI "1;42m"
|
|
|
|
|
#define NORMAL CSI "0m"
|
2016-08-19 12:13:24 -07:00
|
|
|
|
|
|
|
|
/* options */
|
|
|
|
|
|
2018-06-12 12:18:19 -07:00
|
|
|
static int option_full_decode = true;
|
|
|
|
|
static int option_print_offsets = true;
|
2018-05-02 18:40:28 +01:00
|
|
|
static int max_vbo_lines = -1;
|
2016-08-19 12:13:24 -07:00
|
|
|
static enum { COLOR_AUTO, COLOR_ALWAYS, COLOR_NEVER } option_color;
|
|
|
|
|
|
|
|
|
|
/* state */
|
|
|
|
|
|
2016-11-23 19:14:27 -08:00
|
|
|
uint16_t pci_id = 0;
|
2016-11-23 20:24:00 -08:00
|
|
|
char *input_file = NULL, *xml_path = NULL;
|
2021-04-05 13:19:39 -07:00
|
|
|
struct intel_device_info devinfo;
|
2021-03-03 13:49:18 -08:00
|
|
|
struct intel_batch_decode_ctx batch_ctx;
|
2025-04-30 12:16:38 -07:00
|
|
|
struct intel_isa_info isa_info = {};
|
2018-07-29 01:01:36 +01:00
|
|
|
struct aub_mem mem;
|
2016-08-19 12:13:24 -07:00
|
|
|
|
2017-03-15 01:22:00 -07:00
|
|
|
FILE *outfile;
|
|
|
|
|
|
2016-08-19 12:13:24 -07:00
|
|
|
static void
|
2018-07-28 19:13:04 +01:00
|
|
|
aubinator_error(void *user_data, const void *aub_data, const char *msg)
|
2016-08-19 12:13:24 -07:00
|
|
|
{
|
2018-08-25 12:00:30 +02:00
|
|
|
fprintf(stderr, "%s", msg);
|
2016-08-19 12:13:24 -07:00
|
|
|
}
|
|
|
|
|
|
2022-05-19 17:06:48 +02:00
|
|
|
static void
|
|
|
|
|
aubinator_comment(void *user_data, const char *str)
|
|
|
|
|
{
|
|
|
|
|
fprintf(outfile, "%s\n", str);
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-23 19:14:27 -08:00
|
|
|
static void
|
2018-07-28 19:13:04 +01:00
|
|
|
aubinator_init(void *user_data, int aub_pci_id, const char *app_name)
|
2016-11-23 19:14:27 -08:00
|
|
|
{
|
2018-07-28 19:13:04 +01:00
|
|
|
pci_id = aub_pci_id;
|
|
|
|
|
|
2021-04-05 15:59:35 -07:00
|
|
|
if (!intel_get_device_info_from_pci_id(pci_id, &devinfo)) {
|
2016-11-23 19:14:27 -08:00
|
|
|
fprintf(stderr, "can't find device information: pci_id=0x%x\n", pci_id);
|
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-03 13:49:18 -08:00
|
|
|
enum intel_batch_decode_flags batch_flags = 0;
|
2017-12-13 11:51:01 -08:00
|
|
|
if (option_color == COLOR_ALWAYS)
|
2021-03-03 13:58:15 -08:00
|
|
|
batch_flags |= INTEL_BATCH_DECODE_IN_COLOR;
|
2017-12-13 11:51:01 -08:00
|
|
|
if (option_full_decode)
|
2021-03-03 13:58:15 -08:00
|
|
|
batch_flags |= INTEL_BATCH_DECODE_FULL;
|
2017-12-13 11:51:01 -08:00
|
|
|
if (option_print_offsets)
|
2021-03-03 13:58:15 -08:00
|
|
|
batch_flags |= INTEL_BATCH_DECODE_OFFSETS;
|
|
|
|
|
batch_flags |= INTEL_BATCH_DECODE_FLOATS;
|
2016-11-23 19:14:27 -08:00
|
|
|
|
2025-04-30 12:16:38 -07:00
|
|
|
intel_decoder_init(&batch_ctx, &isa_info, &devinfo, outfile,
|
2025-01-15 21:45:32 -08:00
|
|
|
batch_flags, xml_path, NULL, NULL, NULL);
|
2018-09-05 10:19:47 -07:00
|
|
|
|
|
|
|
|
/* Check for valid spec instance, if wrong xml_path is passed then spec
|
|
|
|
|
* instance is not initialized properly
|
|
|
|
|
*/
|
|
|
|
|
if (!batch_ctx.spec) {
|
2021-03-03 13:49:18 -08:00
|
|
|
fprintf(stderr, "Failed to initialize intel_batch_decode_ctx "
|
2018-09-05 10:19:47 -07:00
|
|
|
"spec instance\n");
|
|
|
|
|
free(xml_path);
|
2021-03-03 13:49:18 -08:00
|
|
|
intel_batch_decode_ctx_finish(&batch_ctx);
|
2018-09-05 10:19:47 -07:00
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
|
}
|
|
|
|
|
|
2018-05-02 18:40:28 +01:00
|
|
|
batch_ctx.max_vbo_decoded_lines = max_vbo_lines;
|
2016-11-23 20:24:00 -08:00
|
|
|
|
2017-11-28 15:52:08 -08:00
|
|
|
char *color = GREEN_HEADER, *reset_color = NORMAL;
|
|
|
|
|
if (option_color == COLOR_NEVER)
|
|
|
|
|
color = reset_color = "";
|
|
|
|
|
|
2017-03-15 01:22:00 -07:00
|
|
|
fprintf(outfile, "%sAubinator: Intel AUB file decoder.%-80s%s\n",
|
2017-11-28 15:52:08 -08:00
|
|
|
color, "", reset_color);
|
2016-11-23 20:24:00 -08:00
|
|
|
|
|
|
|
|
if (input_file)
|
2017-03-15 01:22:00 -07:00
|
|
|
fprintf(outfile, "File name: %s\n", input_file);
|
2016-11-23 20:24:00 -08:00
|
|
|
|
|
|
|
|
if (aub_pci_id)
|
2017-03-15 01:22:00 -07:00
|
|
|
fprintf(outfile, "PCI ID: 0x%x\n", aub_pci_id);
|
2016-11-23 20:24:00 -08:00
|
|
|
|
2017-03-15 01:22:00 -07:00
|
|
|
fprintf(outfile, "Application name: %s\n", app_name);
|
2016-11-23 20:24:00 -08:00
|
|
|
|
2021-07-13 17:56:01 -05:00
|
|
|
fprintf(outfile, "Decoding as: %s\n", devinfo.name);
|
2016-11-23 20:24:00 -08:00
|
|
|
|
|
|
|
|
/* Throw in a new line before the first batch */
|
2017-03-15 01:22:00 -07:00
|
|
|
fprintf(outfile, "\n");
|
2016-11-23 19:14:27 -08:00
|
|
|
}
|
|
|
|
|
|
2021-03-03 13:49:18 -08:00
|
|
|
static struct intel_batch_decode_bo
|
2018-08-26 13:52:47 +01:00
|
|
|
get_bo(void *user_data, bool ppgtt, uint64_t addr)
|
|
|
|
|
{
|
|
|
|
|
if (ppgtt)
|
|
|
|
|
return aub_mem_get_ppgtt_bo(user_data, addr);
|
|
|
|
|
else
|
|
|
|
|
return aub_mem_get_ggtt_bo(user_data, addr);
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-28 15:52:09 -08:00
|
|
|
static void
|
2022-10-05 12:52:05 -07:00
|
|
|
handle_execlist_write(void *user_data, enum intel_engine_class engine, uint64_t context_descriptor)
|
2017-11-28 15:52:10 -08:00
|
|
|
{
|
|
|
|
|
const uint32_t pphwsp_size = 4096;
|
2018-06-19 12:11:20 +01:00
|
|
|
uint32_t pphwsp_addr = context_descriptor & 0xfffff000;
|
2021-03-03 13:49:18 -08:00
|
|
|
struct intel_batch_decode_bo pphwsp_bo = aub_mem_get_ggtt_bo(&mem, pphwsp_addr);
|
2018-06-19 12:11:20 +01:00
|
|
|
uint32_t *context = (uint32_t *)((uint8_t *)pphwsp_bo.map +
|
2018-07-31 07:12:56 +01:00
|
|
|
(pphwsp_addr - pphwsp_bo.addr) +
|
2018-06-19 12:11:20 +01:00
|
|
|
pphwsp_size);
|
|
|
|
|
|
2017-11-28 15:52:10 -08:00
|
|
|
uint32_t ring_buffer_head = context[5];
|
|
|
|
|
uint32_t ring_buffer_tail = context[7];
|
|
|
|
|
uint32_t ring_buffer_start = context[9];
|
2018-11-09 16:49:10 +00:00
|
|
|
uint32_t ring_buffer_length = (context[11] & 0x1ff000) + 4096;
|
2018-06-19 12:11:20 +01:00
|
|
|
|
2018-07-29 01:01:36 +01:00
|
|
|
mem.pml4 = (uint64_t)context[49] << 32 | context[51];
|
|
|
|
|
batch_ctx.user_data = &mem;
|
|
|
|
|
|
2021-03-03 13:49:18 -08:00
|
|
|
struct intel_batch_decode_bo ring_bo = aub_mem_get_ggtt_bo(&mem,
|
2021-03-09 09:44:02 -08:00
|
|
|
ring_buffer_start);
|
2018-06-19 12:11:20 +01:00
|
|
|
assert(ring_bo.size > 0);
|
2018-11-09 16:49:11 +00:00
|
|
|
void *commands = (uint8_t *)ring_bo.map + (ring_buffer_start - ring_bo.addr) + ring_buffer_head;
|
2018-06-19 12:34:26 +01:00
|
|
|
|
2018-08-26 13:52:47 +01:00
|
|
|
batch_ctx.get_bo = get_bo;
|
2018-04-06 11:02:55 -07:00
|
|
|
|
2018-11-07 16:50:32 +02:00
|
|
|
batch_ctx.engine = engine;
|
2021-03-03 13:49:18 -08:00
|
|
|
intel_print_batch(&batch_ctx, commands,
|
2018-11-09 16:49:10 +00:00
|
|
|
MIN2(ring_buffer_tail - ring_buffer_head, ring_buffer_length),
|
2018-08-28 11:41:42 +01:00
|
|
|
ring_bo.addr + ring_buffer_head, true);
|
2018-07-29 01:01:36 +01:00
|
|
|
aub_mem_clear_bo_maps(&mem);
|
2017-11-28 15:52:10 -08:00
|
|
|
}
|
|
|
|
|
|
2021-03-03 13:49:18 -08:00
|
|
|
static struct intel_batch_decode_bo
|
2018-08-26 13:52:47 +01:00
|
|
|
get_legacy_bo(void *user_data, bool ppgtt, uint64_t addr)
|
|
|
|
|
{
|
|
|
|
|
return aub_mem_get_ggtt_bo(user_data, addr);
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-28 15:52:10 -08:00
|
|
|
static void
|
2022-10-05 12:52:05 -07:00
|
|
|
handle_ring_write(void *user_data, enum intel_engine_class engine,
|
2018-07-28 19:13:04 +01:00
|
|
|
const void *data, uint32_t data_len)
|
2017-11-28 15:52:10 -08:00
|
|
|
{
|
2018-07-29 01:01:36 +01:00
|
|
|
batch_ctx.user_data = &mem;
|
2018-08-26 13:52:47 +01:00
|
|
|
batch_ctx.get_bo = get_legacy_bo;
|
2018-07-28 19:13:04 +01:00
|
|
|
|
2018-11-07 16:50:32 +02:00
|
|
|
batch_ctx.engine = engine;
|
2021-03-03 13:49:18 -08:00
|
|
|
intel_print_batch(&batch_ctx, data, data_len, 0, false);
|
2018-07-28 19:13:04 +01:00
|
|
|
|
2018-07-29 01:01:36 +01:00
|
|
|
aub_mem_clear_bo_maps(&mem);
|
2017-11-28 15:52:10 -08:00
|
|
|
}
|
|
|
|
|
|
2016-08-19 12:13:24 -07:00
|
|
|
struct aub_file {
|
2016-10-04 15:15:50 +01:00
|
|
|
FILE *stream;
|
|
|
|
|
|
2018-07-28 19:13:04 +01:00
|
|
|
void *map, *end, *cursor;
|
2016-08-19 12:13:24 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static struct aub_file *
|
|
|
|
|
aub_file_open(const char *filename)
|
|
|
|
|
{
|
|
|
|
|
struct aub_file *file;
|
2016-10-04 15:15:50 +01:00
|
|
|
struct stat sb;
|
|
|
|
|
int fd;
|
2016-08-19 12:13:24 -07:00
|
|
|
|
2016-10-04 15:15:50 +01:00
|
|
|
file = calloc(1, sizeof *file);
|
2018-09-05 10:19:47 -07:00
|
|
|
if (file == NULL)
|
|
|
|
|
return NULL;
|
|
|
|
|
|
2016-10-04 15:15:50 +01:00
|
|
|
fd = open(filename, O_RDONLY);
|
|
|
|
|
if (fd == -1) {
|
|
|
|
|
fprintf(stderr, "open %s failed: %s\n", filename, strerror(errno));
|
2018-09-05 10:19:47 -07:00
|
|
|
free(file);
|
2016-09-02 03:12:24 +10:00
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
|
}
|
2016-08-19 12:13:24 -07:00
|
|
|
|
2016-10-04 15:15:50 +01:00
|
|
|
if (fstat(fd, &sb) == -1) {
|
2016-10-04 16:28:43 +01:00
|
|
|
fprintf(stderr, "stat failed: %s\n", strerror(errno));
|
2018-09-05 10:19:47 -07:00
|
|
|
free(file);
|
2016-09-02 03:12:24 +10:00
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
|
}
|
2016-08-19 12:13:24 -07:00
|
|
|
|
2016-10-04 15:15:50 +01:00
|
|
|
file->map = mmap(NULL, sb.st_size,
|
|
|
|
|
PROT_READ, MAP_SHARED, fd, 0);
|
2016-09-02 03:12:24 +10:00
|
|
|
if (file->map == MAP_FAILED) {
|
2016-10-04 16:28:43 +01:00
|
|
|
fprintf(stderr, "mmap failed: %s\n", strerror(errno));
|
2018-09-05 10:19:47 -07:00
|
|
|
free(file);
|
2016-09-02 03:12:24 +10:00
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
|
}
|
2016-08-19 12:13:24 -07:00
|
|
|
|
2017-07-13 16:39:42 +01:00
|
|
|
close(fd);
|
|
|
|
|
|
2016-08-19 12:13:24 -07:00
|
|
|
file->cursor = file->map;
|
2018-07-28 19:13:04 +01:00
|
|
|
file->end = file->map + sb.st_size;
|
2016-08-19 12:13:24 -07:00
|
|
|
|
2016-10-04 15:15:50 +01:00
|
|
|
return file;
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-19 12:13:24 -07:00
|
|
|
static int
|
|
|
|
|
aub_file_more_stuff(struct aub_file *file)
|
|
|
|
|
{
|
2016-10-04 15:15:50 +01:00
|
|
|
return file->cursor < file->end || (file->stream && !feof(file->stream));
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-19 12:13:24 -07:00
|
|
|
static void
|
|
|
|
|
setup_pager(void)
|
|
|
|
|
{
|
|
|
|
|
int fds[2];
|
|
|
|
|
pid_t pid;
|
|
|
|
|
|
|
|
|
|
if (!isatty(1))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (pipe(fds) == -1)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
pid = fork();
|
|
|
|
|
if (pid == -1)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (pid == 0) {
|
|
|
|
|
close(fds[1]);
|
|
|
|
|
dup2(fds[0], 0);
|
aubinator: Use less -RS instead of -r for the implicit pager.
From the less man page:
"Warning: when the -r option is used, less cannot keep track of the
actual appearance of the screen (since this depends on how the
screen responds to each type of control character). Thus, various
display problems may result, such as long lines being split in the
wrong place."
Lines which are too long to fit in the terminal would be word wrapped,
but unfortunately less would get confused about which line it was on,
and text would be drawn on top of other text. The most noticable case
was shader assembly, which is frequently too wide for an 80 character
terminal, and thus would be drawn on top of the following state packets,
making them completely unreadable.
Using -R instead of -r fixes this problem by only allowing color escape
sequences. (Notably, Git's implicit pager invocation uses -R.)
Unfortunately, it means our "clear to the end of the line" hack for
extending the blue bar headers won't work anymore.
Word wrapping usually isn't terribly readable, anyway, so we also add
the -S option (chop long lines) to restrict it to the terminal width.
(You can hit the left and right arrow keys to scroll sideways.)
Then, for a new blue bar hack, we can use a printf specifier to pad
the command packet names to be 80 characters long (arbitrarily), which
extends them "far enough" to look good, and doesn't require us to use
ioctls to determine the terminal width.
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Sirisha Gandikota <sirisha.gandikota@intel.com>
2016-09-29 20:43:42 -07:00
|
|
|
execlp("less", "less", "-FRSi", NULL);
|
2016-08-19 12:13:24 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
close(fds[0]);
|
|
|
|
|
dup2(fds[1], 1);
|
|
|
|
|
close(fds[1]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2016-09-12 12:34:10 +01:00
|
|
|
print_help(const char *progname, FILE *file)
|
2016-08-19 12:13:24 -07:00
|
|
|
{
|
|
|
|
|
fprintf(file,
|
2018-06-10 19:49:12 +01:00
|
|
|
"Usage: %s [OPTION]... FILE\n"
|
|
|
|
|
"Decode aub file contents from FILE.\n\n"
|
2018-05-02 18:40:28 +01:00
|
|
|
" --help display this help and exit\n"
|
|
|
|
|
" --gen=platform decode for given platform (3 letter platform name)\n"
|
|
|
|
|
" --headers decode only command headers\n"
|
|
|
|
|
" --color[=WHEN] colorize the output; WHEN can be 'auto' (default\n"
|
|
|
|
|
" if omitted), 'always', or 'never'\n"
|
|
|
|
|
" --max-vbo-lines=N limit the number of decoded VBO lines\n"
|
|
|
|
|
" --no-pager don't launch pager\n"
|
|
|
|
|
" --no-offsets don't print instruction offsets\n"
|
|
|
|
|
" --xml=DIR load hardware xml description from directory DIR\n",
|
2016-09-12 12:34:10 +01:00
|
|
|
progname);
|
2016-08-19 12:13:24 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
|
{
|
|
|
|
|
struct aub_file *file;
|
2016-10-04 16:29:55 +01:00
|
|
|
int c, i;
|
|
|
|
|
bool help = false, pager = true;
|
|
|
|
|
const struct option aubinator_opts[] = {
|
2018-05-02 18:40:28 +01:00
|
|
|
{ "help", no_argument, (int *) &help, true },
|
|
|
|
|
{ "no-pager", no_argument, (int *) &pager, false },
|
|
|
|
|
{ "no-offsets", no_argument, (int *) &option_print_offsets, false },
|
|
|
|
|
{ "gen", required_argument, NULL, 'g' },
|
|
|
|
|
{ "headers", no_argument, (int *) &option_full_decode, false },
|
2020-11-04 17:33:53 +01:00
|
|
|
{ "color", optional_argument, NULL, 'c' },
|
2018-05-02 18:40:28 +01:00
|
|
|
{ "xml", required_argument, NULL, 'x' },
|
|
|
|
|
{ "max-vbo-lines", required_argument, NULL, 'v' },
|
|
|
|
|
{ NULL, 0, NULL, 0 }
|
2016-10-04 16:29:55 +01:00
|
|
|
};
|
|
|
|
|
|
2017-03-15 01:22:00 -07:00
|
|
|
outfile = stdout;
|
|
|
|
|
|
2016-10-04 16:29:55 +01:00
|
|
|
i = 0;
|
|
|
|
|
while ((c = getopt_long(argc, argv, "", aubinator_opts, &i)) != -1) {
|
|
|
|
|
switch (c) {
|
2018-02-09 19:06:43 -08:00
|
|
|
case 'g': {
|
2021-04-05 13:19:39 -07:00
|
|
|
const int id = intel_device_name_to_pci_device_id(optarg);
|
2018-02-09 19:06:43 -08:00
|
|
|
if (id < 0) {
|
2022-05-19 17:08:43 +02:00
|
|
|
fprintf(stderr, "can't parse gen: '%s', expected lpt, brw, g4x, ilk, "
|
2018-08-30 14:32:57 -07:00
|
|
|
"snb, ivb, hsw, byt, bdw, chv, skl, bxt, kbl, "
|
2022-05-19 17:08:43 +02:00
|
|
|
"aml, glk, cfl, whl, cml, icl, ehl, jsl, tgl, "
|
|
|
|
|
"rkl, dg1, adl, sg1, rpl, dg2\n", optarg);
|
2016-11-23 19:38:00 -08:00
|
|
|
exit(EXIT_FAILURE);
|
2018-02-09 19:06:43 -08:00
|
|
|
} else {
|
|
|
|
|
pci_id = id;
|
2016-11-23 19:38:00 -08:00
|
|
|
}
|
2016-10-04 16:29:55 +01:00
|
|
|
break;
|
2018-02-09 19:06:43 -08:00
|
|
|
}
|
2016-10-04 16:29:55 +01:00
|
|
|
case 'c':
|
|
|
|
|
if (optarg == NULL || strcmp(optarg, "always") == 0)
|
2016-08-19 12:13:24 -07:00
|
|
|
option_color = COLOR_ALWAYS;
|
2016-10-04 16:29:55 +01:00
|
|
|
else if (strcmp(optarg, "never") == 0)
|
2016-08-19 12:13:24 -07:00
|
|
|
option_color = COLOR_NEVER;
|
2016-10-04 16:29:55 +01:00
|
|
|
else if (strcmp(optarg, "auto") == 0)
|
2016-08-19 12:13:24 -07:00
|
|
|
option_color = COLOR_AUTO;
|
2016-09-02 03:12:24 +10:00
|
|
|
else {
|
2016-10-04 16:29:55 +01:00
|
|
|
fprintf(stderr, "invalid value for --color: %s", optarg);
|
2016-09-02 03:12:24 +10:00
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
|
}
|
2016-10-04 16:29:55 +01:00
|
|
|
break;
|
2016-10-05 23:52:51 +01:00
|
|
|
case 'x':
|
|
|
|
|
xml_path = strdup(optarg);
|
|
|
|
|
break;
|
2018-05-02 18:40:28 +01:00
|
|
|
case 'v':
|
|
|
|
|
max_vbo_lines = atoi(optarg);
|
|
|
|
|
break;
|
2016-10-04 16:29:55 +01:00
|
|
|
default:
|
2016-08-19 12:13:24 -07:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-06-10 19:49:12 +01:00
|
|
|
if (optind < argc)
|
|
|
|
|
input_file = argv[optind];
|
|
|
|
|
|
|
|
|
|
if (help || !input_file) {
|
2016-10-04 16:29:55 +01:00
|
|
|
print_help(argv[0], stderr);
|
|
|
|
|
exit(0);
|
2016-08-19 12:13:24 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Do this before we redirect stdout to pager. */
|
|
|
|
|
if (option_color == COLOR_AUTO)
|
|
|
|
|
option_color = isatty(1) ? COLOR_ALWAYS : COLOR_NEVER;
|
|
|
|
|
|
|
|
|
|
if (isatty(1) && pager)
|
|
|
|
|
setup_pager();
|
|
|
|
|
|
2018-07-29 01:01:36 +01:00
|
|
|
if (!aub_mem_init(&mem)) {
|
|
|
|
|
fprintf(stderr, "Unable to create GTT\n");
|
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
|
}
|
2016-10-04 15:15:50 +01:00
|
|
|
|
2018-06-10 19:49:12 +01:00
|
|
|
file = aub_file_open(input_file);
|
2018-09-05 10:19:47 -07:00
|
|
|
if (!file) {
|
|
|
|
|
fprintf(stderr, "Unable to allocate buffer to open aub file\n");
|
|
|
|
|
free(xml_path);
|
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
|
}
|
2016-08-19 12:13:24 -07:00
|
|
|
|
2018-07-28 19:13:04 +01:00
|
|
|
struct aub_read aub_read = {
|
2018-07-29 01:01:36 +01:00
|
|
|
.user_data = &mem,
|
2018-07-28 19:13:04 +01:00
|
|
|
.error = aubinator_error,
|
|
|
|
|
.info = aubinator_init,
|
2022-05-19 17:06:48 +02:00
|
|
|
.comment = aubinator_comment,
|
2018-07-29 01:01:36 +01:00
|
|
|
|
|
|
|
|
.local_write = aub_mem_local_write,
|
|
|
|
|
.phys_write = aub_mem_phys_write,
|
|
|
|
|
.ggtt_write = aub_mem_ggtt_write,
|
|
|
|
|
.ggtt_entry_write = aub_mem_ggtt_entry_write,
|
|
|
|
|
|
2018-07-28 19:13:04 +01:00
|
|
|
.execlist_write = handle_execlist_write,
|
|
|
|
|
.ring_write = handle_ring_write,
|
|
|
|
|
};
|
|
|
|
|
int consumed;
|
2018-06-10 19:49:12 +01:00
|
|
|
while (aub_file_more_stuff(file) &&
|
2018-07-28 19:13:04 +01:00
|
|
|
(consumed = aub_read_command(&aub_read, file->cursor,
|
|
|
|
|
file->end - file->cursor)) > 0) {
|
|
|
|
|
file->cursor += consumed;
|
|
|
|
|
}
|
2016-08-19 12:13:24 -07:00
|
|
|
|
2018-07-29 01:01:36 +01:00
|
|
|
aub_mem_fini(&mem);
|
|
|
|
|
|
2016-08-19 12:13:24 -07:00
|
|
|
fflush(stdout);
|
|
|
|
|
/* close the stdout which is opened to write the output */
|
|
|
|
|
close(1);
|
2018-09-05 10:19:47 -07:00
|
|
|
free(file);
|
2016-10-05 23:52:51 +01:00
|
|
|
free(xml_path);
|
2016-08-19 12:13:24 -07:00
|
|
|
|
|
|
|
|
wait(NULL);
|
2021-03-03 13:49:18 -08:00
|
|
|
intel_batch_decode_ctx_finish(&batch_ctx);
|
2016-08-19 12:13:24 -07:00
|
|
|
|
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
|
}
|