Use panwrap hexdump directly
authorCafe <cafe@not.applicable>
Wed, 2 Aug 2017 05:04:24 +0000 (05:04 +0000)
committerCafe <cafe@not.applicable>
Wed, 2 Aug 2017 05:04:24 +0000 (05:04 +0000)
src/trace.c

index 71dc1720fc9872435a206ce5ee0a5f477e25a1d5..9bce195b2b4115bbd3833bbc5ef2a13a7d681140 100644 (file)
 
 #include "shim.h"
 
-static void formatted_hex_dump(char *array, uint8_t *buffer, size_t s) 
-{
-       if (!buffer) return;
-
-       panwrap_log_hexdump_trimmed(buffer, s, "\t\t");
-}
-
 /* Assert that synthesised command stream is bit-identical with trace */
 
 static void assert_gpu_same(uint64_t addr, size_t s, uint8_t *synth) 
@@ -36,9 +29,9 @@ static void assert_gpu_same(uint64_t addr, size_t s, uint8_t *synth)
        for (unsigned int i = 0; i < s; ++i) {
                if (buffer[i] != synth[i]) {
                        panwrap_log("At %llX, expected:\n", addr);
-                       formatted_hex_dump("b", synth, s);
+                       panwrap_log_hexdump_trimmed(synth, s, "\t\t");
                        panwrap_log("Instead got:\n");
-                       formatted_hex_dump("b", buffer, s);
+                       panwrap_log_hexdump_trimmed(buffer, s, "\t\t");
 
                        break;
                }
@@ -73,7 +66,7 @@ static void quick_dump_gpu(uint64_t addr, size_t s)
                return;
        }
 
-       formatted_hex_dump("a", buf, s);
+       panwrap_log_hexdump_trimmed(buf, s, "\t\t");
        relax_mapped_gpu(buf);
 }
 
@@ -128,11 +121,11 @@ static void chai_trace_fbd(uint32_t fbd)
        panwrap_log("MFBD flags %X, heap free address %llX\n",
                        mfbd->flags, mfbd->heap_free_address);
 
-       formatted_hex_dump("Block 1", (uint8_t *) mfbd->block1, sizeof(mfbd->block1));
+       panwrap_log_hexdump_trimmed((uint8_t *) mfbd->block1, sizeof(mfbd->block1), "\t\t");
 
        panwrap_log("unk2\n");
        buf = fetch_mapped_gpu(mfbd->unknown2, 64);
-       formatted_hex_dump("B", buf, 64);
+       panwrap_log_hexdump_trimmed(buf, 64, "\t\t");
        relax_mapped_gpu(buf);
 
        assert_gpu_zeroes(mfbd->block2[0], 64);
@@ -162,7 +155,7 @@ static void chai_trace_fbd(uint32_t fbd)
        panwrap_log("ugaT %llX, uga %llX\n", mfbd->ugaT, mfbd->unknown_gpu_address);
        panwrap_log("ugan %llX\n", mfbd->unknown_gpu_addressN);
        buf = fetch_mapped_gpu(mfbd->unknown_gpu_addressN, 64);
-       formatted_hex_dump("B", buf, 64);
+       panwrap_log_hexdump_trimmed(buf, 64, "\t\t");
        relax_mapped_gpu(buf);
 
        panwrap_log("unk1 %X, b1 %llX, b2 %llX, unk2 %llX, unk3 %llX, blah %llX\n",
@@ -179,15 +172,15 @@ static void chai_trace_fbd(uint32_t fbd)
                        mfbd->weights[4], mfbd->weights[5],
                        mfbd->weights[6], mfbd->weights[7]);
 
-       formatted_hex_dump("Block 3", (uint8_t *) mfbd->block3, sizeof(mfbd->block3));
+       panwrap_log_hexdump_trimmed((uint8_t *) mfbd->block3, sizeof(mfbd->block3), "\t\t");
        panwrap_log("---\n");
-       formatted_hex_dump("Block 4", (uint8_t *) mfbd->block4, sizeof(mfbd->block4));
+       panwrap_log_hexdump_trimmed((uint8_t *) mfbd->block4, sizeof(mfbd->block4), "\t\t");
 
        panwrap_log("--- (seriously though) --- %X\n", mfbd->block3[4]);
        buf32 = fetch_mapped_gpu(mfbd->block3[4], 128);
        
        if(buf32) {
-               formatted_hex_dump("a", (uint8_t*) buf32, 128);
+               panwrap_log_hexdump_trimmed((uint8_t*) buf32, 128, "\t\t");
 
                quick_dump_gpu(buf32[6], 64);
                quick_dump_gpu(buf32[20], 64);
@@ -330,7 +323,7 @@ static void chai_trace_hw_chain(uint64_t chain)
                        *i_shader & 15);
 
                shader = fetch_mapped_gpu(*i_shader & ~15, 0x880 - 0x540);
-               formatted_hex_dump("s", shader, 0x880 - 0x540);
+               panwrap_log_hexdump_trimmed(shader, 0x880 - 0x540, "\t\t");
                relax_mapped_gpu(shader);
                relax_mapped_gpu(i_shader);
 
@@ -364,7 +357,7 @@ static void chai_trace_hw_chain(uint64_t chain)
                panwrap_log("%cFBD\n", v->fbd & FBD_TYPE ? 'M' : 'S');
                chai_trace_fbd(v->fbd);
 
-               formatted_hex_dump("Block 1", (uint8_t *) v->block1, sizeof(v->block1));
+               panwrap_log_hexdump_trimmed((uint8_t *) v->block1, sizeof(v->block1), "\t\t");
 
                for (int addr = 0; addr < 14; ++addr) {
                        uint32_t address = ((uint32_t *) &(v->zeroes))[addr];
@@ -393,14 +386,14 @@ static void chai_trace_hw_chain(uint64_t chain)
 
                        buf = fetch_mapped_gpu(address, sz);
 
-                       formatted_hex_dump("B", buf, sz);
+                       panwrap_log_hexdump_trimmed(buf, sz, "\t\t");
 
                        if (addr == 8) {
                                uint32_t sub = *((uint32_t *) buf) & 0xFFFFFFFE;
                                uint8_t *sbuf = fetch_mapped_gpu(sub, 64);
 
                                panwrap_log("---\n");
-                               formatted_hex_dump("S", sbuf, 64);
+                               panwrap_log_hexdump_trimmed(sbuf, 64, "\t\t");
                                relax_mapped_gpu(sbuf);
                        }
 
@@ -409,14 +402,14 @@ static void chai_trace_hw_chain(uint64_t chain)
                                uint8_t *sbuf = fetch_mapped_gpu(sub, 64);
 
                                panwrap_log("--- %llX\n", sub);
-                               formatted_hex_dump("S", sbuf, 64);
+                               panwrap_log_hexdump_trimmed(sbuf, 64, "\t\t");
                                relax_mapped_gpu(sbuf);
                        }
 
                        relax_mapped_gpu(buf);
                }
 
-               formatted_hex_dump("Block 2", (uint8_t *) v->block2, sizeof(v->block2));
+               panwrap_log_hexdump_trimmed((uint8_t *) v->block2, sizeof(v->block2), "\t\t");
 
                relax_mapped_gpu(v);
                break;
@@ -454,7 +447,7 @@ static void chai_trace_hw_chain(uint64_t chain)
                                chai_job_type_name(h->job_type));
 
                gen_pay = fetch_mapped_gpu(payload, 256);
-               formatted_hex_dump("pl", gen_pay, 256);
+               panwrap_log_hexdump_trimmed(gen_pay, 256, "\t\t");
                relax_mapped_gpu(gen_pay);
        }
        }