[Intel-gfx] [PATCH] intel_reg_dumper: Add support for reading register dumps from files
Adam Jackson
ajax at redhat.com
Wed Mar 31 23:26:03 CEST 2010
Signed-off-by: Adam Jackson <ajax at redhat.com>
---
lib/intel_gpu_tools.c | 27 +++++++++++++++++++++++++++
lib/intel_gpu_tools.h | 1 +
tools/intel_reg_dumper.c | 7 +++++--
3 files changed, 33 insertions(+), 2 deletions(-)
diff --git a/lib/intel_gpu_tools.c b/lib/intel_gpu_tools.c
index 6c85d2a..a699ae8 100644
--- a/lib/intel_gpu_tools.c
+++ b/lib/intel_gpu_tools.c
@@ -25,12 +25,17 @@
*
*/
+#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#include <errno.h>
#include <err.h>
#include <assert.h>
#include <sys/ioctl.h>
+#include <sys/fcntl.h>
+#include <sys/stat.h>
+#include <sys/mman.h>
#include "intel_gpu_tools.h"
#include "i915_drm.h"
#include "intel_batchbuffer.h"
@@ -83,6 +88,28 @@ intel_get_pci_device(void)
}
void
+intel_map_file(char *file)
+{
+ int fd;
+ struct stat st;
+
+ fd = open(file, O_RDWR);
+ if (fd == -1) {
+ fprintf(stderr, "Couldn't open %s: %s\n", file,
+ strerror(errno));
+ exit(1);
+ }
+ fstat(fd, &st);
+ mmio = mmap(NULL, st.st_size, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0);
+ if (mmio == MAP_FAILED) {
+ fprintf(stderr, "Couldn't mmap %s: %s\n", file,
+ strerror(errno));
+ exit(1);
+ }
+ close(fd);
+}
+
+void
intel_get_mmio(void)
{
int mmio_bar;
diff --git a/lib/intel_gpu_tools.h b/lib/intel_gpu_tools.h
index 07340cc..259fd9a 100644
--- a/lib/intel_gpu_tools.h
+++ b/lib/intel_gpu_tools.h
@@ -56,3 +56,4 @@ void intel_get_drm_devid(int fd);
void intel_copy_bo(struct intel_batchbuffer *batch,
drm_intel_bo *dst_bo, drm_intel_bo *src_bo,
int width, int height);
+void intel_map_file(char *);
diff --git a/tools/intel_reg_dumper.c b/tools/intel_reg_dumper.c
index d3eec1d..8a9cf7a 100644
--- a/tools/intel_reg_dumper.c
+++ b/tools/intel_reg_dumper.c
@@ -1658,9 +1658,12 @@ intel_dump_regs(void)
int main(int argc, char** argv)
{
- intel_get_mmio();
+ if (argc == 2)
+ intel_map_file(argv[1]);
+ else
+ intel_get_mmio();
- if (HAS_PCH_SPLIT(devid))
+ if (HAS_PCH_SPLIT(devid) || getenv("HAS_PCH_SPLIT"))
ironlake_dump_regs();
else
intel_dump_regs();
--
1.6.5.2
More information about the Intel-gfx
mailing list