#include <sys/mman.h>
#include <agx_pack.h>
+#include "util/u_hexdump.h"
#include "decode.h"
-#include "hexdump.h"
#ifdef __APPLE__
#include "agx_iokit.h"
#endif
/* If we fail to decode, default to a hexdump (don't hang) */
if (count == 0) {
- hexdump(agxdecode_dump_stream, map, 8, false);
+ u_hexdump(agxdecode_dump_stream, map, 8, false);
count = 8;
}
DUMP_UNPACKED(USC_UNIFORM, temp, "Uniform\n");
uint8_t *raw = agxdecode_fetch_gpu_mem(temp.buffer, 2 * temp.size_halfs);
- hexdump(agxdecode_dump_stream, raw, 2 * temp.size_halfs, false);
+ u_hexdump(agxdecode_dump_stream, raw, 2 * temp.size_halfs, false);
return AGX_USC_UNIFORM_LENGTH;
}
default:
fprintf(agxdecode_dump_stream, "Unknown USC control type: %u\n", type);
- hexdump(agxdecode_dump_stream, map, 8, false);
+ u_hexdump(agxdecode_dump_stream, map, 8, false);
return 8;
}
if (frag.cf_bindings) {
uint8_t *cf = agxdecode_fetch_gpu_mem(frag.cf_bindings, 128);
- hexdump(agxdecode_dump_stream, cf, 128, false);
+ u_hexdump(agxdecode_dump_stream, cf, 128, false);
DUMP_CL(CF_BINDING_HEADER, cf, "Coefficient binding header:");
cf += AGX_CF_BINDING_HEADER_LENGTH;
default:
fprintf(agxdecode_dump_stream, "Unknown CDM block type: %u\n",
block_type);
- hexdump(agxdecode_dump_stream, map, 8, false);
+ u_hexdump(agxdecode_dump_stream, map, 8, false);
return 8;
}
}
default:
fprintf(agxdecode_dump_stream, "Unknown VDM block type: %u\n",
block_type);
- hexdump(agxdecode_dump_stream, map, 8, false);
+ u_hexdump(agxdecode_dump_stream, map, 8, false);
return 8;
}
}
agx_alloc_types[mmap_array[i].type], mmap_array[i].ptr.gpu,
mmap_array[i].handle);
- hexdump(agxdecode_dump_stream, mmap_array[i].ptr.cpu, mmap_array[i].size,
- false);
+ u_hexdump(agxdecode_dump_stream, mmap_array[i].ptr.cpu,
+ mmap_array[i].size, false);
fprintf(agxdecode_dump_stream, "\n");
}
}
+++ /dev/null
-/*
- * Copyright 2021 Alyssa Rosenzweig
- * SPDX-License-Identifier: MIT
- */
-
-#ifndef __HEXDUMP_H
-#define __HEXDUMP_H
-
-#include <stdbool.h>
-
-static void
-hexdump(FILE *fp, const uint8_t *hex, size_t cnt, bool with_strings)
-{
- for (unsigned i = 0; i < cnt; ++i) {
- if ((i & 0xF) == 0)
- fprintf(fp, "%06X ", i);
-
- uint8_t v = hex[i];
-
- if (v == 0 && (i & 0xF) == 0) {
- /* Check if we're starting an aligned run of zeroes */
- unsigned zero_count = 0;
-
- for (unsigned j = i; j < cnt; ++j) {
- if (hex[j] == 0)
- zero_count++;
- else
- break;
- }
-
- if (zero_count >= 32) {
- fprintf(fp, "*\n");
- i += (zero_count & ~0xF) - 1;
- continue;
- }
- }
-
- fprintf(fp, "%02X ", hex[i]);
- if ((i & 0xF) == 0xF && with_strings) {
- fprintf(fp, " | ");
- for (unsigned j = i & ~0xF; j <= i; ++j) {
- uint8_t c = hex[j];
- fputc((c < 32 || c > 128) ? '.' : c, fp);
- }
- }
-
- if ((i & 0xF) == 0xF)
- fprintf(fp, "\n");
- }
-
- fprintf(fp, "\n");
-}
-
-#endif
#include <mach/mach.h>
#include "util/compiler.h"
+#include "util/u_hexdump.h"
#include "agx_iokit.h"
#include "decode.h"
#include "dyld_interpose.h"
-#include "hexdump.h"
#include "util.h"
/*
if (inputStructCnt) {
printf(", struct:\n");
- hexdump(stdout, inputStruct, inputStructCnt, true);
+ u_hexdump(stdout, inputStruct, inputStructCnt, true);
} else {
printf("\n");
}
if (outputStructCntP) {
printf(" struct\n");
- hexdump(stdout, outputStruct, *outputStructCntP, true);
+ u_hexdump(stdout, outputStruct, *outputStructCntP, true);
if (selector == 2) {
/* Dump linked buffer as well */
void **o = outputStruct;
- hexdump(stdout, *o, 64, true);
+ u_hexdump(stdout, *o, 64, true);
}
}
if (inputStructCnt) {
printf(", struct:\n");
- hexdump(stdout, inputStruct, inputStructCnt, true);
+ u_hexdump(stdout, inputStruct, inputStructCnt, true);
} else {
printf("\n");
}
if (outputStructCntP) {
printf(" struct\n");
- hexdump(stdout, outputStruct, *outputStructCntP, true);
+ u_hexdump(stdout, outputStruct, *outputStructCntP, true);
if (selector == 2) {
/* Dump linked buffer as well */
void **o = outputStruct;
- hexdump(stdout, *o, 64, true);
+ u_hexdump(stdout, *o, 64, true);
}
}