Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
  • 6 commits
  • 6 files changed
  • 0 commit comments
  • 1 contributor
View
263 rnn/demmt.c
@@ -41,19 +41,7 @@ struct region
struct region *next;
};
-struct buffer
-{
- unsigned char *data;
- int length;
- uint64_t offset;
- uint64_t start;
- uint64_t data1;
- uint64_t data2;
- struct pushbuf_decode_state state;
-};
-#define MAX_ID 1024
-
-static struct buffer *buffers[MAX_ID] = { NULL };
+struct buffer *buffers[MAX_ID] = { NULL };
static struct region *wreg_head[MAX_ID] = { NULL };
static struct region *wreg_last[MAX_ID] = { NULL };
static int wreg_count = 0;
@@ -61,6 +49,9 @@ static int writes_since_last_full_dump = 0; // NOTE: you cannot rely too much on
static int writes_since_last_dump = 0;
static int last_wreg_id = -1;
static int compress_clears = 1;
+static int ib_buffer = -1;
+static int dump_ioctls = 0;
+static int print_gpu_addresses = 0;
struct rnndomain *domain;
struct rnndb *rnndb;
@@ -68,7 +59,6 @@ int chipset;
int guess_invalid_pushbuf = 1;
int invalid_pushbufs_visible = 1;
int decode_invalid_buffers = 1;
-int m2mf_hack_enabled = 0;
static void dump(int id)
{
@@ -91,8 +81,14 @@ static void dump_and_abort(int id)
static void dump_writes(int id)
{
struct region *cur = wreg_head[id];
- struct pushbuf_decode_state *state = &buffers[id]->state;
+ struct pushbuf_decode_state *state = &buffers[id]->state.pushbuf;
+ struct ib_decode_state *ibstate = &buffers[id]->state.ib;
+ uint64_t gpu_start = buffers[id]->gpu_start;
char pushbuf_desc[1024];
+ char comment[2][50];
+ comment[0][0] = 0;
+ comment[1][0] = 0;
+
mmt_log("currently buffered writes for id: %d:\n", id);
while (cur)
{
@@ -101,7 +97,7 @@ static void dump_writes(int id)
uint32_t addr = cur->start;
int left = cur->end - addr;
- if (compress_clears && *(uint32_t *)(data + addr) == 0)
+ if (compress_clears && buffers[id]->type == PUSH && *(uint32_t *)(data + addr) == 0)
{
uint32_t addr_start = addr;
while (addr < cur->end)
@@ -141,55 +137,80 @@ static void dump_writes(int id)
state->next_command_offset = addr;
mmt_log("all zeroes between 0x%04x and 0x%04x\n", addr_start, addr);
- fprintf(stdout, "w %d:0x%04x-0x%04x, 0x00000000\n", id, addr_start, addr);
+ if (print_gpu_addresses && gpu_start)
+ {
+ sprintf(comment[0], " (gpu=0x%08lx)", gpu_start + addr_start);
+ sprintf(comment[1], " (gpu=0x%08lx)", gpu_start + addr);
+ }
+ fprintf(stdout, "w %d:0x%04x%s-0x%04x%s, 0x00000000\n", id, addr_start, comment[0], addr, comment[1]);
}
- if (addr != state->next_command_offset)
+ if (buffers[id]->type == IB)
+ ib_decode_start(ibstate);
+ else
{
- mmt_log("restarting pushbuf decode on buffer %d: %x != %x\n", id, addr, state->next_command_offset);
- pushbuf_decode_start(state);
- }
+ if (addr != state->next_command_offset)
+ {
+ mmt_log("restarting pushbuf decode on buffer %d: %x != %x\n", id, addr, state->next_command_offset);
+ pushbuf_decode_start(state);
+ }
- // this is temporary, will be removed when proper IB support lands
- if (state->pushbuf_invalid == 1)
- {
- mmt_log("restarting pushbuf decode on buffer %d\n", id);
- pushbuf_decode_start(state);
+ if (state->pushbuf_invalid == 1)
+ {
+ mmt_log("restarting pushbuf decode on buffer %d\n", id);
+ pushbuf_decode_start(state);
+ }
}
while (addr < cur->end)
{
+ if (print_gpu_addresses && gpu_start)
+ sprintf(comment[0], " (gpu=0x%08lx)", gpu_start + addr);
+
if (left >= 4)
{
- if (state->pushbuf_invalid == 0 || decode_invalid_buffers)
- pushbuf_decode(state, *(uint32_t *)(data + addr), pushbuf_desc);
+ if (buffers[id]->type == IB)
+ {
+ ib_decode(ibstate, *(uint32_t *)(data + addr), pushbuf_desc);
+ fprintf(stdout, "w %d:0x%04x%s, 0x%08x %s\n", id, addr, comment[0], *(uint32_t *)(data + addr), pushbuf_desc);
+ }
else
- pushbuf_desc[0] = 0;
+ {
+ if (ib_buffer != -1)
+ pushbuf_desc[0] = 0;
+ else if (state->pushbuf_invalid == 0 || decode_invalid_buffers)
+ pushbuf_decode(state, *(uint32_t *)(data + addr), pushbuf_desc);
+ else
+ pushbuf_desc[0] = 0;
- if (state->pushbuf_invalid == 1 && invalid_pushbufs_visible == 0)
- break;
+ if (state->pushbuf_invalid == 1 && invalid_pushbufs_visible == 0)
+ break;
- fprintf(stdout, "w %d:0x%04x, 0x%08x %s%s\n", id, addr, *(uint32_t *)(data + addr), state->pushbuf_invalid ? "INVALID " : "", pushbuf_desc);
- state->next_command_offset = addr + 4;
+ state->next_command_offset = addr + 4;
+ fprintf(stdout, "w %d:0x%04x%s, 0x%08x %s%s\n", id, addr, comment[0], *(uint32_t *)(data + addr), state->pushbuf_invalid ? "INVALID " : "", pushbuf_desc);
+ }
addr += 4;
left -= 4;
}
else if (left >= 2)
{
- fprintf(stdout, "w %d:0x%04x, 0x%04x\n", id, addr, *(uint16_t *)(data + addr));
+ fprintf(stdout, "w %d:0x%04x%s, 0x%04x\n", id, addr, comment[0], *(uint16_t *)(data + addr));
addr += 2;
left -= 2;
}
else
{
- fprintf(stdout, "w %d:0x%04x, 0x%02x\n", id, addr, *(uint8_t *)(data + addr));
+ fprintf(stdout, "w %d:0x%04x%s, 0x%02x\n", id, addr, comment[0], *(uint8_t *)(data + addr));
++addr;
--left;
}
}
- pushbuf_decode_end(state);
+ if (buffers[id]->type == IB)
+ ib_decode_end(ibstate);
+ else
+ pushbuf_decode_end(state);
cur = cur->next;
}
@@ -500,13 +521,19 @@ static void clear_buffered_writes()
static void demmt_memread(struct mmt_read *w, void *state)
{
+ char comment[50];
+ if (print_gpu_addresses && buffers[w->id]->gpu_start)
+ sprintf(comment, " (gpu=0x%08lx)", buffers[w->id]->gpu_start + w->offset);
+ else
+ comment[0] = 0;
+
if (w->len == 1)
- fprintf(stdout, "r %d:0x%04x, 0x%02x\n", w->id, w->offset, w->data[0]);
+ fprintf(stdout, "r %d:0x%04x%s, 0x%02x\n", w->id, w->offset, comment, w->data[0]);
else if (w->len == 2)
- fprintf(stdout, "r %d:0x%04x, 0x%04x\n", w->id, w->offset, *(uint16_t *)(w->data));
+ fprintf(stdout, "r %d:0x%04x%s, 0x%04x\n", w->id, w->offset, comment, *(uint16_t *)(w->data));
else if (w->len == 4 || w->len == 8 || w->len == 16 || w->len == 32)
{
- fprintf(stdout, "r %d:0x%04x, ", w->id, w->offset);
+ fprintf(stdout, "r %d:0x%04x%s, ", w->id, w->offset, comment);
int i;
for (i = 0; i < w->len; i += 4)
fprintf(stdout, "0x%08x ", *(uint32_t *)(w->data + i));
@@ -566,15 +593,48 @@ static void demmt_memwrite(struct mmt_write *w, void *state)
writes_since_last_full_dump += w->len;
}
+struct unk_map
+{
+ uint32_t data1;
+ uint32_t data2;
+ uint64_t mmap_offset;
+ struct unk_map *next;
+};
+
+static struct unk_map *unk_maps = NULL;
+
static void demmt_mmap(struct mmt_mmap *mm, void *state)
{
mmt_log("mmap: address: %p, length: 0x%08lx, id: %d, offset: 0x%08lx\n",
(void *)mm->start, mm->len, mm->id, mm->offset);
buffers[mm->id] = calloc(1, sizeof(struct buffer));
buffers[mm->id]->data = calloc(mm->len, 1);
- buffers[mm->id]->start = mm->start;
+ buffers[mm->id]->cpu_start = mm->start;
buffers[mm->id]->length = mm->len;
- buffers[mm->id]->offset = mm->offset;
+ buffers[mm->id]->mmap_offset = mm->offset;
+ if (mm->id == ib_buffer)
+ buffers[mm->id]->type = IB;
+
+ struct unk_map *tmp = unk_maps, *prev;
+ while (tmp)
+ {
+ if (tmp->mmap_offset == mm->offset)
+ {
+ mmt_log("binding data1: 0x%08x, data2: 0x%08x to buffer id: %d\n", tmp->data1, tmp->data2, mm->id);
+ buffers[mm->id]->data1 = tmp->data1;
+ buffers[mm->id]->data2 = tmp->data2;
+
+ if (tmp == unk_maps)
+ unk_maps = tmp->next;
+ else
+ prev->next = tmp->next;
+ free(tmp);
+
+ break;
+ }
+ prev = tmp;
+ tmp = tmp->next;
+ }
}
static void demmt_munmap(struct mmt_unmap *mm, void *state)
@@ -603,12 +663,13 @@ static void demmt_mremap(struct mmt_mremap *mm, void *state)
buffers[mm->id] = calloc(1, sizeof(struct buffer));
buffers[mm->id]->data = calloc(mm->len, 1);
- buffers[mm->id]->start = mm->start;
+ buffers[mm->id]->cpu_start = mm->start;
buffers[mm->id]->length = mm->len;
- buffers[mm->id]->offset = mm->offset;
+ buffers[mm->id]->mmap_offset = mm->offset;
buffers[mm->id]->data1 = mm->data1;
buffers[mm->id]->data2 = mm->data2;
- memcpy(&buffers[mm->id]->state, &oldbuf->state, sizeof(struct pushbuf_decode_state));
+ buffers[mm->id]->type = oldbuf->type;
+ memcpy(&buffers[mm->id]->state, &oldbuf->state, sizeof(buffers[mm->id]->state));
memcpy(buffers[mm->id]->data, oldbuf->data, min(mm->len, oldbuf->length));
free(oldbuf->data);
@@ -630,26 +691,45 @@ static void demmt_nv_destroy_object(struct mmt_nvidia_destroy_object *destroy, v
mmt_log("destroy object: obj1: 0x%08x, obj2: 0x%08x\n", destroy->obj1, destroy->obj2);
}
+static void ioctl_data_print(struct mmt_buf *data)
+{
+ int i;
+ if (!dump_ioctls)
+ return;
+
+ mmt_log_cont(", data:%s", "");
+ for (i = 0; i < data->len; ++i)
+ mmt_log_cont(" 0x%08x", ((uint32_t *)data->data)[i]);
+}
+
static void demmt_nv_ioctl_pre(struct mmt_nvidia_ioctl_pre *ctl, void *state)
{
+ mmt_log("ioctl pre 0x%02x (0x%08x)", ctl->id & 0xff, ctl->id);
+ ioctl_data_print(&ctl->data);
if (1)
{
if (wreg_count)
{
- mmt_log("ioctl 0x%02x (0x%08x), flushing buffered writes\n", ctl->id & 0xff, ctl->id);
+ mmt_log_cont(", flushing buffered writes%s\n", "");
dump_buffered_writes(1);
clear_buffered_writes();
mmt_log("%s\n", "");
}
else
- mmt_log("ioctl 0x%02x (0x%08x), no dirty buffers\n", ctl->id & 0xff, ctl->id);
+ mmt_log_cont(", no dirty buffers%s\n", "");
}
else
- mmt_log("ioctl 0x%02x (0x%08x)\n", ctl->id & 0xff, ctl->id);
+ mmt_log_cont("%s\n", "");
}
static void demmt_nv_ioctl_post(struct mmt_nvidia_ioctl_post *ctl, void *state)
{
+ if (dump_ioctls)
+ {
+ mmt_log("ioctl post 0x%02x (0x%08x)", ctl->id & 0xff, ctl->id);
+ ioctl_data_print(&ctl->data);
+ mmt_log_cont("%s\n", "");
+ }
}
static void demmt_nv_memory_dump(struct mmt_nvidia_memory_dump *d, void *state)
@@ -668,21 +748,26 @@ static void demmt_nv_call_method(struct mmt_nvidia_call_method *m, void *state)
static void demmt_nv_create_mapped(struct mmt_nvidia_create_mapped_object *p, void *state)
{
int i;
- mmt_log("create mapped object: address: %p, data1: 0x%08x, data2: 0x%08x, type: 0x%08x\n",
- (void *)p->addr, p->obj1, p->obj2, p->type);
+ mmt_log("create mapped object: mmap_offset: %p, data1: 0x%08x, data2: 0x%08x, type: 0x%08x\n",
+ (void *)p->mmap_offset, p->data1, p->data2, p->type);
- if (p->addr == 0)
+ if (p->mmap_offset == 0)
return;
for (i = 0; i < MAX_ID; ++i)
- if (buffers[i] && buffers[i]->offset == p->addr)
+ if (buffers[i] && buffers[i]->mmap_offset == p->mmap_offset)
{
- buffers[i]->data1 = p->obj1;
- buffers[i]->data2 = p->obj2;
+ buffers[i]->data1 = p->data1;
+ buffers[i]->data2 = p->data2;
return;
}
- mmt_log("couldn't find buffer%s\n", "");
+ struct unk_map *m = malloc(sizeof(struct unk_map));
+ m->data1 = p->data1;
+ m->data2 = p->data2;
+ m->mmap_offset = p->mmap_offset;
+ m->next = unk_maps;
+ unk_maps = m;
}
static void demmt_nv_create_dma_object(struct mmt_nvidia_create_dma_object *create, void *state)
@@ -694,30 +779,52 @@ static void demmt_nv_create_dma_object(struct mmt_nvidia_create_dma_object *crea
static void demmt_nv_alloc_map(struct mmt_nvidia_alloc_map *alloc, void *state)
{
int i;
- mmt_log("allocate map: address: %p, data1: 0x%08x, data2: 0x%08x\n",
- (void *)alloc->addr, alloc->obj1, alloc->obj2);
+ mmt_log("allocate map: mmap_offset: %p, data1: 0x%08x, data2: 0x%08x\n",
+ (void *)alloc->mmap_offset, alloc->data1, alloc->data2);
for (i = 0; i < MAX_ID; ++i)
- if (buffers[i] && buffers[i]->offset == alloc->addr)
+ if (buffers[i] && buffers[i]->mmap_offset == alloc->mmap_offset)
{
- buffers[i]->data1 = alloc->obj1;
- buffers[i]->data2 = alloc->obj2;
+ buffers[i]->data1 = alloc->data1;
+ buffers[i]->data2 = alloc->data2;
return;
}
- mmt_log("couldn't find buffer%s\n", "");
+ struct unk_map *m = malloc(sizeof(struct unk_map));
+ m->data1 = alloc->data1;
+ m->data2 = alloc->data2;
+ m->mmap_offset = alloc->mmap_offset;
+ m->next = unk_maps;
+ unk_maps = m;
}
static void demmt_nv_gpu_map(struct mmt_nvidia_gpu_map *map, void *state)
{
- mmt_log("gpu map: data1: 0x%08x, data2: 0x%08x, data3: 0x%08x, addr: 0x%08x, len: 0x%08x\n",
- map->data1, map->data2, map->data3, map->addr, map->len);
+ int i;
+ mmt_log("gpu map: data1: 0x%08x, data2: 0x%08x, data3: 0x%08x, gpu_start: 0x%08x, len: 0x%08x\n",
+ map->data1, map->data2, map->data3, map->gpu_start, map->len);
+ for (i = 0; i < MAX_ID; ++i)
+ if (buffers[i] && buffers[i]->data1 == map->data1 && buffers[i]->data2 == map->data3 && buffers[i]->length == map->len)
+ {
+ buffers[i]->gpu_start = map->gpu_start;
+ mmt_log("setting gpu address for buffer %d to 0x%08lx\n", i, buffers[i]->gpu_start);
+ break;
+ }
}
static void demmt_nv_gpu_unmap(struct mmt_nvidia_gpu_unmap *unmap, void *state)
{
- mmt_log("gpu unmap: data1: 0x%08x, data2: 0x%08x, data3: 0x%08x, addr: 0x%08x\n",
- unmap->data1, unmap->data2, unmap->data3, unmap->addr);
+ int i;
+ mmt_log("gpu unmap: data1: 0x%08x, data2: 0x%08x, data3: 0x%08x, gpu_start: 0x%08x\n",
+ unmap->data1, unmap->data2, unmap->data3, unmap->gpu_start);
+ for (i = 0; i < MAX_ID; ++i)
+ if (buffers[i] && buffers[i]->data1 == unmap->data1 && buffers[i]->data2 == unmap->data3 &&
+ buffers[i]->gpu_start == unmap->gpu_start)
+ {
+ mmt_log("clearing gpu address for buffer %d (was: 0x%08lx)\n", i, buffers[i]->gpu_start);
+ buffers[i]->gpu_start = 0;
+ break;
+ }
}
static void demmt_nv_mmap(struct mmt_nvidia_mmap *mm, void *state)
@@ -726,21 +833,23 @@ static void demmt_nv_mmap(struct mmt_nvidia_mmap *mm, void *state)
(void *)mm->start, mm->len, mm->id, mm->offset, mm->data1, mm->data2);
buffers[mm->id] = calloc(1, sizeof(struct buffer));
buffers[mm->id]->data = calloc(mm->len, 1);
- buffers[mm->id]->start = mm->start;
+ buffers[mm->id]->cpu_start = mm->start;
buffers[mm->id]->length = mm->len;
- buffers[mm->id]->offset = mm->offset;
+ buffers[mm->id]->mmap_offset = mm->offset;
buffers[mm->id]->data1 = mm->data1;
buffers[mm->id]->data2 = mm->data2;
+ if (mm->id == ib_buffer)
+ buffers[mm->id]->type = IB;
}
static void demmt_nv_unmap(struct mmt_nvidia_unmap *mm, void *state)
{
int i;
- mmt_log("nv_munmap: address: %p, data1: 0x%08x, data2: 0x%08x\n",
- (void *)mm->addr, mm->obj1, mm->obj2);
+ mmt_log("nv_munmap: mmap_offset: %p, data1: 0x%08x, data2: 0x%08x\n",
+ (void *)mm->mmap_offset, mm->data1, mm->data2);
for (i = 0; i < MAX_ID; ++i)
- if (buffers[i] && buffers[i]->offset == mm->addr)
+ if (buffers[i] && buffers[i]->mmap_offset == mm->mmap_offset)
{
free(buffers[i]->data);
free(buffers[i]);
@@ -819,7 +928,9 @@ static void usage()
" -i\t\tdo not guess invalid pushbufs\n"
" -d\t\thide invalid pushbufs\n"
" -e\t\tdo not decode invalid pushbufs\n"
- " -b\t\tenable hacky IB trick detection, will be removed when proper IB support lands\n"
+ " -n id\t\tassume buffer \"id\" contains IB entries\n"
+ " -o\t\tdump ioctl data\n"
+ " -g\t\tprint gpu addresses\n"
"\n");
exit(1);
}
@@ -849,8 +960,16 @@ int main(int argc, char *argv[])
invalid_pushbufs_visible = 0;
else if (!strcmp(argv[i], "-e"))
decode_invalid_buffers = 0;
- else if (!strcmp(argv[i], "-b"))
- m2mf_hack_enabled = 1;
+ else if (!strcmp(argv[i], "-n"))
+ {
+ if (i + 1 >= argc)
+ usage();
+ ib_buffer = strtoul(argv[++i], NULL, 10);
+ }
+ else if (!strcmp(argv[i], "-o"))
+ dump_ioctls = 1;
+ else if (!strcmp(argv[i], "-g"))
+ print_gpu_addresses = 1;
else
usage();
}
View
30 rnn/demmt.h
@@ -1,16 +1,38 @@
#ifndef DEMMT_H
#define DEMMT_H
+#include "demmt_pushbuf.h"
+
#define MMT_DEBUG 0
-#define mmt_debug(fmt, ...) do { if (MMT_DEBUG) fprintf(stderr, fmt, __VA_ARGS__); } while (0)
-#define mmt_log(fmt, ...) do { fprintf(stdout, "%64s" fmt, " ", __VA_ARGS__); } while (0)
-#define mmt_error(fmt, ...) do { fprintf(stderr, fmt, __VA_ARGS__); } while (0)
+#define mmt_debug(fmt, ...) do { if (MMT_DEBUG) fprintf(stderr, fmt, __VA_ARGS__); } while (0)
+#define mmt_log(fmt, ...) do { fprintf(stdout, "%64s" fmt, " ", __VA_ARGS__); } while (0)
+#define mmt_log_cont(fmt, ...) do { fprintf(stdout, fmt, __VA_ARGS__); } while (0)
+#define mmt_error(fmt, ...) do { fprintf(stderr, fmt, __VA_ARGS__); } while (0)
+
+struct buffer
+{
+ unsigned char *data;
+ int length;
+ uint64_t mmap_offset;
+ uint64_t cpu_start;
+ uint64_t data1;
+ uint64_t data2;
+ uint64_t gpu_start;
+ enum BUFTYPE { PUSH, IB } type;
+ union
+ {
+ struct pushbuf_decode_state pushbuf;
+ struct ib_decode_state ib;
+ } state;
+};
+
+#define MAX_ID 1024
+extern struct buffer *buffers[MAX_ID];
extern struct rnndomain *domain;
extern struct rnndb *rnndb;
extern int chipset;
extern int guess_invalid_pushbuf;
-extern int m2mf_hack_enabled;
#endif
View
101 rnn/demmt_pushbuf.c
@@ -255,16 +255,6 @@ void pushbuf_decode(struct pushbuf_decode_state *state, uint32_t data, char *out
mmt_log("subchannel %d does not have bound object and first command does not bind it, marking this buffer invalid\n", state->subchan);
state->pushbuf_invalid = 1;
}
-
- // XXX HACK
- if (m2mf_hack_enabled &&
- subchans[state->subchan] && subchans[state->subchan]->handle == 0x9039 &&
- state->addr == 0x0304 && state->incr == 0)
- {
- mmt_log("IB trick detected, assuming next word after this one is NOT M2MF.DATA%s\n", "");
- state->size = 0;
- }
- // XXX END HACK
}
else
{
@@ -305,3 +295,94 @@ void pushbuf_decode(struct pushbuf_decode_state *state, uint32_t data, char *out
void pushbuf_decode_end(struct pushbuf_decode_state *state)
{
}
+
+
+void ib_decode_start(struct ib_decode_state *state)
+{
+ memset(state, 0, sizeof(*state));
+ pushbuf_decode_start(&state->pstate);
+}
+
+static void ib_print(struct ib_decode_state *state)
+{
+ char cmdoutput[1024];
+ uint64_t cur = state->address - state->last_buffer->gpu_start;
+ uint64_t end = cur + state->size * 4;
+
+ while (cur < end)
+ {
+ uint32_t cmd = *(uint32_t *)&state->last_buffer->data[cur];
+ pushbuf_decode(&state->pstate, cmd, cmdoutput);
+ fprintf(stdout, "PB: 0x%08x %s\n", cmd, cmdoutput);
+ cur += 4;
+ }
+}
+
+void ib_decode(struct ib_decode_state *state, uint32_t data, char *output)
+{
+ if ((state->word & 1) == 0)
+ {
+ if (state->last_buffer)
+ {
+ ib_print(state);
+ state->last_buffer = NULL;
+ }
+
+ state->address = data & 0xfffffffc;
+ if (data & 0x3)
+ mmt_log("invalid ib entry, low2: %d\n", data & 0x3);
+
+ sprintf(output, "IB: addrlow: 0x%08lx", state->address);
+ }
+ else
+ {
+ int i;
+
+ state->address |= data & 0xff;
+ state->unk8 = (data >> 8) & 0x1;
+ state->not_main = (data >> 9) & 0x1;
+ state->size = (data & 0x7fffffff) >> 10;
+ state->no_prefetch = data >> 31;
+ sprintf(output, "IB: address: 0x%08lx, size: %d", state->address, state->size);
+ if (state->not_main)
+ strcat(output, ", not_main");
+ if (state->no_prefetch)
+ strcat(output, ", no_prefetch?");
+ if (state->unk8)
+ strcat(output, ", unk8");
+
+ struct buffer *buf = NULL;
+ for (i = 0; i < MAX_ID; ++i)
+ {
+ struct buffer *b = buffers[i];
+ if (!b || !b->gpu_start)
+ continue;
+ if (state->address >= b->gpu_start && state->address < b->gpu_start + b->length)
+ {
+ buf = b;
+ break;
+ }
+ }
+
+ state->last_buffer = buf;
+ if (buf)
+ {
+ char cmdoutput[32];
+
+ sprintf(cmdoutput, ", buffer id: %d", i);
+ strcat(output, cmdoutput);
+ }
+ }
+ state->word++;
+}
+
+void ib_decode_end(struct ib_decode_state *state)
+{
+ if (state->last_buffer)
+ {
+ ib_print(state);
+ state->last_buffer = NULL;
+ }
+
+ pushbuf_decode_end(&state->pstate);
+}
View
21 rnn/demmt_pushbuf.h
@@ -14,9 +14,28 @@ struct pushbuf_decode_state
int next_command_offset;
};
+struct ib_decode_state
+{
+ int word;
+
+ uint64_t address;
+ int unk8;
+ int not_main;
+ int size;
+ int no_prefetch;
+
+ struct pushbuf_decode_state pstate;
+ struct buffer *last_buffer;
+};
+
+void pushbuf_add_object(uint32_t handle, uint32_t class);
+
void pushbuf_decode_start(struct pushbuf_decode_state *state);
void pushbuf_decode(struct pushbuf_decode_state *state, uint32_t data, char *output);
void pushbuf_decode_end(struct pushbuf_decode_state *state);
-void pushbuf_add_object(uint32_t handle, uint32_t class);
+
+void ib_decode_start(struct ib_decode_state *state);
+void ib_decode(struct ib_decode_state *state, uint32_t data, char *output);
+void ib_decode_end(struct ib_decode_state *state);
#endif
View
10 rnn/mmt_bin2dedma_nvidia.c
@@ -93,7 +93,7 @@ static void txt_nv_call_method(struct mmt_nvidia_call_method *m, void *state)
static void txt_nv_create_mapped(struct mmt_nvidia_create_mapped_object *p, void *state)
{
- fprintf(stdout, PFX "create mapped object 0x%08x:0x%08x type=0x%08x 0x%08lx\n", p->obj1, p->obj2, p->type, p->addr);
+ fprintf(stdout, PFX "create mapped object 0x%08x:0x%08x type=0x%08x 0x%08lx\n", p->data1, p->data2, p->type, p->mmap_offset);
}
static void txt_nv_create_dma_object(struct mmt_nvidia_create_dma_object *create, void *state)
@@ -103,17 +103,17 @@ static void txt_nv_create_dma_object(struct mmt_nvidia_create_dma_object *create
static void txt_nv_alloc_map(struct mmt_nvidia_alloc_map *alloc, void *state)
{
- fprintf(stdout, PFX "allocate map 0x%08x:0x%08x 0x%08lx\n", alloc->obj1, alloc->obj2, alloc->addr);
+ fprintf(stdout, PFX "allocate map 0x%08x:0x%08x 0x%08lx\n", alloc->data1, alloc->data2, alloc->mmap_offset);
}
static void txt_nv_gpu_map(struct mmt_nvidia_gpu_map *map, void *state)
{
- fprintf(stdout, PFX "gpu map 0x%08x:0x%08x:0x%08x, addr 0x%08x, len 0x%08x\n", map->data1, map->data2, map->data3, map->addr, map->len);
+ fprintf(stdout, PFX "gpu map 0x%08x:0x%08x:0x%08x, addr 0x%08x, len 0x%08x\n", map->data1, map->data2, map->data3, map->gpu_start, map->len);
}
static void txt_nv_gpu_unmap(struct mmt_nvidia_gpu_unmap *unmap, void *state)
{
- fprintf(stdout, PFX "gpu unmap 0x%08x:0x%08x:0x%08x addr 0x%08x\n", unmap->data1, unmap->data2, unmap->data3, unmap->addr);
+ fprintf(stdout, PFX "gpu unmap 0x%08x:0x%08x:0x%08x addr 0x%08x\n", unmap->data1, unmap->data2, unmap->data3, unmap->gpu_start);
}
static void txt_nv_mmap(struct mmt_nvidia_mmap *map, void *state)
@@ -124,7 +124,7 @@ static void txt_nv_mmap(struct mmt_nvidia_mmap *map, void *state)
static void txt_nv_unmap(struct mmt_nvidia_unmap *unmap, void *state)
{
- fprintf(stdout, PFX "deallocate map 0x%08x:0x%08x 0x%08lx\n", unmap->obj1, unmap->obj2, unmap->addr);
+ fprintf(stdout, PFX "deallocate map 0x%08x:0x%08x 0x%08lx\n", unmap->data1, unmap->data2, unmap->mmap_offset);
}
static void txt_nv_bind(struct mmt_nvidia_bind *bnd, void *state)
View
22 rnn/mmt_bin_decode_nvidia.h
@@ -58,10 +58,10 @@ struct mmt_nvidia_call_method
struct mmt_nvidia_create_mapped_object
{
struct mmt_message_nv msg_type;
- uint32_t obj1;
- uint32_t obj2;
+ uint32_t data1;
+ uint32_t data2;
uint32_t type;
- uint64_t addr;
+ uint64_t mmap_offset;
} __packed;
struct mmt_nvidia_create_dma_object
@@ -75,9 +75,9 @@ struct mmt_nvidia_create_dma_object
struct mmt_nvidia_alloc_map
{
struct mmt_message_nv msg_type;
- uint32_t obj1;
- uint32_t obj2;
- uint64_t addr;
+ uint32_t data1;
+ uint32_t data2;
+ uint64_t mmap_offset;
} __packed;
struct mmt_nvidia_gpu_map
@@ -86,7 +86,7 @@ struct mmt_nvidia_gpu_map
uint32_t data1;
uint32_t data2;
uint32_t data3;
- uint32_t addr;
+ uint32_t gpu_start;
uint32_t len;
} __packed;
@@ -96,7 +96,7 @@ struct mmt_nvidia_gpu_unmap
uint32_t data1;
uint32_t data2;
uint32_t data3;
- uint32_t addr;
+ uint32_t gpu_start;
} __packed;
struct mmt_nvidia_bind
@@ -120,9 +120,9 @@ struct mmt_nvidia_mmap
struct mmt_nvidia_unmap
{
struct mmt_message_nv msg_type;
- uint32_t obj1;
- uint32_t obj2;
- uint64_t addr;
+ uint32_t data1;
+ uint32_t data2;
+ uint64_t mmap_offset;
} __packed;
struct mmt_nvidia_create_driver_object

No commit comments for this range

Something went wrong with that request. Please try again.