Permalink
Browse files

demmt: add basic nouveau ioctl parser

  • Loading branch information...
1 parent 4f96b5f commit 805e6954b50aa80cb3b86aa15f585ea972393aa7 @mslusarz mslusarz committed Jul 13, 2014
Showing with 452 additions and 9 deletions.
  1. +10 −1 rnn/CMakeLists.txt
  2. +53 −8 rnn/demmt.c
  3. +1 −0 rnn/demmt.h
  4. +368 −0 rnn/demmt_drm.c
  5. +20 −0 rnn/demmt_drm.h
View
@@ -21,7 +21,16 @@ add_executable(dedma dedma.c dedma_cache.c dedma_back.c)
add_executable(lookup lookup.c)
add_executable(rnncheck rnncheck.c)
add_executable(mmt_bin2dedma mmt_bin2dedma.c mmt_bin2dedma_nvidia.c mmt_bin_decode.c mmt_bin_decode_nvidia.c)
-add_executable(demmt demmt.c mmt_bin_decode.c mmt_bin_decode_nvidia.c demmt_pushbuf.c demmt_objects.c)
+add_executable(demmt demmt.c mmt_bin_decode.c mmt_bin_decode_nvidia.c demmt_pushbuf.c demmt_objects.c demmt_drm.c)
+
+find_package(PkgConfig REQUIRED)
+pkg_check_modules(PC_LIBDRM_NV libdrm_nouveau)
+if (PC_LIBDRM_NV_FOUND)
+ include_directories(${PC_LIBDRM_NV_INCLUDE_DIRS})
+ add_definitions(-DLIBDRM_AVAILABLE)
+else (PC_LIBDRM_NV_FOUND)
+ message("Warning: demmt won't parse nouveau ioctls because libdrm_nouveau was not found")
+endif (PC_LIBDRM_NV_FOUND)
target_link_libraries(rnn ${LIBXML2_LIBRARIES} envyutil)
target_link_libraries(demmio envy nvhw rnn seq)
View
@@ -31,8 +31,9 @@
#include "mmt_bin_decode.h"
#include "mmt_bin_decode_nvidia.h"
#include "demmt.h"
-#include "demmt_pushbuf.h"
+#include "demmt_drm.h"
#include "demmt_objects.h"
+#include "demmt_pushbuf.h"
#include "rnndec.h"
#include "util.h"
@@ -828,31 +829,75 @@ static void ioctl_data_print(struct mmt_buf *data)
mmt_log_cont(" 0x%08x", ((uint32_t *)data->data)[i]);
}
+static void decode_ioctl_id(uint32_t id, uint8_t *dir, uint8_t *type, uint8_t *nr, uint16_t *size)
+{
+ *nr = id & 0x000000ff;
+ *type = (id & 0x0000ff00) >> 8;
+ *size = (id & 0x3fff0000) >> 16;
+ *dir = (id & 0xc0000000) >> 30;
+}
+
+static char *dir_desc[] = { "?", "w", "r", "rw" };
+
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);
+ uint8_t dir, type, nr;
+ uint16_t size;
+ decode_ioctl_id(ctl->id, &dir, &type, &nr, &size);
+ int print_raw = 1;
+
+ if (type == 0x64) // DRM
+ print_raw = demmt_drm_ioctl_pre(dir, nr, size, &ctl->data, state);
+ else if (type == 0x46) // nvidia
+ { }
+ print_raw = print_raw || dump_ioctls;
+
+ if (print_raw)
+ {
+ mmt_log("ioctl pre 0x%02x (0x%08x), dir: %2s, size: %4d", nr, ctl->id, dir_desc[dir], size);
+ if (size != ctl->data.len)
+ mmt_log_cont(", data.len: %d", ctl->data.len);
+
+ ioctl_data_print(&ctl->data);
+ }
+
if (1)
{
if (wreg_count)
{
- mmt_log_cont(", flushing buffered writes%s\n", "");
+ if (print_raw)
+ mmt_log_cont(", flushing buffered writes%s\n", "");
+ else
+ mmt_log("flushing buffered writes%s\n", "");
dump_buffered_writes(1);
clear_buffered_writes();
mmt_log("%s\n", "");
}
- else
+ else if (print_raw)
mmt_log_cont(", no dirty buffers%s\n", "");
}
- else
+ else if (print_raw)
mmt_log_cont("%s\n", "");
}
static void demmt_nv_ioctl_post(struct mmt_nvidia_ioctl_post *ctl, void *state)
{
- if (dump_ioctls)
+ uint8_t dir, type, nr;
+ uint16_t size;
+ decode_ioctl_id(ctl->id, &dir, &type, &nr, &size);
+ int print_raw = 0;
+
+ if (type == 0x64) // DRM
+ print_raw = demmt_drm_ioctl_post(dir, nr, size, &ctl->data, state);
+ else if (type == 0x46) // nvidia
+ { }
+ print_raw = print_raw || dump_ioctls;
+
+ if (print_raw)
{
- mmt_log("ioctl post 0x%02x (0x%08x)", ctl->id & 0xff, ctl->id);
+ mmt_log("ioctl post 0x%02x (0x%08x), dir: %2s, size: %4d", nr, ctl->id, dir_desc[dir], size);
+ if (size != ctl->data.len)
+ mmt_log_cont(", data.len: %d", ctl->data.len);
ioctl_data_print(&ctl->data);
mmt_log_cont("%s\n", "");
}
View
@@ -9,6 +9,7 @@ extern int quiet;
extern int disassemble_shaders;
extern const struct envy_colors *colors;
+#include <stdio.h>
#define mmt_debug(fmt, ...) do { if (MMT_DEBUG) fprintf(stderr, fmt, __VA_ARGS__); } while (0)
#define mmt_log(fmt, ...) do { if (!find_pb_pointer && !quiet) fprintf(stdout, "%64s" fmt, " ", __VA_ARGS__); } while (0)
#define mmt_log_cont(fmt, ...) do { if (!find_pb_pointer && !quiet) fprintf(stdout, fmt, __VA_ARGS__); } while (0)
Oops, something went wrong.

0 comments on commit 805e695

Please sign in to comment.